修正
This commit is contained in:
@@ -231,7 +231,9 @@ class PayrollCalculationService:
|
||||
other_allowance: Decimal = Decimal("0"),
|
||||
resident_tax: Decimal = Decimal("0"),
|
||||
other_deduction: Decimal = Decimal("0"),
|
||||
calculated_by: str = "system"
|
||||
calculated_by: str = "system",
|
||||
calc_income_tax: bool = True,
|
||||
calc_social_insurance: bool = True
|
||||
) -> Dict[str, Any]:
|
||||
"""給与を計算"""
|
||||
|
||||
@@ -378,7 +380,7 @@ class PayrollCalculationService:
|
||||
health_insurance = (
|
||||
health_standard_salary * Decimal(str(health_insurance_rate["employee_rate"]))
|
||||
).quantize(Decimal("0.01"))
|
||||
else:
|
||||
elif calc_social_insurance:
|
||||
errors.append(f"健康保険料率が見つかりません(年度: {payment_date.year})")
|
||||
|
||||
# 介護保険(40歳以上65歳未満が対象、標準報酬月額表から検索した月額で計算)
|
||||
@@ -391,7 +393,7 @@ class PayrollCalculationService:
|
||||
).quantize(Decimal("0.01"))
|
||||
print(f"[DEBUG] 介護保険計算: {health_standard_salary} × {care_insurance_rate['employee_rate']}% = {care_insurance}")
|
||||
else:
|
||||
errors.append(f"介護保険料率が見つかりません(年度: {payment_date.year})")
|
||||
errors.append(f"介護保険料率が見つかりません(年度: {payment_date.year})") if calc_social_insurance else None
|
||||
|
||||
# 厚生年金(上限適用後の標準報酬月額で計算)
|
||||
pension_insurance_rate = PayrollCalculationService.get_insurance_rate("厚生年金", payment_date)
|
||||
@@ -401,7 +403,7 @@ class PayrollCalculationService:
|
||||
pension_standard_salary * Decimal(str(pension_insurance_rate["employee_rate"]))
|
||||
).quantize(Decimal("0.01"))
|
||||
print(f"[DEBUG] 厚生年金計算: {pension_standard_salary} × {pension_insurance_rate['employee_rate']}% = {pension_insurance}")
|
||||
else:
|
||||
elif calc_social_insurance:
|
||||
errors.append(f"厚生年金保険料率が見つかりません(年度: {payment_date.year})")
|
||||
|
||||
# 雇用保険
|
||||
@@ -417,9 +419,16 @@ class PayrollCalculationService:
|
||||
).quantize(Decimal("0.01"))
|
||||
elif not is_employment_insurance_eligible:
|
||||
print(f"[DEBUG] この従業員は雇用保険非対象です")
|
||||
elif not employment_insurance_rate:
|
||||
elif not employment_insurance_rate and calc_social_insurance:
|
||||
errors.append(f"雇用保険料率が見つかりません(年度: {payment_date.year})")
|
||||
|
||||
# 社会保険計算スキップ時は全て。0にする
|
||||
if not calc_social_insurance:
|
||||
health_insurance = Decimal("0")
|
||||
care_insurance = Decimal("0")
|
||||
pension_insurance = Decimal("0")
|
||||
employment_insurance = Decimal("0")
|
||||
|
||||
# エラーがある場合は、エラーメッセージを返す
|
||||
if errors:
|
||||
raise ValueError(f"給与計算に必要なデータが不足しています:\n" + "\n".join(errors))
|
||||
@@ -441,11 +450,14 @@ class PayrollCalculationService:
|
||||
employment_insurance
|
||||
)
|
||||
|
||||
income_tax = PayrollCalculationService.calculate_income_tax(
|
||||
taxable_income,
|
||||
dependents_count,
|
||||
payment_date
|
||||
)
|
||||
if calc_income_tax:
|
||||
income_tax = PayrollCalculationService.calculate_income_tax(
|
||||
taxable_income,
|
||||
dependents_count,
|
||||
payment_date
|
||||
)
|
||||
else:
|
||||
income_tax = Decimal("0")
|
||||
|
||||
# 総控除額
|
||||
total_deduction = (
|
||||
|
||||
Reference in New Issue
Block a user