|
Lines 3-11
Link Here
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
|
4 |
|
| 5 |
use Test::More tests => 44; |
5 |
use Test::More tests => 44; |
| 6 |
use C4::Acquisition qw( populate_order_with_prices ); |
|
|
| 7 |
use C4::Context; |
6 |
use C4::Context; |
| 8 |
use Koha::Database; |
7 |
use Koha::Database; |
|
|
8 |
use Koha::Acquisition::Bookseller; |
| 9 |
use Koha::Acquisition::Order; |
| 9 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
| 10 |
use t::lib::Mocks; |
11 |
use t::lib::Mocks; |
| 11 |
|
12 |
|
|
Lines 37-194
my $bookseller_exc_tax = Koha::Acquisition::Bookseller->new(
Link Here
|
| 37 |
} |
38 |
} |
| 38 |
)->store; |
39 |
)->store; |
| 39 |
|
40 |
|
| 40 |
my $order_exc_tax = { |
41 |
my $basket_exc_tax = Koha::Acquisition::Basket->new( |
| 41 |
tax_rate => .1965, |
42 |
{ |
|
|
43 |
basketname => 'Basket tax excluded', |
| 44 |
booksellerid => $bookseller_exc_tax->id, |
| 45 |
} |
| 46 |
)->store; |
| 47 |
|
| 48 |
my $order_exc_tax = Koha::Acquisition::Order->new({ |
| 49 |
tax_rate_on_ordering => .1965, |
| 50 |
tax_rate_on_receiving => .1965, |
| 42 |
discount => .42, |
51 |
discount => .42, |
| 43 |
rrp => 16.99, |
52 |
rrp => 16.99, |
| 44 |
unitprice => "0.00", |
53 |
unitprice => "0.00", |
| 45 |
quantity => 8, |
54 |
quantity => 8, |
| 46 |
}; |
55 |
basketno => $basket_exc_tax->basketno, |
|
|
56 |
}); |
| 47 |
|
57 |
|
| 48 |
#Vendor prices exclude tax, no rounding, ordering |
58 |
#Vendor prices exclude tax, no rounding, ordering |
| 49 |
t::lib::Mocks::mock_preference('OrderPriceRounding', ''); |
59 |
t::lib::Mocks::mock_preference('OrderPriceRounding', ''); |
| 50 |
my $order_with_prices = C4::Acquisition::populate_order_with_prices({ |
60 |
$order_exc_tax->populate_with_prices_for_ordering(); |
| 51 |
ordering => 1, |
|
|
| 52 |
booksellerid => $bookseller_exc_tax->id, |
| 53 |
order => $order_exc_tax, |
| 54 |
}); |
| 55 |
|
61 |
|
| 56 |
is( $order_with_prices->{rrp_tax_excluded}+0 ,16.99 ,"Ordering tax excluded, no round: rrp tax excluded is rrp"); |
62 |
is( $order_exc_tax->rrp_tax_excluded+0 ,16.99 ,"Ordering tax excluded, no round: rrp tax excluded is rrp"); |
| 57 |
is( $order_with_prices->{rrp_tax_included}+0 ,20.328535 ,"Ordering tax excluded, no round: rrp tax included is rr tax excluded * (1 + tax rate on ordering)"); |
63 |
is( $order_exc_tax->rrp_tax_included+0 ,20.328535 ,"Ordering tax excluded, no round: rrp tax included is rr tax excluded * (1 + tax rate on ordering)"); |
| 58 |
is( $order_with_prices->{ecost_tax_excluded}+0 ,9.8542 ,"Ordering tax excluded, no round: ecost tax excluded is rrp * ( 1 - discount )"); |
64 |
is( $order_exc_tax->ecost_tax_excluded+0 ,9.8542 ,"Ordering tax excluded, no round: ecost tax excluded is rrp * ( 1 - discount )"); |
| 59 |
is( $order_with_prices->{ecost_tax_included}+0 ,11.7905503 ,"Ordering tax excluded, no round: ecost tax included is ecost tax excluded * (1 + tax rate on ordering)"); |
65 |
is( $order_exc_tax->ecost_tax_included+0 ,11.7905503 ,"Ordering tax excluded, no round: ecost tax included is ecost tax excluded * (1 + tax rate on ordering)"); |
| 60 |
is( $order_with_prices->{tax_value_on_ordering}+0 ,15.4908024 ,"Ordering tax excluded, no round: tax value on ordering is quantity * ecost_tax_excluded * tax rate on ordering if no unitprice"); |
66 |
is( $order_exc_tax->tax_value_on_ordering+0 ,15.4908024 ,"Ordering tax excluded, no round: tax value on ordering is quantity * ecost_tax_excluded * tax rate on ordering if no unitprice"); |
| 61 |
|
67 |
|
| 62 |
$order_exc_tax->{unitprice} = 9.85; |
68 |
$order_exc_tax->unitprice(9.85); |
| 63 |
|
69 |
|
| 64 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
70 |
$order_exc_tax->populate_with_prices_for_ordering(); |
| 65 |
ordering => 1, |
|
|
| 66 |
booksellerid => $bookseller_exc_tax->id, |
| 67 |
order => $order_exc_tax, |
| 68 |
}); |
| 69 |
|
71 |
|
| 70 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.85 ,"Ordering tax excluded, no round: rrp tax excluded is rrp"); |
72 |
is( $order_exc_tax->unitprice_tax_excluded+0 ,9.85 ,"Ordering tax excluded, no round: rrp tax excluded is rrp"); |
| 71 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.785525 ,"Ordering tax excluded, no round: rrp tax included is rr tax excluded * (1 + tax rate on ordering)"); |
73 |
is( $order_exc_tax->unitprice_tax_included+0 ,11.785525 ,"Ordering tax excluded, no round: rrp tax included is rr tax excluded * (1 + tax rate on ordering)"); |
| 72 |
is( $order_with_prices->{tax_value_on_ordering}+0 ,15.4842 ,"Ordering tax excluded, no round: tax value on ordering is quantity * unitprice_tax_excluded * tax rate on ordering if unitprice"); |
74 |
is( $order_exc_tax->tax_value_on_ordering+0 ,15.4842 ,"Ordering tax excluded, no round: tax value on ordering is quantity * unitprice_tax_excluded * tax rate on ordering if unitprice"); |
| 73 |
|
75 |
|
| 74 |
#Vendor prices exclude tax, no rounding, receiving |
76 |
#Vendor prices exclude tax, no rounding, receiving |
| 75 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
77 |
$order_exc_tax->populate_with_prices_for_receiving(); |
| 76 |
receiving => 1, |
|
|
| 77 |
booksellerid => $bookseller_exc_tax->id, |
| 78 |
order => $order_exc_tax, |
| 79 |
}); |
| 80 |
|
78 |
|
| 81 |
is( $order_with_prices->{unitprice}+0 ,9.8542 ,"Receiving tax excluded, no round, rounded ecost tax excluded = rounded unitprice : unitprice is ecost tax excluded"); |
79 |
is( $order_exc_tax->unitprice+0 ,9.8542 ,"Receiving tax excluded, no round, rounded ecost tax excluded = rounded unitprice : unitprice is ecost tax excluded"); |
| 82 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.8542 ,"Receiving tax excluded, no round, rounded ecost tax excluded = rounded unitprice : unitprice tax excluded is ecost tax excluded"); |
80 |
is( $order_exc_tax->unitprice_tax_excluded+0 ,9.8542 ,"Receiving tax excluded, no round, rounded ecost tax excluded = rounded unitprice : unitprice tax excluded is ecost tax excluded"); |
| 83 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.7905503 ,"Receiving tax excluded, no round: unitprice tax included is unitprice tax excluded * (1 + tax rate on ordering)"); |
81 |
is( $order_exc_tax->unitprice_tax_included+0 ,11.7905503 ,"Receiving tax excluded, no round: unitprice tax included is unitprice tax excluded * (1 + tax rate on ordering)"); |
| 84 |
is( $order_with_prices->{tax_value_on_receiving}+0 ,15.4908024 ,"Receiving tax excluded, no round: tax value on receiving is quantity * unitprice_tax_excluded * tax rate on receiving"); |
82 |
is( $order_exc_tax->tax_value_on_receiving+0 ,15.4908024 ,"Receiving tax excluded, no round: tax value on receiving is quantity * unitprice_tax_excluded * tax rate on receiving"); |
| 85 |
|
83 |
|
| 86 |
|
84 |
|
| 87 |
$order_exc_tax->{unitprice} = 9.85; |
85 |
$order_exc_tax->unitprice(9.85); |
| 88 |
#populate order with prices updates the passed in order hashref |
86 |
#populate order with prices updates the passed in order hashref |
| 89 |
#we need to reset after additional tests and changes |
87 |
#we need to reset after additional tests and changes |
| 90 |
|
88 |
|
| 91 |
#Vendor prices exclude tax, rounding to nearest cent, ordering |
89 |
#Vendor prices exclude tax, rounding to nearest cent, ordering |
| 92 |
t::lib::Mocks::mock_preference('OrderPriceRounding', 'nearest_cent'); |
90 |
t::lib::Mocks::mock_preference('OrderPriceRounding', 'nearest_cent'); |
| 93 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
91 |
$order_exc_tax->populate_with_prices_for_ordering(); |
| 94 |
ordering => 1, |
|
|
| 95 |
booksellerid => $bookseller_exc_tax->id, |
| 96 |
order => $order_exc_tax, |
| 97 |
}); |
| 98 |
|
92 |
|
| 99 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.85 ,"Ordering tax excluded, round: unitprice tax excluded is unitprice"); |
93 |
is( $order_exc_tax->unitprice_tax_excluded+0 ,9.85 ,"Ordering tax excluded, round: unitprice tax excluded is unitprice"); |
| 100 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.785525 ,"Ordering tax excluded, round: unitprice tax included is unitprice tax excluded * (1 + tax rate on ordering)"); |
94 |
is( $order_exc_tax->unitprice_tax_included+0 ,11.785525 ,"Ordering tax excluded, round: unitprice tax included is unitprice tax excluded * (1 + tax rate on ordering)"); |
| 101 |
is( $order_with_prices->{rrp_tax_excluded}+0 ,16.99 ,"Ordering tax excluded, round: rrp tax excluded is rrp"); |
95 |
is( $order_exc_tax->rrp_tax_excluded+0 ,16.99 ,"Ordering tax excluded, round: rrp tax excluded is rrp"); |
| 102 |
is( $order_with_prices->{rrp_tax_included}+0 ,20.328535 ,"Ordering tax excluded, round: rrp tax included is rr tax excluded * (1 + tax rate on ordering)"); |
96 |
is( $order_exc_tax->rrp_tax_included+0 ,20.328535 ,"Ordering tax excluded, round: rrp tax included is rr tax excluded * (1 + tax rate on ordering)"); |
| 103 |
is( $order_with_prices->{ecost_tax_excluded}+0 ,9.8542 ,"Ordering tax excluded, round: ecost tax excluded is rrp * ( 1 - discount )"); |
97 |
is( $order_exc_tax->ecost_tax_excluded+0 ,9.8542 ,"Ordering tax excluded, round: ecost tax excluded is rrp * ( 1 - discount )"); |
| 104 |
is( $order_with_prices->{ecost_tax_included}+0 ,11.7905503 ,"Ordering tax excluded, round: ecost tax included is ecost tax excluded * (1 + tax rate on ordering)"); |
98 |
is( $order_exc_tax->ecost_tax_included+0 ,11.7905503 ,"Ordering tax excluded, round: ecost tax included is ecost tax excluded * (1 + tax rate on ordering)"); |
| 105 |
is( $order_with_prices->{tax_value_on_ordering}+0 ,15.4842 ,"Ordering tax excluded, round: tax value on ordering is quantity * ecost_tax_excluded * tax rate on ordering"); |
99 |
is( $order_exc_tax->tax_value_on_ordering+0 ,15.4842 ,"Ordering tax excluded, round: tax value on ordering is quantity * ecost_tax_excluded * tax rate on ordering"); |
| 106 |
|
100 |
|
| 107 |
#Vendor prices exclude tax, no rounding, receiving |
101 |
#Vendor prices exclude tax, no rounding, receiving |
| 108 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
102 |
$order_exc_tax->populate_with_prices_for_receiving(); |
| 109 |
receiving => 1, |
|
|
| 110 |
booksellerid => $bookseller_exc_tax->id, |
| 111 |
order => $order_exc_tax, |
| 112 |
}); |
| 113 |
|
103 |
|
| 114 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.8542 ,"Receiving tax excluded, round, rounded ecost tax excluded = rounded unitprice : unitprice tax excluded is ecost tax excluded"); |
104 |
is( $order_exc_tax->unitprice_tax_excluded+0 ,9.8542 ,"Receiving tax excluded, round, rounded ecost tax excluded = rounded unitprice : unitprice tax excluded is ecost tax excluded"); |
| 115 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.7905503 ,"Receiving tax excluded, round: unitprice tax included is unitprice tax excluded * (1 + tax rate on ordering)"); |
105 |
is( $order_exc_tax->unitprice_tax_included+0 ,11.7905503 ,"Receiving tax excluded, round: unitprice tax included is unitprice tax excluded * (1 + tax rate on ordering)"); |
| 116 |
is( $order_with_prices->{tax_value_on_receiving}+0 ,15.4842 ,"Receiving tax excluded, round: tax value on receiving is quantity * unitprice_tax_excluded * tax rate on receiving"); |
106 |
is( $order_exc_tax->tax_value_on_receiving+0 ,15.4842 ,"Receiving tax excluded, round: tax value on receiving is quantity * unitprice_tax_excluded * tax rate on receiving"); |
| 117 |
|
107 |
|
| 118 |
|
108 |
|
|
|
109 |
my $basket_inc_tax = Koha::Acquisition::Basket->new( |
| 110 |
{ |
| 111 |
basketname => 'Basket tax included', |
| 112 |
booksellerid => $bookseller_inc_tax->id, |
| 113 |
} |
| 114 |
)->store; |
| 119 |
|
115 |
|
| 120 |
my $order_inc_tax = { |
116 |
my $order_inc_tax = Koha::Acquisition::Order->new({ |
| 121 |
tax_rate => .1965, |
117 |
tax_rate_on_ordering => .1965, |
|
|
118 |
tax_rate_on_receiving => .1965, |
| 122 |
discount => .42, |
119 |
discount => .42, |
| 123 |
rrp => 20.33, |
120 |
rrp => 20.33, |
| 124 |
unitprice => 0.00, |
121 |
unitprice => 0.00, |
| 125 |
quantity => 8, |
122 |
quantity => 8, |
| 126 |
}; |
123 |
basketno => $basket_inc_tax->basketno, |
|
|
124 |
}); |
| 127 |
|
125 |
|
| 128 |
#Vendor prices include tax, no rounding, ordering |
126 |
#Vendor prices include tax, no rounding, ordering |
| 129 |
t::lib::Mocks::mock_preference('OrderPriceRounding', ''); |
127 |
t::lib::Mocks::mock_preference('OrderPriceRounding', ''); |
| 130 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
128 |
$order_inc_tax->populate_with_prices_for_ordering(); |
| 131 |
ordering => 1, |
|
|
| 132 |
booksellerid => $bookseller_inc_tax->id, |
| 133 |
order => $order_inc_tax, |
| 134 |
}); |
| 135 |
|
129 |
|
| 136 |
is( $order_with_prices->{rrp_tax_included}+0 ,20.33 ,"Ordering tax included, no round: rrp tax included is rrp"); |
130 |
is( $order_inc_tax->rrp_tax_included+0 ,20.33 ,"Ordering tax included, no round: rrp tax included is rrp"); |
| 137 |
is( $order_with_prices->{rrp_tax_excluded}+0 ,16.9912244045132 ,"Ordering tax included, no round: rrp tax excluded is rrp tax included / (1 + tax rate on ordering)"); |
131 |
is( $order_inc_tax->rrp_tax_excluded+0 ,16.9912244045132 ,"Ordering tax included, no round: rrp tax excluded is rrp tax included / (1 + tax rate on ordering)"); |
| 138 |
is( $order_with_prices->{ecost_tax_included}+0 ,11.7914 ,"Ordering tax included, no round: ecost tax included is rrp tax included * (1 - discount)"); |
132 |
is( $order_inc_tax->ecost_tax_included+0 ,11.7914 ,"Ordering tax included, no round: ecost tax included is rrp tax included * (1 - discount)"); |
| 139 |
is( $order_with_prices->{ecost_tax_excluded}+0 ,9.85491015461764 ,"Ordering tax included, no round: ecost tax excluded is rrp tax excluded * ( 1 - discount )"); |
133 |
is( $order_inc_tax->ecost_tax_excluded+0 ,9.85491015461764 ,"Ordering tax included, no round: ecost tax excluded is rrp tax excluded * ( 1 - discount )"); |
| 140 |
is( $order_with_prices->{tax_value_on_ordering}+0 ,15.4919187630589 ,"Ordering tax included, no round: tax value on ordering is ( ecost tax included - ecost tax excluded ) * quantity if no unitprice"); |
134 |
is( $order_inc_tax->tax_value_on_ordering+0 ,15.4919187630589 ,"Ordering tax included, no round: tax value on ordering is ( ecost tax included - ecost tax excluded ) * quantity if no unitprice"); |
| 141 |
|
135 |
|
| 142 |
$order_inc_tax->{unitprice} = 11.79; |
136 |
$order_inc_tax->unitprice(11.79); |
| 143 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
137 |
$order_inc_tax->populate_with_prices_for_ordering(); |
| 144 |
ordering => 1, |
|
|
| 145 |
booksellerid => $bookseller_inc_tax->id, |
| 146 |
order => $order_inc_tax, |
| 147 |
}); |
| 148 |
|
138 |
|
| 149 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.79 ,"Ordering tax included, no round: unitprice tax included is unitprice"); |
139 |
is( $order_inc_tax->unitprice_tax_included+0 ,11.79 ,"Ordering tax included, no round: unitprice tax included is unitprice"); |
| 150 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.85374007521939 ,"Ordering tax included, no round: unitprice tax excluded is unitprice tax included / (1 + tax_rate_on_ordering "); |
140 |
is( $order_inc_tax->unitprice_tax_excluded+0 ,9.85374007521939 ,"Ordering tax included, no round: unitprice tax excluded is unitprice tax included / (1 + tax_rate_on_ordering "); |
| 151 |
is( $order_with_prices->{tax_value_on_ordering}+0 ,15.4900793982449 ,"Ordering tax included, no round: tax value on ordering is ( unitprice tax included - unitprice tax excluded ) * quantity if unitprice"); |
141 |
is( $order_inc_tax->tax_value_on_ordering+0 ,15.4900793982449 ,"Ordering tax included, no round: tax value on ordering is ( unitprice tax included - unitprice tax excluded ) * quantity if unitprice"); |
| 152 |
|
142 |
|
| 153 |
#Vendor prices include tax, no rounding, receiving |
143 |
#Vendor prices include tax, no rounding, receiving |
| 154 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
144 |
$order_inc_tax->populate_with_prices_for_receiving(); |
| 155 |
receiving => 1, |
|
|
| 156 |
booksellerid => $bookseller_inc_tax->id, |
| 157 |
order => $order_inc_tax, |
| 158 |
}); |
| 159 |
|
145 |
|
| 160 |
is( $order_with_prices->{unitprice}+0 ,11.7914 ,"Receiving tax included, no round, rounded ecost tax excluded = rounded unitprice : unitprice is ecost tax excluded"); |
146 |
is( $order_inc_tax->unitprice+0 ,11.7914 ,"Receiving tax included, no round, rounded ecost tax excluded = rounded unitprice : unitprice is ecost tax excluded"); |
| 161 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.7914 ,"Receiving tax included, no round: unitprice tax included is unitprice"); |
147 |
is( $order_inc_tax->unitprice_tax_included+0 ,11.7914 ,"Receiving tax included, no round: unitprice tax included is unitprice"); |
| 162 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.85491015461764 ,"Receiving tax included, no round: unitprice tax excluded is unitprice tax included / (1 + tax rate on receiving)"); |
148 |
is( $order_inc_tax->unitprice_tax_excluded+0 ,9.85491015461764 ,"Receiving tax included, no round: unitprice tax excluded is unitprice tax included / (1 + tax rate on receiving)"); |
| 163 |
is( $order_with_prices->{tax_value_on_receiving}+0 ,15.4919187630589 ,"Receiving tax included, no round: tax value on receiving is quantity * unitprice_tax_excluded * tax rate on receiving"); |
149 |
is( $order_inc_tax->tax_value_on_receiving+0 ,15.4919187630589 ,"Receiving tax included, no round: tax value on receiving is quantity * unitprice_tax_excluded * tax rate on receiving"); |
| 164 |
|
150 |
|
| 165 |
#Vendor prices include tax, rounding to nearest cent, ordering |
151 |
#Vendor prices include tax, rounding to nearest cent, ordering |
| 166 |
t::lib::Mocks::mock_preference('OrderPriceRounding', 'nearest_cent'); |
152 |
t::lib::Mocks::mock_preference('OrderPriceRounding', 'nearest_cent'); |
| 167 |
$order_inc_tax->{unitprice} = 11.79; |
153 |
$order_inc_tax->unitprice(11.79); |
| 168 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
154 |
$order_inc_tax->populate_with_prices_for_ordering(); |
| 169 |
ordering => 1, |
|
|
| 170 |
booksellerid => $bookseller_inc_tax->id, |
| 171 |
order => $order_inc_tax, |
| 172 |
}); |
| 173 |
|
155 |
|
| 174 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.79 ,"Ordering tax included, round: unitprice tax included is unitprice"); |
156 |
is( $order_inc_tax->unitprice_tax_included+0 ,11.79 ,"Ordering tax included, round: unitprice tax included is unitprice"); |
| 175 |
is( $order_with_prices->{unitprice_tax_excluded}+0,9.85374007521939 ,"Ordering tax included, round: unitprice tax excluded is unitprice tax included / (1 + tax_rate_on_ordering "); |
157 |
is( $order_inc_tax->unitprice_tax_excluded+0,9.85374007521939 ,"Ordering tax included, round: unitprice tax excluded is unitprice tax included / (1 + tax_rate_on_ordering "); |
| 176 |
is( $order_with_prices->{rrp_tax_included}+0 ,20.33 ,"Ordering tax included, round: rrp tax included is rrp"); |
158 |
is( $order_inc_tax->rrp_tax_included+0 ,20.33 ,"Ordering tax included, round: rrp tax included is rrp"); |
| 177 |
is( $order_with_prices->{rrp_tax_excluded}+0 ,16.9912244045132 ,"Ordering tax included, round: rrp tax excluded is rounded rrp tax included * (1 + tax rate on ordering)"); |
159 |
is( $order_inc_tax->rrp_tax_excluded+0 ,16.9912244045132 ,"Ordering tax included, round: rrp tax excluded is rounded rrp tax included * (1 + tax rate on ordering)"); |
| 178 |
is( $order_with_prices->{ecost_tax_included}+0 ,11.7914 ,"Ordering tax included, round: ecost tax included is rounded rrp * ( 1 - discount )"); |
160 |
is( $order_inc_tax->ecost_tax_included+0 ,11.7914 ,"Ordering tax included, round: ecost tax included is rounded rrp * ( 1 - discount )"); |
| 179 |
is( $order_with_prices->{ecost_tax_excluded}+0 ,9.85491015461764 ,"Ordering tax included, round: ecost tax excluded is rounded ecost tax excluded * (1 - discount)"); |
161 |
is( $order_inc_tax->ecost_tax_excluded+0 ,9.85491015461764 ,"Ordering tax included, round: ecost tax excluded is rounded ecost tax excluded * (1 - discount)"); |
| 180 |
is( $order_with_prices->{tax_value_on_ordering}+0 ,15.52 ,"Ordering tax included, round: tax value on ordering is (ecost_tax_included - ecost_tax_excluded) * quantity"); |
162 |
is( $order_inc_tax->tax_value_on_ordering+0 ,15.52 ,"Ordering tax included, round: tax value on ordering is (ecost_tax_included - ecost_tax_excluded) * quantity"); |
| 181 |
|
163 |
|
| 182 |
#Vendor prices include tax, no rounding, receiving |
164 |
#Vendor prices include tax, no rounding, receiving |
| 183 |
$order_with_prices = C4::Acquisition::populate_order_with_prices({ |
165 |
$order_inc_tax->populate_with_prices_for_receiving(); |
| 184 |
receiving => 1, |
|
|
| 185 |
booksellerid => $bookseller_inc_tax->id, |
| 186 |
order => $order_inc_tax, |
| 187 |
}); |
| 188 |
|
166 |
|
| 189 |
is( $order_with_prices->{unitprice_tax_included}+0 ,11.7914 ,"Receiving tax included, round: rounded ecost tax included = rounded unitprice : unitprice tax excluded is ecost tax included"); |
167 |
is( $order_inc_tax->unitprice_tax_included+0 ,11.7914 ,"Receiving tax included, round: rounded ecost tax included = rounded unitprice : unitprice tax excluded is ecost tax included"); |
| 190 |
is( $order_with_prices->{unitprice_tax_excluded}+0 ,9.85491015461764 ,"Receiving tax included, round: unitprice tax excluded is unitprice tax included / (1 + tax rate on ordering)"); |
168 |
is( $order_inc_tax->unitprice_tax_excluded+0 ,9.85491015461764 ,"Receiving tax included, round: unitprice tax excluded is unitprice tax included / (1 + tax rate on ordering)"); |
| 191 |
is( $order_with_prices->{tax_value_on_receiving}+0 ,15.4842 ,"Receiving tax included, round: tax value on receiving is quantity * (rounded unitprice_tax_excluded) * tax rate on receiving"); |
169 |
is( $order_inc_tax->tax_value_on_receiving+0 ,15.4842 ,"Receiving tax included, round: tax value on receiving is quantity * (rounded unitprice_tax_excluded) * tax rate on receiving"); |
| 192 |
|
170 |
|
| 193 |
|
171 |
|
| 194 |
$schema->storage->txn_rollback(); |
172 |
$schema->storage->txn_rollback(); |