Files
njts-accounting-core/backend/app/payroll/withholding_slip/schemas.py
admin 63ac6bc99a feat: 給与所得の源泉徴収票機能を追加
- 新規モジュール: backend/app/payroll/withholding_slip/
  - schemas.py: 源泉徴収票データモデル
  - service.py: 年間集計・給与所得控除・控除額計算ロジック
  - router.py: POST /payroll/withholding-slip/generate
- frontend/withholding-slip.html: 票面プレビュー・印刷(3部)ページ
- frontend/payroll.html: 源泉徴収票メニューカード追加
- backend/app/main.py: ルーター登録
2026-05-20 17:10:08 +09:00

96 lines
2.9 KiB
Python

"""
給与所得の源泉徴収票 スキーマ定義
"""
from pydantic import BaseModel
from typing import Optional, List
from decimal import Decimal
class DependentInfo(BaseModel):
"""扶養親族情報"""
name: str
name_kana: Optional[str] = None
relationship: Optional[str] = None
birth_date: Optional[str] = None
is_spouse: bool = False
is_disabled: bool = False
income_amount: Decimal = Decimal("0")
my_number: Optional[str] = None
deduction_type: Optional[str] = None # 一般/特定/老人(同居)/老人(その他)
deduction_amount: Decimal = Decimal("0")
class WithholdingSlipData(BaseModel):
"""源泉徴収票データ"""
# 従業員情報
employee_id: int
employee_code: str
employee_name: str
employee_name_kana: Optional[str] = None
employee_address: Optional[str] = None
employee_birth_date: Optional[str] = None
my_number: Optional[str] = None
# 対象年
tax_year: int
# 支払金額
total_payment: Decimal = Decimal("0") # 年間総支給額(通勤手当含む)
total_payment_excl_commute: Decimal = Decimal("0") # 通勤手当を除く支払金額(源泉徴収票記載用)
# 給与所得控除後の金額
kyuyo_shotoku: Decimal = Decimal("0")
# 社会保険料等の金額
social_insurance_total: Decimal = Decimal("0")
health_insurance_total: Decimal = Decimal("0")
care_insurance_total: Decimal = Decimal("0")
pension_total: Decimal = Decimal("0")
employment_insurance_total: Decimal = Decimal("0")
# 基礎控除
basic_deduction: Decimal = Decimal("0")
# 配偶者控除
has_spouse_deduction: bool = False
spouse_deduction_amount: Decimal = Decimal("0")
spouse_name: Optional[str] = None
spouse_name_kana: Optional[str] = None
spouse_income: Decimal = Decimal("0")
spouse_deduction_type: Optional[str] = None # 配偶者控除/配偶者特別控除
# 扶養親族
dependents_over16: List[DependentInfo] = [] # 16歳以上控除対象扶養親族
dependents_under16: List[DependentInfo] = [] # 16歳未満扶養親族
dependent_deduction_total: Decimal = Decimal("0")
# 所得控除の額の合計額
total_deduction_amount: Decimal = Decimal("0")
# 源泉徴収税額
income_tax_withheld: Decimal = Decimal("0")
# 月数内訳
months_with_salary: int = 0
months_with_bonus: int = 0
# 摘要
remarks: Optional[str] = None
class WithholdingSlipRequest(BaseModel):
"""源泉徴収票生成リクエスト"""
tax_year: int
employee_ids: List[int]
company_name: Optional[str] = None
company_address: Optional[str] = None
company_phone: Optional[str] = None
company_my_number: Optional[str] = None
class WithholdingSlipResponse(BaseModel):
"""源泉徴収票レスポンス"""
tax_year: int
slips: List[WithholdingSlipData]
total_count: int