Bug 31631 - Optionally choose for tax-exclusive values to be used for calculating fund values (spent, ordered)
Summary: Optionally choose for tax-exclusive values to be used for calculating fund va...
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alex Buckley
QA Contact: Testopia
URL:
Keywords:
Depends on: 31840
Blocks:
  Show dependency treegraph
 
Reported: 2022-09-27 03:50 UTC by Alex Buckley
Modified: 2022-11-04 02:27 UTC (History)
2 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 31631: Add new system preference (3.82 KB, patch)
2022-09-27 04:04 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 31631: Optionally use tax-exclusive values for calculating fund values (10.67 KB, patch)
2022-09-27 04:45 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 31631: Unit tests (5.49 KB, patch)
2022-09-27 04:45 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 31631: (follow-up) Use CalculateFundValuesIncludingTax when modifying existing order (1.68 KB, patch)
2022-10-25 03:14 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Screenshot - Receiving order - formatting and default values (96.16 KB, image/png)
2022-10-26 02:56 UTC, David Nind
Details
Bug 31631: Add new system preference (3.87 KB, patch)
2022-11-03 23:22 UTC, David Nind
Details | Diff | Splinter Review
Bug 31631: Optionally use tax-exclusive values for calculating fund values (10.72 KB, patch)
2022-11-03 23:22 UTC, David Nind
Details | Diff | Splinter Review
Bug 31631: Unit tests (5.54 KB, patch)
2022-11-03 23:22 UTC, David Nind
Details | Diff | Splinter Review
Bug 31631: (follow-up) Use CalculateFundValuesIncludingTax when modifying existing order (1.72 KB, patch)
2022-11-03 23:23 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Buckley 2022-09-27 03:50:29 UTC
Public and tertiary libraries in New Zealand can claim back tax on purchases - see https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10461#c33

This means these NZ libraries want to input prices with tax included (as that is what is printed on their invoices), but want the amount removed from their Koha funds to be tax exclusive (as they will be claiming back the tax). 

Bug 13324 enforced that tax-included values were always used for calculating fund values (spent, ordered), for all supplier configurations. 

It would be useful for NZ libraries if they could globally choose for tax-exclusive values to be used for calculating fund values, with the behaviour introduced by 13324 continuing as the default.
Comment 1 Alex Buckley 2022-09-27 04:04:18 UTC
Created attachment 141017 [details] [review]
Bug 31631: Add new system preference

Sponsored-by: Waikato Institute of Technology, New Zealand
Comment 2 Alex Buckley 2022-09-27 04:45:10 UTC
Created attachment 141018 [details] [review]
Bug 31631: Optionally use tax-exclusive values for calculating fund values

Test plan:
1. Apply patches
2. sudo koha-upgrade-schema <instance>
3. Restart services
4. Set TaxRates syspref = 0.15
5. Create a new fund with amount = 1000
6. Add an order to a basket with the following values:
- Fund = Choose the fund from step #5
- Quantity = 1
- Vendor price = 10
- Tax rate = 15%
- Discount = 20%
- Retail price = 10.00
- Replacement cost = 10.00
- Actual cost = 10.00
7. Go to the Acquisitions home page
8. Confirm the 'Ordered' column for the step #5 fund contains 9.20
9. Click on the 9.20 link and confirm the ordered.pl page that loads
also contains 9.20 as the 'Subtotal'

10. Change 'CalculateFundValuesIncludingTax' = 'Exclude'
11. On the Acquisitions home page confirm the 'Ordered' column now
contains 8.00
12. Click on the 8.00 link and confirm the ordered.pl page also contains
8.00 as the 'Subtotal'

13. Close your basket and receive your order keeping all the default
values
14. Go to the Acquisitions home page and confirm the 'Spent' column now
contains 8.00
15. Click on the 8.00 link and confirm the spent.pl page also contains
8.00 as the 'Subtotal'

16. Change 'CalculateFundValuesIncludingTax' = 'Include'
17. Confirm the 'Spent' column on the Acquisitions home page now shows
9.20
18. Click on the 9.20 link and confirm the spent.pl page also contains
9.20 as the 'Subtotal'

Sponsored-by: Waikato Institute of Technology, New Zealand
Comment 3 Alex Buckley 2022-09-27 04:45:33 UTC
Created attachment 141019 [details] [review]
Bug 31631: Unit tests

Test plan:
1. Run tests in koha-shell
sudo koha-shell <instance>
prove t/db_dependent/Budgets.t

Sponsored-by: Waikato Institute of Technology, New Zealand
Comment 4 Aleisha Amohia 2022-10-25 03:14:43 UTC
Created attachment 142597 [details] [review]
Bug 31631: (follow-up) Use CalculateFundValuesIncludingTax when modifying existing order

This patch depends on Bug 31840.

