Details
-
Bug
-
Status: Closed (View Workflow)
-
P3
-
Resolution: Done
-
None
-
-
ACQ Sprint 60
-
1
-
Thunderjet
Description
Overview
The calculation of the order total estimated price is done in MODORDERS-181. However implementation is just to sum double values. This is not right (for example, 1.23 + 4.56 = 5.789999999999999 see Why You Should Never Use Float and Double for Monetary Calculations)
Steps to reproduce
- Create order:
HOST=folio-testing-backend01.aws.indexdata.com curl -X POST \ http://$HOST:9130/orders/composite-orders \ -H 'Content-Type: application/json' \ -H 'x-okapi-token: $OKAPITOKEN' \ -d '{ "orderType": "One-Time", "vendor": "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "compositePoLines": [ { "acquisitionMethod": "Purchase At Vendor System", "cost": { "listUnitPrice": 1.23, "currency": "USD", "quantityPhysical": 1 }, "locations": [ { "locationId": "758258bc-ecc1-41b8-abca-f7b610822ffd", "quantityPhysical": 1 } ], "orderFormat": "Physical Resource", "source": { "code": "FOLIO" } }, { "acquisitionMethod": "Purchase At Vendor System", "cost": { "listUnitPrice": 4.56, "currency": "USD", "quantityPhysical": 1 }, "locations": [ { "locationId": "f34d27c6-a8eb-461b-acd6-5dea81771e70", "quantityPhysical": 1 } ], "orderFormat": "Physical Resource", "source": { "code": "FOLIO" } } ] }'
- The created order:
{ "id" : "a8b53a33-bd91-4d35-99c0-37cb7a0ca8c2", "notes" : [ ], "poNumber" : "10003", "orderType" : "One-Time", "totalEstimatedPrice" : 5.789999999999998, "totalItems" : 2, "vendor" : "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "compositePoLines" : [ { "id" : "d98fef88-fdee-4f4f-8777-580d943dc4e7", "acquisitionMethod" : "Purchase At Vendor System", "alerts" : [ ], "claims" : [ ], "contributors" : [ ], "cost" : { "listUnitPrice" : 1.23, "currency" : "USD", "discountType" : "percentage", "quantityPhysical" : 1, "poLineEstimatedPrice" : 1.23 }, "fundDistribution" : [ ], "locations" : [ { "locationId" : "758258bc-ecc1-41b8-abca-f7b610822ffd", "quantityPhysical" : 1 } ], "orderFormat" : "Physical Resource", "poLineNumber" : "10003-1", "purchaseOrderId" : "a8b53a33-bd91-4d35-99c0-37cb7a0ca8c2", "receiptStatus" : "Pending", "reportingCodes" : [ ], "source" : { "code" : "FOLIO" }, "tags" : [ ] }, { "id" : "62980fc8-d37e-4926-b90f-acda9855283f", "acquisitionMethod" : "Purchase At Vendor System", "alerts" : [ ], "claims" : [ ], "contributors" : [ ], "cost" : { "listUnitPrice" : 4.56, "currency" : "USD", "discountType" : "percentage", "quantityPhysical" : 1, "poLineEstimatedPrice" : 4.56 }, "fundDistribution" : [ ], "locations" : [ { "locationId" : "f34d27c6-a8eb-461b-acd6-5dea81771e70", "quantityPhysical" : 1 } ], "orderFormat" : "Physical Resource", "poLineNumber" : "10003-2", "purchaseOrderId" : "a8b53a33-bd91-4d35-99c0-37cb7a0ca8c2", "receiptStatus" : "Pending", "reportingCodes" : [ ], "source" : { "code" : "FOLIO" }, "tags" : [ ] } ], "metadata" : { "createdDate" : "2019-03-27T09:01:05.100+0000", "createdByUserId" : "a867202f-4045-576c-8152-cb02220c6393", "updatedDate" : "2019-03-27T09:01:05.100+0000", "updatedByUserId" : "a867202f-4045-576c-8152-cb02220c6393" } }
Actual Results: As can be seen "totalEstimatedPrice" is 5.789999999999998 instead of expected 5.79
Expected: use BigDecimal instead of double when operating with prices
TestRail: Results
Attachments
Issue Links
- relates to
-
MODORDERS-180 Updates to poLine Cost
-
- Closed
-