|
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 71-76
$context->mock( 'userenv', sub {
Link Here
|
| 71 |
branch => $branchcode, |
71 |
branch => $branchcode, |
| 72 |
}; |
72 |
}; |
| 73 |
}); |
73 |
}); |
|
|
74 |
my $userenv_branchcode = $branchcode; |
| 75 |
|
| 76 |
# Test chargelostitem |
| 77 |
my $itemtype = $builder->build( { source => 'Itemtype' } ); |
| 78 |
my $item = $builder->build( { source => 'Item', value => { itype => $itemtype->{itemtype} } } ); |
| 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|); |
| 74 |
|
121 |
|
| 75 |
# Testing purge_zero_balance_fees |
122 |
# Testing purge_zero_balance_fees |
| 76 |
|
123 |
|
|
Lines 136-142
$dbh->do(q|DELETE FROM accountlines|);
Link Here
|
| 136 |
|
183 |
|
| 137 |
subtest "Koha::Account::pay tests" => sub { |
184 |
subtest "Koha::Account::pay tests" => sub { |
| 138 |
|
185 |
|
| 139 |
plan tests => 13; |
186 |
plan tests => 14; |
| 140 |
|
187 |
|
| 141 |
# Create a borrower |
188 |
# Create a borrower |
| 142 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
189 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
|
Lines 259-264
subtest "Koha::Account::pay tests" => sub {
Link Here
|
| 259 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
306 |
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); |
| 260 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
307 |
$line3 = Koha::Account::Lines->find( $line3->id ); |
| 261 |
is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); |
308 |
is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); |
|
|
309 |
is( $payment->branchcode, $userenv_branchcode, 'Branchcode set correctly' ); |
| 262 |
}; |
310 |
}; |
| 263 |
|
311 |
|
| 264 |
subtest "Koha::Account::pay particular line tests" => sub { |
312 |
subtest "Koha::Account::pay particular line tests" => sub { |
| 265 |
- |
|
|