From 2e0a69609f0577829d089222d07747d33006b427 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Nov 2019 12:09:11 +0000 Subject: [PATCH] Bug 23523: (follow-up) Adjust tests for new expectations Signed-off-by: Martin Renvoize --- t/Prices.t | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/t/Prices.t b/t/Prices.t index 4039233f5d..b42ce9af6f 100644 --- a/t/Prices.t +++ b/t/Prices.t @@ -253,14 +253,14 @@ for my $currency_format ( qw( US FR ) ) { }; subtest 'Configuration 1: 1 0' => sub { - plan tests => 8; + plan tests => 9; my $biblionumber_1_0 = 44; my $order_1_0 = { biblionumber => $biblionumber_1_0, quantity => 2, listprice => 82.000000, - unitprice => 70.290000, + unitprice => 0, quantityreceived => 2, basketno => $basketno_1_1, invoiceid => $invoiceid_1_1, @@ -311,6 +311,8 @@ for my $currency_format ( qw( US FR ) ) { field => 'ecost_tax_excluded' } ); + # If we order with unitprice = 0, tax is calculated from the ecost + # (note that in addorder.pl and addorderiso2709 the unitprice may/will be set to the ecost compare( { got => $order_1_0->{tax_value_on_ordering}, @@ -319,6 +321,23 @@ for my $currency_format ( qw( US FR ) ) { field => 'tax_value' } ); + $order_1_0->{unitprice} = 70.29; + $order_1_0 = C4::Acquisition::populate_order_with_prices( + { + order => $order_1_0, + booksellerid => 3, + ordering => 1, + } + ); + # If a unitprice is provided at ordering, we calculate the tax from that + compare( + { + got => $order_1_0->{tax_value_on_ordering}, + expected => 6.69, + conf => '1 0', + field => 'tax_value' + } + ); $order_1_0 = C4::Acquisition::populate_order_with_prices( { @@ -355,14 +374,14 @@ for my $currency_format ( qw( US FR ) ) { }; subtest 'Configuration 1: 0 1' => sub { - plan tests => 8; + plan tests => 9; my $biblionumber_0_1 = 45; my $order_0_1 = { biblionumber => $biblionumber_0_1, quantity => 2, listprice => 82.000000, - unitprice => 77.490000, + unitprice => 0, quantityreceived => 2, basketno => $basketno_1_1, invoiceid => $invoiceid_1_1, @@ -413,6 +432,8 @@ for my $currency_format ( qw( US FR ) ) { field => 'ecost_tax_excluded' } ); + # If we order with unitprice = 0, tax is calculated from the ecost + # (note that in addorder.pl and addorderiso2709 the unitprice may/will be set to the ecost compare( { got => $order_0_1->{tax_value_on_ordering}, @@ -421,7 +442,23 @@ for my $currency_format ( qw( US FR ) ) { field => 'tax_value' } ); - + $order_0_1->{unitprice} = 77.490000; + $order_0_1 = C4::Acquisition::populate_order_with_prices( + { + order => $order_0_1, + booksellerid => 2, + ordering => 1, + } + ); + # If a unitprice is provided at ordering, we calculate the tax from that + compare( + { + got => $order_0_1->{tax_value_on_ordering}, + expected => 7.75, + conf => '0 1', + field => 'tax_value' + } + ); $order_0_1 = C4::Acquisition::populate_order_with_prices( { order => $order_0_1, -- 2.39.5