Lines 18-24
Link Here
|
18 |
|
18 |
|
19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
20 |
|
20 |
|
21 |
use Test::More tests => 28; |
21 |
use Test::More tests => 41; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
Lines 69-74
$context->mock( 'userenv', sub {
Link Here
|
69 |
branch => $branchcode, |
69 |
branch => $branchcode, |
70 |
}; |
70 |
}; |
71 |
}); |
71 |
}); |
|
|
72 |
my $userenv_branchcode = $branchcode; |
73 |
|
74 |
# Test chargelostitem |
75 |
my $itemtype = $builder->build( { source => 'Itemtype' } ); |
76 |
my $item = $builder->build( { source => 'Item', value => { itype => $itemtype->{itemtype} } } ); |
77 |
my $patron = $builder->build( { source => 'Borrower' } ); |
78 |
my $amount = '5.000000'; |
79 |
my $description = "Test fee!"; |
80 |
chargelostitem( $patron->{borrowernumber}, $item->{itemnumber}, $amount, $description ); |
81 |
my ($accountline) = Koha::Account::Lines->search( |
82 |
{ |
83 |
borrowernumber => $patron->{borrowernumber} |
84 |
} |
85 |
); |
86 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for chargelostitem' ); |
87 |
is( $accountline->description, $description, 'Accountline description set correctly for chargelostitem' ); |
88 |
is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for chargelostitem' ); |
89 |
$dbh->do(q|DELETE FROM accountlines|); |
90 |
|
91 |
# Test manualinvoice, reuse some of the vars from testing chargelostitem |
92 |
my $type = 'L'; |
93 |
my $note = 'Test note!'; |
94 |
manualinvoice( $patron->{borrowernumber}, $item->{itemnumber}, $description, $type, $amount, $note ); |
95 |
($accountline) = Koha::Account::Lines->search( |
96 |
{ |
97 |
borrowernumber => $patron->{borrowernumber} |
98 |
} |
99 |
); |
100 |
is( $accountline->accounttype, $type, 'Accountline type set correctly for manualinvoice' ); |
101 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for manualinvoice' ); |
102 |
ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); |
103 |
is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); |
104 |
is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for manualinvoice' ); |
105 |
|
106 |
# Test _FixAccountForLostAndReturned, use the accountline from the manualinvoice to test |
107 |
C4::Circulation::_FixAccountForLostAndReturned( $item->{itemnumber} ); |
108 |
my ( $accountline_fee, $accountline_payment ) = Koha::Account::Lines->search( |
109 |
{ |
110 |
borrowernumber => $patron->{borrowernumber} |
111 |
} |
112 |
); |
113 |
is( $accountline_fee->accounttype, 'LR', 'Lost item fee account type updated to LR' ); |
114 |
is( $accountline_fee->amountoutstanding, '0.000000', 'Lost item fee amount outstanding updated to 0' ); |
115 |
is( $accountline_payment->accounttype, 'CR', 'Lost item fee account type is CR' ); |
116 |
is( $accountline_payment->amount, "-$amount", 'Lost item refund amount is correct' ); |
117 |
is( $accountline_payment->branchcode, $branchcode, 'Lost item refund branchcode is set correctly' ); |
118 |
$dbh->do(q|DELETE FROM accountlines|); |
72 |
|
119 |
|
73 |
# Testing purge_zero_balance_fees |
120 |
# Testing purge_zero_balance_fees |
74 |
|
121 |
|
Lines 134-140
$dbh->do(q|DELETE FROM accountlines|);
Link Here
|
134 |
|
181 |
|
135 |
subtest "Koha::Account::pay tests" => sub { |
182 |
subtest "Koha::Account::pay tests" => sub { |
136 |
|
183 |
|
137 |
plan tests => 13; |
184 |
plan tests => 14; |
138 |
|
185 |
|
139 |
# Create a borrower |
186 |
# Create a borrower |
140 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
187 |
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" ); |
304 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
258 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
305 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
259 |
is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); |
306 |
is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); |
|
|
307 |
is( $payment->branchcode, $userenv_branchcode, 'Branchcode set correctly' ); |
260 |
}; |
308 |
}; |
261 |
|
309 |
|
262 |
subtest "Koha::Account::pay particular line tests" => sub { |
310 |
subtest "Koha::Account::pay particular line tests" => sub { |
263 |
- |
|
|