@@ -, +, @@ ecost_tax_included/ecost_tax_excluded --- C4/Acquisition.pm | 1 + acqui/basket.pl | 2 ++ t/Prices.t | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 1 deletion(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -2883,6 +2883,7 @@ sub populate_order_with_prices { if ( $bookseller->listincgst ) { # The user entered the prices tax included + $order->{unitprice} += 0; $order->{unitprice_tax_included} = $order->{unitprice}; $order->{rrp_tax_included} = $order->{rrp}; --- a/acqui/basket.pl +++ a/acqui/basket.pl @@ -459,6 +459,8 @@ sub get_order_infos { $line{budget_name} = $budget->{budget_name}; # If we have an actual cost that should be the total, otherwise use the ecost + $line{unitprice_tax_included} += 0; + $line{unitprice_tax_excluded} += 0; my $cost_tax_included = $line{unitprice_tax_included} || $line{ecost_tax_included}; my $cost_tax_excluded = $line{unitprice_tax_excluded} || $line{ecost_tax_excluded}; $line{total_tax_included} = get_rounded_price($cost_tax_included) * $line{quantity}; --- a/t/Prices.t +++ a/t/Prices.t @@ -151,7 +151,7 @@ for my $currency_format ( qw( US FR ) ) { }; subtest 'Configuration 1: 1 1 (Vendor List prices do include tax / Invoice prices include tax)' => sub { - plan tests => 8; + plan tests => 11; my $biblionumber_1_1 = 43; my $order_1_1 = { @@ -250,6 +250,55 @@ for my $currency_format ( qw( US FR ) ) { field => 'tax_value' } ); + + # When unitprice is 0.00 C4::Acquisition->populate_order_with_prices() falls back to using ecost_tax_included and ecost_tax_excluded + $order_1_1 = { + biblionumber => $biblionumber_1_1, + quantity => 1, + listprice => 10, + unitprice => '0.00', + quantityreceived => 1, + basketno => $basketno_1_1, + invoiceid => $invoiceid_1_1, + rrp => 10.00, + ecost => 10.00, + tax_rate => 0.1500, + discount => 0, + datereceived => $today + }; + + $order_1_1 = C4::Acquisition::populate_order_with_prices( + { + order => $order_1_1, + booksellerid => 4, + ordering => 1, + } + ); + + compare( + { + got => $order_1_1->{ecost_tax_included}, + expected => 10.00, + conf => '1 1', + field => 'ecost_tax_included' + } + ); + compare( + { + got => $order_1_1->{ecost_tax_excluded}, + expected => 8.70, + conf => '1 1', + field => 'ecost_tax_excluded' + } + ); + compare( + { + got => $order_1_1->{tax_value_on_ordering}, + expected => 1.30, + conf => '1 1', + field => 'tax_value' + } + ); }; subtest 'Configuration 1: 1 0 (Vendor List prices include tax / Invoice prices do not include tax)' => sub { @@ -492,6 +541,7 @@ for my $currency_format ( qw( US FR ) ) { } ); }; + } sub compare { --