|
Lines 557-566
subtest 'store' => sub {
Link Here
|
| 557 |
}; |
557 |
}; |
| 558 |
|
558 |
|
| 559 |
subtest |
559 |
subtest |
| 560 |
'Test with partial payement and write off, and remaining debt' => |
560 |
'Test with partial payment and write off, and remaining debt' => |
| 561 |
sub { |
561 |
sub { |
| 562 |
|
562 |
|
| 563 |
plan tests => 17; |
563 |
plan tests => 19; |
|
|
564 |
|
| 565 |
t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 0 ); |
| 564 |
|
566 |
|
| 565 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
567 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 566 |
my $item = $builder->build_sample_item( |
568 |
my $item = $builder->build_sample_item( |
|
Lines 615-625
subtest 'store' => sub {
Link Here
|
| 615 |
is( |
617 |
is( |
| 616 |
$account->balance, |
618 |
$account->balance, |
| 617 |
$processfee_amount + $replacement_amount, |
619 |
$processfee_amount + $replacement_amount, |
| 618 |
'Balance is PROCESSING + L' |
620 |
'Balance is PROCESSING + LOST' |
| 619 |
); |
621 |
); |
| 620 |
|
622 |
|
| 621 |
# Partially pay fee |
623 |
# Partially pay fee (99 - 27 = 72) |
| 622 |
my $payment_amount = 27; |
624 |
my $payment_amount = 24; |
| 623 |
my $payment = $account->add_credit( |
625 |
my $payment = $account->add_credit( |
| 624 |
{ |
626 |
{ |
| 625 |
amount => $payment_amount, |
627 |
amount => $payment_amount, |
|
Lines 630-637
subtest 'store' => sub {
Link Here
|
| 630 |
|
632 |
|
| 631 |
$payment->apply( { debits => [$lost_fee_line] } ); |
633 |
$payment->apply( { debits => [$lost_fee_line] } ); |
| 632 |
|
634 |
|
| 633 |
# Partially write off fee |
635 |
# Partially write off fee (72 - 20 = 52) |
| 634 |
my $write_off_amount = 25; |
636 |
my $write_off_amount = 20; |
| 635 |
my $write_off = $account->add_credit( |
637 |
my $write_off = $account->add_credit( |
| 636 |
{ |
638 |
{ |
| 637 |
amount => $write_off_amount, |
639 |
amount => $write_off_amount, |
|
Lines 641-658
subtest 'store' => sub {
Link Here
|
| 641 |
); |
643 |
); |
| 642 |
$write_off->apply( { debits => [$lost_fee_line] } ); |
644 |
$write_off->apply( { debits => [$lost_fee_line] } ); |
| 643 |
|
645 |
|
|
|
646 |
|
| 647 |
my $payment_amount_2 = 3; |
| 648 |
my $payment_2 = $account->add_credit( |
| 649 |
{ |
| 650 |
amount => $payment_amount_2, |
| 651 |
type => 'PAYMENT', |
| 652 |
interface => 'test', |
| 653 |
} |
| 654 |
); |
| 655 |
|
| 656 |
$payment_2->apply( |
| 657 |
{ debits => [$lost_fee_line] } ); |
| 658 |
|
| 659 |
# Partially write off fee (52 - 5 = 47) |
| 660 |
my $write_off_amount_2 = 5; |
| 661 |
my $write_off_2 = $account->add_credit( |
| 662 |
{ |
| 663 |
amount => $write_off_amount_2, |
| 664 |
type => 'WRITEOFF', |
| 665 |
interface => 'test', |
| 666 |
} |
| 667 |
); |
| 668 |
|
| 669 |
$write_off_2->apply( |
| 670 |
{ debits => [$lost_fee_line] } ); |
| 671 |
|
| 672 |
is( |
| 673 |
$account->balance, |
| 674 |
$processfee_amount + |
| 675 |
$replacement_amount - |
| 676 |
$payment_amount - |
| 677 |
$write_off_amount - |
| 678 |
$payment_amount_2 - |
| 679 |
$write_off_amount_2, |
| 680 |
'Balance is PROCESSING + LOST - PAYMENT 1 - WRITEOFF - PAYMENT 2 - WRITEOFF 2' |
| 681 |
); |
| 682 |
|
| 683 |
# VOID payment_2 and writeoff_2 |
| 684 |
$payment_2->void({ interface => 'test' }); |
| 685 |
$write_off_2->void({ interface => 'test' }); |
| 686 |
|
| 644 |
is( |
687 |
is( |
| 645 |
$account->balance, |
688 |
$account->balance, |
| 646 |
$processfee_amount + |
689 |
$processfee_amount + |
| 647 |
$replacement_amount - |
690 |
$replacement_amount - |
| 648 |
$payment_amount - |
691 |
$payment_amount - |
| 649 |
$write_off_amount, |
692 |
$write_off_amount, |
| 650 |
'Payment and write off applied' |
693 |
'Balance is PROCESSING + LOST - PAYMENT 1 - WRITEOFF (PAYMENT 2 and WRITEOFF 2 VOIDED)' |
| 651 |
); |
694 |
); |
| 652 |
|
695 |
|
| 653 |
# Store the amountoutstanding value |
696 |
# Store the amountoutstanding value |
| 654 |
$lost_fee_line->discard_changes; |
697 |
$lost_fee_line->discard_changes; |
| 655 |
my $outstanding = $lost_fee_line->amountoutstanding; |
698 |
my $outstanding = $lost_fee_line->amountoutstanding; |
|
|
699 |
is( |
| 700 |
$outstanding + 0, |
| 701 |
$replacement_amount - $payment_amount - $write_off_amount, |
| 702 |
"Lost Fee Outstanding is LOST - PAYMENT 1 - WRITEOFF" |
| 703 |
); |
| 656 |
|
704 |
|
| 657 |
# Simulate item marked as found |
705 |
# Simulate item marked as found |
| 658 |
$item->itemlost(0)->store; |
706 |
$item->itemlost(0)->store; |
|
Lines 685-691
subtest 'store' => sub {
Link Here
|
| 685 |
is( |
733 |
is( |
| 686 |
$credit_return->amount + 0, |
734 |
$credit_return->amount + 0, |
| 687 |
( $payment_amount + $outstanding ) * -1, |
735 |
( $payment_amount + $outstanding ) * -1, |
| 688 |
'The account line of type LOST_FOUND has an amount equal to the payment + outstanding' |
736 |
'The account line of type LOST_FOUND has an amount equal to the payment 1 + outstanding' |
| 689 |
); |
737 |
); |
| 690 |
is( |
738 |
is( |
| 691 |
$credit_return->amountoutstanding + 0, |
739 |
$credit_return->amountoutstanding + 0, |
| 692 |
- |
|
|