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