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

(-)a/t/db_dependent/Koha/Account/Line.t (-12 / +40 lines)
Lines 686-692 subtest 'credits() and debits() tests' => sub { Link Here
686
686
687
subtest "void() tests" => sub {
687
subtest "void() tests" => sub {
688
688
689
    plan tests => 16;
689
    plan tests => 23;
690
690
691
    $schema->storage->txn_begin;
691
    $schema->storage->txn_begin;
692
692
Lines 744-752 subtest "void() tests" => sub { Link Here
744
    is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' );
744
    is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' );
745
    is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' );
745
    is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' );
746
746
747
    my $ret = $account_payment->void({ interface => 'test' });
747
    throws_ok {
748
        $line1->void( { interface => 'test' } );
749
    }
750
    'Koha::Exceptions::Account::IsNotCredit',
751
      '->void() can only be used with credits';
752
753
    throws_ok {
754
        $account_payment->void();
755
    }
756
    'Koha::Exceptions::MissingParameter',
757
      "->void() requires the `interface` parameter is passed";
758
759
    throws_ok {
760
        $account_payment->void( { interface => 'intranet' } );
761
    }
762
    'Koha::Exceptions::MissingParameter',
763
      "->void() requires the `staff_id` parameter is passed when `interface` equals 'intranet'";
764
    throws_ok {
765
        $account_payment->void( { interface => 'intranet', staff_id => $borrower->borrowernumber } );
766
    }
767
    'Koha::Exceptions::MissingParameter',
768
      "->void() requires the `branch` parameter is passed when `interface` equals 'intranet'";
769
770
    my $void = $account_payment->void({ interface => 'test' });
748
771
749
    is( ref($ret), 'Koha::Account::Line', 'Void returns the account line' );
772
    is( ref($void), 'Koha::Account::Line', 'Void returns the account line' );
773
    is( $void->debit_type_code, 'VOID', 'Void returns the VOID account line' );
774
    is( $void->manager_id, undef, 'Void proceeds without manager_id OK if interface is not "intranet"' );
775
    is( $void->branchcode, undef, 'Void proceeds without branchcode OK if interface is not "intranet"' );
750
    is( $account->balance(), 30, "Account balance is again 30" );
776
    is( $account->balance(), 30, "Account balance is again 30" );
751
777
752
    $account_payment->_result->discard_changes();
778
    $account_payment->_result->discard_changes();
Lines 755-773 subtest "void() tests" => sub { Link Here
755
781
756
    is( $account_payment->credit_type_code, 'PAYMENT', 'Voided payment credit_type_code is still PAYMENT' );
782
    is( $account_payment->credit_type_code, 'PAYMENT', 'Voided payment credit_type_code is still PAYMENT' );
757
    is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
783
    is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
758
    is( $account_payment->amount+0, -30, 'Voided payment amount is -30' );
784
    is( $account_payment->amount+0, -30, 'Voided payment amount is still -30' );
759
    is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );
785
    is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );
760
786
761
    is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' );
787
    is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' );
762
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
788
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
763
789
764
    # Accountlines that are not credits should be un-voidable
790
    my $credit2 = $account->add_credit( { interface => 'test', amount => 10 } );
765
    my $line1_pre = $line1->unblessed();
791
    $void = $credit2->void(
766
    $ret = $line1->void({ interface => 'test' });
792
        {
767
    $line1->_result->discard_changes();
793
            interface => 'intranet',
768
    my $line1_post = $line1->unblessed();
794
            staff_id  => $borrower->borrowernumber,
769
    is( $ret, undef, 'Attempted void on non-credit returns undef' );
795
            branch    => $branchcode
770
    is_deeply( $line1_pre, $line1_post, 'Non-credit account line cannot be voided' );
796
        }
797
    );
798
    is( $void->manager_id, $borrower->borrowernumber, "->void stores the manager_id when it's passed");
799
    is( $void->branchcode, $branchcode, "->void stores the branchcode when it's passed");
771
800
772
    $schema->storage->txn_rollback;
801
    $schema->storage->txn_rollback;
773
};
802
};
774
- 

Return to bug 27971