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