cqp преди 2 месеца
родител
ревизия
3c00690cbe
променени са 3 файла, в които са добавени 54 реда и са изтрити 24 реда
  1. 12 0
      app/Model/AuxiliaryAccountDetails.php
  2. 36 18
      app/Service/AuxiliaryAccountService.php
  3. 6 6
      app/Service/ExpenseClaimsService.php

+ 12 - 0
app/Model/AuxiliaryAccountDetails.php

@@ -11,4 +11,16 @@ class AuxiliaryAccountDetails extends DataScopeBaseModel
     protected $dateFormat = 'U';
     protected $dateFormat = 'U';
     const employee_column = "crt_id";
     const employee_column = "crt_id";
     const Order_type = "auxiliary_account_details";
     const Order_type = "auxiliary_account_details";
+
+    const TYPE_ONE = 1;
+    const TYPE_TWO = 2;
+    const TYPE_THREE = 3;
+    const TYPE_FOUR = 4;
+    const Type = [
+        self::TYPE_ONE => '人员人工费用',
+        self::TYPE_TWO => '设备折旧费用',
+        self::TYPE_THREE => '报销',
+        self::TYPE_FOUR => '费用',
+    ];
+
 }
 }

+ 36 - 18
app/Service/AuxiliaryAccountService.php

@@ -255,35 +255,53 @@ class AuxiliaryAccountService extends Service
         $monthStart = $data['month'];
         $monthStart = $data['month'];
         $monthEnd = strtotime('+1 month', $monthStart) - 1;
         $monthEnd = strtotime('+1 month', $monthStart) - 1;
         if(empty($data['details'])) return [false, '研发支出辅助账单明细不能为空'];
         if(empty($data['details'])) return [false, '研发支出辅助账单明细不能为空'];
-        foreach ($data['details'] as $index => $item) {
+
+        // 初始化各类型的计数器
+        $typeCounters = [];
+
+        foreach ($data['details'] as $item) {
+            if(empty($item['type']) || ! isset(AuxiliaryAccountDetails::Type[$item['type']])) return [false, 'type类型不能为空或错误'];
+            $type = $item['type'];
+            $tabName = AuxiliaryAccountDetails::Type[$item['type']];
+
+            // 针对当前 type 的行数进行累加
+            if (!isset($typeCounters[$type])) {
+                $typeCounters[$type] = 1;
+            } else {
+                $typeCounters[$type]++;
+            }
+
+            $errorPrefix = "【{$tabName}】第 " . $typeCounters[$type] . " 行:";
+
             if (!isset($item['voucher_date'])) {
             if (!isset($item['voucher_date'])) {
-                return [false, "第" . ($index + 1) . "凭证日期缺失"];
+                return [false, $errorPrefix . "凭证日期缺失"];
+            }
+            // 将报销日期转换为时间戳
+            $claimTime = strtotime($item['voucher_date']);
+            // 判断:voucher_date 必须早于 month
+            // 如果 voucher_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
+            if ($claimTime < $monthStart || $claimTime > $monthEnd) return [false, $errorPrefix . "凭证日期必须早于当前结算月份(" . date("Y-m", $data['month']) . ")"];
+
+            if (!isset($item['voucher_type'])) {
+                return [false, $errorPrefix . "凭证种类缺失"];
             }
             }
             if (!isset($item['voucher_no'])) {
             if (!isset($item['voucher_no'])) {
-                return [false, "第" . ($index + 1) . "凭证号数缺失"];
+                return [false, $errorPrefix . "凭证号数缺失"];
+            }
+            if (!isset($item['voucher_remark'])) {
+                return [false, $errorPrefix . "凭证摘要缺失"];
             }
             }
             if (!isset($item['voucher_amount'])) {
             if (!isset($item['voucher_amount'])) {
-                return [false, "第" . ($index + 1) . "凭证记载金额缺失"];
+                return [false, $errorPrefix . "会计凭证记载金额缺失"];
             }
             }
             $res = $this->checkNumber($item['voucher_amount'], 2, 'non-negative');
             $res = $this->checkNumber($item['voucher_amount'], 2, 'non-negative');
-            if (! $res['valid']) return [false,  "第" . ($index + 1) . "凭证记载金额" . $res['error']];
+            if (! $res['valid']) return [false,  $errorPrefix . "会计凭证记载金额" . $res['error']];
 
 
-            if (!isset($item['voucher_type'])) {
-                return [false, "第" . ($index + 1) . "凭证类型缺失"];
-            }
             if (!isset($item['aggregation_amount'])) {
             if (!isset($item['aggregation_amount'])) {
-                return [false, "第" . ($index + 1) . "凭证归集金额缺失"];
+                return [false, $errorPrefix . "税法规定的归集金额缺失"];
             }
             }
             $res = $this->checkNumber($item['aggregation_amount'], 2, 'non-negative');
             $res = $this->checkNumber($item['aggregation_amount'], 2, 'non-negative');
-            if (! $res['valid']) return [false,  "第" . ($index + 1) . "凭证归集金额" . $res['error']];
-            if (!isset($item['voucher_remark'])) {
-                return [false, "第" . ($index + 1) . "凭证摘要缺失"];
-            }
-            // 将报销日期转换为时间戳
-            $claimTime = strtotime($item['voucher_date']);
-            // 判断:voucher_date 必须早于 month
-            // 如果 voucher_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
-            if ($claimTime < $monthStart || $claimTime > $monthEnd) return [false, "第" . ($index + 1) . "凭证日期必须早于当前结算月份(" . date("Y-m", $data['month']) . ")"];
+            if (! $res['valid']) return [false,  $errorPrefix . "税法规定的归集金额" . $res['error']];
         }
         }
 
 
         $query = AuxiliaryAccount::where('top_depart_id', $user['top_depart_id'])
         $query = AuxiliaryAccount::where('top_depart_id', $user['top_depart_id'])

