|
Lines 18-24
Link Here
|
| 18 |
|
18 |
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 21; |
21 |
use Test::More tests => 22; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
|
Lines 303-308
subtest "Koha::Account::pay particular line tests" => sub {
Link Here
|
| 303 |
is( $line4->amountoutstanding, "4.000000", "Line 4 was not paid" ); |
303 |
is( $line4->amountoutstanding, "4.000000", "Line 4 was not paid" ); |
| 304 |
}; |
304 |
}; |
| 305 |
|
305 |
|
|
|
306 |
subtest "Koha::Account::pay writeoff tests" => sub { |
| 307 |
|
| 308 |
plan tests => 5; |
| 309 |
|
| 310 |
# Create a borrower |
| 311 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
| 312 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 313 |
|
| 314 |
my $borrower = Koha::Patron->new( { |
| 315 |
cardnumber => 'chelseahall', |
| 316 |
surname => 'Hall', |
| 317 |
firstname => 'Chelsea', |
| 318 |
} ); |
| 319 |
$borrower->categorycode( $categorycode ); |
| 320 |
$borrower->branchcode( $branchcode ); |
| 321 |
$borrower->store; |
| 322 |
|
| 323 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
| 324 |
|
| 325 |
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 42 })->store(); |
| 326 |
|
| 327 |
is( $account->balance(), "42.000000", "Account balance is 42" ); |
| 328 |
|
| 329 |
my $id = $account->pay( |
| 330 |
{ |
| 331 |
lines => [$line], |
| 332 |
amount => 42, |
| 333 |
type => 'writeoff', |
| 334 |
} |
| 335 |
); |
| 336 |
|
| 337 |
$line->_result->discard_changes(); |
| 338 |
|
| 339 |
is( $line->amountoutstanding, "0.000000", "Line was written off" ); |
| 340 |
|
| 341 |
my $writeoff = Koha::Account::Lines->find( $id ); |
| 342 |
|
| 343 |
is( $writeoff->accounttype, 'W', 'Type is correct' ); |
| 344 |
is( $writeoff->description, 'Writeoff', 'Description is correct' ); |
| 345 |
is( $writeoff->amount, '-42.000000', 'Amount is correct' ); |
| 346 |
}; |
| 347 |
|
| 306 |
subtest "More Koha::Account::pay tests" => sub { |
348 |
subtest "More Koha::Account::pay tests" => sub { |
| 307 |
|
349 |
|
| 308 |
plan tests => 6; |
350 |
plan tests => 6; |
| 309 |
- |
|
|