[vhrms v0.5.0] Seed phụ cấp + tách cấu trúc lương (Chính thức / Thử việc) + biểu thuế TNCN 5 bậc (TETRA-1328) #1

Merged
tant merged 5 commits from :feat/TETRA-1328-vhrms-phase1-seed-salary into develop 2026-04-20 17:51:49 +07:00
Collaborator

Summary

Setup Phase 1 seed data cho vhrms theo Luật Thuế TNCN 2025 (109/2025/QH15) + Luật BHXH 2024:

  • Salary Components: +10 components mới
    • LCB (Lương cơ bản) — move từ salary_structure sang salary_components (fix OT link bug)
    • 5 phụ cấp không đóng BHXH: PC_AT, PC_XX, PC_DT, PC_NO, PC_TP
    • 4 mức phụ cấp độc hại: PC_DH_M1-M4 (khung 5-15% lương NĐ 145/2020)
  • Salary Structures: thay template cũ "Cơ cấu lương Việt Nam" bằng 2 template mới
    • Lương Chính thức — LCB + 5 PC Bảng A, 9 deductions
    • Lương Thử việc — LCB × 0.85 (BLLĐ Đ26), 9 deductions
    • Cả 2 auto-submit
  • Biểu thuế TNCN 2026 (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
    • Seed Income Tax Slab "Biểu thuế lũy tiến TNCN 2026 (5 bậc)"
    • Vietnam Tax Bracket: 7 → 5 bậc
    • Vietnam Tax Deduction: 2026-01-01 (đúng hiệu lực tiền lương)
  • Insurance Rate: sửa đoàn phí NLĐ 1% → 0.5% (QĐ 61/QĐ-TLĐ), effective 2025-07-01
  • Minimum Wage: xóa NĐ 74/2024 cũ, giữ NĐ 293/2025 effective 2026-01-01
  • 7 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

Test plan

  • Fresh install: docker compose --profile hrms down -v && up -d → site tự seed đầy đủ, không cần lệnh thủ công
  • Patch idempotency: rerun 5/5 patches không lỗi, không tạo duplicate
  • PIT formula: 4/4 test case PASS (bracket 1/2/3 + below threshold)
  • 28 Salary Component, 2 Salary Structure submitted, 1 Income Tax Slab, 5 Tax Bracket, 4 Minimum Wage, 4 Insurance Rate, 2 Grade Category, 1 KPI Bonus Rule

Refs

## Summary Setup Phase 1 seed data cho vhrms theo Luật Thuế TNCN 2025 (109/2025/QH15) + Luật BHXH 2024: - **Salary Components**: +10 components mới - `LCB` (Lương cơ bản) — move từ salary_structure sang salary_components (fix OT link bug) - 5 phụ cấp không đóng BHXH: `PC_AT`, `PC_XX`, `PC_DT`, `PC_NO`, `PC_TP` - 4 mức phụ cấp độc hại: `PC_DH_M1-M4` (khung 5-15% lương NĐ 145/2020) - **Salary Structures**: thay template cũ "Cơ cấu lương Việt Nam" bằng 2 template mới - `Lương Chính thức` — LCB + 5 PC Bảng A, 9 deductions - `Lương Thử việc` — LCB × 0.85 (BLLĐ Đ26), 9 deductions - Cả 2 auto-submit - **Biểu thuế TNCN 2026** (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 - Seed Income Tax Slab "Biểu thuế lũy tiến TNCN 2026 (5 bậc)" - Vietnam Tax Bracket: 7 → 5 bậc - Vietnam Tax Deduction: 2026-01-01 (đúng hiệu lực tiền lương) - **Insurance Rate**: sửa đoàn phí NLĐ 1% → 0.5% (QĐ 61/QĐ-TLĐ), effective 2025-07-01 - **Minimum Wage**: xóa NĐ 74/2024 cũ, giữ NĐ 293/2025 effective 2026-01-01 - **7 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** ## Test plan - [x] Fresh install: `docker compose --profile hrms down -v && up -d` → site tự seed đầy đủ, không cần lệnh thủ công - [x] Patch idempotency: rerun 5/5 patches không lỗi, không tạo duplicate - [x] PIT formula: 4/4 test case PASS (bracket 1/2/3 + below threshold) - [x] 28 Salary Component, 2 Salary Structure submitted, 1 Income Tax Slab, 5 Tax Bracket, 4 Minimum Wage, 4 Insurance Rate, 2 Grade Category, 1 KPI Bonus Rule ## Refs - Ticket: [TETRA-1328](https://tetravn.atlassian.net/browse/TETRA-1328) - Related: [TETRA-1251](https://tetravn.atlassian.net/browse/TETRA-1251)
- 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>
- Bỏ seed 4 records Decree 74/2024 (wages_2024) khỏi fixtures/__init__.py —
  DN triển khai mới từ đầu 2026 không cần lịch sử lương tối thiểu cũ.
- Đổi effective_from của 4 records NĐ 293/2025 từ 2026-07-01 → 2026-01-01,
  đồng bộ với Luật TNCN 2025 và các quy định tiền lương 2026.
- Thêm patch v0_5_0/cleanup_minimum_wages_2026 cho site upgrade:
  xóa records NĐ 74/2024 + re-date NĐ 293/2025.

Refs: TETRA-1328

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>
Fix silent-fail trong fresh install: khi 'bench install-app vhrms' chạy patches
trước lúc doctype đồng bộ ổn định, 2 patch v0_4_0 (setup_salary_grade_scaffolding,
seed_default_kpi_bonus_rule) bị đánh dấu 'applied' nhưng insert fail silent →
site mới không có Grade Category / KPI Bonus Rule.

Cùng pattern đã fix cho Income Tax Slab:
- Extract logic sang setup/grade_category.py + setup/kpi_bonus_rule.py.
- Gọi từ after_install + after_migrate hooks (state stable).
- Patch v0_4_0 refactor thành delegate sang setup function (giữ path upgrade cho
  site cài 0.3.2 lên 0.5.0).

Refs: TETRA-1328
Relates: TETRA-1085, TETRA-1087

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
khanhn changed title from test to [vhrms v0.5.0] Seed phụ cấp + tách cấu trúc lương (Chính thức / Thử việc) + biểu thuế TNCN 5 bậc (TETRA-1328) 2026-04-20 17:43:34 +07:00
tant merged commit c11246a179 into develop 2026-04-20 17:51:49 +07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tant/vhrms!1
No description provided.