View | Details | Raw Unified | Return to bug 27971
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Account/Line.t (-12 / +40 lines)
Lines 714-720 subtest 'credits() and debits() tests' => sub { Link Here
714
714
715
subtest "void() tests" => sub {
715
subtest "void() tests" => sub {
716
716
717
    plan tests => 16;
717
    plan tests => 23;
718
718
719
    $schema->storage->txn_begin;
719
    $schema->storage->txn_begin;
720
720
Lines 772-780 subtest "void() tests" => sub { Link Here
772
    is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' );
772
    is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' );
773
    is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' );
773
    is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' );
774
774
775
    my $ret = $account_payment->void({ interface => 'test' });
775
    throws_ok {
776
        $line1->void( { interface => 'test' } );
777
    }
778
    'Koha::Exceptions::Account::IsNotCredit',
779
      '->void() can only be used with credits';
780
781
    throws_ok {
782
        $account_payment->void();
783
    }
784
    'Koha::Exceptions::MissingParameter',
785
      "->void() requires the `interface` parameter is passed";
786
787
    throws_ok {
788
        $account_payment->void( { interface => 'intranet' } );
789
    }
790
    'Koha::Exceptions::MissingParameter',
791
      "->void() requires the `staff_id` parameter is passed when `interface` equals 'intranet'";
792
    throws_ok {
793
        $account_payment->void( { interface => 'intranet', staff_id => $borrower->borrowernumber } );
794
    }
795
    'Koha::Exceptions::MissingParameter',
796
      "->void() requires the `branch` parameter is passed when `interface` equals 'intranet'";
797
798
    my $void = $account_payment->void({ interface => 'test' });
776
799
777
    is( ref($ret), 'Koha::Account::Line', 'Void returns the account line' );
800
    is( ref($void), 'Koha::Account::Line', 'Void returns the account line' );
801
    is( $void->debit_type_code, 'VOID', 'Void returns the VOID account line' );
802
    is( $void->manager_id, undef, 'Void proceeds without manager_id OK if interface is not "intranet"' );
803
    is( $void->branchcode, undef, 'Void proceeds without branchcode OK if interface is not "intranet"' );
778
    is( $account->balance(), 30, "Account balance is again 30" );
804
    is( $account->balance(), 30, "Account balance is again 30" );
779
805
780
    $account_payment->_result->discard_changes();
806
    $account_payment->_result->discard_changes();
Lines 783-801 subtest "void() tests" => sub { Link Here
783
809
784
    is( $account_payment->credit_type_code, 'PAYMENT', 'Voided payment credit_type_code is still PAYMENT' );
810
    is( $account_payment->credit_type_code, 'PAYMENT', 'Voided payment credit_type_code is still PAYMENT' );
785
    is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
811
    is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
786
    is( $account_payment->amount+0, -30, 'Voided payment amount is -30' );
812
    is( $account_payment->amount+0, -30, 'Voided payment amount is still -30' );
787
    is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );
813
    is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );
788
814
789
    is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' );
815
    is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' );
790
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
816
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
791
817
792
    # Accountlines that are not credits should be un-voidable
818
    my $credit2 = $account->add_credit( { interface => 'test', amount => 10 } );
793
    my $line1_pre = $line1->unblessed();
819
    $void = $credit2->void(
794
    $ret = $line1->void({ interface => 'test' });
820
        {
795
    $line1->_result->discard_changes();
821
            interface => 'intranet',
796
    my $line1_post = $line1->unblessed();
822
            staff_id  => $borrower->borrowernumber,
797
    is( $ret, undef, 'Attempted void on non-credit returns undef' );
823
            branch    => $branchcode
798
    is_deeply( $line1_pre, $line1_post, 'Non-credit account line cannot be voided' );
824
        }
825
    );
826
    is( $void->manager_id, $borrower->borrowernumber, "->void stores the manager_id when it's passed");
827
    is( $void->branchcode, $branchcode, "->void stores the branchcode when it's passed");
799
828
800
    $schema->storage->txn_rollback;
829
    $schema->storage->txn_rollback;
801
};
830
};
802
- 

Return to bug 27971