Are we translating requisition_line.average_monthly_consumption correctly? #5184
Labels
bug
Something is borken
Priority: Must Have
The product will not work without this
Team Ruru 🦉
Andrei, Roxy, Ferg
Milestone
What went wrong? 😲
Month length is 30 rather than 365/12
open-msupply/server/util/src/constants.rs
Lines 7 to 8 in b654ba6
In OMS we're doing 30 for the length of a month.
https://github.com/msupply-foundation/mobile/blob/38602080d644736191062a02c024a1c7e804678c/src/database/utilities/constants.js#L16
In Mobile after much debate the consensus was to use
365/12
religiously.OG mostly uses
365.25/12
. IDK why mobile opted for 365 😆.We store as average monthly consumption rather than (average )daily consumption
open-msupply/server/service/src/sync/translations/requisition_line.rs
Line 111 in ecba924
On pull we translate we convert from daily to monthly and
ceil()
the value. My concern here is that at the translation layer we're applying a different month length constant and rounding saving it to the record - this could break the math of any of the other fields that were calculated based on the daily_consumption and a different length of month right? So possibly subtly breaking past data. This would bleed back to the central server if the records were pushed again.Why do we take the
ceil()
? I'm afraid again of how this may force a facet into all calculations that clients may not be expecting (say in future plugin based suggestions).Why didn't we just use
average_daily_consumption
? I'm guessing probably because OMS frontend found it was only showing AMC (for now 😉), so thought to just make the schema match?Expected behaviour 🤔
How to Reproduce 🔨
Steps to reproduce the behaviour:
Your environment 🌱
The text was updated successfully, but these errors were encountered: