Skip to content

Kemi: stock history is ordered by date but balances follow entry order #1461

Open

Description

@renemadsen

What is wrong

The stock history rows (W2 Lagerhistorik and the W6 stock lines) are ordered by At, but balanceAfter is computed in entry Id order. A backdated entry therefore shows a balance that does not follow from the row below it. The web cannot backdate (at: null in the stock dialog), only an offline mobile outbox can, so it is rare.

Where (stable a81a41b)

  • eform-client/src/app/plugins/modules/backend-configuration-pn/modules/chemicals/helpers/chemical-inventory.helper.ts:171 (b.at.localeCompare(a.at) || b.id - a.id)
  • eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/ChemicalReporting/ChemicalHistoryService.cs:346-347 (order by At, then Action, PlacementId, Seq) against ChemicalInventoryService.BalanceAfterByEntry used at ChemicalHistoryService.cs:134

Suggested fix

Decide the intended order. Either show the balance in the same order as the rows (fold by At), or add a visible cue that a balance follows entry order. Add a test with a backdated entry.

Origin

Plan E final review m-6 (and the parked T13 item), PR #1437 (merged as a81a41b).

🤖 Generated with Claude Code

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions