Lines 444-453
subtest 'store' => sub {
Link Here
|
444 |
}; |
444 |
}; |
445 |
|
445 |
|
446 |
subtest |
446 |
subtest |
447 |
'Test with partial payement and write off, and remaining debt' => |
447 |
'Test with partial payment and write off, and remaining debt' => |
448 |
sub { |
448 |
sub { |
449 |
|
449 |
|
450 |
plan tests => 17; |
450 |
plan tests => 19; |
|
|
451 |
|
452 |
t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 0 ); |
451 |
|
453 |
|
452 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
454 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
453 |
my $item = $builder->build_sample_item( |
455 |
my $item = $builder->build_sample_item( |
Lines 502-512
subtest 'store' => sub {
Link Here
|
502 |
is( |
504 |
is( |
503 |
$account->balance, |
505 |
$account->balance, |
504 |
$processfee_amount + $replacement_amount, |
506 |
$processfee_amount + $replacement_amount, |
505 |
'Balance is PROCESSING + L' |
507 |
'Balance is PROCESSING + LOST' |
506 |
); |
508 |
); |
507 |
|
509 |
|
508 |
# Partially pay fee |
510 |
# Partially pay fee (99 - 27 = 72) |
509 |
my $payment_amount = 27; |
511 |
my $payment_amount = 24; |
510 |
my $payment = $account->add_credit( |
512 |
my $payment = $account->add_credit( |
511 |
{ |
513 |
{ |
512 |
amount => $payment_amount, |
514 |
amount => $payment_amount, |
Lines 518-525
subtest 'store' => sub {
Link Here
|
518 |
$payment->apply( |
520 |
$payment->apply( |
519 |
{ debits => [$lost_fee_line], offset_type => 'Payment' } ); |
521 |
{ debits => [$lost_fee_line], offset_type => 'Payment' } ); |
520 |
|
522 |
|
521 |
# Partially write off fee |
523 |
# Partially write off fee (72 - 20 = 52) |
522 |
my $write_off_amount = 25; |
524 |
my $write_off_amount = 20; |
523 |
my $write_off = $account->add_credit( |
525 |
my $write_off = $account->add_credit( |
524 |
{ |
526 |
{ |
525 |
amount => $write_off_amount, |
527 |
amount => $write_off_amount, |
Lines 527-547
subtest 'store' => sub {
Link Here
|
527 |
interface => 'test', |
529 |
interface => 'test', |
528 |
} |
530 |
} |
529 |
); |
531 |
); |
|
|
532 |
|
530 |
$write_off->apply( |
533 |
$write_off->apply( |
531 |
{ debits => [$lost_fee_line], offset_type => 'Writeoff' } ); |
534 |
{ debits => [$lost_fee_line], offset_type => 'Writeoff' } ); |
532 |
|
535 |
|
|
|
536 |
my $payment_amount_2 = 3; |
537 |
my $payment_2 = $account->add_credit( |
538 |
{ |
539 |
amount => $payment_amount_2, |
540 |
type => 'PAYMENT', |
541 |
interface => 'test', |
542 |
} |
543 |
); |
544 |
|
545 |
$payment_2->apply( |
546 |
{ debits => [$lost_fee_line], offset_type => 'Payment' } ); |
547 |
|
548 |
# Partially write off fee (52 - 5 = 47) |
549 |
my $write_off_amount_2 = 5; |
550 |
my $write_off_2 = $account->add_credit( |
551 |
{ |
552 |
amount => $write_off_amount_2, |
553 |
type => 'WRITEOFF', |
554 |
interface => 'test', |
555 |
} |
556 |
); |
557 |
|
558 |
$write_off_2->apply( |
559 |
{ debits => [$lost_fee_line], offset_type => 'Writeoff' } ); |
560 |
|
561 |
is( |
562 |
$account->balance, |
563 |
$processfee_amount + |
564 |
$replacement_amount - |
565 |
$payment_amount - |
566 |
$write_off_amount - |
567 |
$payment_amount_2 - |
568 |
$write_off_amount_2, |
569 |
'Balance is PROCESSING + LOST - PAYMENT 1 - WRITEOFF - PAYMENT 2 - WRITEOFF 2' |
570 |
); |
571 |
|
572 |
# VOID payment_2 and writeoff_2 |
573 |
$payment_2->void({ interface => 'test' }); |
574 |
$write_off_2->void({ interface => 'test' }); |
575 |
|
533 |
is( |
576 |
is( |
534 |
$account->balance, |
577 |
$account->balance, |
535 |
$processfee_amount + |
578 |
$processfee_amount + |
536 |
$replacement_amount - |
579 |
$replacement_amount - |
537 |
$payment_amount - |
580 |
$payment_amount - |
538 |
$write_off_amount, |
581 |
$write_off_amount, |
539 |
'Payment and write off applied' |
582 |
'Balance is PROCESSING + LOST - PAYMENT 1 - WRITEOFF (PAYMENT 2 and WRITEOFF 2 VOIDED)' |
540 |
); |
583 |
); |
541 |
|
584 |
|
542 |
# Store the amountoutstanding value |
585 |
# Store the amountoutstanding value |
543 |
$lost_fee_line->discard_changes; |
586 |
$lost_fee_line->discard_changes; |
544 |
my $outstanding = $lost_fee_line->amountoutstanding; |
587 |
my $outstanding = $lost_fee_line->amountoutstanding; |
|
|
588 |
is( |
589 |
$outstanding + 0, |
590 |
$replacement_amount - $payment_amount - $write_off_amount, |
591 |
"Lost Fee Outstanding is LOST - PAYMENT 1 - WRITEOFF" |
592 |
); |
545 |
|
593 |
|
546 |
# Simulate item marked as found |
594 |
# Simulate item marked as found |
547 |
$item->itemlost(0)->store; |
595 |
$item->itemlost(0)->store; |
Lines 574-580
subtest 'store' => sub {
Link Here
|
574 |
is( |
622 |
is( |
575 |
$credit_return->amount + 0, |
623 |
$credit_return->amount + 0, |
576 |
( $payment_amount + $outstanding ) * -1, |
624 |
( $payment_amount + $outstanding ) * -1, |
577 |
'The account line of type LOST_FOUND has an amount equal to the payment + outstanding' |
625 |
'The account line of type LOST_FOUND has an amount equal to the payment 1 + outstanding' |
578 |
); |
626 |
); |
579 |
is( |
627 |
is( |
580 |
$credit_return->amountoutstanding + 0, |
628 |
$credit_return->amountoutstanding + 0, |
581 |
- |
|
|