Lines 18-33
Link Here
|
18 |
|
18 |
|
19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
20 |
|
20 |
|
21 |
use Test::More tests => 19; |
21 |
use Test::More tests => 33; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
26 |
|
26 |
|
|
|
27 |
use C4::Circulation; |
28 |
|
27 |
BEGIN { |
29 |
BEGIN { |
28 |
use_ok('C4::Accounts'); |
30 |
use_ok('C4::Accounts'); |
29 |
use_ok('Koha::Object'); |
31 |
use_ok('Koha::Object'); |
30 |
use_ok('Koha::Patron'); |
32 |
use_ok('Koha::Patron'); |
|
|
33 |
use_ok('Koha::Account::Lines'); |
31 |
use_ok('Data::Dumper'); |
34 |
use_ok('Data::Dumper'); |
32 |
} |
35 |
} |
33 |
|
36 |
|
Lines 60-66
$dbh->do(q|DELETE FROM issues|);
Link Here
|
60 |
$dbh->do(q|DELETE FROM borrowers|); |
63 |
$dbh->do(q|DELETE FROM borrowers|); |
61 |
|
64 |
|
62 |
my $branchcode = $library->{branchcode}; |
65 |
my $branchcode = $library->{branchcode}; |
63 |
my $borrower_number; |
|
|
64 |
|
66 |
|
65 |
my $context = new Test::MockModule('C4::Context'); |
67 |
my $context = new Test::MockModule('C4::Context'); |
66 |
$context->mock( 'userenv', sub { |
68 |
$context->mock( 'userenv', sub { |
Lines 71-76
$context->mock( 'userenv', sub {
Link Here
|
71 |
}; |
73 |
}; |
72 |
}); |
74 |
}); |
73 |
|
75 |
|
|
|
76 |
|
77 |
# Test chargelostitem |
78 |
my $item = $builder->build( { source => 'Item' } ); |
79 |
my $patron = $builder->build( { source => 'Borrower' } ); |
80 |
my $amount = '5.000000'; |
81 |
my $description = "Test fee!"; |
82 |
chargelostitem( $patron->{borrowernumber}, $item->{itemnumber}, $amount, $description ); |
83 |
my ($accountline) = Koha::Account::Lines->search( |
84 |
{ |
85 |
borrowernumber => $patron->{borrowernumber} |
86 |
} |
87 |
); |
88 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for chargelostitem' ); |
89 |
is( $accountline->description, $description, 'Accountline description set correctly for chargelostitem' ); |
90 |
is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for chargelostitem' ); |
91 |
$dbh->do(q|DELETE FROM accountlines|); |
92 |
|
93 |
# Test manualinvoice, reuse some of the vars from testing chargelostitem |
94 |
my $type = 'L'; |
95 |
my $note = 'Test note!'; |
96 |
manualinvoice( $patron->{borrowernumber}, $item->{itemnumber}, $description, $type, $amount, $note ); |
97 |
($accountline) = Koha::Account::Lines->search( |
98 |
{ |
99 |
borrowernumber => $patron->{borrowernumber} |
100 |
} |
101 |
); |
102 |
is( $accountline->accounttype, $type, 'Accountline type set correctly for manualinvoice' ); |
103 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for manualinvoice' ); |
104 |
ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); |
105 |
is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); |
106 |
is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for manualinvoice' ); |
107 |
|
108 |
# Test _FixAccountForLostAndReturned, use the accountline from the manualinvoice to test |
109 |
C4::Circulation::_FixAccountForLostAndReturned( $item->{itemnumber} ); |
110 |
my ( $accountline_fee, $accountline_payment ) = Koha::Account::Lines->search( |
111 |
{ |
112 |
borrowernumber => $patron->{borrowernumber} |
113 |
} |
114 |
); |
115 |
is( $accountline_fee->accounttype, 'LR', 'Lost item fee account type updated to LR' ); |
116 |
is( $accountline_fee->amountoutstanding, '0.000000', 'Lost item fee amount outstanding updated to 0' ); |
117 |
is( $accountline_payment->accounttype, 'CR', 'Lost item fee account type is CR' ); |
118 |
is( $accountline_payment->amount, "-$amount", 'Lost item refund amount is correct' ); |
119 |
is( $accountline_payment->branchcode, $branchcode, 'Lost item refund branchcode is set correctly' ); |
120 |
$dbh->do(q|DELETE FROM accountlines|); |
121 |
|
74 |
# Testing purge_zero_balance_fees |
122 |
# Testing purge_zero_balance_fees |
75 |
|
123 |
|
76 |
# The 3rd value in the insert is 'days ago' -- |
124 |
# The 3rd value in the insert is 'days ago' -- |
77 |
- |
|
|