Bug 23195 - Shipping costs are inconsistent in where displayed
Summary: Shipping costs are inconsistent in where displayed
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-24 16:22 UTC by Kelly McElligott
Modified: 2021-05-24 17:03 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
With this patch the shipping costs added to an invoice are always counted as "spent". With this change the totals on the start page of the acquisition module will match the totals on the ordered and spent pages for a fund.
Version(s) released in:
21.05.00,20.11.06,20.05.12


Attachments
Bug 23195: Unit tests (2.98 KB, patch)
2021-04-12 18:19 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 23195: Always count shipping costs as 'spent' (4.12 KB, patch)
2021-04-12 18:20 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 23195: Unit tests (3.12 KB, patch)
2021-04-13 16:20 UTC, Séverine Queune
Details | Diff | Splinter Review
Bug 23195: Always count shipping costs as 'spent' (4.27 KB, patch)
2021-04-13 16:20 UTC, Séverine Queune
Details | Diff | Splinter Review
Bug 23195: Unit tests (3.18 KB, patch)
2021-04-17 18:44 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 23195: Always count shipping costs as 'spent' (4.33 KB, patch)
2021-04-17 18:44 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 23195: (follow-up) One text invoice should be open (869 bytes, patch)
2021-04-21 11:18 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kelly McElligott 2019-06-24 16:22:24 UTC
When an invoice has shipping costs included in it, the totals are displayed inconsistently in Koha Acquisitions.

If looking at the acqui-home.pl, the shipping costs are included in the total, however, clicking on the link to see the ordered totals (ordered.pl), shipping costs are not included in this view, causing the totals to not be consistent.
Comment 1 Nick Clemens 2021-04-12 18:19:57 UTC
Created attachment 119466 [details] [review]
Bug 23195: Unit tests
Comment 2 Nick Clemens 2021-04-12 18:20:01 UTC
Created attachment 119467 [details] [review]
Bug 23195: Always count shipping costs as 'spent'

As shipping costs are created when an invoice is created, and creation
of an invoice implies that items have been received, the shipment costs
are always assumed to be 'spent'

This logic is true in GetBudgetSpent/GetBudgetOrdered, however, GetBudgetHierarchy
treats open invoices shipping costs as 'ordered' and closed invoice shipping costs
as 'spent'

This leads to inconsistencies in acqui-home vs spent.pl and ordered.pl

To test:
 1 - Find a vendor
 2 - Click 'Receive shipments'
 3 - Create a new invoice with a shipping cost on budget A
 4 - Repeate and create a new invoice with a shipping cost on budget B
 5 - Close the second invoice
 6 - View acquisitions ome
 7 - Note budget A includes the shipping under ordered
 8 - Note budget B includes the shipping under spent
 9 - Click the 'ordered' column on budget A - no shipping is listed on ordered page
10 - Click the spent column on budget A - the shipping is listed here
11 - Apply patch
12 - Both budgets list the shipping as 'spent'
13 - Both 'spent' pages include the shipping
14 - Neither 'ordered' page includes shipping
Comment 3 Séverine Queune 2021-04-13 16:20:25 UTC
Created attachment 119542 [details] [review]
Bug 23195: Unit tests

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 4 Séverine Queune 2021-04-13 16:20:29 UTC
Created attachment 119543 [details] [review]
Bug 23195: Always count shipping costs as 'spent'

As shipping costs are created when an invoice is created, and creation
of an invoice implies that items have been received, the shipment costs
are always assumed to be 'spent'

This logic is true in GetBudgetSpent/GetBudgetOrdered, however, GetBudgetHierarchy
treats open invoices shipping costs as 'ordered' and closed invoice shipping costs
as 'spent'

This leads to inconsistencies in acqui-home vs spent.pl and ordered.pl

To test:
 1 - Find a vendor
 2 - Click 'Receive shipments'
 3 - Create a new invoice with a shipping cost on budget A
 4 - Repeate and create a new invoice with a shipping cost on budget B
 5 - Close the second invoice
 6 - View acquisitions ome
 7 - Note budget A includes the shipping under ordered
 8 - Note budget B includes the shipping under spent
 9 - Click the 'ordered' column on budget A - no shipping is listed on ordered page
10 - Click the spent column on budget A - the shipping is listed here
11 - Apply patch
12 - Both budgets list the shipping as 'spent'
13 - Both 'spent' pages include the shipping
14 - Neither 'ordered' page includes shipping

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 5 Séverine Queune 2021-04-13 16:24:29 UTC
I never noticed that problem, very nice catch !
Thanks Nick for the good fix !
Comment 6 Katrin Fischer 2021-04-17 18:43:00 UTC
Pondering this: 

If I am reading this correctly, than shipping costs will always seen as "spent" immediately, independent of the invoice status.
... and after testing I realize that this is exactly how the costs from the order lines work as well. So this really makes sense.

We had to "hunt" down for shipping costs on non-closed invoices in the past, as they remained as 'encumbered' when the budget was closed. So quite happy about this change.
Comment 7 Katrin Fischer 2021-04-17 18:44:05 UTC
Created attachment 119797 [details] [review]
Bug 23195: Unit tests

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Katrin Fischer 2021-04-17 18:44:09 UTC
Created attachment 119798 [details] [review]
Bug 23195: Always count shipping costs as 'spent'

As shipping costs are created when an invoice is created, and creation
of an invoice implies that items have been received, the shipment costs
are always assumed to be 'spent'

This logic is true in GetBudgetSpent/GetBudgetOrdered, however, GetBudgetHierarchy
treats open invoices shipping costs as 'ordered' and closed invoice shipping costs
as 'spent'

This leads to inconsistencies in acqui-home vs spent.pl and ordered.pl

To test:
 1 - Find a vendor
 2 - Click 'Receive shipments'
 3 - Create a new invoice with a shipping cost on budget A
 4 - Repeate and create a new invoice with a shipping cost on budget B
 5 - Close the second invoice
 6 - View acquisitions ome
 7 - Note budget A includes the shipping under ordered
 8 - Note budget B includes the shipping under spent
 9 - Click the 'ordered' column on budget A - no shipping is listed on ordered page
10 - Click the spent column on budget A - the shipping is listed here
11 - Apply patch
12 - Both budgets list the shipping as 'spent'
13 - Both 'spent' pages include the shipping
14 - Neither 'ordered' page includes shipping

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Jonathan Druart 2021-04-21 08:43:10 UTC
The tests are passing without the patch.
Comment 10 Nick Clemens 2021-04-21 11:18:29 UTC
Created attachment 119941 [details] [review]
Bug 23195: (follow-up) One text invoice should be open
Comment 11 Jonathan Druart 2021-04-22 12:39:20 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 12 Fridolin Somers 2021-04-29 14:08:55 UTC
Pushed to 20.11.x for 20.11.06
Comment 13 Andrew Fuerste-Henry 2021-05-24 16:47:23 UTC
Pushed to 20.05.x for 20.05.12
Comment 14 Victor Grousset/tuxayo 2021-05-24 17:03:05 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.