|
Lines 18-24
Link Here
|
| 18 |
|
18 |
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 24; |
21 |
use Test::More tests => 37; |
| 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 $itemtype = $builder->build( { source => 'Itemtype' } ); |
| 79 |
my $item = $builder->build( { source => 'Item', value => { itype => $itemtype->{itemtype} } } ); |
| 80 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 81 |
my $amount = '5.000000'; |
| 82 |
my $description = "Test fee!"; |
| 83 |
chargelostitem( $patron->{borrowernumber}, $item->{itemnumber}, $amount, $description ); |
| 84 |
my ($accountline) = Koha::Account::Lines->search( |
| 85 |
{ |
| 86 |
borrowernumber => $patron->{borrowernumber} |
| 87 |
} |
| 88 |
); |
| 89 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for chargelostitem' ); |
| 90 |
is( $accountline->description, $description, 'Accountline description set correctly for chargelostitem' ); |
| 91 |
is( $accountline->branchcode, $userenv_branchcode, 'Accountline branchcode set correctly for chargelostitem' ); |
| 92 |
$dbh->do(q|DELETE FROM accountlines|); |
| 93 |
|
| 94 |
# Test manualinvoice, reuse some of the vars from testing chargelostitem |
| 95 |
my $type = 'L'; |
| 96 |
my $note = 'Test note!'; |
| 97 |
manualinvoice( $patron->{borrowernumber}, $item->{itemnumber}, $description, $type, $amount, $note ); |
| 98 |
($accountline) = Koha::Account::Lines->search( |
| 99 |
{ |
| 100 |
borrowernumber => $patron->{borrowernumber} |
| 101 |
} |
| 102 |
); |
| 103 |
is( $accountline->accounttype, $type, 'Accountline type set correctly for manualinvoice' ); |
| 104 |
is( $accountline->amount, $amount, 'Accountline amount set correctly for manualinvoice' ); |
| 105 |
ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); |
| 106 |
is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); |
| 107 |
is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for manualinvoice' ); |
| 108 |
|
| 109 |
# Test _FixAccountForLostAndReturned, use the accountline from the manualinvoice to test |
| 110 |
C4::Circulation::_FixAccountForLostAndReturned( $item->{itemnumber} ); |
| 111 |
my ( $accountline_fee, $accountline_payment ) = Koha::Account::Lines->search( |
| 112 |
{ |
| 113 |
borrowernumber => $patron->{borrowernumber} |
| 114 |
} |
| 115 |
); |
| 116 |
is( $accountline_fee->accounttype, 'LR', 'Lost item fee account type updated to LR' ); |
| 117 |
is( $accountline_fee->amountoutstanding, '0.000000', 'Lost item fee amount outstanding updated to 0' ); |
| 118 |
is( $accountline_payment->accounttype, 'CR', 'Lost item fee account type is CR' ); |
| 119 |
is( $accountline_payment->amount, "-$amount", 'Lost item refund amount is correct' ); |
| 120 |
is( $accountline_payment->branchcode, $branchcode, 'Lost item refund branchcode is set correctly' ); |
| 121 |
$dbh->do(q|DELETE FROM accountlines|); |
| 75 |
|
122 |
|
| 76 |
# Testing purge_zero_balance_fees |
123 |
# Testing purge_zero_balance_fees |
| 77 |
|
124 |
|
|
Lines 137-143
$dbh->do(q|DELETE FROM accountlines|);
Link Here
|
| 137 |
|
184 |
|
| 138 |
subtest "Koha::Account::pay tests" => sub { |
185 |
subtest "Koha::Account::pay tests" => sub { |
| 139 |
|
186 |
|
| 140 |
plan tests => 12; |
187 |
plan tests => 13; |
| 141 |
|
188 |
|
| 142 |
# Create a borrower |
189 |
# Create a borrower |
| 143 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
190 |
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 |
- |
|
|