fix(payroll): tách BHTNLĐ-BNN + cleanup Insurance Rate orphans #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/TETRA-1326-vhrms-phase2-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs: TETRA-1326
Summary
Phase 2 cleanup cho tab Bảo hiểm bắt buộc của
/hrm/settingstrong Tetra eOffice. Resolve 2 bugs còn lại từ QA audit (Bug 1 + Bug 2).Bug 1 — capType undefined cho BHTNLĐ-BNN
Doctype
vietnam_insurance_rateenum thiếuBHTNLDBNN→ API Tetra gửiinsurance_type=BHTNLDBNNbị Frappe reject → FE renderhrSettings.insuranceRates.capTypes.undefined(12 console errors).Fix: thêm
BHTNLDBNNvào Select options (giữaBHTNvàTrade Union).Bug 2 — Duplicate Insurance rows → tổng 23%/47%
Patch
cleanup_insurance_rates_2025.pychỉ xóa recordseffective_from=2024-01-01, không đụng orphan với date khác (BHXH 17.5% cũ bundle TNLĐ-BNN, BHTNLDBNN lạc dòng manual insert, BHXH duplicate với rates sai, v.v.). Idempotent check ở bước seed chỉ skip insert, không cleanup orphan → duplicate sống sót.Fix: patch
cleanup_insurance_rates_orphans.pyenforce canonical 5 rows @ 2025-07-01.Thay đổi
vhrms/vhrms/doctype/vietnam_insurance_rate/vietnam_insurance_rate.jsonBHTNLDBNNvhrms/vhrms/fixtures/__init__.pyimport_insurance_rates(): BHXHemployer_rate17.5→17 (tách 0.5% TNLĐ-BNN ra row riêng), thêm row BHTNLDBNN 0/0.5 @ 2025-07-01vhrms/vhrms/patches/v0_5_0/cleanup_insurance_rates_orphans.pyvhrms/patches.txtcleanup_insurance_rates_2025)Canonical Vietnam Insurance Rate (5 rows @ 2025-07-01)
Tổng NLĐ 10.5% + DN 21.5% = 32% (bảo hiểm, Trade Union kèm ngoài).
Căn cứ pháp lý
Test plan
bench --site hrms.localhost migratetrên site có orphans → patch xóa + seed canonical/hrm/settingstab Bảo hiểm → hiển thị 5 rows, không còncapTypes.undefinedLưu ý merge
Branch này base từ
develop, net-new only — KHÔNG overlap với commits547223f(TD 2024 cleanup) và9292cc8(PC_AT 730k) hiện đang ởmainnhưng chưa vàodevelop. Khi mergemain→develop(trước hoặc sau PR này đều OK), không có conflict.Resolve 2 bugs trong tab Bảo hiểm bắt buộc của /hrm/settings (TETRA-1326): Bug 1 — capType undefined cho BHTNLĐ-BNN: Doctype vietnam_insurance_rate enum thiếu "BHTNLDBNN" → API Tetra gửi insurance_type=BHTNLDBNN bị reject → FE render capTypes.undefined. Thêm BHTNLDBNN vào Select options. Bug 2 — Duplicate Insurance rows → tổng 23%/47%: Patch cleanup_insurance_rates_2025 chỉ xóa records effective_from=2024-01-01, không đụng orphan với effective_from khác (BHXH 17.5% cũ bundle TNLĐ-BNN, manual BHTNLDBNN lạc dòng, v.v.). Thêm patch orphan cleanup enforce canonical set 5 dòng. Thay đổi: - doctype/vietnam_insurance_rate.json: enum thêm BHTNLDBNN. - fixtures/__init__.py: BHXH employer_rate 17.5 → 17 (tách 0.5% TNLĐ-BNN ra row riêng), thêm row BHTNLDBNN 0/0.5 @ 2025-07-01. - patches/v0_5_0/cleanup_insurance_rates_orphans.py: idempotent patch xóa mọi record không match canonical set (BHXH 8/17, BHYT 1.5/3, BHTN 1/1, BHTNLDBNN 0/0.5, Trade Union 0.5/2 @ 2025-07-01) + upsert 5 canonical rows. - patches.txt: đăng ký patch mới. Sau apply: - Tab Bảo hiểm hiển thị 5 rows riêng (không còn capTypes.undefined). - Tổng NLĐ 10.5% + DN 21.5% = 32% (bảo hiểm, không gồm Trade Union). Refs: TETRA-1326