Lines 593-598
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
593 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
593 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
594 |
}; |
594 |
}; |
595 |
|
595 |
|
|
|
596 |
subtest "GetLatestAutoRenewDate" => sub { |
597 |
plan tests => 3; |
598 |
my $item_to_auto_renew = $builder->build( |
599 |
{ source => 'Item', |
600 |
value => { |
601 |
biblionumber => $biblionumber, |
602 |
homebranch => $branch, |
603 |
holdingbranch => $branch, |
604 |
} |
605 |
} |
606 |
); |
607 |
|
608 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
609 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
610 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
611 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = ""'); |
612 |
my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
613 |
is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after is not defined' ); |
614 |
my $five_days_before = dt_from_string->add( days => -5 ); |
615 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 5'); |
616 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
617 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
618 |
$five_days_before->truncate( to => 'minute' ), |
619 |
'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' |
620 |
); |
621 |
my $five_days_ahead = dt_from_string->add( days => 5 ); |
622 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 15'); |
623 |
$latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
624 |
is( $latest_auto_renew_date->truncate( to => 'minute' ), |
625 |
$five_days_ahead->truncate( to => 'minute' ), |
626 |
'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' |
627 |
); |
628 |
}; |
629 |
|
596 |
# Too many renewals |
630 |
# Too many renewals |
597 |
|
631 |
|
598 |
# set policy to forbid renewals |
632 |
# set policy to forbid renewals |
599 |
- |
|
|