Fix billing data integrity, sale atomicity and stock safety #1
Reference in New Issue
Block a user
Delete Branch "fix/billing-data-integrity"
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?
Bills were persisted correctly but read back wrong. The read path rebuilt a
cart from its lines alone, dropping bill-level discounts and loyalty, so every
figure derived from a stored bill was overstated: the upload payload, the day
archive and the shift report. A discounted 529 bill read back as 620.
Money and data integrity
keep the reconstruction tier-less so the membership discount is not applied
twice. Trust the recorded total and points via SaleTransaction.storedTotal.
the loyalty update in one transaction. Previously a failure part-way through
left a persisted bill the cashier believed had failed, inviting a duplicate.
after its stock was sold passed validation and oversold.
read-modify-write could hand two sales the same number and fail UNIQUE.
re-import cannot restore stock that has already been sold.
hardcoded seed session, and pass the terminal id through.
whole on a tax invoice.
Sync and reporting
at one page; stop on rejection so rejected rows cannot loop forever.
schema already defined but nothing used. It was in memory, so the only record
that bills had been uploaded died at restart.
(business_date, cashier_name) so a till stays settleable after its bills are
uploaded and deleted. Schema v4 with a migration that carries v3 rows across.
Input and UI
in the focused field, and raise the bar to 60ms/char while a text field has
focus so typing a mobile number is not read as a scan. Clock and focus check
injected so the behaviour is testable.
the Charge button by up to 131px.
entered without its transaction.
number matches.
Cleanup
OrderDao.insertOrder, all superseded by commitSale.
Tests: 23 passing / 15 failing -> 90 passing. Fixed the two defects that broke
the existing suite (containsAll type argument, reset() needing a catalogue) and
deleted the leftover template test. Added coverage for the order round trip,
the day archive after a real sync, stock safety, checkout atomicity, the v3->v4
migration, scanner-versus-human input, and an app-level smoke test that renders
every module.
Note: bills already uploaded with a discount went up overstated. This stops it
happening again but does not correct historical server data.