|
Lines 39-45
my $today;
Link Here
|
| 39 |
for my $currency_format ( qw( US FR ) ) { |
39 |
for my $currency_format ( qw( US FR ) ) { |
| 40 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format ); |
40 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format ); |
| 41 |
subtest 'Configuration 1: 0 0' => sub { |
41 |
subtest 'Configuration 1: 0 0' => sub { |
| 42 |
plan tests => 12; |
42 |
plan tests => 8; |
| 43 |
$bookseller_module->mock( |
43 |
$bookseller_module->mock( |
| 44 |
'fetch', |
44 |
'fetch', |
| 45 |
sub { |
45 |
sub { |
|
Lines 71-77
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 71 |
} |
71 |
} |
| 72 |
); |
72 |
); |
| 73 |
|
73 |
|
| 74 |
# Note that this configuration is correct \o/ |
|
|
| 75 |
compare( |
74 |
compare( |
| 76 |
{ |
75 |
{ |
| 77 |
got => $order_0_0->{rrp_tax_included}, |
76 |
got => $order_0_0->{rrp_tax_included}, |
|
Lines 112-133
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 112 |
field => 'tax_value' |
111 |
field => 'tax_value' |
| 113 |
} |
112 |
} |
| 114 |
); |
113 |
); |
| 115 |
compare( |
|
|
| 116 |
{ |
| 117 |
got => $order_0_0->{total_tax_included}, |
| 118 |
expected => 154.98, |
| 119 |
conf => '0 0', |
| 120 |
field => 'total_tax_included' |
| 121 |
} |
| 122 |
); |
| 123 |
compare( |
| 124 |
{ |
| 125 |
got => $order_0_0->{total_tax_excluded}, |
| 126 |
expected => 147.60, |
| 127 |
conf => '0 0', |
| 128 |
field => 'total_tax_excluded' |
| 129 |
} |
| 130 |
); |
| 131 |
|
114 |
|
| 132 |
$order_0_0 = C4::Acquisition::populate_order_with_prices( |
115 |
$order_0_0 = C4::Acquisition::populate_order_with_prices( |
| 133 |
{ |
116 |
{ |
|
Lines 137-143
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 137 |
} |
120 |
} |
| 138 |
); |
121 |
); |
| 139 |
|
122 |
|
| 140 |
# Note that this configuration is correct \o/ |
|
|
| 141 |
compare( |
123 |
compare( |
| 142 |
{ |
124 |
{ |
| 143 |
got => $order_0_0->{unitprice_tax_included}, |
125 |
got => $order_0_0->{unitprice_tax_included}, |
|
Lines 162-187
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 162 |
field => 'tax_value' |
144 |
field => 'tax_value' |
| 163 |
} |
145 |
} |
| 164 |
); |
146 |
); |
| 165 |
compare( |
|
|
| 166 |
{ |
| 167 |
got => $order_0_0->{total_tax_included}, |
| 168 |
expected => 154.98, |
| 169 |
conf => '0 0', |
| 170 |
field => 'total_tax_included' |
| 171 |
} |
| 172 |
); |
| 173 |
compare( |
| 174 |
{ |
| 175 |
got => $order_0_0->{total_tax_excluded}, |
| 176 |
expected => 147.60, |
| 177 |
conf => '0 0', |
| 178 |
field => 'total_tax_excluded' |
| 179 |
} |
| 180 |
); |
| 181 |
}; |
147 |
}; |
| 182 |
|
148 |
|
| 183 |
subtest 'Configuration 1: 1 1' => sub { |
149 |
subtest 'Configuration 1: 1 1' => sub { |
| 184 |
plan tests => 12; |
150 |
plan tests => 8; |
| 185 |
$bookseller_module->mock( |
151 |
$bookseller_module->mock( |
| 186 |
'fetch', |
152 |
'fetch', |
| 187 |
sub { |
153 |
sub { |
|
Lines 213-220
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 213 |
} |
179 |
} |
| 214 |
); |
180 |
); |
| 215 |
|
181 |
|
| 216 |
# Note that this configuration is *not* correct |
|
|
| 217 |
# tax_value should be 7.03 instead of 7.02 |
| 218 |
compare( |
182 |
compare( |
| 219 |
{ |
183 |
{ |
| 220 |
got => $order_1_1->{rrp_tax_included}, |
184 |
got => $order_1_1->{rrp_tax_included}, |
|
Lines 250-276
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 250 |
compare( |
214 |
compare( |
| 251 |
{ |
215 |
{ |
| 252 |
got => $order_1_1->{tax_value}, |
216 |
got => $order_1_1->{tax_value}, |
| 253 |
expected => 7.02, |
217 |
expected => 7.03, |
| 254 |
conf => '1 1', |
218 |
conf => '1 1', |
| 255 |
field => 'tax_value' |
219 |
field => 'tax_value' |
| 256 |
} |
220 |
} |
| 257 |
); |
221 |
); |
| 258 |
compare( |
|
|
| 259 |
{ |
| 260 |
got => $order_1_1->{total_tax_included}, |
| 261 |
expected => 147.60, |
| 262 |
conf => '1 1', |
| 263 |
field => 'total_tax_included' |
| 264 |
} |
| 265 |
); |
| 266 |
compare( |
| 267 |
{ |
| 268 |
got => $order_1_1->{total_tax_excluded}, |
| 269 |
expected => 140.58, |
| 270 |
conf => '1 1', |
| 271 |
field => 'total_tax_excluded' |
| 272 |
} |
| 273 |
); |
| 274 |
|
222 |
|
| 275 |
$order_1_1 = C4::Acquisition::populate_order_with_prices( |
223 |
$order_1_1 = C4::Acquisition::populate_order_with_prices( |
| 276 |
{ |
224 |
{ |
|
Lines 279-286
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 279 |
receiving => 1, |
227 |
receiving => 1, |
| 280 |
} |
228 |
} |
| 281 |
); |
229 |
); |
| 282 |
# Note that this configuration is *not* correct! |
230 |
|
| 283 |
# tax_value should be 7.03 |
|
|
| 284 |
compare( |
231 |
compare( |
| 285 |
{ |
232 |
{ |
| 286 |
got => $order_1_1->{unitprice_tax_included}, |
233 |
got => $order_1_1->{unitprice_tax_included}, |
|
Lines 300-330
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 300 |
compare( |
247 |
compare( |
| 301 |
{ |
248 |
{ |
| 302 |
got => $order_1_1->{tax_value}, |
249 |
got => $order_1_1->{tax_value}, |
| 303 |
expected => 7.02, |
250 |
expected => 7.03, |
| 304 |
conf => '1 1', |
251 |
conf => '1 1', |
| 305 |
field => 'tax_value' |
252 |
field => 'tax_value' |
| 306 |
} |
253 |
} |
| 307 |
); |
254 |
); |
| 308 |
compare( |
|
|
| 309 |
{ |
| 310 |
got => $order_1_1->{total_tax_included}, |
| 311 |
expected => 147.60, |
| 312 |
conf => '1 1', |
| 313 |
field => 'total_tax_included' |
| 314 |
} |
| 315 |
); |
| 316 |
compare( |
| 317 |
{ |
| 318 |
got => $order_1_1->{total_tax_excluded}, |
| 319 |
expected => 140.58, |
| 320 |
conf => '1 1', |
| 321 |
field => 'total_tax_excluded' |
| 322 |
} |
| 323 |
); |
| 324 |
}; |
255 |
}; |
| 325 |
|
256 |
|
| 326 |
subtest 'Configuration 1: 1 0' => sub { |
257 |
subtest 'Configuration 1: 1 0' => sub { |
| 327 |
plan tests => 12; |
258 |
plan tests => 8; |
| 328 |
$bookseller_module->mock( |
259 |
$bookseller_module->mock( |
| 329 |
'fetch', |
260 |
'fetch', |
| 330 |
sub { |
261 |
sub { |
|
Lines 337-347
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 337 |
biblionumber => $biblionumber_1_0, |
268 |
biblionumber => $biblionumber_1_0, |
| 338 |
quantity => 2, |
269 |
quantity => 2, |
| 339 |
listprice => 82.000000, |
270 |
listprice => 82.000000, |
| 340 |
unitprice => 73.804500, |
271 |
unitprice => 70.290000, |
| 341 |
quantityreceived => 2, |
272 |
quantityreceived => 2, |
| 342 |
basketno => $basketno_1_1, |
273 |
basketno => $basketno_1_1, |
| 343 |
invoiceid => $invoiceid_1_1, |
274 |
invoiceid => $invoiceid_1_1, |
| 344 |
rrp => 82.01, |
275 |
rrp => 82.00, |
| 345 |
ecost => 73.80, |
276 |
ecost => 73.80, |
| 346 |
tax_rate => 0.0500, |
277 |
tax_rate => 0.0500, |
| 347 |
discount => 10.0000, |
278 |
discount => 10.0000, |
|
Lines 356-369
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 356 |
} |
287 |
} |
| 357 |
); |
288 |
); |
| 358 |
|
289 |
|
| 359 |
# Note that this configuration is *not* correct! |
|
|
| 360 |
# rrp_tax_included should be 82 (what we inserted!) |
| 361 |
# tax_value should be 7.03 instead of 7.02 |
| 362 |
|
| 363 |
compare( |
290 |
compare( |
| 364 |
{ |
291 |
{ |
| 365 |
got => $order_1_0->{rrp_tax_included}, |
292 |
got => $order_1_0->{rrp_tax_included}, |
| 366 |
expected => 82.01, |
293 |
expected => 82, |
| 367 |
conf => '1 0', |
294 |
conf => '1 0', |
| 368 |
field => 'rrp_tax_included' |
295 |
field => 'rrp_tax_included' |
| 369 |
} |
296 |
} |
|
Lines 395-421
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 395 |
compare( |
322 |
compare( |
| 396 |
{ |
323 |
{ |
| 397 |
got => $order_1_0->{tax_value}, |
324 |
got => $order_1_0->{tax_value}, |
| 398 |
expected => 7.02, |
325 |
expected => 7.03, |
| 399 |
conf => '1 0', |
326 |
conf => '1 0', |
| 400 |
field => 'tax_value' |
327 |
field => 'tax_value' |
| 401 |
} |
328 |
} |
| 402 |
); |
329 |
); |
| 403 |
compare( |
|
|
| 404 |
{ |
| 405 |
got => $order_1_0->{total_tax_included}, |
| 406 |
expected => 147.60, |
| 407 |
conf => '1 0', |
| 408 |
field => 'total_tax_included' |
| 409 |
} |
| 410 |
); |
| 411 |
compare( |
| 412 |
{ |
| 413 |
got => $order_1_0->{total_tax_excluded}, |
| 414 |
expected => 140.58, |
| 415 |
conf => '1 0', |
| 416 |
field => 'total_tax_excluded' |
| 417 |
} |
| 418 |
); |
| 419 |
|
330 |
|
| 420 |
$order_1_0 = C4::Acquisition::populate_order_with_prices( |
331 |
$order_1_0 = C4::Acquisition::populate_order_with_prices( |
| 421 |
{ |
332 |
{ |
|
Lines 424-431
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 424 |
receiving => 1, |
335 |
receiving => 1, |
| 425 |
} |
336 |
} |
| 426 |
); |
337 |
); |
| 427 |
# Note that this configuration is *not* correct! |
338 |
|
| 428 |
# gstvalue should be 7.03 |
|
|
| 429 |
compare( |
339 |
compare( |
| 430 |
{ |
340 |
{ |
| 431 |
got => $order_1_0->{unitprice_tax_included}, |
341 |
got => $order_1_0->{unitprice_tax_included}, |
|
Lines 445-475
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 445 |
compare( |
355 |
compare( |
| 446 |
{ |
356 |
{ |
| 447 |
got => $order_1_0->{tax_value}, |
357 |
got => $order_1_0->{tax_value}, |
| 448 |
expected => 7.02, |
358 |
expected => 7.03, |
| 449 |
conf => '1 0', |
359 |
conf => '1 0', |
| 450 |
field => 'tax_value' |
360 |
field => 'tax_value' |
| 451 |
} |
361 |
} |
| 452 |
); |
362 |
); |
| 453 |
compare( |
|
|
| 454 |
{ |
| 455 |
got => $order_1_0->{total_tax_included}, |
| 456 |
expected => 147.60, |
| 457 |
conf => '1 0', |
| 458 |
field => 'total_tax_included' |
| 459 |
} |
| 460 |
); |
| 461 |
compare( |
| 462 |
{ |
| 463 |
got => $order_1_0->{total_tax_excluded}, |
| 464 |
expected => 140.58, |
| 465 |
conf => '1 0', |
| 466 |
field => 'total_tax_excluded' |
| 467 |
} |
| 468 |
); |
| 469 |
}; |
363 |
}; |
| 470 |
|
364 |
|
| 471 |
subtest 'Configuration 1: 0 1' => sub { |
365 |
subtest 'Configuration 1: 0 1' => sub { |
| 472 |
plan tests => 12; |
366 |
plan tests => 8; |
| 473 |
$bookseller_module->mock( |
367 |
$bookseller_module->mock( |
| 474 |
'fetch', |
368 |
'fetch', |
| 475 |
sub { |
369 |
sub { |
|
Lines 482-488
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 482 |
biblionumber => $biblionumber_0_1, |
376 |
biblionumber => $biblionumber_0_1, |
| 483 |
quantity => 2, |
377 |
quantity => 2, |
| 484 |
listprice => 82.000000, |
378 |
listprice => 82.000000, |
| 485 |
unitprice => 73.800000, |
379 |
unitprice => 77.490000, |
| 486 |
quantityreceived => 2, |
380 |
quantityreceived => 2, |
| 487 |
basketno => $basketno_1_1, |
381 |
basketno => $basketno_1_1, |
| 488 |
invoiceid => $invoiceid_1_1, |
382 |
invoiceid => $invoiceid_1_1, |
|
Lines 501-512
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 501 |
} |
395 |
} |
| 502 |
); |
396 |
); |
| 503 |
|
397 |
|
| 504 |
# Note that this configuration is correct \o/ |
|
|
| 505 |
compare( |
398 |
compare( |
| 506 |
{ |
399 |
{ |
| 507 |
got => $order_0_1->{rrp_tax_included}, |
400 |
got => $order_0_1->{rrp_tax_included}, |
| 508 |
expected => 86.10, |
401 |
expected => 86.10, |
| 509 |
conf => '1 0', |
402 |
conf => '0 1', |
| 510 |
field => 'rrp_tax_included' |
403 |
field => 'rrp_tax_included' |
| 511 |
} |
404 |
} |
| 512 |
); |
405 |
); |
|
Lines 514-520
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 514 |
{ |
407 |
{ |
| 515 |
got => $order_0_1->{rrp_tax_excluded}, |
408 |
got => $order_0_1->{rrp_tax_excluded}, |
| 516 |
expected => 82.00, |
409 |
expected => 82.00, |
| 517 |
conf => '1 0', |
410 |
conf => '0 1', |
| 518 |
field => 'rrp_tax_excluded' |
411 |
field => 'rrp_tax_excluded' |
| 519 |
} |
412 |
} |
| 520 |
); |
413 |
); |
|
Lines 522-528
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 522 |
{ |
415 |
{ |
| 523 |
got => $order_0_1->{ecost_tax_included}, |
416 |
got => $order_0_1->{ecost_tax_included}, |
| 524 |
expected => 77.49, |
417 |
expected => 77.49, |
| 525 |
conf => '1 0', |
418 |
conf => '0 1', |
| 526 |
field => 'ecost_tax_included' |
419 |
field => 'ecost_tax_included' |
| 527 |
} |
420 |
} |
| 528 |
); |
421 |
); |
|
Lines 530-536
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 530 |
{ |
423 |
{ |
| 531 |
got => $order_0_1->{ecost_tax_excluded}, |
424 |
got => $order_0_1->{ecost_tax_excluded}, |
| 532 |
expected => 73.80, |
425 |
expected => 73.80, |
| 533 |
conf => '1 0', |
426 |
conf => '0 1', |
| 534 |
field => 'ecost_tax_excluded' |
427 |
field => 'ecost_tax_excluded' |
| 535 |
} |
428 |
} |
| 536 |
); |
429 |
); |
|
Lines 538-563
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 538 |
{ |
431 |
{ |
| 539 |
got => $order_0_1->{tax_value}, |
432 |
got => $order_0_1->{tax_value}, |
| 540 |
expected => 7.38, |
433 |
expected => 7.38, |
| 541 |
conf => '1 0', |
434 |
conf => '0 1', |
| 542 |
field => 'tax_value' |
435 |
field => 'tax_value' |
| 543 |
} |
436 |
} |
| 544 |
); |
437 |
); |
| 545 |
compare( |
|
|
| 546 |
{ |
| 547 |
got => $order_0_1->{total_tax_included}, |
| 548 |
expected => 154.98, |
| 549 |
conf => '1 0', |
| 550 |
field => 'total_tax_included' |
| 551 |
} |
| 552 |
); |
| 553 |
compare( |
| 554 |
{ |
| 555 |
got => $order_0_1->{total_tax_excluded}, |
| 556 |
expected => 147.60, |
| 557 |
conf => '1 0', |
| 558 |
field => 'total_tax_excluded' |
| 559 |
} |
| 560 |
); |
| 561 |
|
438 |
|
| 562 |
$order_0_1 = C4::Acquisition::populate_order_with_prices( |
439 |
$order_0_1 = C4::Acquisition::populate_order_with_prices( |
| 563 |
{ |
440 |
{ |
|
Lines 566-572
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 566 |
receiving => 1, |
443 |
receiving => 1, |
| 567 |
} |
444 |
} |
| 568 |
); |
445 |
); |
| 569 |
# Note that this configuration is correct |
446 |
|
| 570 |
compare( |
447 |
compare( |
| 571 |
{ |
448 |
{ |
| 572 |
got => $order_0_1->{unitprice_tax_included}, |
449 |
got => $order_0_1->{unitprice_tax_included}, |
|
Lines 591-612
for my $currency_format ( qw( US FR ) ) {
Link Here
|
| 591 |
field => 'tax_value' |
468 |
field => 'tax_value' |
| 592 |
} |
469 |
} |
| 593 |
); |
470 |
); |
| 594 |
compare( |
|
|
| 595 |
{ |
| 596 |
got => $order_0_1->{total_tax_included}, |
| 597 |
expected => 154.98, |
| 598 |
conf => '0 1', |
| 599 |
field => 'total_tax_included' |
| 600 |
} |
| 601 |
); |
| 602 |
compare( |
| 603 |
{ |
| 604 |
got => $order_0_1->{total_tax_excluded}, |
| 605 |
expected => 147.60, |
| 606 |
conf => '0 1', |
| 607 |
field => 'total_tax_excluded' |
| 608 |
} |
| 609 |
); |
| 610 |
}; |
471 |
}; |
| 611 |
} |
472 |
} |
| 612 |
|
473 |
|
| 613 |
- |
|
|