Skip to content

FINERACT-2767: Tax Component – Fields should be locked once linked to transactions - #6288

Open
rymghosn wants to merge 1 commit into
apache:developfrom
foodeveloper:port/CBS-162-tax-component-editability-lock
Open

FINERACT-2767: Tax Component – Fields should be locked once linked to transactions#6288
rymghosn wants to merge 1 commit into
apache:developfrom
foodeveloper:port/CBS-162-tax-component-editability-lock

Conversation

@rymghosn

Copy link
Copy Markdown
Contributor

Currently, a Tax Component's percentage, GL accounts (debit/credit), and start date can be modified at any time via PUT /v1/taxes/component/{id},
even after the component has been linked to transactions through a Tax Group. This risks inconsistencies in historical calculations and journal
entries, since past periods rely on the component's percentage and GL account mapping at the time they were recorded.

This PR enforces the following rules on tax component updates:

  • If a Tax Component has not been linked to any Tax Group, all fields (name, percentage, GL accounts, start date) remain editable.

  • If a Tax Component is linked to a Tax Group that is in turn referenced by at least one Charge (i.e. it is "in use"), only the name can still be
    edited. Attempting to change percentage, GL accounts, or start date returns a validation error.

  • Start date specifically: if the existing start date is still in the future (not yet active), it can still be changed, but only to another date
    strictly after today. Once the start date has passed (component active), it is locked regardless of usage.

  • GL account (debit/credit type and account) updates are now supported through the update endpoint for components not yet in use — previously
    this endpoint did not support changing GL accounts at all.
    Changes

  • ChargeRepository: added existsByTaxGroupContainingTaxComponent(Long) to check whether any Charge references a Tax Group containing a given Tax
    Component.

  • TaxComponent: added isInUse(Supplier) (mapped-to-a-group AND charge-usage check), and extended update(...) to accept and apply GL
    account changes.

  • TaxComponentData: added accountsEditable indicator, surfaced on GET /v1/taxes/component/{id}.

  • TaxReadPlatformServiceImpl: computes accountsEditable and conditionally includes GL account template options based on it.

  • TaxWritePlatformServiceImpl: enforces the restricted-fields validation when a component is in use, and resolves GL accounts from the update
    command.

  • TaxValidator: extends supported update parameters to include GL account fields; adds the two-tier start-date validation rule described above.

  • TaxConfiguration: wires the new ChargeRepository/GLAccountRepositoryWrapper dependencies into the read/write service beans.

@rymghosn
rymghosn force-pushed the port/CBS-162-tax-component-editability-lock branch from 107c007 to a1fb7ae Compare August 19, 2026 11:05
Percentage, GL account, and start date fields on a TaxComponent become
read-only once the component is in use (mapped to a TaxGroup that is
referenced by at least one Charge); only the name remains editable.
Before activation (start date in the future) the start date can still
be changed, but only to another future date. Once active, only GL
accounts can be updated via the update endpoint, which previously
allowed no GL account changes at all.
@rymghosn
rymghosn force-pushed the port/CBS-162-tax-component-editability-lock branch from a1fb7ae to bb9fced Compare August 20, 2026 07:07
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.

1 participant