+ 6 - 6
app/Service/ExpenseClaimsService.php

@@ -129,18 +129,18 @@ class ExpenseClaimsService extends Service
         $monthEnd = strtotime('+1 month', $monthStart) - 1;
         $monthEnd = strtotime('+1 month', $monthStart) - 1;
         if(empty($data['details'])) return [false, '项目费用报销单详情不能为空'];
         if(empty($data['details'])) return [false, '项目费用报销单详情不能为空'];
         foreach ($data['details'] as $index => $item) {
         foreach ($data['details'] as $index => $item) {
-            if(empty($item['item_id'])) return [false, "第" . ($index + 1) . "项目不能为空"];
-            if(empty($item['fee_id'])) return [false, "第" . ($index + 1) . "费用类型不能为空"];
-            if(! isset($item['amount'])) return [false, "第" . ($index + 1) . "费用金额不存在"];
+            if(empty($item['item_id'])) return [false, "第" . ($index + 1) . "项目不能为空"];
+            if(empty($item['fee_id'])) return [false, "第" . ($index + 1) . "费用类型不能为空"];
+            if(! isset($item['amount'])) return [false, "第" . ($index + 1) . "费用金额不存在"];
             $res = $this->checkNumber($item['amount'], 2, 'non-negative');
             $res = $this->checkNumber($item['amount'], 2, 'non-negative');
-            if (! $res['valid']) return [false,  "第" . ($index + 1) . "费用金额" . $res['error']];
+            if (! $res['valid']) return [false,  "第" . ($index + 1) . "费用金额" . $res['error']];
 
 
-            if (!isset($item['claim_date'])) return [false, "第" . ($index + 1) . "项报销日期缺失"];
+            if (!isset($item['claim_date'])) return [false, "第" . ($index + 1) . "项报销日期缺失"];
             // 将报销日期转换为时间戳
             // 将报销日期转换为时间戳
             $claimTime = strtotime($item['claim_date']);
             $claimTime = strtotime($item['claim_date']);
             // 判断:claim_date 必须早于 month
             // 判断:claim_date 必须早于 month
             // 如果 claim_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
             // 如果 claim_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
-            if ($claimTime < $monthStart || $claimTime > $monthEnd) return [false, "第" . ($index + 1) . "项报销日期必须在当前月份内(" . date("Y-m", $data['month']) . ")"];
+            if ($claimTime < $monthStart || $claimTime > $monthEnd) return [false, "第" . ($index + 1) . "项报销日期必须在当前月份内(" . date("Y-m", $data['month']) . ")"];
         }
         }
 
 
         $query = ExpenseClaims::where('top_depart_id', $data['top_depart_id'])
         $query = ExpenseClaims::where('top_depart_id', $data['top_depart_id'])