To test:
1) Edit an order and increase the price so that you would expect it to
trigger a warning that you will exceed the amount allowed for this Fund
2) Confirm the warning is triggered
Comment 5 Aleisha Amohia 2022-10-25 03:15:09 UTC
Ready for testing.
Comment 6 David Nind 2022-10-26 02:56:12 UTC
Created attachment 142661 [details]
Screenshot - Receiving order - formatting and default values

Testing notes and issues/query (tested using koha-testing-docker).

Three things I noticed:

1. Tax Rate system preference warning message
---------------------------------------------

Even though I defined the Tax Rate system preference as 0.15, when adding an item to a basket: for tax rate there is a message saying "Tax rate not defined in system preference TaxRates!".

Despite the warning, everything is calculated correctly using the 15% tax rate. 

I've logged bug 31984 for this, as this was happening before the patches were applied (includes a screenshot to show what I mean).

2. Step 13 - Formatting things
------------------------------

When receiving order (see screenshot):

- For the Retail price field: no space after value and the opening bracket; no space between comma and tax exclusive

- For the Budgeted cost field: no space after value and the opening bracket

3. For step 13 - Query about using the default values
-----------------------------------------------------

I received the order with the default values (see the screenshot). As the actual cost defaulted to $10 (as entered in step 6), then the 10.00 is the value excluding tax, so:
- For step 14: spent = 10.00
- For step 15: subtotal = 10.00
- For step 17: spent = 11.50
- For step 18: subtotal = 11.50

These values are correctly calculated, but don't match up with the test plan. So should I have entered the actual costs as 8.00 (the $10 retail price less the 20% discount, tax exclusive)?
Comment 7 Aleisha Amohia 2022-11-03 22:11:15 UTC
Thanks for testing David

(In reply to David Nind from comment #6)
> Created attachment 142661 [details]
> Screenshot - Receiving order - formatting and default values
> 
> Testing notes and issues/query (tested using koha-testing-docker).
> 
> Three things I noticed:
> 
> 1. Tax Rate system preference warning message
> ---------------------------------------------
> 

Unrelated (exists before patches), see bug 31984 

> 
> 2. Step 13 - Formatting things
> ------------------------------
> 

Unrelated (exists before patches), maybe open another bug for this?

> 
> 3. For step 13 - Query about using the default values
> -----------------------------------------------------
> 
> These values are correctly calculated, but don't match up with the test
> plan. So should I have entered the actual costs as 8.00 (the $10 retail
> price less the 20% discount, tax exclusive)?

Yes I think that's right sorry!
Comment 8 David Nind 2022-11-03 23:22:45 UTC
Created attachment 143156 [details] [review]
Bug 31631: Add new system preference

Sponsored-by: Waikato Institute of Technology, New Zealand

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2022-11-03 23:22:50 UTC
Created attachment 143157 [details] [review]
Bug 31631: Optionally use tax-exclusive values for calculating fund values

Test plan:
1. Apply patches
2. sudo koha-upgrade-schema <instance>
3. Restart services
4. Set TaxRates syspref = 0.15
5. Create a new fund with amount = 1000
6. Add an order to a basket with the following values:
- Fund = Choose the fund from step #5
- Quantity = 1
- Vendor price = 10
- Tax rate = 15%
- Discount = 20%
- Retail price = 10.00
- Replacement cost = 10.00
- Actual cost = 10.00
7. Go to the Acquisitions home page
8. Confirm the 'Ordered' column for the step #5 fund contains 9.20
9. Click on the 9.20 link and confirm the ordered.pl page that loads
also contains 9.20 as the 'Subtotal'

10. Change 'CalculateFundValuesIncludingTax' = 'Exclude'
11. On the Acquisitions home page confirm the 'Ordered' column now
contains 8.00
12. Click on the 8.00 link and confirm the ordered.pl page also contains
8.00 as the 'Subtotal'

13. Close your basket and receive your order keeping all the default
values
14. Go to the Acquisitions home page and confirm the 'Spent' column now
contains 8.00
15. Click on the 8.00 link and confirm the spent.pl page also contains
8.00 as the 'Subtotal'

16. Change 'CalculateFundValuesIncludingTax' = 'Include'
17. Confirm the 'Spent' column on the Acquisitions home page now shows
9.20
18. Click on the 9.20 link and confirm the spent.pl page also contains
9.20 as the 'Subtotal'

Sponsored-by: Waikato Institute of Technology, New Zealand

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2022-11-03 23:22:55 UTC
Created attachment 143158 [details] [review]
Bug 31631: Unit tests

Test plan:
1. Run tests in koha-shell
sudo koha-shell <instance>
prove t/db_dependent/Budgets.t

Sponsored-by: Waikato Institute of Technology, New Zealand

Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2022-11-03 23:23:00 UTC
Created attachment 143159 [details] [review]
Bug 31631: (follow-up) Use CalculateFundValuesIncludingTax when modifying existing order

This patch depends on Bug 31840.

To test:
1) Edit an order and increase the price so that you would expect it to
trigger a warning that you will exceed the amount allowed for this Fund
2) Confirm the warning is triggered

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