Lines 47-53
my $today;
Link Here
|
47 |
for my $currency_format ( qw( US FR ) ) { |
47 |
for my $currency_format ( qw( US FR ) ) { |
48 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format ); |
48 |
t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format ); |
49 |
subtest 'Configuration 1: 0 0' => sub { |
49 |
subtest 'Configuration 1: 0 0' => sub { |
50 |
plan tests => 12; |
50 |
plan tests => 8; |
51 |
$bookseller_module->mock( |
51 |
$bookseller_module->mock( |
52 |
'fetch', |
52 |
'fetch', |
53 |
sub { |
53 |
sub { |
Lines 79-85
for my $currency_format ( qw( US FR ) ) {
Link Here
|
79 |
} |
79 |
} |
80 |
); |
80 |
); |
81 |
|
81 |
|
82 |
# Note that this configuration is correct \o/ |
|
|
83 |
compare( |
82 |
compare( |
84 |
{ |
83 |
{ |
85 |
got => $order_0_0->{rrp_tax_included}, |
84 |
got => $order_0_0->{rrp_tax_included}, |
Lines 120-141
for my $currency_format ( qw( US FR ) ) {
Link Here
|
120 |
field => 'tax_value' |
119 |
field => 'tax_value' |
121 |
} |
120 |
} |
122 |
); |
121 |
); |
123 |
compare( |
|
|
124 |
{ |
125 |
got => $order_0_0->{total_tax_included}, |
126 |
expected => 154.98, |
127 |
conf => '0 0', |
128 |
field => 'total_tax_included' |
129 |
} |
130 |
); |
131 |
compare( |
132 |
{ |
133 |
got => $order_0_0->{total_tax_excluded}, |
134 |
expected => 147.60, |
135 |
conf => '0 0', |
136 |
field => 'total_tax_excluded' |
137 |
} |
138 |
); |
139 |
|
122 |
|
140 |
$order_0_0 = C4::Acquisition::populate_order_with_prices( |
123 |
$order_0_0 = C4::Acquisition::populate_order_with_prices( |
141 |
{ |
124 |
{ |
Lines 145-151
for my $currency_format ( qw( US FR ) ) {
Link Here
|
145 |
} |
128 |
} |
146 |
); |
129 |
); |
147 |
|
130 |
|
148 |
# Note that this configuration is correct \o/ |
|
|
149 |
compare( |
131 |
compare( |
150 |
{ |
132 |
{ |
151 |
got => $order_0_0->{unitprice_tax_included}, |
133 |
got => $order_0_0->{unitprice_tax_included}, |
Lines 170-195
for my $currency_format ( qw( US FR ) ) {
Link Here
|
170 |
field => 'tax_value' |
152 |
field => 'tax_value' |
171 |
} |
153 |
} |
172 |
); |
154 |
); |
173 |
compare( |
|
|
174 |
{ |
175 |
got => $order_0_0->{total_tax_included}, |
176 |
expected => 154.98, |
177 |
conf => '0 0', |
178 |
field => 'total_tax_included' |
179 |
} |
180 |
); |
181 |
compare( |
182 |
{ |
183 |
got => $order_0_0->{total_tax_excluded}, |
184 |
expected => 147.60, |
185 |
conf => '0 0', |
186 |
field => 'total_tax_excluded' |
187 |
} |
188 |
); |
189 |
}; |
155 |
}; |
190 |
|
156 |
|
191 |
subtest 'Configuration 1: 1 1' => sub { |
157 |
subtest 'Configuration 1: 1 1' => sub { |
192 |
plan tests => 12; |
158 |
plan tests => 8; |
193 |
$bookseller_module->mock( |
159 |
$bookseller_module->mock( |
194 |
'fetch', |
160 |
'fetch', |
195 |
sub { |
161 |
sub { |
Lines 221-228
for my $currency_format ( qw( US FR ) ) {
Link Here
|
221 |
} |
187 |
} |
222 |
); |
188 |
); |
223 |
|
189 |
|
224 |
# Note that this configuration is *not* correct |
|
|
225 |
# tax_value should be 7.03 instead of 7.02 |
226 |
compare( |
190 |
compare( |
227 |
{ |
191 |
{ |
228 |
got => $order_1_1->{rrp_tax_included}, |
192 |
got => $order_1_1->{rrp_tax_included}, |
Lines 258-284
for my $currency_format ( qw( US FR ) ) {
Link Here
|
258 |
compare( |
222 |
compare( |
259 |
{ |
223 |
{ |
260 |
got => $order_1_1->{tax_value}, |
224 |
got => $order_1_1->{tax_value}, |
261 |
expected => 7.02, |
225 |
expected => 7.03, |
262 |
conf => '1 1', |
226 |
conf => '1 1', |
263 |
field => 'tax_value' |
227 |
field => 'tax_value' |
264 |
} |
228 |
} |
265 |
); |
229 |
); |
266 |
compare( |
|
|
267 |
{ |
268 |
got => $order_1_1->{total_tax_included}, |
269 |
expected => 147.60, |
270 |
conf => '1 1', |
271 |
field => 'total_tax_included' |
272 |
} |
273 |
); |
274 |
compare( |
275 |
{ |
276 |
got => $order_1_1->{total_tax_excluded}, |
277 |
expected => 140.58, |
278 |
conf => '1 1', |
279 |
field => 'total_tax_excluded' |
280 |
} |
281 |
); |
282 |
|
230 |
|
283 |
$order_1_1 = C4::Acquisition::populate_order_with_prices( |
231 |
$order_1_1 = C4::Acquisition::populate_order_with_prices( |
284 |
{ |
232 |
{ |
Lines 287-294
for my $currency_format ( qw( US FR ) ) {
Link Here
|
287 |
receiving => 1, |
235 |
receiving => 1, |
288 |
} |
236 |
} |
289 |
); |
237 |
); |
290 |
# Note that this configuration is *not* correct! |
238 |
|
291 |
# tax_value should be 7.03 |
|
|
292 |
compare( |
239 |
compare( |
293 |
{ |
240 |
{ |
294 |
got => $order_1_1->{unitprice_tax_included}, |
241 |
got => $order_1_1->{unitprice_tax_included}, |
Lines 308-338
for my $currency_format ( qw( US FR ) ) {
Link Here
|
308 |
compare( |
255 |
compare( |
309 |
{ |
256 |
{ |
310 |
got => $order_1_1->{tax_value}, |
257 |
got => $order_1_1->{tax_value}, |
311 |
expected => 7.02, |
258 |
expected => 7.03, |
312 |
conf => '1 1', |
259 |
conf => '1 1', |
313 |
field => 'tax_value' |
260 |
field => 'tax_value' |
314 |
} |
261 |
} |
315 |
); |
262 |
); |
316 |
compare( |
|
|
317 |
{ |
318 |
got => $order_1_1->{total_tax_included}, |
319 |
expected => 147.60, |
320 |
conf => '1 1', |
321 |
field => 'total_tax_included' |
322 |
} |
323 |
); |
324 |
compare( |
325 |
{ |
326 |
got => $order_1_1->{total_tax_excluded}, |
327 |
expected => 140.58, |
328 |
conf => '1 1', |
329 |
field => 'total_tax_excluded' |
330 |
} |
331 |
); |
332 |
}; |
263 |
}; |
333 |
|
264 |
|
334 |
subtest 'Configuration 1: 1 0' => sub { |
265 |
subtest 'Configuration 1: 1 0' => sub { |
335 |
plan tests => 12; |
266 |
plan tests => 8; |
336 |
$bookseller_module->mock( |
267 |
$bookseller_module->mock( |
337 |
'fetch', |
268 |
'fetch', |
338 |
sub { |
269 |
sub { |
Lines 345-355
for my $currency_format ( qw( US FR ) ) {
Link Here
|
345 |
biblionumber => $biblionumber_1_0, |
276 |
biblionumber => $biblionumber_1_0, |
346 |
quantity => 2, |
277 |
quantity => 2, |
347 |
listprice => 82.000000, |
278 |
listprice => 82.000000, |
348 |
unitprice => 73.804500, |
279 |
unitprice => 70.290000, |
349 |
quantityreceived => 2, |
280 |
quantityreceived => 2, |
350 |
basketno => $basketno_1_1, |
281 |
basketno => $basketno_1_1, |
351 |
invoiceid => $invoiceid_1_1, |
282 |
invoiceid => $invoiceid_1_1, |
352 |
rrp => 82.01, |
283 |
rrp => 82.00, |
353 |
ecost => 73.80, |
284 |
ecost => 73.80, |
354 |
tax_rate => 0.0500, |
285 |
tax_rate => 0.0500, |
355 |
discount => 10.0000, |
286 |
discount => 10.0000, |
Lines 364-377
for my $currency_format ( qw( US FR ) ) {
Link Here
|
364 |
} |
295 |
} |
365 |
); |
296 |
); |
366 |
|
297 |
|
367 |
# Note that this configuration is *not* correct! |
|
|
368 |
# rrp_tax_included should be 82 (what we inserted!) |
369 |
# tax_value should be 7.03 instead of 7.02 |
370 |
|
371 |
compare( |
298 |
compare( |
372 |
{ |
299 |
{ |
373 |
got => $order_1_0->{rrp_tax_included}, |
300 |
got => $order_1_0->{rrp_tax_included}, |
374 |
expected => 82.01, |
301 |
expected => 82, |
375 |
conf => '1 0', |
302 |
conf => '1 0', |
376 |
field => 'rrp_tax_included' |
303 |
field => 'rrp_tax_included' |
377 |
} |
304 |
} |
Lines 403-429
for my $currency_format ( qw( US FR ) ) {
Link Here
|
403 |
compare( |
330 |
compare( |
404 |
{ |
331 |
{ |
405 |
got => $order_1_0->{tax_value}, |
332 |
got => $order_1_0->{tax_value}, |
406 |
expected => 7.02, |
333 |
expected => 7.03, |
407 |
conf => '1 0', |
334 |
conf => '1 0', |
408 |
field => 'tax_value' |
335 |
field => 'tax_value' |
409 |
} |
336 |
} |
410 |
); |
337 |
); |
411 |
compare( |
|
|
412 |
{ |
413 |
got => $order_1_0->{total_tax_included}, |
414 |
expected => 147.60, |
415 |
conf => '1 0', |
416 |
field => 'total_tax_included' |
417 |
} |
418 |
); |
419 |
compare( |
420 |
{ |
421 |
got => $order_1_0->{total_tax_excluded}, |
422 |
expected => 140.58, |
423 |
conf => '1 0', |
424 |
field => 'total_tax_excluded' |
425 |
} |
426 |
); |
427 |
|
338 |
|
428 |
$order_1_0 = C4::Acquisition::populate_order_with_prices( |
339 |
$order_1_0 = C4::Acquisition::populate_order_with_prices( |
429 |
{ |
340 |
{ |
Lines 432-439
for my $currency_format ( qw( US FR ) ) {
Link Here
|
432 |
receiving => 1, |
343 |
receiving => 1, |
433 |
} |
344 |
} |
434 |
); |
345 |
); |
435 |
# Note that this configuration is *not* correct! |
346 |
|
436 |
# gstvalue should be 7.03 |
|
|
437 |
compare( |
347 |
compare( |
438 |
{ |
348 |
{ |
439 |
got => $order_1_0->{unitprice_tax_included}, |
349 |
got => $order_1_0->{unitprice_tax_included}, |
Lines 453-483
for my $currency_format ( qw( US FR ) ) {
Link Here
|
453 |
compare( |
363 |
compare( |
454 |
{ |
364 |
{ |
455 |
got => $order_1_0->{tax_value}, |
365 |
got => $order_1_0->{tax_value}, |
456 |
expected => 7.02, |
366 |
expected => 7.03, |
457 |
conf => '1 0', |
367 |
conf => '1 0', |
458 |
field => 'tax_value' |
368 |
field => 'tax_value' |
459 |
} |
369 |
} |
460 |
); |
370 |
); |
461 |
compare( |
|
|
462 |
{ |
463 |
got => $order_1_0->{total_tax_included}, |
464 |
expected => 147.60, |
465 |
conf => '1 0', |
466 |
field => 'total_tax_included' |
467 |
} |
468 |
); |
469 |
compare( |
470 |
{ |
471 |
got => $order_1_0->{total_tax_excluded}, |
472 |
expected => 140.58, |
473 |
conf => '1 0', |
474 |
field => 'total_tax_excluded' |
475 |
} |
476 |
); |
477 |
}; |
371 |
}; |
478 |
|
372 |
|
479 |
subtest 'Configuration 1: 0 1' => sub { |
373 |
subtest 'Configuration 1: 0 1' => sub { |
480 |
plan tests => 12; |
374 |
plan tests => 8; |
481 |
$bookseller_module->mock( |
375 |
$bookseller_module->mock( |
482 |
'fetch', |
376 |
'fetch', |
483 |
sub { |
377 |
sub { |
Lines 490-496
for my $currency_format ( qw( US FR ) ) {
Link Here
|
490 |
biblionumber => $biblionumber_0_1, |
384 |
biblionumber => $biblionumber_0_1, |
491 |
quantity => 2, |
385 |
quantity => 2, |
492 |
listprice => 82.000000, |
386 |
listprice => 82.000000, |
493 |
unitprice => 73.800000, |
387 |
unitprice => 77.490000, |
494 |
quantityreceived => 2, |
388 |
quantityreceived => 2, |
495 |
basketno => $basketno_1_1, |
389 |
basketno => $basketno_1_1, |
496 |
invoiceid => $invoiceid_1_1, |
390 |
invoiceid => $invoiceid_1_1, |
Lines 509-520
for my $currency_format ( qw( US FR ) ) {
Link Here
|
509 |
} |
403 |
} |
510 |
); |
404 |
); |
511 |
|
405 |
|
512 |
# Note that this configuration is correct \o/ |
|
|
513 |
compare( |
406 |
compare( |
514 |
{ |
407 |
{ |
515 |
got => $order_0_1->{rrp_tax_included}, |
408 |
got => $order_0_1->{rrp_tax_included}, |
516 |
expected => 86.10, |
409 |
expected => 86.10, |
517 |
conf => '1 0', |
410 |
conf => '0 1', |
518 |
field => 'rrp_tax_included' |
411 |
field => 'rrp_tax_included' |
519 |
} |
412 |
} |
520 |
); |
413 |
); |
Lines 522-528
for my $currency_format ( qw( US FR ) ) {
Link Here
|
522 |
{ |
415 |
{ |
523 |
got => $order_0_1->{rrp_tax_excluded}, |
416 |
got => $order_0_1->{rrp_tax_excluded}, |
524 |
expected => 82.00, |
417 |
expected => 82.00, |
525 |
conf => '1 0', |
418 |
conf => '0 1', |
526 |
field => 'rrp_tax_excluded' |
419 |
field => 'rrp_tax_excluded' |
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_included}, |
424 |
got => $order_0_1->{ecost_tax_included}, |
532 |
expected => 77.49, |
425 |
expected => 77.49, |
533 |
conf => '1 0', |
426 |
conf => '0 1', |
534 |
field => 'ecost_tax_included' |
427 |
field => 'ecost_tax_included' |
535 |
} |
428 |
} |
536 |
); |
429 |
); |
Lines 538-544
for my $currency_format ( qw( US FR ) ) {
Link Here
|
538 |
{ |
431 |
{ |
539 |
got => $order_0_1->{ecost_tax_excluded}, |
432 |
got => $order_0_1->{ecost_tax_excluded}, |
540 |
expected => 73.80, |
433 |
expected => 73.80, |
541 |
conf => '1 0', |
434 |
conf => '0 1', |
542 |
field => 'ecost_tax_excluded' |
435 |
field => 'ecost_tax_excluded' |
543 |
} |
436 |
} |
544 |
); |
437 |
); |
Lines 546-571
for my $currency_format ( qw( US FR ) ) {
Link Here
|
546 |
{ |
439 |
{ |
547 |
got => $order_0_1->{tax_value}, |
440 |
got => $order_0_1->{tax_value}, |
548 |
expected => 7.38, |
441 |
expected => 7.38, |
549 |
conf => '1 0', |
442 |
conf => '0 1', |
550 |
field => 'tax_value' |
443 |
field => 'tax_value' |
551 |
} |
444 |
} |
552 |
); |
445 |
); |
553 |
compare( |
|
|
554 |
{ |
555 |
got => $order_0_1->{total_tax_included}, |
556 |
expected => 154.98, |
557 |
conf => '1 0', |
558 |
field => 'total_tax_included' |
559 |
} |
560 |
); |
561 |
compare( |
562 |
{ |
563 |
got => $order_0_1->{total_tax_excluded}, |
564 |
expected => 147.60, |
565 |
conf => '1 0', |
566 |
field => 'total_tax_excluded' |
567 |
} |
568 |
); |
569 |
|
446 |
|
570 |
$order_0_1 = C4::Acquisition::populate_order_with_prices( |
447 |
$order_0_1 = C4::Acquisition::populate_order_with_prices( |
571 |
{ |
448 |
{ |
Lines 574-580
for my $currency_format ( qw( US FR ) ) {
Link Here
|
574 |
receiving => 1, |
451 |
receiving => 1, |
575 |
} |
452 |
} |
576 |
); |
453 |
); |
577 |
# Note that this configuration is correct |
454 |
|
578 |
compare( |
455 |
compare( |
579 |
{ |
456 |
{ |
580 |
got => $order_0_1->{unitprice_tax_included}, |
457 |
got => $order_0_1->{unitprice_tax_included}, |
Lines 599-620
for my $currency_format ( qw( US FR ) ) {
Link Here
|
599 |
field => 'tax_value' |
476 |
field => 'tax_value' |
600 |
} |
477 |
} |
601 |
); |
478 |
); |
602 |
compare( |
|
|
603 |
{ |
604 |
got => $order_0_1->{total_tax_included}, |
605 |
expected => 154.98, |
606 |
conf => '0 1', |
607 |
field => 'total_tax_included' |
608 |
} |
609 |
); |
610 |
compare( |
611 |
{ |
612 |
got => $order_0_1->{total_tax_excluded}, |
613 |
expected => 147.60, |
614 |
conf => '0 1', |
615 |
field => 'total_tax_excluded' |
616 |
} |
617 |
); |
618 |
}; |
479 |
}; |
619 |
} |
480 |
} |
620 |
|
481 |
|
621 |
- |
|
|