|
Lines 21-27
my $today;
Link Here
|
| 21 |
for my $currency_format ( qw( US FR ) ) { |
21 |
for my $currency_format ( qw( US FR ) ) { |
| 22 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format ); |
22 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format ); |
| 23 |
subtest 'Configuration 1: 0 0' => sub { |
23 |
subtest 'Configuration 1: 0 0' => sub { |
| 24 |
plan tests => 12; |
24 |
plan tests => 8; |
| 25 |
$bookseller_module->mock( |
25 |
$bookseller_module->mock( |
| 26 |
'fetch', |
26 |
'fetch', |
| 27 |
sub { |
27 |
sub { |
|
Lines 53-59
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 53 |
} |
53 |
} |
| 54 |
); |
54 |
); |
| 55 |
|
55 |
|
| 56 |
# Note that this configuration is correct \o/ |
|
|
| 57 |
compare( |
56 |
compare( |
| 58 |
{ |
57 |
{ |
| 59 |
got => $order_0_0->{rrp_tax_included}, |
58 |
got => $order_0_0->{rrp_tax_included}, |
|
Lines 94-115
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 94 |
field => 'tax_value' |
93 |
field => 'tax_value' |
| 95 |
} |
94 |
} |
| 96 |
); |
95 |
); |
| 97 |
compare( |
|
|
| 98 |
{ |
| 99 |
got => $order_0_0->{total_tax_included}, |
| 100 |
expected => 154.98, |
| 101 |
conf => '0 0', |
| 102 |
field => 'total_tax_included' |
| 103 |
} |
| 104 |
); |
| 105 |
compare( |
| 106 |
{ |
| 107 |
got => $order_0_0->{total_tax_excluded}, |
| 108 |
expected => 147.60, |
| 109 |
conf => '0 0', |
| 110 |
field => 'total_tax_excluded' |
| 111 |
} |
| 112 |
); |
| 113 |
|
96 |
|
| 114 |
$order_0_0 = C4::Acquisition::populate_order_with_prices( |
97 |
$order_0_0 = C4::Acquisition::populate_order_with_prices( |
| 115 |
{ |
98 |
{ |
|
Lines 119-125
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 119 |
} |
102 |
} |
| 120 |
); |
103 |
); |
| 121 |
|
104 |
|
| 122 |
# Note that this configuration is correct \o/ |
|
|
| 123 |
compare( |
105 |
compare( |
| 124 |
{ |
106 |
{ |
| 125 |
got => $order_0_0->{unitprice_tax_included}, |
107 |
got => $order_0_0->{unitprice_tax_included}, |
|
Lines 144-169
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 144 |
field => 'tax_value' |
126 |
field => 'tax_value' |
| 145 |
} |
127 |
} |
| 146 |
); |
128 |
); |
| 147 |
compare( |
|
|
| 148 |
{ |
| 149 |
got => $order_0_0->{total_tax_included}, |
| 150 |
expected => 154.98, |
| 151 |
conf => '0 0', |
| 152 |
field => 'total_tax_included' |
| 153 |
} |
| 154 |
); |
| 155 |
compare( |
| 156 |
{ |
| 157 |
got => $order_0_0->{total_tax_excluded}, |
| 158 |
expected => 147.60, |
| 159 |
conf => '0 0', |
| 160 |
field => 'total_tax_excluded' |
| 161 |
} |
| 162 |
); |
| 163 |
}; |
129 |
}; |
| 164 |
|
130 |
|
| 165 |
subtest 'Configuration 1: 1 1' => sub { |
131 |
subtest 'Configuration 1: 1 1' => sub { |
| 166 |
plan tests => 12; |
132 |
plan tests => 8; |
| 167 |
$bookseller_module->mock( |
133 |
$bookseller_module->mock( |
| 168 |
'fetch', |
134 |
'fetch', |
| 169 |
sub { |
135 |
sub { |
|
Lines 195-202
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 195 |
} |
161 |
} |
| 196 |
); |
162 |
); |
| 197 |
|
163 |
|
| 198 |
# Note that this configuration is *not* correct |
|
|
| 199 |
# tax_value should be 7.03 instead of 7.02 |
| 200 |
compare( |
164 |
compare( |
| 201 |
{ |
165 |
{ |
| 202 |
got => $order_1_1->{rrp_tax_included}, |
166 |
got => $order_1_1->{rrp_tax_included}, |
|
Lines 232-258
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 232 |
compare( |
196 |
compare( |
| 233 |
{ |
197 |
{ |
| 234 |
got => $order_1_1->{tax_value}, |
198 |
got => $order_1_1->{tax_value}, |
| 235 |
expected => 7.02, |
199 |
expected => 7.03, |
| 236 |
conf => '1 1', |
200 |
conf => '1 1', |
| 237 |
field => 'tax_value' |
201 |
field => 'tax_value' |
| 238 |
} |
202 |
} |
| 239 |
); |
203 |
); |
| 240 |
compare( |
|
|
| 241 |
{ |
| 242 |
got => $order_1_1->{total_tax_included}, |
| 243 |
expected => 147.60, |
| 244 |
conf => '1 1', |
| 245 |
field => 'total_tax_included' |
| 246 |
} |
| 247 |
); |
| 248 |
compare( |
| 249 |
{ |
| 250 |
got => $order_1_1->{total_tax_excluded}, |
| 251 |
expected => 140.58, |
| 252 |
conf => '1 1', |
| 253 |
field => 'total_tax_excluded' |
| 254 |
} |
| 255 |
); |
| 256 |
|
204 |
|
| 257 |
$order_1_1 = C4::Acquisition::populate_order_with_prices( |
205 |
$order_1_1 = C4::Acquisition::populate_order_with_prices( |
| 258 |
{ |
206 |
{ |
|
Lines 261-268
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 261 |
receiving => 1, |
209 |
receiving => 1, |
| 262 |
} |
210 |
} |
| 263 |
); |
211 |
); |
| 264 |
# Note that this configuration is *not* correct! |
212 |
|
| 265 |
# tax_value should be 7.03 |
|
|
| 266 |
compare( |
213 |
compare( |
| 267 |
{ |
214 |
{ |
| 268 |
got => $order_1_1->{unitprice_tax_included}, |
215 |
got => $order_1_1->{unitprice_tax_included}, |
|
Lines 282-312
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 282 |
compare( |
229 |
compare( |
| 283 |
{ |
230 |
{ |
| 284 |
got => $order_1_1->{tax_value}, |
231 |
got => $order_1_1->{tax_value}, |
| 285 |
expected => 7.02, |
232 |
expected => 7.03, |
| 286 |
conf => '1 1', |
233 |
conf => '1 1', |
| 287 |
field => 'tax_value' |
234 |
field => 'tax_value' |
| 288 |
} |
235 |
} |
| 289 |
); |
236 |
); |
| 290 |
compare( |
|
|
| 291 |
{ |
| 292 |
got => $order_1_1->{total_tax_included}, |
| 293 |
expected => 147.60, |
| 294 |
conf => '1 1', |
| 295 |
field => 'total_tax_included' |
| 296 |
} |
| 297 |
); |
| 298 |
compare( |
| 299 |
{ |
| 300 |
got => $order_1_1->{total_tax_excluded}, |
| 301 |
expected => 140.58, |
| 302 |
conf => '1 1', |
| 303 |
field => 'total_tax_excluded' |
| 304 |
} |
| 305 |
); |
| 306 |
}; |
237 |
}; |
| 307 |
|
238 |
|
| 308 |
subtest 'Configuration 1: 1 0' => sub { |
239 |
subtest 'Configuration 1: 1 0' => sub { |
| 309 |
plan tests => 12; |
240 |
plan tests => 8; |
| 310 |
$bookseller_module->mock( |
241 |
$bookseller_module->mock( |
| 311 |
'fetch', |
242 |
'fetch', |
| 312 |
sub { |
243 |
sub { |
|
Lines 319-329
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 319 |
biblionumber => $biblionumber_1_0, |
250 |
biblionumber => $biblionumber_1_0, |
| 320 |
quantity => 2, |
251 |
quantity => 2, |
| 321 |
listprice => 82.000000, |
252 |
listprice => 82.000000, |
| 322 |
unitprice => 73.804500, |
253 |
unitprice => 70.290000, |
| 323 |
quantityreceived => 2, |
254 |
quantityreceived => 2, |
| 324 |
basketno => $basketno_1_1, |
255 |
basketno => $basketno_1_1, |
| 325 |
invoiceid => $invoiceid_1_1, |
256 |
invoiceid => $invoiceid_1_1, |
| 326 |
rrp => 82.01, |
257 |
rrp => 82.00, |
| 327 |
ecost => 73.80, |
258 |
ecost => 73.80, |
| 328 |
tax_rate => 0.0500, |
259 |
tax_rate => 0.0500, |
| 329 |
discount => 10.0000, |
260 |
discount => 10.0000, |
|
Lines 338-351
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 338 |
} |
269 |
} |
| 339 |
); |
270 |
); |
| 340 |
|
271 |
|
| 341 |
# Note that this configuration is *not* correct! |
|
|
| 342 |
# rrp_tax_included should be 82 (what we inserted!) |
| 343 |
# tax_value should be 7.03 instead of 7.02 |
| 344 |
|
| 345 |
compare( |
272 |
compare( |
| 346 |
{ |
273 |
{ |
| 347 |
got => $order_1_0->{rrp_tax_included}, |
274 |
got => $order_1_0->{rrp_tax_included}, |
| 348 |
expected => 82.01, |
275 |
expected => 82, |
| 349 |
conf => '1 0', |
276 |
conf => '1 0', |
| 350 |
field => 'rrp_tax_included' |
277 |
field => 'rrp_tax_included' |
| 351 |
} |
278 |
} |
|
Lines 377-403
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 377 |
compare( |
304 |
compare( |
| 378 |
{ |
305 |
{ |
| 379 |
got => $order_1_0->{tax_value}, |
306 |
got => $order_1_0->{tax_value}, |
| 380 |
expected => 7.02, |
307 |
expected => 7.03, |
| 381 |
conf => '1 0', |
308 |
conf => '1 0', |
| 382 |
field => 'tax_value' |
309 |
field => 'tax_value' |
| 383 |
} |
310 |
} |
| 384 |
); |
311 |
); |
| 385 |
compare( |
|
|
| 386 |
{ |
| 387 |
got => $order_1_0->{total_tax_included}, |
| 388 |
expected => 147.60, |
| 389 |
conf => '1 0', |
| 390 |
field => 'total_tax_included' |
| 391 |
} |
| 392 |
); |
| 393 |
compare( |
| 394 |
{ |
| 395 |
got => $order_1_0->{total_tax_excluded}, |
| 396 |
expected => 140.58, |
| 397 |
conf => '1 0', |
| 398 |
field => 'total_tax_excluded' |
| 399 |
} |
| 400 |
); |
| 401 |
|
312 |
|
| 402 |
$order_1_0 = C4::Acquisition::populate_order_with_prices( |
313 |
$order_1_0 = C4::Acquisition::populate_order_with_prices( |
| 403 |
{ |
314 |
{ |
|
Lines 406-413
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 406 |
receiving => 1, |
317 |
receiving => 1, |
| 407 |
} |
318 |
} |
| 408 |
); |
319 |
); |
| 409 |
# Note that this configuration is *not* correct! |
320 |
|
| 410 |
# gstvalue should be 7.03 |
|
|
| 411 |
compare( |
321 |
compare( |
| 412 |
{ |
322 |
{ |
| 413 |
got => $order_1_0->{unitprice_tax_included}, |
323 |
got => $order_1_0->{unitprice_tax_included}, |
|
Lines 427-457
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 427 |
compare( |
337 |
compare( |
| 428 |
{ |
338 |
{ |
| 429 |
got => $order_1_0->{tax_value}, |
339 |
got => $order_1_0->{tax_value}, |
| 430 |
expected => 7.02, |
340 |
expected => 7.03, |
| 431 |
conf => '1 0', |
341 |
conf => '1 0', |
| 432 |
field => 'tax_value' |
342 |
field => 'tax_value' |
| 433 |
} |
343 |
} |
| 434 |
); |
344 |
); |
| 435 |
compare( |
|
|
| 436 |
{ |
| 437 |
got => $order_1_0->{total_tax_included}, |
| 438 |
expected => 147.60, |
| 439 |
conf => '1 0', |
| 440 |
field => 'total_tax_included' |
| 441 |
} |
| 442 |
); |
| 443 |
compare( |
| 444 |
{ |
| 445 |
got => $order_1_0->{total_tax_excluded}, |
| 446 |
expected => 140.58, |
| 447 |
conf => '1 0', |
| 448 |
field => 'total_tax_excluded' |
| 449 |
} |
| 450 |
); |
| 451 |
}; |
345 |
}; |
| 452 |
|
346 |
|
| 453 |
subtest 'Configuration 1: 0 1' => sub { |
347 |
subtest 'Configuration 1: 0 1' => sub { |
| 454 |
plan tests => 12; |
348 |
plan tests => 8; |
| 455 |
$bookseller_module->mock( |
349 |
$bookseller_module->mock( |
| 456 |
'fetch', |
350 |
'fetch', |
| 457 |
sub { |
351 |
sub { |
|
Lines 464-470
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 464 |
biblionumber => $biblionumber_0_1, |
358 |
biblionumber => $biblionumber_0_1, |
| 465 |
quantity => 2, |
359 |
quantity => 2, |
| 466 |
listprice => 82.000000, |
360 |
listprice => 82.000000, |
| 467 |
unitprice => 73.800000, |
361 |
unitprice => 77.490000, |
| 468 |
quantityreceived => 2, |
362 |
quantityreceived => 2, |
| 469 |
basketno => $basketno_1_1, |
363 |
basketno => $basketno_1_1, |
| 470 |
invoiceid => $invoiceid_1_1, |
364 |
invoiceid => $invoiceid_1_1, |
|
Lines 483-494
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 483 |
} |
377 |
} |
| 484 |
); |
378 |
); |
| 485 |
|
379 |
|
| 486 |
# Note that this configuration is correct \o/ |
|
|
| 487 |
compare( |
380 |
compare( |
| 488 |
{ |
381 |
{ |
| 489 |
got => $order_0_1->{rrp_tax_included}, |
382 |
got => $order_0_1->{rrp_tax_included}, |
| 490 |
expected => 86.10, |
383 |
expected => 86.10, |
| 491 |
conf => '1 0', |
384 |
conf => '0 1', |
| 492 |
field => 'rrp_tax_included' |
385 |
field => 'rrp_tax_included' |
| 493 |
} |
386 |
} |
| 494 |
); |
387 |
); |
|
Lines 496-502
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 496 |
{ |
389 |
{ |
| 497 |
got => $order_0_1->{rrp_tax_excluded}, |
390 |
got => $order_0_1->{rrp_tax_excluded}, |
| 498 |
expected => 82.00, |
391 |
expected => 82.00, |
| 499 |
conf => '1 0', |
392 |
conf => '0 1', |
| 500 |
field => 'rrp_tax_excluded' |
393 |
field => 'rrp_tax_excluded' |
| 501 |
} |
394 |
} |
| 502 |
); |
395 |
); |
|
Lines 504-510
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 504 |
{ |
397 |
{ |
| 505 |
got => $order_0_1->{ecost_tax_included}, |
398 |
got => $order_0_1->{ecost_tax_included}, |
| 506 |
expected => 77.49, |
399 |
expected => 77.49, |
| 507 |
conf => '1 0', |
400 |
conf => '0 1', |
| 508 |
field => 'ecost_tax_included' |
401 |
field => 'ecost_tax_included' |
| 509 |
} |
402 |
} |
| 510 |
); |
403 |
); |
|
Lines 512-518
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 512 |
{ |
405 |
{ |
| 513 |
got => $order_0_1->{ecost_tax_excluded}, |
406 |
got => $order_0_1->{ecost_tax_excluded}, |
| 514 |
expected => 73.80, |
407 |
expected => 73.80, |
| 515 |
conf => '1 0', |
408 |
conf => '0 1', |
| 516 |
field => 'ecost_tax_excluded' |
409 |
field => 'ecost_tax_excluded' |
| 517 |
} |
410 |
} |
| 518 |
); |
411 |
); |
|
Lines 520-545
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 520 |
{ |
413 |
{ |
| 521 |
got => $order_0_1->{tax_value}, |
414 |
got => $order_0_1->{tax_value}, |
| 522 |
expected => 7.38, |
415 |
expected => 7.38, |
| 523 |
conf => '1 0', |
416 |
conf => '0 1', |
| 524 |
field => 'tax_value' |
417 |
field => 'tax_value' |
| 525 |
} |
418 |
} |
| 526 |
); |
419 |
); |
| 527 |
compare( |
|
|
| 528 |
{ |
| 529 |
got => $order_0_1->{total_tax_included}, |
| 530 |
expected => 154.98, |
| 531 |
conf => '1 0', |
| 532 |
field => 'total_tax_included' |
| 533 |
} |
| 534 |
); |
| 535 |
compare( |
| 536 |
{ |
| 537 |
got => $order_0_1->{total_tax_excluded}, |
| 538 |
expected => 147.60, |
| 539 |
conf => '1 0', |
| 540 |
field => 'total_tax_excluded' |
| 541 |
} |
| 542 |
); |
| 543 |
|
420 |
|
| 544 |
$order_0_1 = C4::Acquisition::populate_order_with_prices( |
421 |
$order_0_1 = C4::Acquisition::populate_order_with_prices( |
| 545 |
{ |
422 |
{ |
|
Lines 548-554
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 548 |
receiving => 1, |
425 |
receiving => 1, |
| 549 |
} |
426 |
} |
| 550 |
); |
427 |
); |
| 551 |
# Note that this configuration is correct |
428 |
|
| 552 |
compare( |
429 |
compare( |
| 553 |
{ |
430 |
{ |
| 554 |
got => $order_0_1->{unitprice_tax_included}, |
431 |
got => $order_0_1->{unitprice_tax_included}, |
|
Lines 573-594
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 573 |
field => 'tax_value' |
450 |
field => 'tax_value' |
| 574 |
} |
451 |
} |
| 575 |
); |
452 |
); |
| 576 |
compare( |
|
|
| 577 |
{ |
| 578 |
got => $order_0_1->{total_tax_included}, |
| 579 |
expected => 154.98, |
| 580 |
conf => '0 1', |
| 581 |
field => 'total_tax_included' |
| 582 |
} |
| 583 |
); |
| 584 |
compare( |
| 585 |
{ |
| 586 |
got => $order_0_1->{total_tax_excluded}, |
| 587 |
expected => 147.60, |
| 588 |
conf => '0 1', |
| 589 |
field => 'total_tax_excluded' |
| 590 |
} |
| 591 |
); |
| 592 |
}; |
453 |
}; |
| 593 |
} |
454 |
} |
| 594 |
|
455 |
|
| 595 |
- |
|
|