Update total validation

Description

Overview: When using only dollar amount distributions the system doesn't acknowledge that all cost in accounted for and order will not open.
Fund distribution total validation should allow 2 cases: either totals in the currency add up, or percentages add up to 100%. Currently the first case is not supported (it used to be the only one supported before https://folio-org.atlassian.net/browse/MODORDERS-482#icft=MODORDERS-482).

Steps to Reproduce:

  1. Log into some FOLIO environment as User X

  2. Create order

  3. Add order line with cost of $90

  4. Add 3 fund distributions using percentage

  5. Each Fund 33.33%

  6. Save POL

  7. Click action menu for order

  8. Click Open

Expected Results: Order is opened and encumbered successfully. Three encumbrances, 1 for each fund for $30

 
Actual Results: Order fails to open. error shown "Fund distribution total must add to 100% or totalPrice"

Approach
New API should be created.
Please take a look -> https://folio-org.atlassian.net/browse/UIOR-988#icft=UIOR-988 Create API contract for fund distribution validation
File with APIs -> fundValidationAPIContract.txt

  • Reuse: org.folio.orders.utils.FundDistributionUtils#validateFundDistributionTotal

Additional Information: This was found in bugfest lotus release.

The new implementation should be callable directly by UI in a new endpoint. See https://folio-org.atlassian.net/browse/UIOR-988#icft=UIOR-988.

URL:

Interested parties:

CSP Request Details

None

CSP Rejection Details

None

Potential Workaround

Use a dollar amount for at least one of your fund distributions such that the system will not encounter a rounding error. ie. for $90 use 33.33%, 33.33% and $33.34. This ensures the total after rounding up or down is in fact $90 and not $89.991 resulting in 1 penny missing.

Attachments

20
  • 22 Jul 2022, 08:21 AM
  • 22 Jul 2022, 08:19 AM
  • 22 Jul 2022, 08:18 AM
  • 22 Jul 2022, 08:15 AM
  • 22 Jul 2022, 08:13 AM
  • 22 Jul 2022, 08:12 AM
  • 22 Jul 2022, 08:10 AM
  • 22 Jul 2022, 08:08 AM
  • 22 Jul 2022, 08:08 AM
  • 22 Jul 2022, 08:07 AM
  • 22 Jul 2022, 08:04 AM
  • 07 Jun 2022, 02:09 PM

Checklist

hide

TestRail: Results

Activity

Show:

Dennis Bridges August 8, 2022 at 8:36 PM

Test successful in bugfest-mg

Oleksii Petrenko July 25, 2022 at 12:49 PM

Deployed to MG bf. Please proceed with verification.

Serhii_Nosko July 22, 2022 at 8:21 AM

Postman collection has been attached and verified on the snapshot env:

Validation passed
Request:

{    "cost":{       "poLineEstimatedPrice":100.00,       "additionalCost":0,       "currency":"USD",       "discount":0,       "discountType":"percentage",       "exchangeRate":1,       "listUnitPrice":50,       "listUnitPriceElectronic":50,       "quantityElectronic":1,       "quantityPhysical":1    },    "fundDistribution":[       {          "code":"HIST",          "fundId":"63157e96-0693-426d-b0df-948bacdfdb08",          "distributionType":"percentage",          "value":50.0       },       {          "code":"EUROHIST",          "fundId":"e9285a1c-1dfc-4380-868c-e74073003f43",          "distributionType":"amount",          "value":50.00       }    ] }

Response:

Validation failed because inconsistent amounts

Request:

 

{    "cost":{       "poLineEstimatedPrice":100.00,       "additionalCost":0,       "currency":"USD",       "discount":0,       "discountType":"percentage",       "exchangeRate":1,       "listUnitPrice":50,       "listUnitPriceElectronic":50,       "quantityElectronic":1,       "quantityPhysical":1    },    "fundDistribution":[       {          "code":"HIST",          "fundId":"63157e96-0693-426d-b0df-948bacdfdb08",          "distributionType":"percentage",          "value":50.0       },       {          "code":"EUROHIST",          "fundId":"e9285a1c-1dfc-4380-868c-e74073003f43",          "distributionType":"amount",          "value":50.00       }    ] }

Response:

 

Validation failed because inconsistent amounts(test #2)

Request:

 

{    "cost":{       "listUnitPrice":90,       "listUnitPriceElectronic":0,       "currency":"USD",       "additionalCost":0,       "discount":0,       "discountType":"percentage",       "quantityPhysical":1,       "quantityElectronic":0,       "poLineEstimatedPrice":null    },    "fundDistribution":[       {          "code":"UNIV-SUBN",          "fundId":"4428a37c-8bae-4f0d-865d-970d83d5ad55",          "distributionType":"amount",          "value":50       },       {          "distributionType":"amount",          "value":35,          "fundId":"55f48dc6-efa7-4cfe-bc7c-4786efe493e3",          "code":"ASIAHIST"       }    ] }

Response:

 

Validation failed because inconsistent amounts(test #3)

Request:

 

{    "cost":{       "listUnitPrice":90,       "listUnitPriceElectronic":0,       "currency":"USD",       "additionalCost":0,       "discount":0,       "discountType":"percentage",       "quantityPhysical":1,       "quantityElectronic":0,       "poLineEstimatedPrice":null    },    "fundDistribution":[       {          "code":"UNIV-SUBN",          "fundId":"4428a37c-8bae-4f0d-865d-970d83d5ad55",          "distributionType":"amount",          "value":50       },       {          "distributionType":"amount",          "value":35,          "fundId":"55f48dc6-efa7-4cfe-bc7c-4786efe493e3",          "code":"ASIAHIST"       }    ] }

Response:

 

Validation failed because inconsistent amounts for zero price 

Request:

 

{    "cost":{       "listUnitPrice":"90",       "listUnitPriceElectronic":0,       "currency":"USD",       "additionalCost":0,       "discount":0,       "discountType":"percentage",       "quantityPhysical":1,       "quantityElectronic":0,       "poLineEstimatedPrice":null    },    "fundDistribution":[       {          "code":"UNIV-SUBN",          "fundId":"4428a37c-8bae-4f0d-865d-970d83d5ad55",          "distributionType":"percentage",          "value":93       },       {          "distributionType":"percentage",          "value":3,          "fundId":"55f48dc6-efa7-4cfe-bc7c-4786efe493e3",          "code":"ASIAHIST"       }    ] }

Response:

 

For zero price remainingAmount param always will be 0.

Validation failed because mixed distribution types for zero price 

Request:

 

{    "cost":{       "poLineEstimatedPrice":null,       "additionalCost":0,       "currency":"USD",       "discount":0,       "discountType":"percentage",       "exchangeRate":1,       "listUnitPrice":0,       "listUnitPriceElectronic":0,       "quantityElectronic":1,       "quantityPhysical":1    },    "fundDistribution":[       {          "code":"HIST",          "fundId":"63157e96-0693-426d-b0df-948bacdfdb08",          "distributionType":"percentage",          "value":49.99       },       {          "code":"EUROHIST",          "fundId":"e9285a1c-1dfc-4380-868c-e74073003f43",          "distributionType":"percentage",          "value":50.00       }    ] }

Response:

 

Validation failed because required param missed

Request: ** 

 

{    "cost":{       "poLineEstimatedPrice":null,       "additionalCost":0,       "currency":"USD",       "discount":0,       "discountType":"percentage",       "exchangeRate":1,       "listUnitPrice":0,       "listUnitPriceElectronic":0,       "quantityElectronic":1,       "quantityPhysical":1    },    "fundDistribution":[       {          "code":"HIST",          "fundId":"63157e96-0693-426d-b0df-948bacdfdb08",          "distributionType":"percentage",          "value":33.33       },       {          "code":"EUROHIST",          "fundId":"e9285a1c-1dfc-4380-868c-e74073003f43",          "distributionType":"amount",          "value":33.33       }    ] }

Response:

 

 

Done

Details

Assignee

Reporter

Tester Assignee

Priority

Story Points

Sprint

Development Team

Thunderjet

Fix versions

Release

Morning Glory (R2 2022) Bug Fix

RCA Group

Legitimate regression

Affected Institution

!!!ALL!!!

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created June 7, 2022 at 2:09 PM
Updated August 8, 2022 at 8:36 PM
Resolved July 22, 2022 at 8:22 AM
TestRail: Cases
TestRail: Runs

Flag notifications