Răsfoiți Sursa

封装的报表类方法

gogs 1 lună în urmă
părinte
comite
e12f888ea9
1 a modificat fișierele cu 29 adăugiri și 3 ștergeri
  1. 29 3
      app/Service/StatisticService.php

+ 29 - 3
app/Service/StatisticService.php

@@ -316,16 +316,42 @@ class StatisticService extends StatisticCommonService
         //组合所有数据
         $return = [];
         foreach ($item_key_list as $v) {
+            $other =  collect($item_fee_list[$v['id']] ?? [])->values()->all();
+            $employee_salary = isset($item_employee_list[$v['id']]['salary']) ?  round($item_employee_list[$v['id']]['salary'],2) : 0;
+            $device_depreciation = isset($item_device_list[$v['id']]['allocated_depreciation']) ? round($item_device_list[$v['id']]['allocated_depreciation'],2): 0;
+            $other_amount = 0;
+            $total_amount = $employee_salary + $device_depreciation;
+            $jj_total_amount = $employee_salary + $device_depreciation;
+            foreach ($other as $vv){
+                if($vv['is_other'] == 1) $other_amount += $vv['total_amount'];
+                else {
+                    $total_amount += $vv['total_amount'];
+                    $jj_total_amount += $vv['total_amount'];
+                }
+            }
+            //限额调整其他费用
+            $jj_other_amount = round(($total_amount+$other_amount)*0.2,2);
+            if($other_amount <=  $jj_other_amount)  $jj_other_amount = $other_amount;
+
+            //加计其他费用
+            $jj_amount = round(($total_amount+$other_amount)*0.1,2);
+            if($other_amount <=  $jj_amount)  $jj_amount = $other_amount;
+
 
+            //允许加计扣除项 : 其他费用 <= (其他费用+费用)*10% +费用
+            // 经限额调整后的其他相关费用 : 其他费用 <= (其他费用+费用)*20%
             //其他费用是个数组
             $item_value = [
                 "code" => $v['code'],
                 "title" => $v['title'],
                 "state" => $v['state'] == 3 ? "完结" : "进行中",
-                "employee_salary" => isset($item_employee_list[$v['id']]['salary']) ?  round($item_employee_list[$v['id']]['salary'],2) : 0,
-                "device_depreciation" => isset($item_device_list[$v['id']]['allocated_depreciation']) ? round($item_device_list[$v['id']]['allocated_depreciation'],2): 0,
+                "employee_salary" => $employee_salary,
+                "device_depreciation" => $device_depreciation,
                 "expense_type" => "费用化支出",
-                "fee_list" => collect($item_fee_list[$v['id']] ?? [])->values()->all(),
+                "fee_list" => $other,
+                "other_amount" => $other_amount,
+                "jj_other_amount" => $jj_other_amount,
+                "jj_total_amount" => $jj_amount+$jj_total_amount,
             ];
             $return[] = $item_value;
         }