Lines 934-946
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
934 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
934 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
935 |
is( $line->debit_type_code, 'OVERDUE', 'Account line type is OVERDUE' ); |
935 |
is( $line->debit_type_code, 'OVERDUE', 'Account line type is OVERDUE' ); |
936 |
is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' ); |
936 |
is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' ); |
937 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
937 |
is( $line->amountoutstanding+0, 15, 'Account line amount outstanding is 15.00' ); |
938 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
938 |
is( $line->amount+0, 15, 'Account line amount is 15.00' ); |
939 |
is( $line->issue_id, $issue->id, 'Account line issue id matches' ); |
939 |
is( $line->issue_id, $issue->id, 'Account line issue id matches' ); |
940 |
|
940 |
|
941 |
my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next(); |
941 |
my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next(); |
942 |
is( $offset->type, 'OVERDUE', 'Account offset type is Fine' ); |
942 |
is( $offset->type, 'OVERDUE', 'Account offset type is Fine' ); |
943 |
is( $offset->amount, '15.000000', 'Account offset amount is 15.00' ); |
943 |
is( $offset->amount+0, 15, 'Account offset amount is 15.00' ); |
944 |
|
944 |
|
945 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','0'); |
945 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','0'); |
946 |
t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0'); |
946 |
t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0'); |
Lines 961-967
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
961 |
undef, $renewing_borrower->{borrowernumber} |
961 |
undef, $renewing_borrower->{borrowernumber} |
962 |
); |
962 |
); |
963 |
|
963 |
|
964 |
is( $total_due, '15.000000', 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' ); |
964 |
is( $total_due+0, 15, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' ); |
965 |
|
965 |
|
966 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
966 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
967 |
|
967 |
|
Lines 2523-2529
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2523 |
|
2523 |
|
2524 |
$accountline->_result()->discard_changes(); |
2524 |
$accountline->_result()->discard_changes(); |
2525 |
|
2525 |
|
2526 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2526 |
is( $accountline->amountoutstanding+0, 99, 'Fine has the same amount outstanding as previously' ); |
2527 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2527 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2528 |
is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )'); |
2528 |
is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )'); |
2529 |
|
2529 |
|
Lines 3119-3125
subtest 'Incremented fee tests' => sub {
Link Here
|
3119 |
value => { |
3119 |
value => { |
3120 |
notforloan => undef, |
3120 |
notforloan => undef, |
3121 |
rentalcharge => 0, |
3121 |
rentalcharge => 0, |
3122 |
rentalcharge_daily => 1.000000 |
3122 |
rentalcharge_daily => 1, |
3123 |
} |
3123 |
} |
3124 |
} |
3124 |
} |
3125 |
)->store; |
3125 |
)->store; |
Lines 3131-3138
subtest 'Incremented fee tests' => sub {
Link Here
|
3131 |
} |
3131 |
} |
3132 |
); |
3132 |
); |
3133 |
|
3133 |
|
3134 |
is( $itemtype->rentalcharge_daily, |
3134 |
is( $itemtype->rentalcharge_daily+0, |
3135 |
'1.000000', 'Daily rental charge stored and retreived correctly' ); |
3135 |
1, 'Daily rental charge stored and retreived correctly' ); |
3136 |
is( $item->effective_itemtype, $itemtype->id, |
3136 |
is( $item->effective_itemtype, $itemtype->id, |
3137 |
"Itemtype set correctly for item" ); |
3137 |
"Itemtype set correctly for item" ); |
3138 |
|
3138 |
|
Lines 3145-3157
subtest 'Incremented fee tests' => sub {
Link Here
|
3145 |
my $issue = |
3145 |
my $issue = |
3146 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3146 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3147 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3147 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3148 |
is( $accountline->amount, '7.000000', |
3148 |
is( $accountline->amount+0, 7, |
3149 |
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar" |
3149 |
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar" |
3150 |
); |
3150 |
); |
3151 |
$accountline->delete(); |
3151 |
$accountline->delete(); |
3152 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3152 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3153 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3153 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3154 |
is( $accountline->amount, '6.000000', |
3154 |
is( $accountline->amount+0, 6, |
3155 |
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal" |
3155 |
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal" |
3156 |
); |
3156 |
); |
3157 |
$accountline->delete(); |
3157 |
$accountline->delete(); |
Lines 3161-3173
subtest 'Incremented fee tests' => sub {
Link Here
|
3161 |
$issue = |
3161 |
$issue = |
3162 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3162 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3163 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3163 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3164 |
is( $accountline->amount, '7.000000', |
3164 |
is( $accountline->amount+0, 7, |
3165 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed" |
3165 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed" |
3166 |
); |
3166 |
); |
3167 |
$accountline->delete(); |
3167 |
$accountline->delete(); |
3168 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3168 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3169 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3169 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3170 |
is( $accountline->amount, '6.000000', |
3170 |
is( $accountline->amount+0, 6, |
3171 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal" |
3171 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal" |
3172 |
); |
3172 |
); |
3173 |
$accountline->delete(); |
3173 |
$accountline->delete(); |
Lines 3188-3207
subtest 'Incremented fee tests' => sub {
Link Here
|
3188 |
$issue = |
3188 |
$issue = |
3189 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3189 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3190 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3190 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3191 |
is( $accountline->amount, '6.000000', |
3191 |
is( $accountline->amount+0, 6, |
3192 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name" |
3192 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name" |
3193 |
); |
3193 |
); |
3194 |
$accountline->delete(); |
3194 |
$accountline->delete(); |
3195 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3195 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3196 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3196 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
3197 |
is( $accountline->amount, '5.000000', |
3197 |
is( $accountline->amount+0, 5, |
3198 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name, for renewal" |
3198 |
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name, for renewal" |
3199 |
); |
3199 |
); |
3200 |
$accountline->delete(); |
3200 |
$accountline->delete(); |
3201 |
$issue->delete(); |
3201 |
$issue->delete(); |
3202 |
|
3202 |
|
3203 |
$itemtype->rentalcharge('2.000000')->store; |
3203 |
$itemtype->rentalcharge(2)->store; |
3204 |
is( $itemtype->rentalcharge, '2.000000', |
3204 |
is( $itemtype->rentalcharge+0, 2, |
3205 |
'Rental charge updated and retreived correctly' ); |
3205 |
'Rental charge updated and retreived correctly' ); |
3206 |
$issue = |
3206 |
$issue = |
3207 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3207 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
Lines 3216-3223
subtest 'Incremented fee tests' => sub {
Link Here
|
3216 |
"Fixed charge and accrued charge recorded distinctly, for renewal" ); |
3216 |
"Fixed charge and accrued charge recorded distinctly, for renewal" ); |
3217 |
$accountlines->delete(); |
3217 |
$accountlines->delete(); |
3218 |
$issue->delete(); |
3218 |
$issue->delete(); |
3219 |
$itemtype->rentalcharge('00.000000')->store; |
3219 |
$itemtype->rentalcharge(0)->store; |
3220 |
is( $itemtype->rentalcharge, '00.000000', |
3220 |
is( $itemtype->rentalcharge+0, 0, |
3221 |
'Rental charge reset and retreived correctly' ); |
3221 |
'Rental charge reset and retreived correctly' ); |
3222 |
|
3222 |
|
3223 |
# Hourly |
3223 |
# Hourly |
Lines 3331-3341
subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub {
Link Here
|
3331 |
my $dt_from = dt_from_string(); |
3331 |
my $dt_from = dt_from_string(); |
3332 |
my $dt_due = dt_from_string()->add( days => 3 ); |
3332 |
my $dt_due = dt_from_string()->add( days => 3 ); |
3333 |
|
3333 |
|
3334 |
$itemtype->rentalcharge('1.000000')->store; |
3334 |
$itemtype->rentalcharge(1)->store; |
3335 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); |
3335 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); |
3336 |
is_deeply( $needsconfirmation, { RENTALCHARGE => '1.00' }, 'Item needs rentalcharge confirmation to be issued' ); |
3336 |
is_deeply( $needsconfirmation, { RENTALCHARGE => '1.00' }, 'Item needs rentalcharge confirmation to be issued' ); |
3337 |
$itemtype->rentalcharge('0')->store; |
3337 |
$itemtype->rentalcharge('0')->store; |
3338 |
$itemtype->rentalcharge_daily('1.000000')->store; |
3338 |
$itemtype->rentalcharge_daily(1)->store; |
3339 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); |
3339 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); |
3340 |
is_deeply( $needsconfirmation, { RENTALCHARGE => '3' }, 'Item needs rentalcharge confirmation to be issued, increment' ); |
3340 |
is_deeply( $needsconfirmation, { RENTALCHARGE => '3' }, 'Item needs rentalcharge confirmation to be issued, increment' ); |
3341 |
$itemtype->rentalcharge_daily('0')->store; |
3341 |
$itemtype->rentalcharge_daily('0')->store; |
Lines 3380-3387
subtest "Test Backdating of Returns" => sub {
Link Here
|
3380 |
my ( undef, $message ) = AddReturn( $item->barcode, $branch, undef, $due_date ); |
3380 |
my ( undef, $message ) = AddReturn( $item->barcode, $branch, undef, $due_date ); |
3381 |
|
3381 |
|
3382 |
my $accountline = Koha::Account::Lines->find( { issue_id => $issue->id } ); |
3382 |
my $accountline = Koha::Account::Lines->find( { issue_id => $issue->id } ); |
3383 |
is( $accountline->amountoutstanding, '0.000000', 'Fee amount outstanding was reduced to 0' ); |
3383 |
is( $accountline->amountoutstanding+0, 0, 'Fee amount outstanding was reduced to 0' ); |
3384 |
is( $accountline->amount, '0.000000', 'Fee amount was reduced to 0' ); |
3384 |
is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' ); |
3385 |
}; |
3385 |
}; |
3386 |
|
3386 |
|
3387 |
$schema->storage->txn_rollback; |
3387 |
$schema->storage->txn_rollback; |