Files
njts-accounting-core/debug_income_tax.py
2026-01-22 22:10:17 +09:00

122 lines
3.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
所得税計算のデバッグスクリプト
ユーザーが提供したデータ:
- 月収(控除後): 356,600円
- 扶養人数: 3人
- 期待される所得税: 5,840円
"""
# サンプルCSVデータから月収356,600に対応する税額を逆算
sample_data_3 = """
月収From,月収To,扶養人数,税額
0,96000,3,0
96000,98000,3,150
98000,100000,3,200
100000,102000,3,280
102000,104000,3,360
104000,106000,3,440
106000,108000,3,520
108000,110000,3,600
110000,112000,3,680
112000,114000,3,760
114000,116000,3,840
116000,118000,3,930
118000,127000,3,1100
127000,129000,3,1230
129000,131000,3,1360
131000,133000,3,1490
133000,135000,3,1620
135000,137000,3,1750
137000,139000,3,1880
139000,141000,3,2010
141000,143000,3,2140
143000,145000,3,2270
145000,147000,3,2400
147000,149000,3,2530
149000,151000,3,2660
151000,153000,3,2790
153000,155000,3,2920
155000,157000,3,3050
157000,159000,3,3180
159000,161000,3,3310
161000,163000,3,3430
163000,165000,3,3560
165000,167000,3,3690
167000,169000,3,3820
169000,171000,3,3950
171000,173000,3,4080
173000,175000,3,4210
175000,177000,3,4340
177000,179000,3,4470
179000,181000,3,4600
181000,183000,3,4730
183000,185000,3,4860
185000,187000,3,4990
187000,189000,3,5120
189000,191000,3,5250
191000,193000,3,5380
193000,195000,3,5510
195000,197000,3,5640
197000,199000,3,5770
199000,201000,3,5900
201000,203000,3,6030
203000,205000,3,6160
205000,207000,3,6290
207000,209000,3,6420
209000,211000,3,6550
211000,213000,3,6680
213000,215000,3,6810
215000,217000,3,6940
217000,219000,3,7070
219000,221000,3,7200
221000,223000,3,7330
223000,225000,3,7460
225000,227000,3,7590
"""
# パースして月収356,600に対応する税額を探す
lines = sample_data_3.strip().split('\n')[1:] # ヘッダーをスキップ
monthly_income = 356600
print(f"月収 {monthly_income:,} 円に対応する所得税を検索...\n")
found = False
for line in lines:
parts = line.split(',')
from_val = int(parts[0])
to_val = int(parts[1])
dependents = int(parts[2])
tax = int(parts[3])
# 月収が範囲内か確認
if from_val <= monthly_income < to_val:
print(f"✓ 見つかりました!")
print(f" 月収範囲: {from_val:,} {to_val:,}")
print(f" 扶養人数: {dependents}")
print(f" 所得税: ¥{tax:,}")
found = True
break
elif from_val <= monthly_income <= to_val:
print(f"✓ 見つかりましたToが同値")
print(f" 月収範囲: {from_val:,} {to_val:,}")
print(f" 扶養人数: {dependents}")
print(f" 所得税: ¥{tax:,}")
found = True
break
if not found:
print(f"✗ 月収 {monthly_income:,} に対応する範囲が見つかりません")
print(f"\n最後の10行:")
for line in lines[-10:]:
parts = line.split(',')
from_val = int(parts[0])
to_val = int(parts[1])
tax = int(parts[3])
print(f" {from_val:,} {to_val:,}: ¥{tax:,}")
print(f"\n=== ユーザーが提供した期待値 ===")
print(f" 月収: ¥356,600")
print(f" 扶養人数: 3人")
print(f" 期待される所得税: ¥5,840")