|
Lines 18-24
Link Here
|
| 18 |
|
18 |
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 30; |
21 |
use Test::More tests => 25; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
|
Lines 134-170
for my $data (@test_data) {
Link Here
|
| 134 |
} |
134 |
} |
| 135 |
|
135 |
|
| 136 |
$dbh->do(q|DELETE FROM accountlines|); |
136 |
$dbh->do(q|DELETE FROM accountlines|); |
| 137 |
my $debit = Koha::Account::Line->new({ borrowernumber => $borrower->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
|
|
| 138 |
my $credit = Koha::Account::Line->new({ borrowernumber => $borrower->id, date => '1900-01-01', amountoutstanding => -5 })->store(); |
| 139 |
my $offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment' })->store(); |
| 140 |
purge_zero_balance_fees( 1 ); |
| 141 |
my $debit_2 = Koha::Account::Lines->find( $debit->id ); |
| 142 |
my $credit_2 = Koha::Account::Lines->find( $credit->id ); |
| 143 |
ok( $debit_2, 'Debit was correctly not deleted when credit has balance' ); |
| 144 |
ok( $credit_2, 'Credit was correctly not deleted when credit has balance' ); |
| 145 |
|
| 146 |
$dbh->do(q|DELETE FROM accountlines|); |
| 147 |
$debit = Koha::Account::Line->new({ borrowernumber => $borrower->id, date => '1900-01-01', amountoutstanding => 5 })->store(); |
| 148 |
$credit = Koha::Account::Line->new({ borrowernumber => $borrower->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 149 |
$offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment' })->store(); |
| 150 |
purge_zero_balance_fees( 1 ); |
| 151 |
$debit_2 = $credit_2 = undef; |
| 152 |
$debit_2 = Koha::Account::Lines->find( $debit->id ); |
| 153 |
$credit_2 = Koha::Account::Lines->find( $credit->id ); |
| 154 |
ok( $debit_2, 'Debit was correctly not deleted when debit has balance' ); |
| 155 |
ok( $credit_2, 'Credit was correctly not deleted when debit has balance' ); |
| 156 |
|
| 157 |
$dbh->do(q|DELETE FROM accountlines|); |
| 158 |
$debit = Koha::Account::Line->new({ borrowernumber => $borrower->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 159 |
$credit = Koha::Account::Line->new({ borrowernumber => $borrower->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 160 |
$offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment' })->store(); |
| 161 |
purge_zero_balance_fees( 1 ); |
| 162 |
$debit_2 = Koha::Account::Lines->find( $debit->id ); |
| 163 |
$credit_2 = Koha::Account::Lines->find( $credit->id ); |
| 164 |
ok( !$debit_2, 'Debit was correctly deleted' ); |
| 165 |
ok( !$credit_2, 'Credit was correctly deleted' ); |
| 166 |
|
| 167 |
$dbh->do(q|DELETE FROM accountlines|); |
| 168 |
|
137 |
|
| 169 |
subtest "Koha::Account::pay tests" => sub { |
138 |
subtest "Koha::Account::pay tests" => sub { |
| 170 |
|
139 |
|
|
Lines 828-831
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 828 |
is( $other_charges, 0, 'If 1|1|1 there should not have any other charges' ); |
797 |
is( $other_charges, 0, 'If 1|1|1 there should not have any other charges' ); |
| 829 |
}; |
798 |
}; |
| 830 |
|
799 |
|
|
|
800 |
subtest "Koha::Account::non_issues_charges tests" => sub { |
| 801 |
plan tests => 6; |
| 802 |
|
| 803 |
my $patron = $builder->build_object( |
| 804 |
{ |
| 805 |
class => "Koha::Patrons", |
| 806 |
value => { |
| 807 |
firstname => 'Test', |
| 808 |
surname => 'Patron', |
| 809 |
categorycode => $categorycode, |
| 810 |
branchcode => $branchcode |
| 811 |
} |
| 812 |
} |
| 813 |
); |
| 814 |
|
| 815 |
my $debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 816 |
my $credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => -5 })->store(); |
| 817 |
my $offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment' })->store(); |
| 818 |
purge_zero_balance_fees( 1 ); |
| 819 |
my $debit_2 = Koha::Account::Lines->find( $debit->id ); |
| 820 |
my $credit_2 = Koha::Account::Lines->find( $credit->id ); |
| 821 |
ok( $debit_2, 'Debit was correctly not deleted when credit has balance' ); |
| 822 |
ok( $credit_2, 'Credit was correctly not deleted when credit has balance' ); |
| 823 |
|
| 824 |
$dbh->do(q|DELETE FROM accountlines WHERE borrowernumber=?|, undef, $patron->id); |
| 825 |
$debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 5 })->store(); |
| 826 |
$credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 827 |
$offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment' })->store(); |
| 828 |
purge_zero_balance_fees( 1 ); |
| 829 |
$debit_2 = $credit_2 = undef; |
| 830 |
$debit_2 = Koha::Account::Lines->find( $debit->id ); |
| 831 |
$credit_2 = Koha::Account::Lines->find( $credit->id ); |
| 832 |
ok( $debit_2, 'Debit was correctly not deleted when debit has balance' ); |
| 833 |
ok( $credit_2, 'Credit was correctly not deleted when debit has balance' ); |
| 834 |
|
| 835 |
$dbh->do(q|DELETE FROM accountlines WHERE borrowernumber=?|, undef, $patron->id); |
| 836 |
$debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 837 |
$credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store(); |
| 838 |
$offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment' })->store(); |
| 839 |
purge_zero_balance_fees( 1 ); |
| 840 |
$debit_2 = Koha::Account::Lines->find( $debit->id ); |
| 841 |
$credit_2 = Koha::Account::Lines->find( $credit->id ); |
| 842 |
ok( !$debit_2, 'Debit was correctly deleted' ); |
| 843 |
ok( !$credit_2, 'Credit was correctly deleted' ); |
| 844 |
}; |
| 845 |
|
| 831 |
1; |
846 |
1; |
| 832 |
- |
|
|