Lines 18-24
Link Here
|
18 |
|
18 |
|
19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
20 |
|
20 |
|
21 |
use Test::More tests => 23; |
21 |
use Test::More tests => 36; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
Lines 72-77
$context->mock( 'userenv', sub {
Link Here
|
72 |
branch => $branchcode, |
72 |
branch => $branchcode, |
73 |
}; |
73 |
}; |
74 |
}); |
74 |
}); |
|
|
75 |
my $userenv_branchcode = $branchcode; |
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|); |
75 |
|
121 |
|
76 |
# Testing purge_zero_balance_fees |
122 |
# Testing purge_zero_balance_fees |
77 |
|
123 |
|
Lines 137-143
$dbh->do(q|DELETE FROM accountlines|);
Link Here
|
137 |
|
183 |
|
138 |
subtest "Koha::Account::pay tests" => sub { |
184 |
subtest "Koha::Account::pay tests" => sub { |
139 |
|
185 |
|
140 |
plan tests => 12; |
186 |
plan tests => 13; |
141 |
|
187 |
|
142 |
# Create a borrower |
188 |
# Create a borrower |
143 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
189 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
Lines 257-262
subtest "Koha::Account::pay tests" => sub {
Link Here
|
257 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
303 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
258 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
304 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
259 |
is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); |
305 |
is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); |
|
|
306 |
is( $payment->branchcode, $userenv_branchcode, 'Branchcode set correctly' ); |
260 |
}; |
307 |
}; |
261 |
|
308 |
|
262 |
subtest "Koha::Account::pay particular line tests" => sub { |
309 |
subtest "Koha::Account::pay particular line tests" => sub { |
263 |
- |
|
|