OP-1428 Persist the per-lot remaining quantity (LT_QTY) - #1645
OP-1428 Persist the per-lot remaining quantity (LT_QTY)#1645giuseppesorge wants to merge 5 commits into
Conversation
… computed definition
Add LT_QTY to the oh_medicaldsrlot demo table and back-fill it from the demo stock movements (main store plus wards), regenerated via a MariaDB round-trip of the migration, so a clean demo DB matches the migrated schema.
|
@dbmalkovsky — good call, thanks. Synced |
1 similar comment
|
@dbmalkovsky — good call, thanks. Synced |
…lot-quantity # Conflicts: # sql/step_04_all_following_steps.sql
|
Merged |
OP-1428 (Persist the per-lot remaining quantity LT_QTY): https://openhospital.atlassian.net/browse/OP-1428
Follow-up of OP-1231. Persists
LT_QTY(DECIMAL(19,2)) onOH_MEDICALDSRLOTas a mirror of the computed hospital-wide overall quantity, maintained by atomic per-operation deltas (as agreed on the issue: LT_QTY is the total remaining quantity; charge/discharge/delete operations only apply their own delta).LotIoOperationRepository.updateQuantity(code, delta)— atomic@Modifyingincrement (no optimistic-lock retries;LT_QTYisupdatable = falseso entity saves can't clobber it).MedicalStockIoOperations.updateStockQuantity, +qty; store→ward discharge is net-zero by design), delete-last-movement (MovBrowserManager, −qty when the lot survives), ward dispense/rectify (MedicalStockWardIoOperations, the delta mirrors the INT-truncated ward columns to stay consistent), delete-last-ward-movement (MovWardBrowserManager). Sign follows the type prefix ('+%') like the computed definition.sql/step_aXXX_persist_lot_quantity.sql: adds the column + backfills from movements/ward stock (consistent with the live JPQL). Migration tested on a real MariaDB 10.6 demo copy (values match the live computation).@Transientmain-store/ward quantities stay as the validation/strip-empty source;getOverallQuantity()is unchanged.Note: one deviation to flag — the io-level
updateStockQuantityDISCHARGE branch decrements LT_QTY for theward == nullcase (reachable via the io API / existing tests), where stock genuinely leaves the hospital.Merge order: this must merge before OP-1427 (openhospital-core#1646), whose migration drops
MDSRWRD_LT_ID_Athat this backfill joins on.