Bug 31840 - Incorrect warning that order total amount exceeds allowed budget when editing existing order
Summary: Incorrect warning that order total amount exceeds allowed budget when editing...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Aleisha Amohia
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 31631
  Show dependency treegraph
 
Reported: 2022-10-17 00:43 UTC by Aleisha Amohia
Modified: 2023-06-08 22:28 UTC (History)
0 users

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patch deducts the current cost of an order if modifying it, so that the current cost isn't counted when checking whether the updated cost will take the order total amount above the allowed budget.
Version(s) released in:
22.11.00


Attachments
Bug 31840: Consider current cost if modifying order (2.37 KB, patch)
2022-10-17 02:27 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 31840: Consider current cost if modifying order (2.41 KB, patch)
2022-10-19 04:50 UTC, David Nind
Details | Diff | Splinter Review
Bug 31840: Consider current cost if modifying order (2.52 KB, patch)
2022-11-02 17:51 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2022-10-17 00:43:58 UTC
We've noticed that we're getting a warning that the order total amount exceeds the allowed budget when we shouldn't be.

To reproduce:

1. Add an active budget of $1,000
2. Attach a fund of $900
3. In Acquisitions, add an order to a basket, give it a vendor price of $500 with no discount and Save
4. Modify the order and change the vendor price to $450. Save the order
5. Notice the warning that we'll exceed the allowed budget, even though this is the only order using this fund and it does not exceed $900.

Koha does a weird 500+450 calculation and thinks we've now ordered more than $900 but it is not considering that we've modified an existing order.
Comment 1 Aleisha Amohia 2022-10-17 02:27:14 UTC
Created attachment 141949 [details] [review]
Bug 31840: Consider current cost if modifying order

This patch deducts the current cost of an order if modifying it, so that
the current cost isn't counted when checking whether the updated cost
will take the order total amount above the allowed budget.

To test:
1. Add an active budget of $1,000
2. Attach a fund of $1,000. Set the fund to warn at 98% and $900.
3. Add an order to a basket, give it a vendor price of $500 with no
discount or tax and Save
4. Modify the order and change the vendor price to $450 and Save
5. Notice you get a warning that this order total amount will exceed the
allowed budget - this is incorrect.
6. Apply the patch and cancel the change so you're redirected back to
the basket
7. Modify the order and change the vendor price to $450 and Save
8. You should be able to Save without requiring confirmation
9. Add another order to the basket, give it a vendor price of $100 with
no discount or tax and Save. This should save normally, confirming we
can add new orders that do not exceed the allowed budget
10. Add another order to the basket, give it a vendor price of $500 with
no discount or tax and Save. This should trigger the warning that you
will exceed the allowed budget, as expected.

Sponsored-by: Waikato Institute of Technology
Comment 2 David Nind 2022-10-19 04:50:15 UTC
Created attachment 142129 [details] [review]
Bug 31840: Consider current cost if modifying order

This patch deducts the current cost of an order if modifying it, so that
the current cost isn't counted when checking whether the updated cost
will take the order total amount above the allowed budget.

To test:
1. Add an active budget of $1,000
2. Attach a fund of $1,000. Set the fund to warn at 98% and $900.
3. Add an order to a basket, give it a vendor price of $500 with no
discount or tax and Save
4. Modify the order and change the vendor price to $450 and Save
5. Notice you get a warning that this order total amount will exceed the
allowed budget - this is incorrect.
6. Apply the patch and cancel the change so you're redirected back to
the basket
7. Modify the order and change the vendor price to $450 and Save
8. You should be able to Save without requiring confirmation
9. Add another order to the basket, give it a vendor price of $100 with
no discount or tax and Save. This should save normally, confirming we
can add new orders that do not exceed the allowed budget
10. Add another order to the basket, give it a vendor price of $500 with
no discount or tax and Save. This should trigger the warning that you
will exceed the allowed budget, as expected.

Sponsored-by: Waikato Institute of Technology

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Katrin Fischer 2022-11-02 17:51:16 UTC
Created attachment 143023 [details] [review]
Bug 31840: Consider current cost if modifying order

This patch deducts the current cost of an order if modifying it, so that
the current cost isn't counted when checking whether the updated cost
will take the order total amount above the allowed budget.

To test:
1. Add an active budget of $1,000
2. Attach a fund of $1,000. Set the fund to warn at 98% and $900.
3. Add an order to a basket, give it a vendor price of $500 with no
discount or tax and Save
4. Modify the order and change the vendor price to $450 and Save
5. Notice you get a warning that this order total amount will exceed the
allowed budget - this is incorrect.
6. Apply the patch and cancel the change so you're redirected back to
the basket
7. Modify the order and change the vendor price to $450 and Save
8. You should be able to Save without requiring confirmation
9. Add another order to the basket, give it a vendor price of $100 with
no discount or tax and Save. This should save normally, confirming we
can add new orders that do not exceed the allowed budget
10. Add another order to the basket, give it a vendor price of $500 with
no discount or tax and Save. This should trigger the warning that you
will exceed the allowed budget, as expected.

Sponsored-by: Waikato Institute of Technology

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 4 Tomás Cohen Arazi 2022-11-04 23:21:22 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!