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

(-)a/t/db_dependent/Accounts.t (-8 / +49 lines)
Lines 18-24 Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
20
21
use Test::More tests => 26;
21
use Test::More tests => 27;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 846-852 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
846
846
847
subtest "Koha::Account::Line::void tests" => sub {
847
subtest "Koha::Account::Line::void tests" => sub {
848
848
849
    plan tests => 14;
849
    plan tests => 12;
850
850
851
    # Create a borrower
851
    # Create a borrower
852
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
852
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
Lines 877-887 subtest "Koha::Account::Line::void tests" => sub { Link Here
877
        }
877
        }
878
    );
878
    );
879
879
880
    # Test debit and credit methods fo Koha::Account::Offset
881
    my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } );
882
    is( $account_offset->debit->id, $line1->id, "Koha::Account::Offset->debit gets correct accountline" );
883
    is( $account_offset->credit->id, $id, "Koha::Account::Offset->credit gets correct accountline" );
884
885
    my $account_payment = Koha::Account::Lines->find( $id );
880
    my $account_payment = Koha::Account::Lines->find( $id );
886
881
887
    is( $account->balance(), 0, "Account balance is 0" );
882
    is( $account->balance(), 0, "Account balance is 0" );
Lines 907-910 subtest "Koha::Account::Line::void tests" => sub { Link Here
907
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
902
    is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' );
908
};
903
};
909
904
905
subtest "Koha::Account::Offset credit & debit tests" => sub {
906
907
    plan tests => 4;
908
909
    # Create a borrower
910
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
911
    my $branchcode   = $builder->build({ source => 'Branch' })->{ branchcode };
912
913
    my $borrower = Koha::Patron->new( {
914
        cardnumber => 'kyliehall',
915
        surname => 'Hall',
916
        firstname => 'Kylie',
917
    } );
918
    $borrower->categorycode( $categorycode );
919
    $borrower->branchcode( $branchcode );
920
    $borrower->store;
921
922
    my $account = Koha::Account->new({ patron_id => $borrower->id });
923
924
    my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10 })->store();
925
    my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20 })->store();
926
927
    my $id = $account->pay(
928
        {
929
            lines  => [$line1, $line2],
930
            amount => 30,
931
        }
932
    );
933
934
    # Test debit and credit methods for Koha::Account::Offset
935
    my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } );
936
    is( $account_offset->debit->id, $line1->id, "Koha::Account::Offset->debit gets correct accountline" );
937
    is( $account_offset->credit->id, $id, "Koha::Account::Offset->credit gets correct accountline" );
938
939
    $account_offset = Koha::Account::Offset->new(
940
        {
941
            credit_id => undef,
942
            debit_id  => undef,
943
            type      => 'Payment',
944
            amount    => 0,
945
        }
946
    )->store();
947
948
    is( $account_offset->debit, undef, "Koha::Account::Offset->debit returns undef if no associated debit" );
949
    is( $account_offset->credit, undef, "Koha::Account::Offset->credit returns undef if no associated credit" );
950
};
951
910
1;
952
1;
911
- 

Return to bug 2696