Skip to content

[19.0][IMP] payroll: share monthly tax facts with evidence readers - #56

Open
votrelec wants to merge 2 commits into
Data-Dance:19.0from
votrelec:feat/sk-monthly-tax-facts-hook-20261118
Open

votrelec wants to merge 2 commits into
Data-Dance:19.0from
votrelec:feat/sk-monthly-tax-facts-hook-20261118

Conversation

@votrelec

Copy link
Copy Markdown
Contributor

Monthly allowance calculation currently reads declaration and January pension fields directly. Evidence adapters need the same dated facts; supplying a checked alternative source otherwise requires duplicating the allowance policy.

Add _l10n_sk_monthly_tax_facts(version, *, include_january=False) as a cooperative scalar reader. Its default returns detached company/employee/version IDs, year and ISO cutoff, the signed flag and, when requested, facts from the existing native January-version lookup. No field or register is added, and caller dictionaries/context are not authority.

Monthly NČZD keeps its own company/employee check before delegation, the unsigned early exit without January lookup, and the existing January company/pension-consistency checks and dated parameter. Evidence integrations can call the same reader with January explicitly requested; providers remain responsible for checking their owned source, relevant year and provenance.

Validation:32 targeted native Odoo19 cases passed:6 new reader/extension-boundary regressions plus existing monthly/annual tax, wage-hook and2027 parameter cases. A separate fresh normal registry verified actual payroll-Officer access without System/payrollManager/sudo in READ ONLY, unchanged version metadata and detached output. An actual-method comparison covers144 default combinations; the other20 existing model methods remain AST-identical. New tests are in the existing class, avoiding another inherited full-suite repetition. Ruff and git diff --check pass. No new translatable messages were introduced. EN/SK source docs and18.0 carry-over are recorded; the generated-repository docs tool is absent, so generated output is not claimed. OCA only; Enterprise/18.0 are untested.

This changes the fact-reading seam, not statutory amounts, stored declarations, payroll posting or live tax submissions.

Keep monthly allowance scope, lazy unsigned exit and January consistency policy while allowing cooperative owned evidence readers to use the same detached facts. No new fields, registers or tax parameters. Cover the existing default policy and the extension boundary.

Assisted-by: OpenAI Codex
@Rad0van

Rad0van commented Nov 18, 2026

Copy link
Copy Markdown
Member

Thank you, this is a useful seam and the behaviour claim holds up. Monthly NČZD keeps its own employee/company check before the hook is reached, the unsigned declaration still returns before any January lookup, and the January company and pension-consistency checks now run on the hook's output, so an override cannot slip past them.

What we checked on our side:

  • Behaviour: we ran the 19.0 l10n_sk_monthly_nczd and yours side by side over 290 combinations of signed flag, tax-pensioner flag, six pension types, annual amount, a January version in the same company, in another company or absent, and an own or foreign version (including inconsistent rows written past the constraints). Results and error messages were identical in every case: 27 allowances, 84 zeros, 177 errors.
  • Tests: baseline on 19.0 is 290 green; with this PR 296 green. As a negative control we made the unsigned path request January and dropped the January company check; three of your new tests failed (unsigned lookup, cooperative reader, company guard), so they do guard what they claim.
  • Security: the hook is private, so not callable over RPC; it returns a fresh dict of IDs and scalars, reads no context, writes nothing and does not elevate. That matches what you describe.
  • January logic is not duplicated: the default delegates to hr.employee._l10n_sk_january_tax_version, the same reader that the annual _l10n_sk_annual_january_tax_version from [IMP] l10n_sk_hr_payroll_oca: expose annual January tax fact reader #51 uses by default.
  • It applies cleanly next to [19.0][FIX] payroll: reject conflicting effective parameter values #54; the two only touch the same lines in CHANGELOG.rst, __manifest__.py, en.md and sk.md, and with both applied the suite is 305 green.

Changes we would like before merging:

  • Please move the "Shared monthly tax facts" section from doc/en.md and doc/sk.md to doc/DEVELOPER.md, next to the notes on _l10n_sk_monthly_cash_wage and the annual January reader, as we asked on [IMP] payroll: expose a cooperative monthly cash wage input #49 and [IMP] l10n_sk_hr_payroll_oca: expose annual January tax fact reader #51. en.md and sk.md are rendered into the user pages, and a private method signature is not something a payroll accountant can act on.
  • In that section please state the extension contract explicitly: the hook is called twice per allowance (once without January, once with), and the allowance itself runs both in the compute_sheet pre-check and in the salary rule, so it must be a pure, repeatable function of the payslip and version, as the cash-wage note says; and list the dict keys as a stable interface, since an override that omits one gets a KeyError rather than a readable error.
  • Please leave the existing UserError lines in l10n_sk_monthly_nczd in their original layout. The rewrap adds about twenty lines of diff without changing anything, and it makes the 18.0 carry-over harder to cherry-pick; the repository is not formatted to that line length.
  • A space is missing in "the18.0" (changelog carry-over entry and en.md) and "pre18.0" (sk.md).

Smaller points, take them or leave them:

  • The annual reader from [IMP] l10n_sk_hr_payroll_oca: expose annual January tax fact reader #51 returns a native hr.version, while this one returns a detached dict whose keys are renamed from the fields (insurance_pension for l10n_sk_pension_type, pension_annual for l10n_sk_nczd_pension_annual). If the reason is that an evidence adapter may have no hr.version to return, which makes sense, a sentence saying so in DEVELOPER.md would help the next person who meets both seams. Using the field names as keys would also make the mapping self-explanatory.
  • year and as_of guard against an empty date_to, but the January branch then reads self.date_to.year unguarded. Either both or neither; since the payslip always has a date_to when the allowance is computed, neither is simpler.
  • The hook repeats the employee/company check that l10n_sk_monthly_nczd has already made. Keeping it in the hook is reasonable for evidence callers that come in directly; just noting that the allowance pays for it twice.

Version: your entry jumps to 19.0.1.26.5, presumably leaving room for #54 and #55. That is fine as a placeholder; we assign the final numbers in the order the three are ported, so the number here will change.

Verdict: changes requested, all of them small: docs to DEVELOPER.md with the call contract, no rewrap of untouched lines, the typo. The code itself we are happy with.

Keep the allowance errors in their original layout and retain the user documentation for payroll operations.

Co-authored-by: Codex <codex@openai.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants