feat(payroll): PC_AT default 730k + clean up Tax Deduction 2024 #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch ":feat/TETRA-1328-vhrms-phase1-seed-salary"
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?
Summary
Changes
setup/salary_structure.py— thêmamount: 730000cho PC_AT trong_earnings_for_official().patches/v0_5_0/set_pc_at_default_amount.py(new) — idempotent patch update PC_AT row trên site đã deploy (chỉ đụng khi amount = 0/NULL).fixtures/__init__.py— xóa listdeductions_2024, chỉ seed 2026.doctype/vietnam_tax_deduction.json— update 2 description fields reflect mức 2026.patches/v0_5_0/cleanup_tax_deductions_2024.py(new) — idempotent patch xóa 2 records 2024 trên site deploy (safe-guard: chỉ xóa khi amount khớp 11M/4.4M, tránh đè admin đã sửa tay).patches.txt— đăng ký 2 patches mới.Test plan
cleanup_tax_deductions_2024trên DB có seed cũ — xóa đúng 2 records 2024, còn lại 2 records 2026.get_personal_deduction()→ 15.500.000đ;get_dependent_deduction()→ 6.200.000đ.Refs: TETRA-1326, TETRA-1328
Bối cảnh -------- Tetra API TETRA-1089 đã ship DTO `salary_bands[]` trên Salary Grades endpoints nhưng vhrms chưa có doctype/custom field hỗ trợ → Frappe drop silently. 20 Employee Grade hiện tại trên staging do seed thủ công bên ngoài code, chỉ có `grade_category` Select Tech/Non-Tech + grade_level + increment_percentage, không có child bands. Fresh install không có gì. Thay đổi -------- 2 doctype mới: 1. `Vietnam Grade Category` — configurable thay cho Select hard-coded. HR có thể thêm Mgmt / Lao động phổ thông / ... mà không sửa code. Patch seed 2 record mặc định "Tech" + "Non-Tech". 2. `Vietnam Salary Band` (child, istable=1) — 3 field khớp Tetra DTO contract: `band_number` Int ≥1, `base_amount` Currency ≥0, `effective_from` Date. Custom fields trên Employee Grade qua `setup/custom_fields.py`: - vn_salary_grade_section + grade_category (Link → Vietnam Grade Category) + grade_level + increment_percentage (default 10%) - salary_bands_section + salary_bands (Table → Vietnam Salary Band) Custom field `salary_band` (Int) trên Employee. Validation: - Vietnam Salary Band.validate: band_number ≥1, base_amount ≥0, msgprint cảnh báo (không hard-fail) khi band_1 < lương tối thiểu vùng IV (3.7M fallback hoặc tra Vietnam Minimum Wage doctype nếu có). - Employee Grade.validate hook: bands không trùng band_number, msgprint cảnh báo nếu thiếu band_1. Override Salary Structure Assignment.validate auto-fill `base` từ `employee.grade.salary_bands[employee.salary_band].base_amount`. Tôn trọng input thủ công (skip nếu base đã set), throw nếu band index không tồn tại (tránh silent wrong base pay). Patch `v0_4_0/setup_salary_grade_scaffolding`: - Seed 2 Vietnam Grade Category mặc định - Trigger `create_custom_fields(get_custom_fields(), ignore_validate=True)` để bổ sung field mới (idempotent — site cũ có grade_category Select sẽ được upgrade thành Link, dữ liệu cột "Tech"/"Non-Tech" giữ nguyên) Helper `_seed_bands_for_grade(grade_name, bands)` whitelisted để scripts/hrms/seed_salary_grades.py upsert child bands sạch qua bench execute. Tests ----- 13 unit tests cho validate + parent hook + override auto-fill (mock-based, chạy được trong bench environment). Compliance ---------- KPI hằng tháng (TETRA-1087) tách riêng — file mới không chạm Appraisal namespace nào. Grep `appraisal` trên toàn bộ file mới = 0 matches. Refs: TETRA-1085, TETRA-1089 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>- Thêm 10 Salary Component mới: + Lương cơ bản (LCB) vào create_vietnam_salary_components (fix bug create_overtime_type() fail do link tới LCB chưa tồn tại) + 5 phụ cấp không đóng BHXH: PC_AT, PC_XX, PC_DT, PC_NO, PC_TP (ăn trưa/xăng xe/điện thoại/nhà ở/trang phục — theo CV 1198/CTL&BHXH-BHXH) + 4 mức phụ cấp độc hại: PC_DH_M1-M4 (0.1-0.4 × LCS, khung 5-15% lương theo NĐ 145/2020 Đ103 + TT 26/2022) - Thay Salary Structure "Cơ cấu lương Việt Nam" (1 template) bằng 2 template: + "Lương Chính thức" (LCB + 5 phụ cấp, 9 deductions) + "Lương Thử việc" (LCB × 0.85 theo BLLĐ Đ26, 9 deductions) + Cả 2 auto-submit (docstatus=1) - Biểu thuế TNCN theo Luật 109/2025 (xem TETRA-1251): + PIT formula: 7 bậc → 5 bậc (5/10/20/30/35%) + Giảm trừ: 11tr/4.4tr → 15.5tr/6.2tr + Vietnam Tax Deduction 2026: effective 2026-07-01 → 2026-01-01 + Seed Income Tax Slab "Biểu thuế lũy tiến TNCN 2026 (5 bậc)" - 5 migration patches v0_5_0 cho site upgrade 0.3.2 → 0.5.0 (idempotent) - Fix after_install hook: handle existing Company case (Company tạo trước khi install vhrms → on_company_created không fire retroactively) - Bump version 0.3.2 → 0.5.0 Refs: TETRA-1328 Relates: TETRA-1251 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>- Update fixtures/import_tax_brackets(): seed 5 bậc mới (effective 2026-01-01) theo Luật TNCN 2025 thay vì 7 bậc cũ (effective 2024-01-01): Bậc 1: 0-10M, 5% Bậc 2: 10-30M, 10% Bậc 3: 30-60M, 20% Bậc 4: 60-100M, 30% Bậc 5: 100M+, 35% - Thêm patch v0_5_0/cleanup_tax_brackets_2026 cho site upgrade: xóa 7 bậc cũ (2024-01-01) + seed 5 bậc mới (2026-01-01). Refs: TETRA-1328 Relates: TETRA-1251 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>- Fix Trade Union NLĐ: 1.0% → 0.5% theo QĐ 61/QĐ-TLĐ (hiệu lực 01/07/2025, giảm đoàn phí công đoàn). - Update effective_from của toàn bộ 4 loại (BHXH/BHYT/BHTN/Trade Union) từ 2024-01-01 → 2025-07-01 đồng bộ với Luật BHXH 2024 + NĐ 158/2025. - Các rate khác giữ nguyên (theo luật hiện hành, đúng như cũ): BHXH NLĐ 8% DN 17.5% (hưu trí/tử tuất + ốm đau/thai sản + TNLĐ-BNN) BHYT NLĐ 1.5% DN 3% BHTN NLĐ 1% DN 1% Tổng: NLĐ 10.5% + DN 21.5% = 32%. - Thêm patch v0_5_0/cleanup_insurance_rates_2025 cho site upgrade. Refs: TETRA-1328 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>