Lines 1652-1659
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1652 |
; # Add another overdue |
1652 |
; # Add another overdue |
1653 |
|
1653 |
|
1654 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
1654 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
1655 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, |
1655 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1656 |
undef, undef, dt_from_string ); |
|
|
1657 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
1656 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
1658 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1657 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1659 |
is( scalar(@$debarments), 1 ); |
1658 |
is( scalar(@$debarments), 1 ); |
Lines 1669-1676
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1669 |
); |
1668 |
); |
1670 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1669 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1671 |
|
1670 |
|
1672 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, |
1671 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1673 |
undef, undef, dt_from_string ); |
|
|
1674 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1672 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1675 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1673 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1676 |
is( scalar(@$debarments), 1 ); |
1674 |
is( scalar(@$debarments), 1 ); |
Lines 1690-1697
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1690 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
1688 |
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue |
1691 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
1689 |
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) |
1692 |
; # Add another overdue |
1690 |
; # Add another overdue |
1693 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, |
1691 |
AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1694 |
undef, undef, dt_from_string ); |
|
|
1695 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1692 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1696 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1693 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1697 |
is( scalar(@$debarments), 1 ); |
1694 |
is( scalar(@$debarments), 1 ); |
Lines 1704-1711
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
1704 |
); |
1701 |
); |
1705 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1702 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
1706 |
|
1703 |
|
1707 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, |
1704 |
AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, dt_from_string ); |
1708 |
undef, undef, dt_from_string ); |
|
|
1709 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1705 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
1710 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1706 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
1711 |
is( scalar(@$debarments), 1 ); |
1707 |
is( scalar(@$debarments), 1 ); |
Lines 1934-1958
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1934 |
|
1930 |
|
1935 |
# specify return date 5 days before => no overdue |
1931 |
# specify return date 5 days before => no overdue |
1936 |
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago |
1932 |
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago |
1937 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $ten_days_ago ); |
1933 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, $ten_days_ago ); |
1938 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
1934 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
1939 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1935 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1940 |
|
1936 |
|
1941 |
# specify return date 5 days later => overdue |
1937 |
# specify return date 5 days later => overdue |
1942 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1938 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1943 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $five_days_ago ); |
1939 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, $five_days_ago ); |
1944 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
1940 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
1945 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1941 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1946 |
|
1942 |
|
1947 |
# specify dropbox date 5 days before => no overdue |
1943 |
# specify dropbox date 5 days before => no overdue |
1948 |
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago |
1944 |
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago |
1949 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $ten_days_ago ); |
1945 |
AddReturn( $item->{barcode}, $library->{branchcode}, $ten_days_ago ); |
1950 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
1946 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
1951 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1947 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1952 |
|
1948 |
|
1953 |
# specify dropbox date 5 days later => overdue, or... not |
1949 |
# specify dropbox date 5 days later => overdue, or... not |
1954 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1950 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1955 |
AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); |
1951 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1956 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
1952 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
1957 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1953 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1958 |
}; |
1954 |
}; |
Lines 2335-2341
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
2335 |
}; |
2331 |
}; |
2336 |
|
2332 |
|
2337 |
subtest '_FixOverduesOnReturn' => sub { |
2333 |
subtest '_FixOverduesOnReturn' => sub { |
2338 |
plan tests => 10; |
2334 |
plan tests => 6; |
2339 |
|
2335 |
|
2340 |
my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' }); |
2336 |
my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' }); |
2341 |
|
2337 |
|
Lines 2389-2412
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2389 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2385 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2390 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2386 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2391 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2387 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2392 |
|
|
|
2393 |
## Run again, with dropbox mode enabled |
2394 |
$accountline->set( |
2395 |
{ |
2396 |
accounttype => 'FU', |
2397 |
amountoutstanding => 99.00, |
2398 |
} |
2399 |
)->store(); |
2400 |
|
2401 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 0, 1 ); |
2402 |
|
2403 |
$accountline->_result()->discard_changes(); |
2404 |
$offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Dropbox' })->next(); |
2405 |
|
2406 |
is( $accountline->amountoutstanding + 0, 90, 'Fine has been reduced to 90' ); |
2407 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
2408 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via dropbox" ); |
2409 |
is( $offset->amount, '-9.000000', "Amount of offset is correct" ); |
2410 |
}; |
2388 |
}; |
2411 |
|
2389 |
|
2412 |
subtest 'Set waiting flag' => sub { |
2390 |
subtest 'Set waiting flag' => sub { |
Lines 3007-3014
sub test_debarment_on_checkout {
Link Here
|
3007 |
my $line_number = $caller[2]; |
2985 |
my $line_number = $caller[2]; |
3008 |
AddIssue( $patron, $item->{barcode}, $due_date ); |
2986 |
AddIssue( $patron, $item->{barcode}, $due_date ); |
3009 |
|
2987 |
|
3010 |
my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, |
2988 |
my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, $return_date ); |
3011 |
undef, undef, $return_date ); |
|
|
3012 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
2989 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
3013 |
or diag('AddReturn returned message ' . Dumper $message ); |
2990 |
or diag('AddReturn returned message ' . Dumper $message ); |
3014 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
2991 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |