Add units, PO details, delivery date, and supplier columns to stock notification queries#304
Conversation
…and templates Updates both SQL queries and HTML templates in reference_notifications.md to include: Units, AMC, SOH, MOS, PO Placed, PO Number, Stock on Order, Delivery Date, and Supplier columns in the requested order. Adds consumption_months parameter for dynamic AMC/MOS header labeling. Agent-Logs-Url: https://github.com/msupply-foundation/notify/sessions/09a45cc7-cc88-4f58-a54e-136c22adf33b Co-authored-by: jmbrunskill <8287373+jmbrunskill@users.noreply.github.com>
|
@copilot can you add the The pos CTE's RANK() column exists but is not filtered on (ranking = 1) in the main query — this is pre-existing behavior, unchanged here. The max() aggregation handles multiple PO matches. That would ensure the max resolves to the same PO right? |
…ame purchase order Agent-Logs-Url: https://github.com/msupply-foundation/notify/sessions/6326016e-3b1d-4161-b3cc-096d301cd074 Co-authored-by: jmbrunskill <8287373+jmbrunskill@users.noreply.github.com>
Yes, exactly right — without the filter, |
|
@copilot getting this error see screenshot- note units are in a different table called unit
|
… i.units Agent-Logs-Url: https://github.com/msupply-foundation/notify/sessions/cfff383b-9663-47fd-821d-e72d797a144e Co-authored-by: jmbrunskill <8287373+jmbrunskill@users.noreply.github.com>
Fixed in a729d57. The |
|
@copilot can we rearrange the columns so that it appears in this order: Store name / Item code / Item Name / Units / AMC / SOH / MOS Remaining / PO Placed / PO Number / Stock on Order / Delivery Date / Supplier @louisaw123 I've had a quick look at the mSupply Docs and a copy of the dashboard database. I can't see where/how the AMC is defined from the docs it sounds like it might be all months with consumptions?. Perhaps have a discussion with @JonnaQuismundo or @ferreiratoni might be familar with this? One option it to make this configurable with another parameter. We could take the months consumption numbers for the last x months and average them in the query, or I think in a number of places we've re-implemented AMC calcs in the query itself. I think if we want to go that way best to provide a query from dashboard to base this one on. |
…sted order Agent-Logs-Url: https://github.com/msupply-foundation/notify/sessions/f8f3679f-06cf-459a-a4fe-e61ede7b6b9e Co-authored-by: jmbrunskill <8287373+jmbrunskill@users.noreply.github.com>
Rearranged both templates to the requested column order: Store Name / Item Code / Item Name / Units / AMC / SOH / MOS Remaining / PO Placed / PO Number / Stock on Order / Delivery Date / Supplier (e625506). |
@jmbrunskill for dashboard, it's the average of all months (depends on look back period) regardless of whether there is any consumption. |
@JonnaQuismundo Is there anywhere lookback period is available to query in the dashboard database. @louisaw123 wants to display it. |
@jmbrunskill hmm, I dont think the lookback period is in dashboard. The config is in the scheduler.
Also want to correct my previous statement, only months with consumption are considered in AMC. |
|
Would there be an alternative way to grab it and present it then? It just needs to be somehow presented so that users are aware what the basis of the lookback is when it is presenting the information. Or otherwise even if it is a default as 12 then I am happy to have it included in the body of the message at the top before the table |
We could make it configurable so we can for example hardcode it to 3months? But it sounds like the information about the default one in mSupply isn't available in the dashboard database. |
|
@JonnaQuismundo is the lookback period able to be on dashboards? do you know if its the same in all countries or is it something that countries have changed themselves? |
@louisaw123 not without adding changes because we are not exporting the
It's usually 12. I don't know any country using different period. The configuration can be changed, but only support as normal user will not have access to the scheduler window. |
|
thanks team! in that case im happy with just having the text say (12 months) without pulling it from anywhere or doing anything extra then. can consider review in future if this changes (i.e., countries are able to adjust this easily without support), but otherwise we can just make an internal note of it for ourselves that this is where its coming from and to adjust if the country is known to have a different one. |
|
@copilot please add a note to the AMC column to say |
…ths parameter Agent-Logs-Url: https://github.com/msupply-foundation/notify/sessions/4e8c3888-9767-49a9-adbd-341f97695155 Co-authored-by: jmbrunskill <8287373+jmbrunskill@users.noreply.github.com>
jmbrunskill
left a comment
There was a problem hiding this comment.
It's working for Louisa, so I think good to merge:)





👩🏻💻 What does this PR do?
Extends the
critical_stockandstock_out_todayreference SQL queries and templates with additional columns for richer stock reporting.SQL changes (both queries):
nametable viapo.name_idin theposCTE to resolve supplier namesunittable viai.unit_IDto resolve item units (units are stored in a separateunittable, not on theitemtable directly)u.units,po.serial_number,po_outstanding,delivery_date_expected, and supplier name to SELECTcurrentMOSaggregator join tostock_out_today(was previously missing)u.unitsposCTE join onranking = 1so all PO-related columns (serial_number, supplier, delivery_date, po_outstanding) consistently resolve from the single most recent confirmed PO per store/itemTemplate changes (both notifications):
AMC (12 months)— the lookback period is typically 12 months across deployments and is not queryable from the dashboard database🧪 How has/should this change been tested?
Documentation-only change. Verify SQL syntax and template variable references match by visual review. Queries should be validated against an mSupply database with aggregator data populated.
💌 Any notes for the reviewer?
po.serial_numberandpo.name_idfield names are based on the mSupply purchase_order schema — worth confirming against the target deployment.LEFT JOIN unit u ON i.unit_ID = u.idsince theitemtable stores a foreign key (unit_ID) rather than the unit name directly.📃 Documentation
docs/reference_notifications.md— added columns, templates, and parameters for bothcritical_stockandstock_out_todaynotifications