diff --git a/config/labor_expense_table.php b/config/labor_expense_table.php
index b621ca25..7ce0498c 100644
--- a/config/labor_expense_table.php
+++ b/config/labor_expense_table.php
@@ -22,7 +22,7 @@ return [
['key' => 'I', 'label' => '扣除额', 'group' => 'original', 'kind' => 'number'],
['key' => 'J', 'label' => '原需报个税基数', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=F#-G#-H#-I#'],
['key' => 'K', 'label' => '原个税比列', 'group' => 'original', 'kind' => 'formula_percent', 'formula' => '=IF(J#<=0,"",IF(J#<=3000,0.03,IF(J#<=12000,0.1,IF(J#<=25000,0.2,IF(J#<=35000,0.25,IF(J#<=55000,0.3,IF(J#<=80000,0.35,0.45)))))))'],
- ['key' => 'L', 'label' => '原速算扣除数', 'group' => 'original', 'kind' => 'number'],
+ ['key' => 'L', 'label' => '原速算扣除数', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=IF(J#<=0,"",IF(J#<=3000,0,IF(J#<=12000,210,IF(J#<=25000,1410,IF(J#<=35000,2660,IF(J#<=55000,4410,IF(J#<=80000,7160,15160)))))))'],
['key' => 'M', 'label' => '原需交个税金额', 'group' => 'original', 'kind' => 'number'],
['key' => 'N', 'label' => '原需年交个税金额', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=M#*12'],
['key' => 'O', 'label' => '新公积金缴存基数', 'group' => 'fund', 'kind' => 'number'],
@@ -31,7 +31,7 @@ return [
['key' => 'R', 'label' => '超额代扣缴', 'group' => 'fund', 'kind' => 'number'],
['key' => 'S', 'label' => '新月度应纳税所得额', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=F#-G#-I#-P#-R#'],
['key' => 'T', 'label' => '新月度个税比列', 'group' => 'fund', 'kind' => 'formula_percent', 'formula' => '=IF(S#<=0,"",IF(S#<=3000,0.03,IF(S#<=12000,0.1,IF(S#<=25000,0.2,IF(S#<=35000,0.25,IF(S#<=55000,0.3,IF(S#<=80000,0.35,0.45)))))))'],
- ['key' => 'U', 'label' => '新月度新速算扣除数', 'group' => 'fund', 'kind' => 'number'],
+ ['key' => 'U', 'label' => '新月度新速算扣除数', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=IF(S#<=0,"",IF(S#<=3000,0,IF(S#<=12000,210,IF(S#<=25000,1410,IF(S#<=35000,2660,IF(S#<=55000,4410,IF(S#<=80000,7160,15160)))))))'],
['key' => 'V', 'label' => '新月度个税金额', 'group' => 'fund', 'kind' => 'number'],
['key' => 'W', 'label' => '全年应纳税所得额', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=S#*12'],
['key' => 'X', 'label' => '年度税率', 'group' => 'fund', 'kind' => 'formula_percent', 'formula' => '=IF(S#=0,"",IF(W#<=0,0,IF(W#<=36000,0.03,IF(W#<=144000,0.1,IF(W#<=300000,0.2,IF(W#<=420000,0.25,IF(W#<=660000,0.3,IF(W#<=960000,0.35,0.45))))))))'],
@@ -44,7 +44,7 @@ return [
['key' => 'AE', 'label' => '新8月工资应发', 'group' => 'salary_parttime', 'kind' => 'formula_number', 'formula' => '=F#-AD#'],
['key' => 'AF', 'label' => '新月度应纳税所得额', 'group' => 'salary_parttime', 'kind' => 'formula_number', 'formula' => '=AE#-G#-I#-P#-R#'],
['key' => 'AG', 'label' => '新月度个税比列', 'group' => 'salary_parttime', 'kind' => 'formula_percent', 'formula' => '=IF(AF#<=0,"",IF(AF#<=3000,0.03,IF(AF#<=12000,0.1,IF(AF#<=25000,0.2,IF(AF#<=35000,0.25,IF(AF#<=55000,0.3,IF(AF#<=80000,0.35,0.45)))))))'],
- ['key' => 'AH', 'label' => '新月度新速算扣除数', 'group' => 'salary_parttime', 'kind' => 'number'],
+ ['key' => 'AH', 'label' => '新月度新速算扣除数', 'group' => 'salary_parttime', 'kind' => 'formula_number', 'formula' => '=IF(AF#<=0,"",IF(AF#<=3000,0,IF(AF#<=12000,210,IF(AF#<=25000,1410,IF(AF#<=35000,2660,IF(AF#<=55000,4410,IF(AF#<=80000,7160,15160)))))))'],
['key' => 'AI', 'label' => '新月度个税金额', 'group' => 'salary_parttime', 'kind' => 'number'],
['key' => 'AJ', 'label' => '全年应纳税所得额', 'group' => 'salary_parttime', 'kind' => 'formula_number', 'formula' => '=AF#*12'],
['key' => 'AK', 'label' => '年度税率', 'group' => 'salary_parttime', 'kind' => 'formula_percent', 'formula' => '=IF(AJ#=0,"",IF(AJ#<=0,0,IF(AJ#<=36000,0.03,IF(AJ#<=144000,0.1,IF(AJ#<=300000,0.2,IF(AJ#<=420000,0.25,IF(AJ#<=660000,0.3,IF(AJ#<=960000,0.35,0.45))))))))'],
diff --git a/resources/views/business/pages/financial-operations/labor-expenses.blade.php b/resources/views/business/pages/financial-operations/labor-expenses.blade.php
index fda814df..83e3fdfa 100644
--- a/resources/views/business/pages/financial-operations/labor-expenses.blade.php
+++ b/resources/views/business/pages/financial-operations/labor-expenses.blade.php
@@ -377,7 +377,7 @@
人工费用测算表
-
表头与公式依据 {{ $laborExpenseTable['source_label'] ?? '工资表' }}。黄色字段用于录入,浅金列按公式实时计算;月度工资税率按月度应纳税所得额、年度税率按全年应纳税所得额匹配税法档位,公式中的 # 表示当前行。
+
表头与公式依据 {{ $laborExpenseTable['source_label'] ?? '工资表' }}。黄色字段用于录入,浅金列按公式实时计算;月度、年度税率及速算扣除数按对应应纳税所得额匹配税法档位,公式中的 # 表示当前行。
{{ count($laborFields) }} 个业务列 · {{ $laborFormulaCount }} 个公式
@@ -506,13 +506,13 @@
const monthlyWageBracket = (income) => {
if (income <= 0) return null;
- if (income <= 3000) return 0.03;
- if (income <= 12000) return 0.1;
- if (income <= 25000) return 0.2;
- if (income <= 35000) return 0.25;
- if (income <= 55000) return 0.3;
- if (income <= 80000) return 0.35;
- return 0.45;
+ if (income <= 3000) return { rate: 0.03, deduction: 0 };
+ if (income <= 12000) return { rate: 0.1, deduction: 210 };
+ if (income <= 25000) return { rate: 0.2, deduction: 1410 };
+ if (income <= 35000) return { rate: 0.25, deduction: 2660 };
+ if (income <= 55000) return { rate: 0.3, deduction: 4410 };
+ if (income <= 80000) return { rate: 0.35, deduction: 7160 };
+ return { rate: 0.45, deduction: 15160 };
};
const annualBracket = (income) => {
@@ -549,12 +549,12 @@
const originalAnnualTaxAmount = originalRate === null || originalDeduction === null
? null
: newAnnualTaxable * originalRate - originalDeduction;
- const originalMonthlyRate = monthlyWageBracket(originalTaxable);
+ const originalMonthlyBracket = monthlyWageBracket(originalTaxable);
const parttimeSalary = v('AB') + v('AC');
const newSalary = v('F') - parttimeSalary;
const salaryTaxable = newSalary - v('G') - v('I') - v('P') - v('R');
- const newMonthlyRate = monthlyWageBracket(newMonthlyTaxable);
- const salaryMonthlyRate = monthlyWageBracket(salaryTaxable);
+ const newMonthlyBracket = monthlyWageBracket(newMonthlyTaxable);
+ const salaryMonthlyBracket = monthlyWageBracket(salaryTaxable);
const salaryAnnualTaxable = salaryTaxable * 12;
const salaryBracket = annualBracket(salaryAnnualTaxable);
const salaryRate = salaryAnnualTaxable === 0 ? null : salaryBracket.rate;
@@ -607,12 +607,15 @@
X: originalRate,
Y: originalDeduction,
Z: originalAnnualTaxAmount,
- K: originalMonthlyRate,
- T: newMonthlyRate,
+ K: originalMonthlyBracket?.rate ?? null,
+ L: originalMonthlyBracket?.deduction ?? null,
+ T: newMonthlyBracket?.rate ?? null,
+ U: newMonthlyBracket?.deduction ?? null,
AD: parttimeSalary,
AE: newSalary,
AF: salaryTaxable,
- AG: salaryMonthlyRate,
+ AG: salaryMonthlyBracket?.rate ?? null,
+ AH: salaryMonthlyBracket?.deduction ?? null,
AJ: salaryAnnualTaxable,
AK: salaryRate,
AL: salaryDeduction,
diff --git a/tests/Feature/Business/LaborExpensePageAccessTest.php b/tests/Feature/Business/LaborExpensePageAccessTest.php
index 2120476c..3b62f4b1 100644
--- a/tests/Feature/Business/LaborExpensePageAccessTest.php
+++ b/tests/Feature/Business/LaborExpensePageAccessTest.php
@@ -69,7 +69,7 @@ class LaborExpensePageAccessTest extends FeatureTestCase
);
$this->assertCount(61, $fields);
- $this->assertCount(37, $formulaFields);
+ $this->assertCount(40, $formulaFields);
$response = $this->loginAs($chenxi)->get(route('business.pages.show', [
'section' => 'financial-operations',
@@ -85,12 +85,39 @@ class LaborExpensePageAccessTest extends FeatureTestCase
->assertSee('data-labor-expense-table', false)
->assertSee('=F#-G#-H#-I#', false)
->assertSee('=IF(AN#<=0,0,IF(AN#<=4000,800,AN#*0.2))', false)
- ->assertSee('=IF(J#<=0,"",IF(J#<=3000,0.03', false)
+ ->assertSee('=IF(J#<=0,"",IF(J#<=3000,0.03', false)
+ ->assertSee('=IF(J#<=0,"",IF(J#<=3000,0,IF(J#<=12000,210', false)
->assertDontSee('data-labor-row="0"', false);
$html = $response->getContent();
$this->assertSame(61, substr_count($html, 'data-labor-header="'));
- $this->assertSame(37, substr_count($html, 'class="labor-expense-formula"'));
+ $this->assertSame(40, substr_count($html, 'class="labor-expense-formula"'));
+ }
+
+ public function test_monthly_and_annual_tax_quick_deductions_are_formula_driven(): void
+ {
+ $fields = collect(config('labor_expense_table.fields'))->keyBy('key');
+
+ foreach (['L', 'U', 'AH', 'Y', 'AL', 'BD'] as $key) {
+ $this->assertNotEmpty($fields[$key]['formula'] ?? null, "{$key} 应配置速算扣除数公式");
+ }
+
+ foreach (['L' => 'J', 'U' => 'S', 'AH' => 'AF'] as $key => $taxableKey) {
+ $this->assertSame('formula_number', $fields[$key]['kind']);
+ $this->assertStringStartsWith("=IF({$taxableKey}#<=0,\"\"", $fields[$key]['formula']);
+ $this->assertSame(
+ [0, 210, 1410, 2660, 4410, 7160, 15160],
+ $this->quickDeductions($fields[$key]['formula'])
+ );
+ }
+
+ foreach (['Y' => 'W', 'AL' => 'AJ', 'BD' => 'BB'] as $key => $taxableKey) {
+ $this->assertStringStartsWith("=IF({$taxableKey}#", $fields[$key]['formula']);
+ $this->assertSame(
+ [0, 2520, 16920, 31920, 52920, 85920, 181920],
+ $this->quickDeductions($fields[$key]['formula'])
+ );
+ }
}
private function pageIsVisible(User $user): bool
@@ -119,4 +146,16 @@ class LaborExpensePageAccessTest extends FeatureTestCase
return $user;
}
+
+ private function quickDeductions(string $formula): array
+ {
+ preg_match_all('/IF\([A-Z]+#<=\d+,(\d+)/', $formula, $matches);
+ $deductions = array_values(array_unique(array_map('intval', $matches[1])));
+
+ if (preg_match('/,(\d+)\)+\s*$/', $formula, $fallback)) {
+ $deductions[] = (int) $fallback[1];
+ }
+
+ return $deductions;
+ }
}