Lines 1701-1714
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1701 |
$rule->store(); |
1701 |
$rule->store(); |
1702 |
|
1702 |
|
1703 |
# Patron cannot issue item_1, they have overdues |
1703 |
# Patron cannot issue item_1, they have overdues |
1704 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
1704 |
my $now = dt_from_string; |
1705 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
1705 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
|
|
1706 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
1706 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
1707 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
1707 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
1708 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
1708 |
; # Add another overdue |
1709 |
; # Add another overdue |
1709 |
|
1710 |
|
1710 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
1711 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
1711 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1712 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now ); |
1712 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
1713 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
1713 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1714 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1714 |
is( scalar(@$debarments), 1 ); |
1715 |
is( scalar(@$debarments), 1 ); |
Lines 1717-1736
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1717 |
# Same for the others |
1718 |
# Same for the others |
1718 |
my $expected_expiration = output_pref( |
1719 |
my $expected_expiration = output_pref( |
1719 |
{ |
1720 |
{ |
1720 |
dt => dt_from_string->add( days => ( 5 - 1 ) * 2 ), |
1721 |
dt => $now->clone->add( days => ( 5 - 1 ) * 2 ), |
1721 |
dateformat => 'sql', |
1722 |
dateformat => 'sql', |
1722 |
dateonly => 1 |
1723 |
dateonly => 1 |
1723 |
} |
1724 |
} |
1724 |
); |
1725 |
); |
1725 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1726 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1726 |
|
1727 |
|
1727 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1728 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, $now ); |
1728 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1729 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1729 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1730 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1730 |
is( scalar(@$debarments), 1 ); |
1731 |
is( scalar(@$debarments), 1 ); |
1731 |
$expected_expiration = output_pref( |
1732 |
$expected_expiration = output_pref( |
1732 |
{ |
1733 |
{ |
1733 |
dt => dt_from_string->add( days => ( 10 - 1 ) * 2 ), |
1734 |
dt => $now->clone->add( days => ( 10 - 1 ) * 2 ), |
1734 |
dateformat => 'sql', |
1735 |
dateformat => 'sql', |
1735 |
dateonly => 1 |
1736 |
dateonly => 1 |
1736 |
} |
1737 |
} |
Lines 1744-1769
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1744 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
1745 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
1745 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
1746 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
1746 |
; # Add another overdue |
1747 |
; # Add another overdue |
1747 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1748 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now ); |
1748 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1749 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1749 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1750 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1750 |
is( scalar(@$debarments), 1 ); |
1751 |
is( scalar(@$debarments), 1 ); |
1751 |
$expected_expiration = output_pref( |
1752 |
$expected_expiration = output_pref( |
1752 |
{ |
1753 |
{ |
1753 |
dt => dt_from_string->add( days => ( 5 - 1 ) * 2 ), |
1754 |
dt => $now->clone->add( days => ( 5 - 1 ) * 2 ), |
1754 |
dateformat => 'sql', |
1755 |
dateformat => 'sql', |
1755 |
dateonly => 1 |
1756 |
dateonly => 1 |
1756 |
} |
1757 |
} |
1757 |
); |
1758 |
); |
1758 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1759 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1759 |
|
1760 |
|
1760 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1761 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, $now ); |
1761 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1762 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1762 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1763 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1763 |
is( scalar(@$debarments), 1 ); |
1764 |
is( scalar(@$debarments), 1 ); |
1764 |
$expected_expiration = output_pref( |
1765 |
$expected_expiration = output_pref( |
1765 |
{ |
1766 |
{ |
1766 |
dt => dt_from_string->add( days => ( 5 - 1 ) * 2 + ( 10 - 1 ) * 2 ), |
1767 |
dt => $now->clone->add( days => ( 5 - 1 ) * 2 + ( 10 - 1 ) * 2 ), |
1767 |
dateformat => 'sql', |
1768 |
dateformat => 'sql', |
1768 |
dateonly => 1 |
1769 |
dateonly => 1 |
1769 |
} |
1770 |
} |
Lines 3047-3053
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
3047 |
$context = Test::MockModule->new('C4::Context'); |
3048 |
$context = Test::MockModule->new('C4::Context'); |
3048 |
$context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew) |
3049 |
$context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew) |
3049 |
|
3050 |
|
3050 |
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); |
3051 |
my $now = dt_from_string; |
|
|
3052 |
$date = output_pref( { dt => $now, dateonly => 1, dateformat => 'iso' } ); |
3051 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
3053 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
3052 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
3054 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
3053 |
$sth->execute($item->id, $library->id); |
3055 |
$sth->execute($item->id, $library->id); |
Lines 3127-3135
subtest 'Incremented fee tests' => sub {
Link Here
|
3127 |
is( $item->effective_itemtype, $itemtype->id, |
3129 |
is( $item->effective_itemtype, $itemtype->id, |
3128 |
"Itemtype set correctly for item" ); |
3130 |
"Itemtype set correctly for item" ); |
3129 |
|
3131 |
|
3130 |
my $dt_from = dt_from_string(); |
3132 |
my $now = dt_from_string; |
3131 |
my $dt_to = dt_from_string()->add( days => 7 ); |
3133 |
my $dt_from = $now->clone; |
3132 |
my $dt_to_renew = dt_from_string()->add( days => 13 ); |
3134 |
my $dt_to = $now->clone->add( days => 7 ); |
|
|
3135 |
my $dt_to_renew = $now->clone->add( days => 13 ); |
3133 |
|
3136 |
|
3134 |
# Daily Tests |
3137 |
# Daily Tests |
3135 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' ); |
3138 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' ); |
Lines 3221-3228
subtest 'Incremented fee tests' => sub {
Link Here
|
3221 |
is( $itemtype->rentalcharge_hourly, |
3224 |
is( $itemtype->rentalcharge_hourly, |
3222 |
'0.25', 'Hourly rental charge stored and retreived correctly' ); |
3225 |
'0.25', 'Hourly rental charge stored and retreived correctly' ); |
3223 |
|
3226 |
|
3224 |
$dt_to = dt_from_string()->add( hours => 168 ); |
3227 |
$dt_to = $now->clone->add( hours => 168 ); |
3225 |
$dt_to_renew = dt_from_string()->add( hours => 312 ); |
3228 |
$dt_to_renew = $now->clone->add( hours => 312 ); |
3226 |
|
3229 |
|
3227 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' ); |
3230 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' ); |
3228 |
$issue = |
3231 |
$issue = |
Lines 3314-3320
subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub {
Link Here
|
3314 |
|
3317 |
|
3315 |
my ( $issuingimpossible, $needsconfirmation ); |
3318 |
my ( $issuingimpossible, $needsconfirmation ); |
3316 |
my $dt_from = dt_from_string(); |
3319 |
my $dt_from = dt_from_string(); |
3317 |
my $dt_due = dt_from_string()->add( days => 3 ); |
3320 |
my $dt_due = $dt_from->clone->add( days => 3 ); |
3318 |
|
3321 |
|
3319 |
$itemtype->rentalcharge('1.000000')->store; |
3322 |
$itemtype->rentalcharge('1.000000')->store; |
3320 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); |
3323 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); |
3321 |
- |
|
|