Lines 32-37
use Koha::Notice::Messages;
Link Here
|
32 |
use Koha::Notice::Templates; |
32 |
use Koha::Notice::Templates; |
33 |
use Koha::DateUtils qw( dt_from_string ); |
33 |
use Koha::DateUtils qw( dt_from_string ); |
34 |
|
34 |
|
|
|
35 |
use C4::Circulation qw( MarkIssueReturned ); |
36 |
|
35 |
BEGIN { |
37 |
BEGIN { |
36 |
use_ok('C4::Accounts'); |
38 |
use_ok('C4::Accounts'); |
37 |
use_ok('Koha::Object'); |
39 |
use_ok('Koha::Object'); |
Lines 569-580
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
569 |
my $cli_issue_id_2 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2 } })->{issue_id}; |
571 |
my $cli_issue_id_2 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2 } })->{issue_id}; |
570 |
my $cli_issue_id_3 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3 } })->{issue_id}; |
572 |
my $cli_issue_id_3 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber3 } })->{issue_id}; |
571 |
my $cli_issue_id_4 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4 } })->{issue_id}; |
573 |
my $cli_issue_id_4 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4 } })->{issue_id}; |
|
|
574 |
my $cli_issue_id_4X = undef; |
572 |
|
575 |
|
573 |
my $lostfine; |
576 |
my $lostfine; |
574 |
my $procfee; |
577 |
my $procfee; |
575 |
|
578 |
|
576 |
subtest "fee application tests" => sub { |
579 |
subtest "fee application tests" => sub { |
577 |
plan tests => 40; |
580 |
plan tests => 44; |
578 |
|
581 |
|
579 |
t::lib::Mocks::mock_preference('item-level_itypes', '1'); |
582 |
t::lib::Mocks::mock_preference('item-level_itypes', '1'); |
580 |
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '0'); |
583 |
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '0'); |
Lines 688-695
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
688 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and default set"); |
691 |
is( $lostfine->amount, "6.120000", "Lost fine equals replacementcost when pref on and default set"); |
689 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
692 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
690 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
693 |
is( $procfee->issue_id, $cli_issue_id_4, "Processing fee issue id is correct" ); |
691 |
$lostfine->delete(); |
694 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, 6.12, "Perdedor"); |
692 |
$procfee->delete(); |
695 |
my $lostfines = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
|
|
696 |
my $procfees = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
697 |
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 |
MarkIssueReturned($cli_borrowernumber, $cli_itemnumber4); |
700 |
$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 |
$lostfines = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
703 |
$procfees = Koha::Account::Lines->search({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => '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( $procfees->count == 2, "Processing fee can be charged twice for the same item if they are distinct issue_id's"); |
706 |
$lostfines->delete(); |
707 |
$procfees->delete(); |
693 |
}; |
708 |
}; |
694 |
|
709 |
|
695 |
subtest "basic fields tests" => sub { |
710 |
subtest "basic fields tests" => sub { |
Lines 702-708
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
702 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
717 |
$lostfine = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'LOST' }); |
703 |
ok($lostfine, "Lost fine created"); |
718 |
ok($lostfine, "Lost fine created"); |
704 |
is($lostfine->manager_id, $staff_id, "Lost fine manager_id set correctly"); |
719 |
is($lostfine->manager_id, $staff_id, "Lost fine manager_id set correctly"); |
705 |
is($lostfine->issue_id, $cli_issue_id_4, "Lost fine issue_id set correctly"); |
720 |
is($lostfine->issue_id, $cli_issue_id_4X, "Lost fine issue_id set correctly"); |
706 |
is($lostfine->description, "Perdedor", "Lost fine issue_id set correctly"); |
721 |
is($lostfine->description, "Perdedor", "Lost fine issue_id set correctly"); |
707 |
is($lostfine->note, '', "Lost fine does not contain a note"); |
722 |
is($lostfine->note, '', "Lost fine does not contain a note"); |
708 |
is($lostfine->branchcode, $branchcode, "Lost fine branchcode set correctly"); |
723 |
is($lostfine->branchcode, $branchcode, "Lost fine branchcode set correctly"); |
Lines 711-717
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
711 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
726 |
$procfee = Koha::Account::Lines->find({ borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber4, accounttype => 'PF' }); |
712 |
ok($procfee, "Processing fee created"); |
727 |
ok($procfee, "Processing fee created"); |
713 |
is($procfee->manager_id, $staff_id, "Processing fee manager_id set correctly"); |
728 |
is($procfee->manager_id, $staff_id, "Processing fee manager_id set correctly"); |
714 |
is($procfee->issue_id, $cli_issue_id_4, "Processing fee issue_id set correctly"); |
729 |
is($procfee->issue_id, $cli_issue_id_4X, "Processing fee issue_id set correctly"); |
715 |
is($procfee->description, "Perdedor", "Processing fee issue_id set correctly"); |
730 |
is($procfee->description, "Perdedor", "Processing fee issue_id set correctly"); |
716 |
is($procfee->note, C4::Context->preference("ProcessingFeeNote"), "Processing fee contains note matching ProcessingFeeNote"); |
731 |
is($procfee->note, C4::Context->preference("ProcessingFeeNote"), "Processing fee contains note matching ProcessingFeeNote"); |
717 |
is($procfee->branchcode, $branchcode, "Processing fee branchcode set correctly"); |
732 |
is($procfee->branchcode, $branchcode, "Processing fee branchcode set correctly"); |
718 |
- |
|
|