-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inbound shipment cost price is NaN #5896
inbound shipment cost price is NaN #5896
Conversation
Bundle size differenceComparing this PR to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I can pop in a quick request? the outbound shipment suffers the same fate, as you've noted:
Would be nice to fix that too.
I would also say that there's no need to add a function to ArrayUtils if it is only used in one place.. though yes, it makes the test creation easier π
To that end.. I'd make the ArrayUtils function more generic and implement in both inbound and outbound. ticks both boxes
I've made the change in this suggestion branch
An alternative would be to fix the CurrencyCell.. as that input is demanding a number and not handling gracefully the bad data. I'd prefer to have |
β¦msupply into 5768-inbound-shipment-NaN-cost-price
Great thank you Mark! In regards to handling the data in Currency Cell, I did look at this but didn't come up with any answers. To me it looked like the NaN is handled prior to the calculation of the average, thus not returning the error or ' ' in this case. open-msupply/client/packages/common/src/ui/layout/tables/hooks/useColumns/useColumns.tsx Lines 73 to 82 in d36246d
If you have any wisdom on this that'd be great! |
β¦tion)' into 5768-inbound-shipment-NaN-cost-price
Great thank you for going into that for me! |
I can't merge until it's been ticked as approved π |
β¦msupply into 5768-inbound-shipment-NaN-cost-price
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π’
Fixes #5768
π©π»βπ» What does this PR do?
Creates an ArrayUtil function to handle the calculation of unit cost price (average from a 'grouped by' array). Added tests to check the new function.
Also updated SellPrice to CostPrice for the ungrouped result.
The existing function was returning NaN where
costPricePerPack
andnumberOfPacks
were both 0. Typescript does not check if NaN can be a result of a function that contains only number types, and allows0/0 = NaN
.There are already several NaN checks in place (eg in the Currency cell definition). This calculated cost price for the 'grouped by' option is not picked up as NaN from the cell type, so implemented the ArrayUtil to handle it.
This matches the pattern of other columns that use ArrayUtils for calculations
π Any notes for the reviewer?
It might be worth having another ArrayUtils calculation for 'Sell Price'
I can replicate this error for grouped sell price in
Outbound Shipment
->Detail View
Some other areas also using sell price column calculations, but I was unable to replicate NaN without the grouped toggle being available:
Outbound Shipment`` ->
Detail View->
Outbound Line Edit```Supplier Returns
->Detail View
Prescriptions
->Detail View
π§ͺ Testing
π Documentation
1.
2.