Lines 2-8
Link Here
|
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
4 |
|
4 |
|
5 |
use Test::More tests => 53; |
5 |
use Test::More tests => 61; |
6 |
use C4::Context; |
6 |
use C4::Context; |
7 |
use Koha::DateUtils; |
7 |
use Koha::DateUtils; |
8 |
use DateTime::Duration; |
8 |
use DateTime::Duration; |
Lines 476-492
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" )
Link Here
|
476 |
%suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 4, undef, undef ); |
476 |
%suppliers = C4::Bookseller::GetBooksellersWithLateOrders( 4, undef, undef ); |
477 |
isnt( exists( $suppliers{$id_supplier1} ), |
477 |
isnt( exists( $suppliers{$id_supplier1} ), |
478 |
1, "Supplier1 has late orders but today > now() - 4 days" ); |
478 |
1, "Supplier1 has late orders but today > now() - 4 days" ); |
479 |
#FIXME: If only the field delay is given, it doen't consider the deliverytime |
479 |
isnt( exists( $suppliers{$id_supplier2} ), |
480 |
#isnt( exists( $suppliers{$id_supplier2} ), |
480 |
1, "Supplier2 has late orders and $daysago5 <= now() - (4 days+2)" ); |
481 |
# 1, "Supplier2 has late orders and $daysago5 <= now() - (4 days+2)" ); |
|
|
482 |
ok( exists( $suppliers{$id_supplier3} ), |
481 |
ok( exists( $suppliers{$id_supplier3} ), |
483 |
"Supplier3 has late orders and $daysago10 <= now() - (4 days+3)" ); |
482 |
"Supplier3 has late orders and $daysago10 <= now() - (4 days+3)" ); |
484 |
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" ); |
483 |
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" ); |
485 |
|
484 |
|
486 |
#Case 3: With $delay = -1 |
485 |
#Case 3: With $delay = -1 |
487 |
#FIXME: GetBooksellersWithLateOrders doesn't test if the delay is a positive value |
486 |
is( C4::Bookseller::GetBooksellersWithLateOrders( -1, undef, undef ), |
488 |
#is( C4::Bookseller::GetBooksellersWithLateOrders( -1, undef, undef ), |
487 |
undef, "-1 is a wrong value for a delay" ); |
489 |
# undef, "-1 is a wrong value for a delay" ); |
|
|
490 |
|
488 |
|
491 |
#Case 4: With $delay = 0 |
489 |
#Case 4: With $delay = 0 |
492 |
# today == now-0 -LATE- (if no deliverytime or deliverytime == 0) |
490 |
# today == now-0 -LATE- (if no deliverytime or deliverytime == 0) |
Lines 516-524
my $daysago4 = output_pref( $dt_today3, 'iso', '24hr', 1 );
Link Here
|
516 |
%suppliers = |
514 |
%suppliers = |
517 |
C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago4, undef ); |
515 |
C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago4, undef ); |
518 |
|
516 |
|
519 |
#FIXME: if the deliverytime is undef, it doesn't consider the supplier |
517 |
ok( exists( $suppliers{$id_supplier1} ), |
520 |
#ok( exists( $suppliers{$id_supplier1} ), |
518 |
"Supplier1 has late orders and $today >= $daysago4 -deliverytime undef" ); |
521 |
# "Supplier1 has late orders and $today >= $daysago4 -deliverytime undef" ); |
|
|
522 |
ok( exists( $suppliers{$id_supplier2} ), |
519 |
ok( exists( $suppliers{$id_supplier2} ), |
523 |
"Supplier2 has late orders and $daysago5 + 2 days >= $daysago4 " ); |
520 |
"Supplier2 has late orders and $daysago5 + 2 days >= $daysago4 " ); |
524 |
isnt( exists( $suppliers{$id_supplier3} ), |
521 |
isnt( exists( $suppliers{$id_supplier3} ), |
Lines 552-564
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
Link Here
|
552 |
# quantityreceived = quantity -NOT LATE- |
549 |
# quantityreceived = quantity -NOT LATE- |
553 |
%suppliers = |
550 |
%suppliers = |
554 |
C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago5 ); |
551 |
C4::Bookseller::GetBooksellersWithLateOrders( undef, undef, $daysago5 ); |
555 |
#FIXME: if only the estimateddeliverydatefrom is given, it doesn't consider the parameters, |
552 |
isnt( exists( $suppliers{$id_supplier1} ), |
556 |
#but it replaces it today's date |
553 |
1, |
557 |
#isnt( exists( $suppliers{$id_supplier1} ), |
554 |
"Supplier1 has late orders but $today >= $daysago5 - deliverytime undef" ); |
558 |
# 1, |
555 |
isnt( exists( $suppliers{$id_supplier2} ), |
559 |
# "Supplier1 has late orders but $today >= $daysago5 - deliverytime undef" ); |
556 |
1, "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 " ); |
560 |
#isnt( exists( $suppliers{$id_supplier2} ), |
|
|
561 |
# 1, "Supplier2 has late orders but $daysago5 + 2 days > $daysago5 " ); |
562 |
ok( exists( $suppliers{$id_supplier3} ), |
557 |
ok( exists( $suppliers{$id_supplier3} ), |
563 |
"Supplier3 has late orders and $daysago10 + 3 <= $daysago5" ); |
558 |
"Supplier3 has late orders and $daysago10 + 3 <= $daysago5" ); |
564 |
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" ); |
559 |
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" ); |
Lines 616-628
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
Link Here
|
616 |
C4::Bookseller::GetBooksellersWithLateOrders( 5, undef, $daysago5 ); |
611 |
C4::Bookseller::GetBooksellersWithLateOrders( 5, undef, $daysago5 ); |
617 |
isnt( exists( $suppliers{$id_supplier1} ), |
612 |
isnt( exists( $suppliers{$id_supplier1} ), |
618 |
1, "Supplier2 has late orders but today > $daysago5 today > now() -5" ); |
613 |
1, "Supplier2 has late orders but today > $daysago5 today > now() -5" ); |
619 |
#FIXME: GetBookSellersWithLateOrders replace estimateddeliverydateto by |
614 |
isnt( |
620 |
#today's date when no estimateddeliverydatefrom is give |
615 |
exists( $suppliers{$id_supplier2} ), |
621 |
#isnt( |
616 |
1, |
622 |
# exists( $suppliers{$id_supplier2} ), |
617 |
"Supplier2 has late orders but $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days" |
623 |
# 1, |
618 |
); |
624 |
#"Supplier2 has late orders but $daysago5 + 2 days > $daysago5 and $daysago5 > now() - 2+5 days" |
|
|
625 |
#); |
626 |
ok( |
619 |
ok( |
627 |
exists( $suppliers{$id_supplier3} ), |
620 |
exists( $suppliers{$id_supplier3} ), |
628 |
"Supplier2 has late orders and $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days " |
621 |
"Supplier2 has late orders and $daysago10 + 3 days <= $daysago5 and $daysago10 <= now() - 3+5 days " |
Lines 643-652
$basket1info = {
Link Here
|
643 |
ModBasket($basket1info); |
636 |
ModBasket($basket1info); |
644 |
%suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, |
637 |
%suppliers = C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, |
645 |
$daysago10 ); |
638 |
$daysago10 ); |
646 |
#FIXME :GetBookSellers doesn't take care if the closedate is ==$estimateddeliverydateto |
639 |
ok( exists( $suppliers{$id_supplier1} ), |
647 |
# ok( exists( $suppliers{$id_supplier1} ), |
640 |
"Supplier1 has late orders and $daysago10==$daysago10==$daysago10 " ) |
648 |
# "Supplier1 has late orders and $daysago10==$daysago10==$daysago10 " ) |
641 |
; |
649 |
# ; |
|
|
650 |
isnt( exists( $suppliers{$id_supplier2} ), |
642 |
isnt( exists( $suppliers{$id_supplier2} ), |
651 |
1, |
643 |
1, |
652 |
"Supplier2 has late orders but $daysago10==$daysago10<$daysago5+2" ); |
644 |
"Supplier2 has late orders but $daysago10==$daysago10<$daysago5+2" ); |
Lines 658-666
isnt( exists( $suppliers{$id_supplier4} ), 1, "Supplier4 hasnt late orders" );
Link Here
|
658 |
#Case 12: closedate == $estimateddeliverydatefrom =today-10 |
650 |
#Case 12: closedate == $estimateddeliverydatefrom =today-10 |
659 |
%suppliers = |
651 |
%suppliers = |
660 |
C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, undef ); |
652 |
C4::Bookseller::GetBooksellersWithLateOrders( undef, $daysago10, undef ); |
661 |
#FIXME :GetBookSellers doesn't take care if the closedate is ==$estimateddeliverydateto |
653 |
ok( exists( $suppliers{$id_supplier1} ), |
662 |
#ok( exists( $suppliers{$id_supplier1} ), |
654 |
"Supplier1 has late orders and $daysago10==$daysago10 " ); |
663 |
# "Supplier1 has late orders and $daysago10==$daysago10 " ); |
|
|
664 |
|
655 |
|
665 |
#Case 13: closedate == $estimateddeliverydateto =today-10 |
656 |
#Case 13: closedate == $estimateddeliverydateto =today-10 |
666 |
%suppliers = |
657 |
%suppliers = |
667 |
- |
|
|