The patchsets on bugs 23523 and 23522 set and display respectively the unitprice_tax_included/unitprice_tax_excluded if 'Actual cost' has been entered. If 'Actual cost' is not entered entered then Koha should fallback to ecost_tax_included/ecost_tax_excluded. However the fallback is not working correctly. When 'Actual cost' is not set it has a value of 0.00 and Koha evaluates 0.00 to true so ecost_tax_included/ecost_tax_excluded is never used. e.g. In this fallback: my $cost_tax_included = $line{unitprice_tax_included} || $line{ecost_tax_included}; my $cost_tax_included = 0.00 || 7.23 $cost_tax_included is set to 0.00 as Perl treats 0.00 as true.
Created attachment 105866 [details] [review] Bug 25750: fix fallback to ecost_tax_included/ecost_tax_excluded If 'Actual cost' has not been set then it has the value of 0.00 which Perl evaluates to true so this patchset resets it to 0, so the fallback to ecost_tax_included/ecost_tax_excluded happens. Test plan: 1. Add item to acquisition basket (make sure the vendor has: tax rate: 15%, 'List prices: Include tax', 'Invoice prices: Include tax') 2. Set 'Vendor price' = 10 and do not set 'Actual cost' 3. Save order 4. Observe basket.pl shows 'Total tax exc.' has a value of 0.00 and GST column has value of -8.70 5. Jump into the database: select tax_value_on_ordering from aqorders where ordernumber=<ordernumber>; [You can get the ordernumber from clicking on the 'Modify' line the item is listed in] 6. Observe a negative value: -8.70 7. Apply patch and restart plack 8. Add a second item to the basket 9. Set 'Vendor price' = 10 and don't set 'Actual cost' 10. Save order 11. Observe basket.pl shows 'Total tax exc' has value of 8.70 and GST has value of 1.30 12. Repeat step 5 and observe tax_value_on_ordering = 1.30 Sponsored-by: Horowhenua District Council, NZ
Created attachment 105872 [details] [review] Bug 25750: fix fallback to ecost_tax_included/ecost_tax_excluded If 'Actual cost' has not been set then it has the value of 0.00 which Perl evaluates to true so this patchset resets it to 0, so the fallback to ecost_tax_included/ecost_tax_excluded happens. Test plan: 1. Add item to acquisition basket (make sure the vendor has: tax rate: 15%, 'List prices: Include tax', 'Invoice prices: Include tax') 2. Set 'Vendor price' = 10 and do not set 'Actual cost' 3. Save order 4. Observe basket.pl shows 'Total tax exc.' has a value of 0.00 and GST column has value of -8.70 5. Jump into the database: select tax_value_on_ordering from aqorders where ordernumber=<ordernumber>; [You can get the ordernumber from clicking on the 'Modify' line the item is listed in] 6. Observe a negative value: -8.70 7. Apply patch and restart plack 8. Add a second item to the basket 9. Set 'Vendor price' = 10 and don't set 'Actual cost' 10. Save order 11. Observe basket.pl shows 'Total tax exc' has value of 8.70 and GST has value of 1.30 12. Repeat step 5 and observe tax_value_on_ordering = 1.30 Sponsored-by: Horowhenua District Council, NZ Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Alex, try: $order->{unitprice} += 0; instead. And add a quick test to cover the change.
Created attachment 106217 [details] [review] Bug 25750: fix fallback to ecost_tax_included/ecost_tax_excluded If 'Actual cost' has not been set then it has the value of 0.00 which Perl evaluates to true so this patchset resets it to 0, so the fallback to ecost_tax_included/ecost_tax_excluded happens. Test plan: 1. Add item to acquisition basket (make sure the vendor has: tax rate: 15%, 'List prices: Include tax', 'Invoice prices: Include tax') 2. Set 'Vendor price' = 10 and do not set 'Actual cost' 3. Save order 4. Observe basket.pl shows 'Total tax exc.' has a value of 0.00 and GST column has value of -8.70 5. Jump into the database: select tax_value_on_ordering from aqorders where ordernumber=<ordernumber>; [You can get the ordernumber from clicking on the 'Modify' line the item is listed in] 6. Observe a negative value: -8.70 7. Apply patch and restart plack 8. Add a second item to the basket 9. Set 'Vendor price' = 10 and don't set 'Actual cost' 10. Save order 11. Observe basket.pl shows 'Total tax exc' has value of 8.70 and GST has value of 1.30 12. Repeat step 5 and observe tax_value_on_ordering = 1.30 13. Run t/Prices.t unit test: sudo koha-shell <instancename> prove t/Prices.t Sponsored-by: Horowhenua District Council, NZ
(In reply to Jonathan Druart in comment #3): Thanks very much Jonathan. I have made those changes :) Andrew if you have time could you please re-test the patch now?
Created attachment 106244 [details] [review] Bug 25750: fix fallback to ecost_tax_included/ecost_tax_excluded If 'Actual cost' has not been set then it has the value of 0.00 which Perl evaluates to true so this patchset resets it to 0, so the fallback to ecost_tax_included/ecost_tax_excluded happens. Test plan: 1. Add item to acquisition basket (make sure the vendor has: tax rate: 15%, 'List prices: Include tax', 'Invoice prices: Include tax') 2. Set 'Vendor price' = 10 and do not set 'Actual cost' 3. Save order 4. Observe basket.pl shows 'Total tax exc.' has a value of 0.00 and GST column has value of -8.70 5. Jump into the database: select tax_value_on_ordering from aqorders where ordernumber=<ordernumber>; [You can get the ordernumber from clicking on the 'Modify' line the item is listed in] 6. Observe a negative value: -8.70 7. Apply patch and restart plack 8. Add a second item to the basket 9. Set 'Vendor price' = 10 and don't set 'Actual cost' 10. Save order 11. Observe basket.pl shows 'Total tax exc' has value of 8.70 and GST has value of 1.30 12. Repeat step 5 and observe tax_value_on_ordering = 1.30 13. Run t/Prices.t unit test: sudo koha-shell <instancename> prove t/Prices.t Sponsored-by: Horowhenua District Council, NZ Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Hey Nick, I see you set bug 25322 as a dependent patchset of this bug report. I was wondering did you mean to set something else instead? As Bug 25322 does not touch the Acquisitions module. Thanks, Alex
Thanks Nick!
Created attachment 106410 [details] [review] Bug 25750: fix fallback to ecost_tax_included/ecost_tax_excluded If 'Actual cost' has not been set then it has the value of 0.00 which Perl evaluates to true so this patchset resets it to 0, so the fallback to ecost_tax_included/ecost_tax_excluded happens. Test plan: 1. Add item to acquisition basket (make sure the vendor has: tax rate: 15%, 'List prices: Include tax', 'Invoice prices: Include tax') 2. Set 'Vendor price' = 10 and do not set 'Actual cost' 3. Save order 4. Observe basket.pl shows 'Total tax exc.' has a value of 0.00 and GST column has value of -8.70 5. Jump into the database: select tax_value_on_ordering from aqorders where ordernumber=<ordernumber>; [You can get the ordernumber from clicking on the 'Modify' line the item is listed in] 6. Observe a negative value: -8.70 7. Apply patch and restart plack 8. Add a second item to the basket 9. Set 'Vendor price' = 10 and don't set 'Actual cost' 10. Save order 11. Observe basket.pl shows 'Total tax exc' has value of 8.70 and GST has value of 1.30 12. Repeat step 5 and observe tax_value_on_ordering = 1.30 13. Run t/Prices.t unit test: sudo koha-shell <instancename> prove t/Prices.t Sponsored-by: Horowhenua District Council, NZ Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Pushed to master for 20.11, thanks to everybody involved!
backported to 20.05.x for 20.05.04
backported to 19.11.x for 19.11.10
Missing dependencies for 19.05.x, can't backport.