chore(stage2): add legal reference materials and compensation research report
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
"""보고서 계산자료 재생성. Python 표준 라이브러리만 사용한다.
|
||||
|
||||
공식 법령표 기재값과 수학적 계산값을 구분하며 원문을 수정하지 않는다.
|
||||
"""
|
||||
from decimal import Decimal, ROUND_DOWN, getcontext
|
||||
from pathlib import Path
|
||||
import csv
|
||||
import json
|
||||
|
||||
getcontext().prec = 50
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
official = json.loads((ROOT / 'sources/산재_별표11_라이프니츠_추출값.json').read_text())
|
||||
monthly_rate = Decimal('0.05') / 12
|
||||
unit = Decimal('0.0001')
|
||||
|
||||
def trunc4(x):
|
||||
return x.quantize(unit, rounding=ROUND_DOWN)
|
||||
|
||||
H = {0: Decimal(0)}
|
||||
L = {0: Decimal(0)}
|
||||
rows = []
|
||||
differences = []
|
||||
for n in range(721):
|
||||
if n:
|
||||
H[n] = H[n-1] + 1 / (1 + monthly_rate*n)
|
||||
L[n] = (1 - (1 + monthly_rate)**(-n)) / monthly_rate
|
||||
printed = official.get(str(n), '')
|
||||
match = '' if not printed else str(Decimal(printed) == trunc4(L[n]))
|
||||
row = {
|
||||
'개월수': n,
|
||||
'월이율': str(monthly_rate),
|
||||
'호프만_수학값_소수8자리': f'{H[n]:.8f}',
|
||||
'호프만_소수4자리절사': str(trunc4(H[n])),
|
||||
'라이프니츠_수학값_소수8자리': f'{L[n]:.8f}',
|
||||
'라이프니츠_소수4자리절사': str(trunc4(L[n])),
|
||||
'산재령별표11_원문기재값': printed,
|
||||
'원문과공식절사값_일치': match,
|
||||
}
|
||||
rows.append(row)
|
||||
if match == 'False':
|
||||
differences.append({
|
||||
'개월수': n, '원문기재값': printed,
|
||||
'공식계산_소수4자리절사': str(trunc4(L[n])),
|
||||
'차이_공식값빼기원문': str(trunc4(L[n])-Decimal(printed)),
|
||||
})
|
||||
|
||||
assert len(official) == 666 and set(map(int, official)) == set(range(1, 667))
|
||||
assert [x['개월수'] for x in differences] == [339, 365, 594]
|
||||
assert H[413] < 240 < H[414]
|
||||
assert abs(H[1] - L[1]) < Decimal('1e-45')
|
||||
assert all(H[n] > L[n] for n in range(2, 721))
|
||||
|
||||
with (ROOT / '호프만_라이프니츠_월계수_0-720개월.csv').open('w', encoding='utf-8-sig', newline='') as f:
|
||||
writer = csv.DictWriter(f, fieldnames=list(rows[0]))
|
||||
writer.writeheader()
|
||||
writer.writerows(rows)
|
||||
|
||||
h = lambda n: trunc4(H[n])
|
||||
l = lambda n: trunc4(L[n])
|
||||
examples = {
|
||||
'공통전제': '연 5%, 월말 지급, 월이율 0.05/12. 예시는 계수 소수 4자리 절사 후 연산. 실제 적용은 개별 법령·판결·약관에 따름.',
|
||||
'월300만원_상실률30퍼센트_120개월_호프만': str(Decimal(900000)*h(120)),
|
||||
'월300만원_상실률30퍼센트_120개월_라이프니츠': str(Decimal(900000)*l(120)),
|
||||
'첫6개월100퍼센트_이후114개월30퍼센트_호프만': str(Decimal(3000000)*h(6)+Decimal(900000)*(h(120)-h(6))),
|
||||
'121개월부터600개월까지_호프만구간계수': str(h(600)-h(120)),
|
||||
'잘못된선상한후공제_240빼기H120': str(Decimal(240)-h(120)),
|
||||
'산재9급_일평균10만원_385일': '38500000',
|
||||
'산재1급특별급여_일평균10만원_잔여240개월': str(Decimal(3000000)*Decimal(official['240'])-Decimal(100000)*1474),
|
||||
'3년뒤수술비1000만원_단할인_원미만절사': str((Decimal(10000000)/(1+Decimal('.05')*3)).quantize(Decimal('1'),rounding=ROUND_DOWN)),
|
||||
'동질손해1억원_산재급여4천만원_피해자과실20퍼센트_제3자추가배상': '48000000',
|
||||
'산재법령표와공식의불일치': differences,
|
||||
}
|
||||
(ROOT / '계산예시_검산결과.json').write_text(json.dumps(examples,ensure_ascii=False,indent=2)+'\n')
|
||||
print(json.dumps({'CSV행수': len(rows), '공식법령표대조행수': len(official), '불일치': differences, '계산예시': examples},ensure_ascii=False,indent=2))
|
||||
Reference in New Issue
Block a user