Lines 26-31
use t::lib::TestBuilder;
Link Here
|
26 |
use t::lib::Mocks; |
26 |
use t::lib::Mocks; |
27 |
|
27 |
|
28 |
use Koha::Account; |
28 |
use Koha::Account; |
|
|
29 |
use Koha::Account::DebitTypes; |
29 |
use Koha::Account::Lines; |
30 |
use Koha::Account::Lines; |
30 |
use Koha::Account::Offsets; |
31 |
use Koha::Account::Offsets; |
31 |
use Koha::Notice::Messages; |
32 |
use Koha::Notice::Messages; |
Lines 92-98
my ($accountline) = Koha::Account::Lines->search(
Link Here
|
92 |
borrowernumber => $patron->{borrowernumber} |
93 |
borrowernumber => $patron->{borrowernumber} |
93 |
} |
94 |
} |
94 |
); |
95 |
); |
95 |
is( $accountline->accounttype, $type, 'Accountline type set correctly for manualinvoice' ); |
96 |
is( $accountline->debit_type_code, $type, 'Debit type set correctly for manualinvoice' ); |
96 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for manualinvoice' ); |
97 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for manualinvoice' ); |
97 |
ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); |
98 |
ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); |
98 |
is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); |
99 |
is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); |
Lines 373-379
subtest "Koha::Account::pay writeoff tests" => sub {
Link Here
|
373 |
|
374 |
|
374 |
my $writeoff = Koha::Account::Lines->find( $id ); |
375 |
my $writeoff = Koha::Account::Lines->find( $id ); |
375 |
|
376 |
|
376 |
is( $writeoff->accounttype, 'W', 'Type is correct' ); |
377 |
is( $writeoff->accounttype, 'W', 'Type is correct for writeoff' ); |
377 |
is( $writeoff->description, 'Writeoff', 'Description is correct' ); |
378 |
is( $writeoff->description, 'Writeoff', 'Description is correct' ); |
378 |
is( $writeoff->amount, '-42.000000', 'Amount is correct' ); |
379 |
is( $writeoff->amount, '-42.000000', 'Amount is correct' ); |
379 |
}; |
380 |
}; |
Lines 583-621
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
583 |
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '0'); |
584 |
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '0'); |
584 |
|
585 |
|
585 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor"); |
586 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor"); |
586 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'LOST' }); |
587 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'LOST' }); |
587 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'PF' }); |
588 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'PF' }); |
588 |
ok( !$lostfine, "No lost fine if no replacementcost or default when pref off"); |
589 |
ok( !$lostfine, "No lost fine if no replacementcost or default when pref off"); |
589 |
ok( !$procfee, "No processing fee if no processing fee"); |
590 |
ok( !$procfee, "No processing fee if no processing fee"); |
590 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 6.12, "Perdedor"); |
591 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 6.12, "Perdedor"); |
591 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'LOST' }); |
592 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'LOST' }); |
592 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'PF' }); |
593 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'PF' }); |
593 |
ok( $lostfine->amount == 6.12, "Lost fine equals replacementcost when pref off and no default set"); |
594 |
ok( $lostfine->amount == 6.12, "Lost fine equals replacementcost when pref off and no default set"); |
594 |
ok( !$procfee, "No processing fee if no processing fee"); |
595 |
ok( !$procfee, "No processing fee if no processing fee"); |
595 |
$lostfine->delete(); |
596 |
$lostfine->delete(); |
596 |
|
597 |
|
597 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 0, "Perdedor"); |
598 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 0, "Perdedor"); |
598 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'LOST' }); |
599 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'LOST' }); |
599 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'PF' }); |
600 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'PF' }); |
600 |
ok( !$lostfine, "No lost fine if no replacementcost but default set when pref off"); |
601 |
ok( !$lostfine, "No lost fine if no replacementcost but default set when pref off"); |
601 |
ok( !$procfee, "No processing fee if no processing fee"); |
602 |
ok( !$procfee, "No processing fee if no processing fee"); |
602 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 6.12, "Perdedor"); |
603 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 6.12, "Perdedor"); |
603 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'LOST' }); |
604 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'LOST' }); |
604 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'PF' }); |
605 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'PF' }); |
605 |
ok( $lostfine->amount == 6.12 , "Lost fine equals replacementcost when pref off and default set"); |
606 |
ok( $lostfine->amount == 6.12 , "Lost fine equals replacementcost when pref off and default set"); |
606 |
ok( !$procfee, "No processing fee if no processing fee"); |
607 |
ok( !$procfee, "No processing fee if no processing fee"); |
607 |
$lostfine->delete(); |
608 |
$lostfine->delete(); |
608 |
|
609 |
|
609 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 0, "Perdedor"); |
610 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 0, "Perdedor"); |
610 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'LOST' }); |
611 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'LOST' }); |
611 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'PF' }); |
612 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'PF' }); |
612 |
ok( !$lostfine, "No lost fine if no replacementcost and no default set when pref off"); |
613 |
ok( !$lostfine, "No lost fine if no replacementcost and no default set when pref off"); |
613 |
ok( $procfee->amount == 8.16, "Processing fee if processing fee"); |
614 |
ok( $procfee->amount == 8.16, "Processing fee if processing fee"); |
614 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
615 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
615 |
$procfee->delete(); |
616 |
$procfee->delete(); |
616 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 6.12, "Perdedor"); |
617 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 6.12, "Perdedor"); |
617 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'LOST' }); |
618 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'LOST' }); |
618 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'PF' }); |
619 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'PF' }); |
619 |
ok( $lostfine->amount == 6.12 , "Lost fine equals replacementcost when pref off and no default set"); |
620 |
ok( $lostfine->amount == 6.12 , "Lost fine equals replacementcost when pref off and no default set"); |
620 |
ok( $procfee->amount == 8.16, "Processing fee if processing fee"); |
621 |
ok( $procfee->amount == 8.16, "Processing fee if processing fee"); |
621 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
622 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
Lines 623-637
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
623 |
$procfee->delete(); |
624 |
$procfee->delete(); |
624 |
|
625 |
|
625 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
626 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
626 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
627 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
627 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
628 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
628 |
ok( !$lostfine, "No lost fine if no replacementcost but default set when pref off"); |
629 |
ok( !$lostfine, "No lost fine if no replacementcost but default set when pref off"); |
629 |
ok( $procfee->amount == 2.04, "Processing fee if processing fee"); |
630 |
ok( $procfee->amount == 2.04, "Processing fee if processing fee"); |
630 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
631 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
631 |
$procfee->delete(); |
632 |
$procfee->delete(); |
632 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
633 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
633 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
634 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
634 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
635 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
635 |
ok( $lostfine->amount == 6.12 , "Lost fine equals replacementcost when pref off and default set"); |
636 |
ok( $lostfine->amount == 6.12 , "Lost fine equals replacementcost when pref off and default set"); |
636 |
ok( $procfee->amount == 2.04, "Processing fee if processing fee"); |
637 |
ok( $procfee->amount == 2.04, "Processing fee if processing fee"); |
637 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
638 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
Lines 641-706
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
641 |
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '1'); |
642 |
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '1'); |
642 |
|
643 |
|
643 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor"); |
644 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor"); |
644 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'LOST' }); |
645 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'LOST' }); |
645 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'PF' }); |
646 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'PF' }); |
646 |
ok( !$lostfine, "No lost fine if no replacementcost or default when pref on"); |
647 |
ok( !$lostfine, "No lost fine if no replacementcost or default when pref on"); |
647 |
ok( !$procfee, "No processing fee if no processing fee"); |
648 |
ok( !$procfee, "No processing fee if no processing fee"); |
648 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 6.12, "Perdedor"); |
649 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 6.12, "Perdedor"); |
649 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'LOST' }); |
650 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'LOST' }); |
650 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, accounttype => 'PF' }); |
651 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1, debit_type_code => 'PF' }); |
651 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and no default set"); |
652 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and no default set"); |
652 |
ok( !$procfee, "No processing fee if no processing fee"); |
653 |
ok( !$procfee, "No processing fee if no processing fee"); |
653 |
|
654 |
|
654 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 0, "Perdedor"); |
655 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 0, "Perdedor"); |
655 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'LOST' }); |
656 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'LOST' }); |
656 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'PF' }); |
657 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'PF' }); |
657 |
is( $lostfine->amount(), "16.320000", "Lost fine is default if no replacementcost but default set when pref on"); |
658 |
is( $lostfine->amount(), "16.320000", "Lost fine is default if no replacementcost but default set when pref on"); |
658 |
ok( !$procfee, "No processing fee if no processing fee"); |
659 |
ok( !$procfee, "No processing fee if no processing fee"); |
659 |
$lostfine->delete(); |
660 |
$lostfine->delete(); |
660 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 6.12, "Perdedor"); |
661 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber2, 6.12, "Perdedor"); |
661 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'LOST' }); |
662 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'LOST' }); |
662 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, accounttype => 'PF' }); |
663 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2, debit_type_code => 'PF' }); |
663 |
is( $lostfine->amount, "6.120000" , "Lost fine equals replacementcost when pref on and default set"); |
664 |
is( $lostfine->amount, "6.120000" , "Lost fine equals replacementcost when pref on and default set"); |
664 |
ok( !$procfee, "No processing fee if no processing fee"); |
665 |
ok( !$procfee, "No processing fee if no processing fee"); |
665 |
|
666 |
|
666 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 0, "Perdedor"); |
667 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 0, "Perdedor"); |
667 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'LOST' }); |
668 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'LOST' }); |
668 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'PF' }); |
669 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'PF' }); |
669 |
ok( !$lostfine, "No lost fine if no replacementcost and default not set when pref on"); |
670 |
ok( !$lostfine, "No lost fine if no replacementcost and default not set when pref on"); |
670 |
is( $procfee->amount, "8.160000", "Processing fee if processing fee"); |
671 |
is( $procfee->amount, "8.160000", "Processing fee if processing fee"); |
671 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
672 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
672 |
$procfee->delete(); |
673 |
$procfee->delete(); |
673 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 6.12, "Perdedor"); |
674 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber3, 6.12, "Perdedor"); |
674 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'LOST' }); |
675 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'LOST' }); |
675 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, accounttype => 'PF' }); |
676 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3, debit_type_code => 'PF' }); |
676 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and no default set"); |
677 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and no default set"); |
677 |
is( $procfee->amount, "8.160000", "Processing fee if processing fee"); |
678 |
is( $procfee->amount, "8.160000", "Processing fee if processing fee"); |
678 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
679 |
is( $procfee->issue_id, $cli_issue_id_3, "Processing fee issue id is correct" ); |
679 |
|
680 |
|
680 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
681 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
681 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
682 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
682 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
683 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
683 |
is( $lostfine->amount, "4.080000", "Lost fine is default if no replacementcost but default set when pref on"); |
684 |
is( $lostfine->amount, "4.080000", "Lost fine is default if no replacementcost but default set when pref on"); |
684 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
685 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
685 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
686 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
686 |
$lostfine->delete(); |
687 |
$lostfine->delete(); |
687 |
$procfee->delete(); |
688 |
$procfee->delete(); |
688 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
689 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
689 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
690 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
690 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
691 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
691 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and default set"); |
692 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and default set"); |
692 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
693 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
693 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
694 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
694 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
695 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
695 |
my $lostfines = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
696 |
my $lostfines = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
696 |
my $procfees = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
697 |
my $procfees = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
697 |
ok( $lostfines->count == 1 , "Lost fine cannot be double charged for the same issue_id"); |
698 |
ok( $lostfines->count == 1 , "Lost fine cannot be double charged for the same issue_id"); |
698 |
ok( $procfees->count == 1, "Processing fee cannot be double charged for the same issue_id"); |
699 |
ok( $procfees->count == 1, "Processing fee cannot be double charged for the same issue_id"); |
699 |
MarkIssueReturned($cli_borrowernumber, $cli_itemnumber4); |
700 |
MarkIssueReturned($cli_borrowernumber, $cli_itemnumber4); |
700 |
$cli_issue_id_4X = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4 } })->{issue_id}; |
701 |
$cli_issue_id_4X = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4 } })->{issue_id}; |
701 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
702 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
702 |
$lostfines = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
703 |
$lostfines = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
703 |
$procfees = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
704 |
$procfees = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
704 |
ok( $lostfines->count == 2 , "Lost fine can be charged twice for the same item if they are distinct issue_id's"); |
705 |
ok( $lostfines->count == 2 , "Lost fine can be charged twice for the same item if they are distinct issue_id's"); |
705 |
ok( $procfees->count == 2, "Processing fee can be charged twice for the same item if they are distinct issue_id's"); |
706 |
ok( $procfees->count == 2, "Processing fee can be charged twice for the same item if they are distinct issue_id's"); |
706 |
$lostfines->delete(); |
707 |
$lostfines->delete(); |
Lines 714-720
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
714 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor"); |
715 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor"); |
715 |
|
716 |
|
716 |
# Lost Item Fee |
717 |
# Lost Item Fee |
717 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
718 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
718 |
ok($lostfine, "Lost fine created"); |
719 |
ok($lostfine, "Lost fine created"); |
719 |
is($lostfine->manager_id, $staff_id, "Lost fine manager_id set correctly"); |
720 |
is($lostfine->manager_id, $staff_id, "Lost fine manager_id set correctly"); |
720 |
is($lostfine->issue_id, $cli_issue_id_4X, "Lost fine issue_id set correctly"); |
721 |
is($lostfine->issue_id, $cli_issue_id_4X, "Lost fine issue_id set correctly"); |
Lines 723-729
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
723 |
is($lostfine->branchcode, $branchcode, "Lost fine branchcode set correctly"); |
724 |
is($lostfine->branchcode, $branchcode, "Lost fine branchcode set correctly"); |
724 |
|
725 |
|
725 |
# Processing Fee |
726 |
# Processing Fee |
726 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
727 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
727 |
ok($procfee, "Processing fee created"); |
728 |
ok($procfee, "Processing fee created"); |
728 |
is($procfee->manager_id, $staff_id, "Processing fee manager_id set correctly"); |
729 |
is($procfee->manager_id, $staff_id, "Processing fee manager_id set correctly"); |
729 |
is($procfee->issue_id, $cli_issue_id_4X, "Processing fee issue_id set correctly"); |
730 |
is($procfee->issue_id, $cli_issue_id_4X, "Processing fee issue_id set correctly"); |
Lines 741-756
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
741 |
|
742 |
|
742 |
t::lib::Mocks::mock_preference( 'FinesLog', 0 ); |
743 |
t::lib::Mocks::mock_preference( 'FinesLog', 0 ); |
743 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
744 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
744 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
745 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
745 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
746 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
746 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No logs were added' ); |
747 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No logs were added' ); |
747 |
$lostfine->delete(); |
748 |
$lostfine->delete(); |
748 |
$procfee->delete(); |
749 |
$procfee->delete(); |
749 |
|
750 |
|
750 |
t::lib::Mocks::mock_preference( 'FinesLog', 1 ); |
751 |
t::lib::Mocks::mock_preference( 'FinesLog', 1 ); |
751 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
752 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 0, "Perdedor"); |
752 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
753 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'LOST' }); |
753 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
754 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, debit_type_code => 'PF' }); |
754 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 2, 'Logs were added' ); |
755 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 2, 'Logs were added' ); |
755 |
$lostfine->delete(); |
756 |
$lostfine->delete(); |
756 |
$procfee->delete(); |
757 |
$procfee->delete(); |
Lines 786-792
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
786 |
interface => 'commandline' |
787 |
interface => 'commandline' |
787 |
} |
788 |
} |
788 |
); |
789 |
); |
789 |
Koha::Account::DebitTypes->new( |
790 |
Koha::Account::DebitTypes->find_or_create( |
790 |
{ |
791 |
{ |
791 |
code => 'Copie', |
792 |
code => 'Copie', |
792 |
description => 'Fee for copie', |
793 |
description => 'Fee for copie', |
Lines 798-804
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
798 |
borrowernumber => $patron->borrowernumber, |
799 |
borrowernumber => $patron->borrowernumber, |
799 |
date => $today, |
800 |
date => $today, |
800 |
description => 'a Manual invoice fee', |
801 |
description => 'a Manual invoice fee', |
801 |
debit_type => 'Copie', |
802 |
debit_type_code => 'Copie', |
802 |
amountoutstanding => $manual, |
803 |
amountoutstanding => $manual, |
803 |
interface => 'commandline' |
804 |
interface => 'commandline' |
804 |
} |
805 |
} |