From 9fcc7655289be27de92f83408e59a00217011d63 Mon Sep 17 00:00:00 2001 From: chenxi Date: Mon, 26 Oct 2026 17:13:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=A8=E4=BA=BA=E5=B7=A5?= =?UTF-8?q?=E8=B4=B9=E7=94=A8=E5=85=AC=E7=A7=AF=E9=87=91=E5=8F=8A=E6=9C=88?= =?UTF-8?q?=E5=BA=A6=E4=B8=AA=E7=A8=8E=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/labor_expense_table.php | 8 +++---- .../labor-expenses.blade.php | 24 +++++++++++++++---- .../Business/LaborExpensePageAccessTest.php | 12 ++++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/config/labor_expense_table.php b/config/labor_expense_table.php index 74d1f38f..3d2316af 100644 --- a/config/labor_expense_table.php +++ b/config/labor_expense_table.php @@ -26,13 +26,13 @@ return [ ['key' => 'M', 'label' => '原需交个税金额', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=J#*K#-L#'], ['key' => 'N', 'label' => '原需年交个税金额', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=M#*12'], ['key' => 'O', 'label' => '新公积金缴存基数', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=IF(F#<=0,"",IF(F#<=8500,4952,IF(F#<=15000,8000,IF(F#<=25000,10000,12000))))'], - ['key' => 'P', 'label' => '新单位公积金月缴存12%', 'group' => 'fund', 'kind' => 'number'], - ['key' => 'Q', 'label' => '新个人公积金月缴存12%', 'group' => 'fund', 'kind' => 'number'], - ['key' => 'R', 'label' => '超额代扣缴', 'group' => 'fund', 'kind' => 'number'], + ['key' => 'P', 'label' => '新单位公积金月缴存12%', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=O#*0.12'], + ['key' => 'Q', 'label' => '新个人公积金月缴存12%', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=O#*0.12'], + ['key' => 'R', 'label' => '超额代扣缴', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=Q#-H#'], ['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' => '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' => 'V', 'label' => '新月度个税金额', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=S#*T#-U#'], ['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))))))))'], ['key' => 'Y', 'label' => '年度速算扣除数', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=IF(W#=0,"",IF(W#<=0,0,IF(W#<=36000,0,IF(W#<=144000,2520,IF(W#<=300000,16920,IF(W#<=420000,31920,IF(W#<=660000,52920,IF(W#<=960000,85920,181920))))))))'], 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 a1a88a05..de293d48 100644 --- a/resources/views/business/pages/financial-operations/labor-expenses.blade.php +++ b/resources/views/business/pages/financial-operations/labor-expenses.blade.php @@ -549,7 +549,14 @@ const v = (key) => numeric(row[key]); const monthlyBasicDeduction = 5000; const originalTaxable = v('F') - v('G') - v('H') - monthlyBasicDeduction; - const newMonthlyTaxable = v('F') - v('G') - monthlyBasicDeduction - v('P') - v('R'); + const newHousingFundBase = housingFundBase(v('F')); + const newEmployerHousingFund = newHousingFundBase === null ? null : newHousingFundBase * 0.12; + const newPersonalHousingFund = newHousingFundBase === null ? null : newHousingFundBase * 0.12; + const excessHousingFundWithholding = newPersonalHousingFund === null + ? null + : newPersonalHousingFund - v('H'); + const newMonthlyTaxable = v('F') - v('G') - monthlyBasicDeduction + - numeric(newEmployerHousingFund) - numeric(excessHousingFundWithholding); const newAnnualTaxable = newMonthlyTaxable * 12; const newAnnualBracket = annualBracket(newAnnualTaxable); const originalRate = newMonthlyTaxable === 0 ? null : newAnnualBracket.rate; @@ -562,11 +569,14 @@ ? null : originalTaxable * originalMonthlyBracket.rate - originalMonthlyBracket.deduction; const originalAnnualTax = originalMonthlyTax === null ? null : originalMonthlyTax * 12; - const newHousingFundBase = housingFundBase(v('F')); const parttimeSalary = v('AB') + v('AC'); const newSalary = v('F') - parttimeSalary; - const salaryTaxable = newSalary - v('G') - monthlyBasicDeduction - v('P') - v('R'); + const salaryTaxable = newSalary - v('G') - monthlyBasicDeduction + - numeric(newEmployerHousingFund) - numeric(excessHousingFundWithholding); const newMonthlyBracket = monthlyWageBracket(newMonthlyTaxable); + const newMonthlyTax = newMonthlyBracket === null + ? null + : newMonthlyTaxable * newMonthlyBracket.rate - newMonthlyBracket.deduction; const salaryMonthlyBracket = monthlyWageBracket(salaryTaxable); const salaryAnnualTaxable = salaryTaxable * 12; const salaryBracket = annualBracket(salaryAnnualTaxable); @@ -594,7 +604,9 @@ const parttimeIncome = monthlyParttime * 12 * 0.8; const totalIncome = salaryIncome + parttimeIncome; const annualBasicDeduction = 60000; - const socialFundDeduction = (v('G') + v('P') + v('R')) * 12; + const socialFundDeduction = ( + v('G') + numeric(newEmployerHousingFund) + numeric(excessHousingFundWithholding) + ) * 12; const settlementTaxable = totalIncome - annualBasicDeduction - socialFundDeduction; const settlementBracket = annualBracket(settlementTaxable); const settlementRate = settlementTaxable <= 0 ? null : settlementBracket.rate; @@ -618,7 +630,11 @@ M: originalMonthlyTax, N: originalAnnualTax, O: newHousingFundBase, + P: newEmployerHousingFund, + Q: newPersonalHousingFund, + R: excessHousingFundWithholding, S: newMonthlyTaxable, + V: newMonthlyTax, W: newAnnualTaxable, X: originalRate, Y: originalDeduction, diff --git a/tests/Feature/Business/LaborExpensePageAccessTest.php b/tests/Feature/Business/LaborExpensePageAccessTest.php index 468ac37d..ee5eca04 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(43, $formulaFields); + $this->assertCount(47, $formulaFields); $response = $this->loginAs($chenxi)->get(route('business.pages.show', [ 'section' => 'financial-operations', @@ -89,11 +89,14 @@ class LaborExpensePageAccessTest extends FeatureTestCase ->assertSee('=IF(J#<=0,"",IF(J#<=3000,0,IF(J#<=12000,210', false) ->assertSee('=J#*K#-L#', false) ->assertSee('=IF(F#<=0,"",IF(F#<=8500,4952', false) + ->assertSee('=O#*0.12', false) + ->assertSee('=Q#-H#', false) + ->assertSee('=S#*T#-U#', false) ->assertDontSee('data-labor-row="0"', false); $html = $response->getContent(); $this->assertSame(61, substr_count($html, 'data-labor-header="')); - $this->assertSame(43, substr_count($html, 'class="labor-expense-formula"')); + $this->assertSame(47, substr_count($html, 'class="labor-expense-formula"')); } public function test_basic_deduction_tax_amount_and_housing_fund_base_are_formula_driven(): void @@ -113,6 +116,11 @@ class LaborExpensePageAccessTest extends FeatureTestCase [4952, 8000, 10000, 12000], $this->housingFundBases($fields['O']['formula']) ); + + foreach (['P' => '=O#*0.12', 'Q' => '=O#*0.12', 'R' => '=Q#-H#', 'V' => '=S#*T#-U#'] as $key => $formula) { + $this->assertSame('formula_number', $fields[$key]['kind']); + $this->assertSame($formula, $fields[$key]['formula']); + } } public function test_monthly_and_annual_tax_quick_deductions_are_formula_driven(): void -- 2.47.2