msupply-foundation / open-msupply

Open mSupply represents our most recent advancement in the Logistics Management Information System (LMIS), expanding on more than two decades of development inherited from the well-established legacy of the original mSupply.
https://msupply.foundation/open-msupply/
Other
23 stars 15 forks source link

Open mSupply Views don't account for negative stock correctly #5368

Open jmbrunskill opened 2 days ago

jmbrunskill commented 2 days ago

What went wrong? 😲

Discovered while investigating this issue... https://github.com/msupply-foundation/open-msupply/issues/5359

If an invoice is cancelled it creates a duplicate invoice with negative values in it.

image

However, our stock movements view filters out these canceled invoices, but still includes the uncancelled version.

image

This means our ledger is incorrect, and results in miss-calculations when backdating stock

Expected behaviour πŸ€”

We either need to include cancelled invoice movements in the stock movements OR filter out both the original and the cancellation (treating it as though the stock movement never happened)

I think the first one sounds easier but might have unexpected effects on item_stats?

How to Reproduce πŸ”¨

Steps to reproduce the behaviour:

  1. Create an invoice in mSupply, cancel that invoice, then migrate the store to OMS
  2. Check Ledger in open-mSupply (See the cancelation is missing from ledge)
  3. This might also allow you to back date a prescription to before you first introduced stock as it's using the same data source

Your environment 🌱

roxy-dao commented 2 days ago

Putting as high as ledger integrity is pretty important and milestone pending Gary's reply on backdating prescriptions release

roxy-dao commented 1 day ago

Gary has confirmed that backdated prescriptions won't be deployed until early 2025, so putting this to be fixed in 2.4 during cooldown period