修正
This commit is contained in:
@@ -12,7 +12,7 @@ class BonusCalculationService:
|
||||
|
||||
@staticmethod
|
||||
def get_insurance_rate(rate_type: str, target_date: date, calculation_target: str = '賞与') -> Dict[str, Any]:
|
||||
"""保険料率を取得(賞与用)"""
|
||||
"""保険料率を取得(賞与用、年度がない場合は前年度を参照)"""
|
||||
with get_connection() as conn:
|
||||
with conn.cursor() as cur:
|
||||
# rate_yearで年度を判定
|
||||
@@ -28,7 +28,28 @@ class BonusCalculationService:
|
||||
""",
|
||||
(rate_type, target_year, calculation_target)
|
||||
)
|
||||
return cur.fetchone()
|
||||
result = cur.fetchone()
|
||||
|
||||
# 現在の年度でデータが見つからない場合は前年度を検索(最大3年遡る)
|
||||
if not result:
|
||||
for year_offset in range(1, 4):
|
||||
previous_year = target_year - year_offset
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT * FROM insurance_rates
|
||||
WHERE rate_type = %s
|
||||
AND rate_year = %s
|
||||
AND calculation_target = %s
|
||||
ORDER BY rate_id DESC
|
||||
LIMIT 1
|
||||
""",
|
||||
(rate_type, previous_year, calculation_target)
|
||||
)
|
||||
result = cur.fetchone()
|
||||
if result:
|
||||
break
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_insurance_limit(setting_type: str, target_date: date) -> Decimal:
|
||||
|
||||
Reference in New Issue
Block a user