Lines 274-280
subtest 'apply() tests' => sub {
Link Here
|
274 |
itemnumber => $item->id, |
274 |
itemnumber => $item->id, |
275 |
branchcode => $library->id, |
275 |
branchcode => $library->id, |
276 |
date => \'NOW()', |
276 |
date => \'NOW()', |
277 |
accounttype => 'OVERDUE', |
277 |
debit_type_code => 'OVERDUE', |
278 |
status => 'UNRETURNED', |
278 |
status => 'UNRETURNED', |
279 |
interface => 'cli', |
279 |
interface => 'cli', |
280 |
amount => '1', |
280 |
amount => '1', |
Lines 287-292
subtest 'apply() tests' => sub {
Link Here
|
287 |
my $called = 0; |
287 |
my $called = 0; |
288 |
my $module = new Test::MockModule('C4::Circulation'); |
288 |
my $module = new Test::MockModule('C4::Circulation'); |
289 |
$module->mock('AddRenewal', sub { $called = 1; }); |
289 |
$module->mock('AddRenewal', sub { $called = 1; }); |
|
|
290 |
$module->mock('CanBookBeRenewed', sub { return 1; }); |
290 |
my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' }); |
291 |
my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' }); |
291 |
my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list; |
292 |
my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list; |
292 |
$credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } ); |
293 |
$credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } ); |
Lines 336-342
subtest 'Keep account info when related patron, staff, item or cash_register is
Link Here
|
336 |
|
337 |
|
337 |
$patron->delete; |
338 |
$patron->delete; |
338 |
$line = $line->get_from_storage; |
339 |
$line = $line->get_from_storage; |
339 |
is( $line->borro1wernumber, undef, "The account line should not be deleted when the related patron is delete"); |
340 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
340 |
|
341 |
|
341 |
$register->delete; |
342 |
$register->delete; |
342 |
$line = $line->get_from_storage; |
343 |
$line = $line->get_from_storage; |
Lines 370-376
subtest 'Renewal related tests' => sub {
Link Here
|
370 |
borrowernumber => $patron->borrowernumber, |
371 |
borrowernumber => $patron->borrowernumber, |
371 |
manager_id => $staff->borrowernumber, |
372 |
manager_id => $staff->borrowernumber, |
372 |
itemnumber => $item->itemnumber, |
373 |
itemnumber => $item->itemnumber, |
373 |
accounttype => "OVERDUE", |
374 |
debit_type_code => "OVERDUE", |
374 |
status => "UNRETURNED", |
375 |
status => "UNRETURNED", |
375 |
amountoutstanding => 0, |
376 |
amountoutstanding => 0, |
376 |
interface => 'commandline', |
377 |
interface => 'commandline', |
Lines 380-394
subtest 'Renewal related tests' => sub {
Link Here
|
380 |
$line->amountoutstanding(5); |
381 |
$line->amountoutstanding(5); |
381 |
is( $line->renewable, 0, "Item is returned as unrenewable when it has outstanding fine" ); |
382 |
is( $line->renewable, 0, "Item is returned as unrenewable when it has outstanding fine" ); |
382 |
$line->amountoutstanding(0); |
383 |
$line->amountoutstanding(0); |
383 |
$line->accounttype("VOID"); |
384 |
$line->debit_type_code("VOID"); |
384 |
is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account type" ); |
385 |
is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account type" ); |
385 |
$line->accounttype("OVERDUE"); |
386 |
$line->debit_type_code("OVERDUE"); |
386 |
$line->status("RETURNED"); |
387 |
$line->status("RETURNED"); |
387 |
is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account status" ); |
388 |
is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account status" ); |
388 |
|
389 |
|
389 |
|
390 |
|
390 |
t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 ); |
391 |
t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 ); |
391 |
is ($line->renew_item, 0, 'Attempt to renew fails when syspref is not set'); |
392 |
is ($line->renew_item, undef, 'Attempt to renew fails when syspref is not set'); |
392 |
t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 ); |
393 |
t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 ); |
393 |
is_deeply( |
394 |
is_deeply( |
394 |
$line->renew_item, |
395 |
$line->renew_item, |
Lines 414-419
subtest 'Renewal related tests' => sub {
Link Here
|
414 |
my $called = 0; |
415 |
my $called = 0; |
415 |
my $module = new Test::MockModule('C4::Circulation'); |
416 |
my $module = new Test::MockModule('C4::Circulation'); |
416 |
$module->mock('AddRenewal', sub { $called = 1; }); |
417 |
$module->mock('AddRenewal', sub { $called = 1; }); |
|
|
418 |
$module->mock('CanBookBeRenewed', sub { return 1; }); |
417 |
$line->renew_item; |
419 |
$line->renew_item; |
418 |
is( $called, 1, 'Attempt to renew succeeds when conditions are met' ); |
420 |
is( $called, 1, 'Attempt to renew succeeds when conditions are met' ); |
419 |
|
421 |
|
420 |
- |
|
|