|
@@ -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'])
|