Bug 23805: Update accounttype references in tests

Signed-off-by: Kyle Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-10-14 11:42:57 +01:00
parent 25047ce341
commit b7900423a2
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
5 changed files with 31 additions and 32 deletions

View File

@ -115,7 +115,7 @@ my $sth = $dbh->prepare(
date,
description,
interface,
accounttype,
credit_type_code,
debit_type_code
)
VALUES ( ?, ?, (select date_sub(CURRENT_DATE, INTERVAL ? DAY) ), ?, ?, ?, ? )"
@ -124,17 +124,17 @@ my $sth = $dbh->prepare(
my $days = 5;
my @test_data = (
{ amount => 0 , days_ago => 0 , description =>'purge_zero_balance_fees should not delete 0 balance fees with date today' , delete => 0, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => 0 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete 0 balance fees with date before threshold day' , delete => 0, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => 0 , days_ago => $days , description =>'purge_zero_balance_fees should not delete 0 balance fees with date on threshold day' , delete => 0, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => 0 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete 0 balance fees with date after threshold day' , delete => 1, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => undef , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete NULL balance fees with date after threshold day' , delete => 1, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => 5 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with positive amout owed before threshold day' , delete => 0, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => 5 , days_ago => $days , description =>'purge_zero_balance_fees should not delete fees with positive amout owed on threshold day' , delete => 0, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => 5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with positive amout owed after threshold day' , delete => 0, accounttype => undef, debit_type => 'OVERDUE' } ,
{ amount => -5 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed before threshold day' , delete => 0, accounttype => 'Pay', debit_type => undef } ,
{ amount => -5 , days_ago => $days , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day' , delete => 0, accounttype => 'Pay', debit_type => undef } ,
{ amount => -5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day' , delete => 0, accounttype => 'Pay', debit_type => undef }
{ amount => 0 , days_ago => 0 , description =>'purge_zero_balance_fees should not delete 0 balance fees with date today' , delete => 0, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => 0 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete 0 balance fees with date before threshold day' , delete => 0, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => 0 , days_ago => $days , description =>'purge_zero_balance_fees should not delete 0 balance fees with date on threshold day' , delete => 0, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => 0 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete 0 balance fees with date after threshold day' , delete => 1, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => undef , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete NULL balance fees with date after threshold day' , delete => 1, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => 5 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with positive amout owed before threshold day' , delete => 0, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => 5 , days_ago => $days , description =>'purge_zero_balance_fees should not delete fees with positive amout owed on threshold day' , delete => 0, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => 5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with positive amout owed after threshold day' , delete => 0, credit_type => undef, debit_type => 'OVERDUE' } ,
{ amount => -5 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed before threshold day' , delete => 0, credit_type => 'PAYMENT', debit_type => undef } ,
{ amount => -5 , days_ago => $days , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day' , delete => 0, credit_type => 'PAYMENT', debit_type => undef } ,
{ amount => -5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day' , delete => 0, credit_type => 'PAYMENT', debit_type => undef }
);
my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => $categorycode, branchcode => $branchcode } )->store();
@ -146,7 +146,7 @@ for my $data ( @test_data ) {
$data->{days_ago},
$data->{description},
'commandline',
$data->{accounttype},
$data->{credit_type},
$data->{debit_type}
);
}
@ -384,7 +384,7 @@ subtest "Koha::Account::pay writeoff tests" => sub {
my $writeoff = Koha::Account::Lines->find( $id );
is( $writeoff->accounttype, 'W', 'Type is correct for writeoff' );
is( $writeoff->credit_type_code, 'W', 'Type is correct for writeoff' );
is( $writeoff->description, 'Writeoff', 'Description is correct' );
is( $writeoff->amount, '-42.000000', 'Amount is correct' );
};
@ -411,7 +411,7 @@ subtest "More Koha::Account::pay tests" => sub {
borrowernumber => $borrowernumber,
amount => $amount,
amountoutstanding => $amount,
accounttype => undef,
credit_type_code => undef,
}
}
);
@ -471,7 +471,7 @@ subtest "Even more Koha::Account::pay tests" => sub {
borrowernumber => $borrowernumber,
amount => $amount,
amountoutstanding => $amount,
accounttype => undef,
credit_type_code => undef,
}
}
);
@ -523,7 +523,7 @@ subtest 'balance' => sub {
borrowernumber => $patron->borrowernumber,
amount => 42,
amountoutstanding => 42,
accounttype => undef,
credit_type_code => undef,
}
}
);
@ -981,7 +981,7 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
date => '1900-01-01',
amountoutstanding => -5,
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store();
my $offset = Koha::Account::Offset->new(
@ -1014,7 +1014,7 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
date => '1900-01-01',
amountoutstanding => 0,
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store();
$offset = Koha::Account::Offset->new(
@ -1048,7 +1048,7 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
date => '1900-01-01',
amountoutstanding => 0,
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store();
$offset = Koha::Account::Offset->new(

View File

@ -2219,7 +2219,7 @@ subtest '_FixAccountForLostAndReturned' => sub {
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
is( $credit_return->accounttype, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->credit_type_code, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->amount + 0,
-99.00, 'The account line of type LOST_RETURN has an amount of -99' );
is( $credit_return->amountoutstanding + 0,
@ -2277,7 +2277,7 @@ subtest '_FixAccountForLostAndReturned' => sub {
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
is( $credit_return->accounttype, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->credit_type_code, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->amount + 0, -99.00, 'The account line of type LOST_RETURN has an amount of -99' );
is( $credit_return->amountoutstanding + 0, 0, 'The account line of type LOST_RETURN has an amountoutstanding of 0' );
@ -2371,7 +2371,7 @@ subtest '_FixAccountForLostAndReturned' => sub {
'LOST', 'Lost fee now still has account type of LOST' );
is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED");
is( $credit_return->accounttype, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->credit_type_code, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->amount + 0,
($payment_amount + $outstanding ) * -1,
'The account line of type LOST_RETURN has an amount equal to the payment + outstanding'

View File

@ -200,7 +200,6 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
source => 'Accountline',
value => {
borrowernumber => $brwr->{borrowernumber},
accounttype => undef,
debit_type_code => 'OVERDUE',
amountoutstanding => 10
}

View File

@ -86,7 +86,7 @@ subtest 'outstanding_debits() tests' => sub {
borrowernumber => $patron_2->id,
amountoutstanding => -2,
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store;
my $just_one = Koha::Account::Line->new(
@ -104,7 +104,7 @@ subtest 'outstanding_debits() tests' => sub {
amount => -6,
amountoutstanding => -6,
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store;
$lines = $patron_2->account->outstanding_debits();
@ -135,7 +135,7 @@ subtest 'outstanding_debits() tests' => sub {
amount => -3,
amountoutstanding => 3,
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store();
$lines = $account_4->outstanding_debits();
@ -241,7 +241,7 @@ subtest 'add_credit() tests' => sub {
is( $account->balance, -25, 'Patron has a balance of -25' );
is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' );
is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' );
is( $line_1->accounttype, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' );
is( $line_1->credit_type_code, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' );
# Enable logs
t::lib::Mocks::mock_preference( 'FinesLog', 1 );
@ -259,7 +259,7 @@ subtest 'add_credit() tests' => sub {
is( $account->balance, -62, 'Patron has a balance of -25' );
is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' );
is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' );
is( $line_2->accounttype, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' );
is( $line_2->credit_type_code, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' );
# offsets have the credit_id set to accountlines_id, and debit_id is undef
my $offset_1 = Koha::Account::Offsets->search({ credit_id => $line_1->id })->next;
@ -903,7 +903,7 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub {
amount => "-0.500000",
amountoutstanding => "-0.500000",
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store();
my $debits = $account->outstanding_debits;
@ -922,7 +922,7 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub {
amount => "-0.500000",
amountoutstanding => "-0.500000",
interface => 'commandline',
accounttype => 'Pay'
credit_type_code => 'PAYMENT'
}
)->store();
$debits = $account->outstanding_debits;

View File

@ -587,7 +587,7 @@ subtest "void() tests" => sub {
$line1->_result->discard_changes();
$line2->_result->discard_changes();
is( $account_payment->accounttype, 'Pay', 'Voided payment accounttype is still Pay' );
is( $account_payment->credit_type_code, 'Pay', 'Voided payment credit_type_code is still Pay' );
is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
is( $account_payment->amount+0, 0, 'Voided payment amount is 0' );
is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );