feat(npt): TETRA-1421 deprecate v0_4_0 child-table migration + fix npt_count short-circuit #61
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/TETRA-1421-deprecate-v0_4_0-npt"
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?
Ticket
TETRA-1421 — [vhrms] Remove obsolete v0_4_0 child-table NPT migration + fix npt_count short-circuit
Context
Story 4.2 (v0_4_0) introduced an
npt_dependentschild table on Employee. v0_7_0 (migrate_npt_to_full_doctypes) replaced that model with the standaloneNPT Dependentdoctype. Two leftovers from v0_4_0 still caused silent payroll bugs:_update_npt_count(override Employeeon_update) had a short-circuit Whenever an employee record kept legacy child rows lingering,npt_countwas never refreshed from the standalone source → PIT deduction stale, payroll under/over-counts dependents.migrate_npt_dependent_to_child_tablewas still listed inpatches.txt, running on every fresh install / re-migrate even though the destination model has been abandoned.Changes
vhrms/overrides/employee.py::_update_npt_count— drop short-circuit; callget_active_npt_count(doc.name, today())unconditionally; write back viadb.set_value(update_modified=False)only when value differs (preserve infinite-loop guard); also updatedoc.npt_countso in-memory doc stays consistent.vhrms/patches.txt— comment-outvhrms.vhrms.patches.v0_4_0.migrate_npt_dependent_to_child_tablewith TETRA-1421 note.vhrms/patches/v0_4_0/migrate_npt_dependent_to_child_table.py→migrate_npt_dependent_to_child_table.py.deprecated(git mvpreserves history).vhrms/__init__.py— bump__version__0.9.5 → 0.9.6.CHANGELOG.md— Unreleased / Fixed entry.vhrms/tests/test_npt_count_standalone_priority.py— 5 unit tests (frappe-stub offline pattern).Tests
Cases:
test_standalone_used_when_child_table_empty— baseline: standalone count → set_value.test_standalone_used_even_when_child_table_has_rows— regression guard for the bug: child rows present, standalone count still wins.test_no_write_when_count_unchanged— infinite-loop guard preserved.test_doc_attr_missing_does_not_crash— tolerates doc withoutnpt_dependentsattr.test_exception_swallowed_logs_error— try/except contract preserved (save must not fail).Full suite NOT run per
feedback_vhrms_test_stub_fragility(stub collision when running multiple files together).Out of scope (TODO)
Employee.npt_dependentsCustom Field +Employee NPT Itemrows on staging DB (PR #3 in original ticket plan). Requires baseline query on staging DB; staging is offline (project_staging_offline_2026_04). Defer until staging back.Risk
_update_npt_count. Standaloneget_active_npt_countwas already the canonical payroll source; this aligns the override hook with the rest of the engine.