Bug 22600: Update Tests adding 'interface' as needed
Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
d2e189ca1c
commit
b1171d9ef3
|
|
@ -166,6 +166,7 @@ sub manualinvoice {
|
|||
itemnumber => $itemnum || undef,
|
||||
note => $note,
|
||||
manager_id => $manager_id,
|
||||
interface => C4::Context->interface,
|
||||
branchcode => $branchcode,
|
||||
}
|
||||
)->store();
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ $context->mock( 'userenv', sub {
|
|||
branch => $branchcode,
|
||||
};
|
||||
});
|
||||
$context->mock( 'interface', sub { return "commandline" } );
|
||||
my $userenv_branchcode = $branchcode;
|
||||
|
||||
# Test manualinvoice
|
||||
|
|
@ -109,9 +110,10 @@ my $sth = $dbh->prepare(
|
|||
borrowernumber,
|
||||
amountoutstanding,
|
||||
date,
|
||||
description
|
||||
description,
|
||||
interface
|
||||
)
|
||||
VALUES ( ?, ?, (select date_sub(CURRENT_DATE, INTERVAL ? DAY) ), ? )"
|
||||
VALUES ( ?, ?, (select date_sub(CURRENT_DATE, INTERVAL ? DAY) ), ?, ? )"
|
||||
);
|
||||
|
||||
my $days = 5;
|
||||
|
|
@ -133,7 +135,7 @@ my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
|
|||
my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => $categorycode, branchcode => $branchcode } )->store();
|
||||
|
||||
for my $data ( @test_data ) {
|
||||
$sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
|
||||
$sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description}, 'commandline');
|
||||
}
|
||||
|
||||
purge_zero_balance_fees( $days );
|
||||
|
|
@ -178,8 +180,8 @@ subtest "Koha::Account::pay tests" => sub {
|
|||
|
||||
my $account = Koha::Account->new({ patron_id => $borrower->id });
|
||||
|
||||
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 100 })->store();
|
||||
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 200 })->store();
|
||||
my $line1 = $account->add_debit({ type => 'account', amount => 100, interface => 'commandline' });
|
||||
my $line2 = $account->add_debit({ type => 'account', amount => 200, interface => 'commandline' });
|
||||
|
||||
$sth = $dbh->prepare("SELECT count(*) FROM accountlines");
|
||||
$sth->execute;
|
||||
|
|
@ -278,7 +280,7 @@ subtest "Koha::Account::pay tests" => sub {
|
|||
$note = $sth->fetchrow_array;
|
||||
is($note,'$200.00 payment note', '$200.00 payment note is registered');
|
||||
|
||||
my $line3 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 42, accounttype => 'TEST' })->store();
|
||||
my $line3 = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' });
|
||||
my $payment_id = $account->pay( { lines => [$line3], amount => 42 } );
|
||||
my $payment = Koha::Account::Lines->find( $payment_id );
|
||||
is( $payment->amount(), '-42.000000', "Payment paid the specified fine" );
|
||||
|
|
@ -306,10 +308,10 @@ subtest "Koha::Account::pay particular line tests" => sub {
|
|||
|
||||
my $account = Koha::Account->new({ patron_id => $borrower->id });
|
||||
|
||||
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 1 })->store();
|
||||
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 2 })->store();
|
||||
my $line3 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 3 })->store();
|
||||
my $line4 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 4 })->store();
|
||||
my $line1 = $account->add_debit({ type => 'account', amount => 1, interface => 'commandline' });
|
||||
my $line2 = $account->add_debit({ type => 'account', amount => 2, interface => 'commandline' });
|
||||
my $line3 = $account->add_debit({ type => 'account', amount => 3, interface => 'commandline' });
|
||||
my $line4 = $account->add_debit({ type => 'account', amount => 4, interface => 'commandline' });
|
||||
|
||||
is( $account->balance(), 10, "Account balance is 10" );
|
||||
|
||||
|
|
@ -351,7 +353,7 @@ subtest "Koha::Account::pay writeoff tests" => sub {
|
|||
|
||||
my $account = Koha::Account->new({ patron_id => $borrower->id });
|
||||
|
||||
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 42 })->store();
|
||||
my $line = $account->add_debit({ type => 'account', amount => 42, interface => 'commandline' });
|
||||
|
||||
is( $account->balance(), 42, "Account balance is 42" );
|
||||
|
||||
|
|
@ -747,29 +749,28 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
|
|||
plan tests => 21;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $account = $patron->account;
|
||||
|
||||
my $today = dt_from_string;
|
||||
my $res = 3;
|
||||
my $rent = 5;
|
||||
my $manual = 7;
|
||||
Koha::Account::Line->new(
|
||||
$account->add_debit(
|
||||
{
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
date => $today,
|
||||
description => 'a Res fee',
|
||||
accounttype => 'Res',
|
||||
amountoutstanding => $res,
|
||||
description => 'a Res fee',
|
||||
type => 'reserve',
|
||||
amount => $res,
|
||||
interface => 'commandline'
|
||||
}
|
||||
)->store;
|
||||
Koha::Account::Line->new(
|
||||
);
|
||||
$account->add_debit(
|
||||
{
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
date => $today,
|
||||
description => 'a Rental fee',
|
||||
accounttype => 'Rent',
|
||||
amountoutstanding => $rent,
|
||||
description => 'a Rental fee',
|
||||
type => 'rent',
|
||||
amount => $rent,
|
||||
interface => 'commandline'
|
||||
}
|
||||
)->store;
|
||||
);
|
||||
Koha::Account::Line->new(
|
||||
{
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
|
|
@ -777,6 +778,7 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
|
|||
description => 'a Manual invoice fee',
|
||||
accounttype => 'Copie',
|
||||
amountoutstanding => $manual,
|
||||
interface => 'commandline'
|
||||
}
|
||||
)->store;
|
||||
Koha::AuthorisedValue->new(
|
||||
|
|
@ -787,7 +789,6 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
|
|||
}
|
||||
)->store;
|
||||
|
||||
my $account = $patron->account;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 );
|
||||
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 );
|
||||
|
|
@ -925,8 +926,8 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
|
|||
}
|
||||
);
|
||||
|
||||
my $debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store();
|
||||
my $credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => -5 })->store();
|
||||
my $debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0, interface => 'commandline' })->store();
|
||||
my $credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => -5, interface => 'commandline' })->store();
|
||||
my $offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment', amount => 0 })->store();
|
||||
purge_zero_balance_fees( 1 );
|
||||
my $debit_2 = Koha::Account::Lines->find( $debit->id );
|
||||
|
|
@ -935,8 +936,8 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
|
|||
ok( $credit_2, 'Credit was correctly not deleted when credit has balance' );
|
||||
is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2, "The 2 account lines still exists" );
|
||||
|
||||
$debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 5 })->store();
|
||||
$credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store();
|
||||
$debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 5, interface => 'commanline' })->store();
|
||||
$credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0, interface => 'commandline' })->store();
|
||||
$offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment', amount => 0 })->store();
|
||||
purge_zero_balance_fees( 1 );
|
||||
$debit_2 = $credit_2 = undef;
|
||||
|
|
@ -946,8 +947,8 @@ subtest "Koha::Account::non_issues_charges tests" => sub {
|
|||
ok( $credit_2, 'Credit was correctly not deleted when debit has balance' );
|
||||
is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2 + 2, "The 2 + 2 account lines still exists" );
|
||||
|
||||
$debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store();
|
||||
$credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0 })->store();
|
||||
$debit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0, interface => 'commandline' })->store();
|
||||
$credit = Koha::Account::Line->new({ borrowernumber => $patron->id, date => '1900-01-01', amountoutstanding => 0, interface => 'commandline' })->store();
|
||||
$offset = Koha::Account::Offset->new({ credit_id => $credit->id, debit_id => $debit->id, type => 'Payment', amount => 0 })->store();
|
||||
purge_zero_balance_fees( 1 );
|
||||
$debit_2 = Koha::Account::Lines->find( $debit->id );
|
||||
|
|
@ -976,8 +977,8 @@ subtest "Koha::Account::Line::void tests" => sub {
|
|||
|
||||
my $account = Koha::Account->new({ patron_id => $borrower->id });
|
||||
|
||||
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10 })->store();
|
||||
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20 })->store();
|
||||
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10, interface => 'commandline' })->store();
|
||||
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20, interface => 'commandline' })->store();
|
||||
|
||||
is( $account->balance(), 30, "Account balance is 30" );
|
||||
is( $line1->amountoutstanding, 10, 'First fee has amount outstanding of 10' );
|
||||
|
|
@ -1043,8 +1044,8 @@ subtest "Koha::Account::Offset credit & debit tests" => sub {
|
|||
|
||||
my $account = Koha::Account->new({ patron_id => $borrower->id });
|
||||
|
||||
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10 })->store();
|
||||
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20 })->store();
|
||||
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10, interface => 'commandline' })->store();
|
||||
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20, interface => 'commandline' })->store();
|
||||
|
||||
my $id = $account->pay(
|
||||
{
|
||||
|
|
@ -1103,7 +1104,7 @@ subtest "Payment notice tests" => sub {
|
|||
});
|
||||
my $account = Koha::Account->new({ patron_id => $borrower->id });
|
||||
|
||||
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 27 })->store();
|
||||
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 27, interface => 'commandline' })->store();
|
||||
|
||||
my $letter = Koha::Notice::Templates->find( { code => 'ACCOUNT_PAYMENT' } );
|
||||
$letter->content('[%- USE Price -%]A payment of [% credit.amount * -1 | $Price %] has been applied to your account.');
|
||||
|
|
|
|||
|
|
@ -684,6 +684,7 @@ my ( $reused_itemnumber_1, $reused_itemnumber_2 );
|
|||
$account->add_debit(
|
||||
{
|
||||
amount => $fines_amount,
|
||||
interface => 'test',
|
||||
type => 'fine',
|
||||
item_id => $item_to_auto_renew->{itemnumber},
|
||||
description => "Some fines"
|
||||
|
|
@ -697,6 +698,7 @@ my ( $reused_itemnumber_1, $reused_itemnumber_2 );
|
|||
$account->add_debit(
|
||||
{
|
||||
amount => $fines_amount,
|
||||
interface => 'test',
|
||||
type => 'fine',
|
||||
item_id => $item_to_auto_renew->{itemnumber},
|
||||
description => "Some fines"
|
||||
|
|
@ -710,6 +712,7 @@ my ( $reused_itemnumber_1, $reused_itemnumber_2 );
|
|||
$account->add_debit(
|
||||
{
|
||||
amount => $fines_amount,
|
||||
interface => 'test',
|
||||
type => 'fine',
|
||||
item_id => $item_to_auto_renew->{itemnumber},
|
||||
description => "Some fines"
|
||||
|
|
@ -2046,7 +2049,8 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
# Write off the debt
|
||||
my $credit = $account->add_credit(
|
||||
{ amount => $account->balance,
|
||||
type => 'writeoff'
|
||||
type => 'writeoff',
|
||||
interface => 'test',
|
||||
}
|
||||
);
|
||||
$credit->apply( { debits => $debts, offset_type => 'Writeoff' } );
|
||||
|
|
@ -2106,7 +2110,8 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
# Write off the debt
|
||||
my $credit = $account->add_credit(
|
||||
{ amount => $account->balance,
|
||||
type => 'payment'
|
||||
type => 'payment',
|
||||
interface => 'test',
|
||||
}
|
||||
);
|
||||
$credit->apply( { debits => $debts, offset_type => 'Payment' } );
|
||||
|
|
@ -2226,7 +2231,8 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
my $payment_amount = 27;
|
||||
my $payment = $account->add_credit(
|
||||
{ amount => $payment_amount,
|
||||
type => 'payment'
|
||||
type => 'payment',
|
||||
interface => 'test',
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -2236,7 +2242,8 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
my $write_off_amount = 25;
|
||||
my $write_off = $account->add_credit(
|
||||
{ amount => $write_off_amount,
|
||||
type => 'writeoff'
|
||||
type => 'writeoff',
|
||||
interface => 'test',
|
||||
}
|
||||
);
|
||||
$write_off->apply( { debits => $lost_fee_lines->reset, offset_type => 'Writeoff' } );
|
||||
|
|
@ -2327,7 +2334,8 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
my $payment_amount = 27;
|
||||
my $payment = $account->add_credit(
|
||||
{ amount => $payment_amount,
|
||||
type => 'payment'
|
||||
type => 'payment',
|
||||
interface => 'test',
|
||||
}
|
||||
);
|
||||
$payment->apply({ debits => $lost_fee_lines->reset, offset_type => 'Payment' });
|
||||
|
|
@ -2338,7 +2346,7 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
|||
);
|
||||
|
||||
my $manual_debit_amount = 80;
|
||||
$account->add_debit( { amount => $manual_debit_amount, type => 'fine' } );
|
||||
$account->add_debit( { amount => $manual_debit_amount, type => 'fine', interface =>'test' } );
|
||||
|
||||
is( $account->balance, $manual_debit_amount + $replacement_amount - $payment_amount, 'Manual debit applied' );
|
||||
|
||||
|
|
@ -2380,6 +2388,7 @@ subtest '_FixOverduesOnReturn' => sub {
|
|||
itemnumber => $item->itemnumber,
|
||||
amount => 99.00,
|
||||
amountoutstanding => 99.00,
|
||||
interface => 'test',
|
||||
}
|
||||
)->store();
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item-
|
|||
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
|
||||
|
||||
my $account = Koha::Account->new( { patron_id => $guarantee->{borrowernumber} } );
|
||||
$account->add_debit({ amount => 10.00, type => 'lost_item' });
|
||||
$account->add_debit({ amount => 10.00, type => 'lost_item', interface => 'test' });
|
||||
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
|
||||
is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" );
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ use t::lib::TestBuilder;
|
|||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
C4::Context->interface('commandline');
|
||||
|
||||
subtest 'new' => sub {
|
||||
|
||||
|
|
@ -59,10 +60,10 @@ subtest 'outstanding_debits() tests' => sub {
|
|||
my $account = $patron->account;
|
||||
|
||||
my @generated_lines;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4, interface => 'commandline' })->store;
|
||||
|
||||
my $lines = $account->outstanding_debits();
|
||||
my @lines_arr = $account->outstanding_debits();
|
||||
|
|
@ -79,9 +80,9 @@ subtest 'outstanding_debits() tests' => sub {
|
|||
$i++;
|
||||
}
|
||||
my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -2 })->store;
|
||||
my $just_one = Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => 3, amountoutstanding => 3 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -6, amountoutstanding => -6 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -2, interface => 'commandline' })->store;
|
||||
my $just_one = Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => 3, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -6, amountoutstanding => -6, interface => 'commandline' })->store;
|
||||
$lines = $patron_2->account->outstanding_debits();
|
||||
is( $lines->total_outstanding, 3, "Total if some outstanding debits and some credits is only debits" );
|
||||
is( $lines->count, 1, "With 1 outstanding debits, we get back a Lines object with 1 lines" );
|
||||
|
|
@ -89,9 +90,9 @@ subtest 'outstanding_debits() tests' => sub {
|
|||
is_deeply( $the_line->unblessed, $lines->next->unblessed, "We get back the one correct line");
|
||||
|
||||
my $patron_3 = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -2, amountoutstanding => -2 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -20, amountoutstanding => -20 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -200, amountoutstanding => -200 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -2, amountoutstanding => -2, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -20, amountoutstanding => -20, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => -200, amountoutstanding => -200, interface => 'commandline' })->store;
|
||||
$lines = $patron_3->account->outstanding_debits();
|
||||
is( $lines->total_outstanding, 0, "Total if no outstanding debits total is 0" );
|
||||
is( $lines->count, 0, "With 0 outstanding debits, we get back a Lines object with 0 lines" );
|
||||
|
|
@ -103,7 +104,7 @@ subtest 'outstanding_debits() tests' => sub {
|
|||
is( $lines->count, 0, "With no outstanding debits, we get back a Lines object with 0 lines" );
|
||||
|
||||
# create a pathological credit with amountoutstanding > 0 (BZ 14591)
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_4->id, amount => -3, amountoutstanding => 3 })->store();
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_4->id, amount => -3, amountoutstanding => 3, interface => 'commandline' })->store();
|
||||
$lines = $account_4->outstanding_debits();
|
||||
is( $lines->count, 0, 'No credits are confused with debits because of the amountoutstanding value' );
|
||||
|
||||
|
|
@ -120,10 +121,10 @@ subtest 'outstanding_credits() tests' => sub {
|
|||
my $account = $patron->account;
|
||||
|
||||
my @generated_lines;
|
||||
push @generated_lines, $account->add_credit({ amount => 1 });
|
||||
push @generated_lines, $account->add_credit({ amount => 2 });
|
||||
push @generated_lines, $account->add_credit({ amount => 3 });
|
||||
push @generated_lines, $account->add_credit({ amount => 4 });
|
||||
push @generated_lines, $account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
push @generated_lines, $account->add_credit({ amount => 2, interface => 'commandline' });
|
||||
push @generated_lines, $account->add_credit({ amount => 3, interface => 'commandline' });
|
||||
push @generated_lines, $account->add_credit({ amount => 4, interface => 'commandline' });
|
||||
|
||||
my $lines = $account->outstanding_credits();
|
||||
my @lines_arr = $account->outstanding_credits();
|
||||
|
|
@ -147,7 +148,7 @@ subtest 'outstanding_credits() tests' => sub {
|
|||
is( $lines->count, 0, "With no outstanding credits, we get back a Lines object with 0 lines" );
|
||||
|
||||
# create a pathological debit with amountoutstanding < 0 (BZ 14591)
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => 2, amountoutstanding => -3 })->store();
|
||||
Koha::Account::Line->new({ borrowernumber => $patron_2->id, amount => 2, amountoutstanding => -3, interface => 'commandline' })->store();
|
||||
$lines = $account->outstanding_credits();
|
||||
is( $lines->count, 0, 'No debits are confused with credits because of the amountoutstanding value' );
|
||||
|
||||
|
|
@ -178,7 +179,8 @@ subtest 'add_credit() tests' => sub {
|
|||
library_id => $patron->branchcode,
|
||||
note => 'not really important',
|
||||
type => 'payment',
|
||||
user_id => $patron->id
|
||||
user_id => $patron->id,
|
||||
interface => 'commandline'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -197,7 +199,8 @@ subtest 'add_credit() tests' => sub {
|
|||
library_id => $patron->branchcode,
|
||||
note => 'not really important',
|
||||
user_id => $patron->id,
|
||||
sip => $sip_code
|
||||
sip => $sip_code,
|
||||
interface => 'commandline'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -220,7 +223,8 @@ subtest 'add_credit() tests' => sub {
|
|||
description => 'Manual credit applied',
|
||||
library_id => $patron->branchcode,
|
||||
user_id => $patron->id,
|
||||
type => 'forgiven'
|
||||
type => 'forgiven',
|
||||
interface => 'commandline'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -254,7 +258,8 @@ subtest 'add_debit() tests' => sub {
|
|||
library_id => $patron->branchcode,
|
||||
note => 'this should fail anyway',
|
||||
type => 'rent',
|
||||
user_id => $patron->id
|
||||
user_id => $patron->id,
|
||||
interface => 'commandline'
|
||||
}
|
||||
); } 'Koha::Exceptions::Account::AmountNotPositive', 'Expected validation exception thrown (amount)';
|
||||
|
||||
|
|
@ -266,7 +271,8 @@ subtest 'add_debit() tests' => sub {
|
|||
library_id => $patron->branchcode,
|
||||
note => 'this should fail anyway',
|
||||
type => 'failure',
|
||||
user_id => $patron->id
|
||||
user_id => $patron->id,
|
||||
interface => 'commandline'
|
||||
}
|
||||
); } 'Koha::Exceptions::Account::UnrecognisedType', 'Expected validation exception thrown (type)';
|
||||
|
||||
|
|
@ -280,7 +286,8 @@ subtest 'add_debit() tests' => sub {
|
|||
library_id => $patron->branchcode,
|
||||
note => 'not really important',
|
||||
type => 'rent',
|
||||
user_id => $patron->id
|
||||
user_id => $patron->id,
|
||||
interface => 'commandline'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -308,6 +315,7 @@ subtest 'add_debit() tests' => sub {
|
|||
note => 'not really important',
|
||||
type => 'rent',
|
||||
user_id => $patron->id,
|
||||
interface => 'commandline'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -349,20 +357,20 @@ subtest 'lines() tests' => sub {
|
|||
my @generated_lines;
|
||||
|
||||
# Add Credits
|
||||
push @generated_lines, $account->add_credit({ amount => 1 });
|
||||
push @generated_lines, $account->add_credit({ amount => 2 });
|
||||
push @generated_lines, $account->add_credit({ amount => 3 });
|
||||
push @generated_lines, $account->add_credit({ amount => 4 });
|
||||
push @generated_lines, $account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
push @generated_lines, $account->add_credit({ amount => 2, interface => 'commandline' });
|
||||
push @generated_lines, $account->add_credit({ amount => 3, interface => 'commandline' });
|
||||
push @generated_lines, $account->add_credit({ amount => 4, interface => 'commandline' });
|
||||
|
||||
# Add Debits
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 2 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 2, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4, interface => 'commandline' })->store;
|
||||
|
||||
# Paid Off
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0 })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
|
||||
my $lines = $account->lines;
|
||||
is( $lines->_resultset->count, 10, "All accountlines (debits, credits and paid off) were fetched");
|
||||
|
|
@ -384,21 +392,21 @@ subtest 'reconcile_balance' => sub {
|
|||
my $account = $patron->account;
|
||||
|
||||
# Add Credits
|
||||
$account->add_credit({ amount => 1 });
|
||||
$account->add_credit({ amount => 2 });
|
||||
$account->add_credit({ amount => 3 });
|
||||
$account->add_credit({ amount => 4 });
|
||||
$account->add_credit({ amount => 5 });
|
||||
$account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 2, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 3, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 4, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 5, interface => 'commandline' });
|
||||
|
||||
# Add Debits TODO: replace for calls to add_debit when time comes
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4, interface => 'commandline' })->store;
|
||||
|
||||
# Paid Off
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
|
||||
is( $account->balance(), -5, "Account balance is -5" );
|
||||
is( $account->outstanding_debits->total_outstanding, 10, 'Outstanding debits sum 10' );
|
||||
|
|
@ -423,20 +431,20 @@ subtest 'reconcile_balance' => sub {
|
|||
my $account = $patron->account;
|
||||
|
||||
# Add Credits
|
||||
$account->add_credit({ amount => 1 });
|
||||
$account->add_credit({ amount => 2 });
|
||||
$account->add_credit({ amount => 3 });
|
||||
$account->add_credit({ amount => 4 });
|
||||
$account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 2, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 3, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 4, interface => 'commandline' });
|
||||
|
||||
# Add Debits TODO: replace for calls to add_debit when time comes
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4, interface => 'commandline' })->store;
|
||||
|
||||
# Paid Off
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
|
||||
is( $account->balance(), 0, "Account balance is 0" );
|
||||
is( $account->outstanding_debits->total_outstanding, 10, 'Outstanding debits sum 10' );
|
||||
|
|
@ -461,21 +469,21 @@ subtest 'reconcile_balance' => sub {
|
|||
my $account = $patron->account;
|
||||
|
||||
# Add Credits
|
||||
$account->add_credit({ amount => 1 });
|
||||
$account->add_credit({ amount => 2 });
|
||||
$account->add_credit({ amount => 3 });
|
||||
$account->add_credit({ amount => 4 });
|
||||
$account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 2, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 3, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 4, interface => 'commandline' });
|
||||
|
||||
# Add Debits TODO: replace for calls to add_debit when time comes
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 5, amountoutstanding => 5 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 5, amountoutstanding => 5, interface => 'commandline' })->store;
|
||||
|
||||
# Paid Off
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0, interface => 'commandline' })->store;
|
||||
|
||||
is( $account->balance(), 5, "Account balance is 5" );
|
||||
is( $account->outstanding_debits->total_outstanding, 15, 'Outstanding debits sum 15' );
|
||||
|
|
@ -500,13 +508,13 @@ subtest 'reconcile_balance' => sub {
|
|||
my $account = $patron->account;
|
||||
|
||||
# Add Credits
|
||||
$account->add_credit({ amount => 1 });
|
||||
$account->add_credit({ amount => 3 });
|
||||
$account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
$account->add_credit({ amount => 3, interface => 'commandline' });
|
||||
|
||||
# Add Debits TODO: replace for calls to add_debit when time comes
|
||||
my $debit_1 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store;
|
||||
my $debit_2 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
|
||||
my $debit_3 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
|
||||
my $debit_1 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1, interface => 'commandline' })->store;
|
||||
my $debit_2 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2, interface => 'commandline' })->store;
|
||||
my $debit_3 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3, interface => 'commandline' })->store;
|
||||
|
||||
is( $account->balance(), 2, "Account balance is 2" );
|
||||
is( $account->outstanding_debits->total_outstanding, 6, 'Outstanding debits sum 6' );
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ subtest 'item() tests' => sub {
|
|||
itemnumber => $item->itemnumber,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
interface => 'commandline',
|
||||
})->store;
|
||||
|
||||
my $account_line_item = $line->item;
|
||||
|
|
@ -86,7 +87,8 @@ subtest 'total_outstanding() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
amountoutstanding => 10
|
||||
amountoutstanding => 10,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -94,7 +96,8 @@ subtest 'total_outstanding() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
amountoutstanding => 10
|
||||
amountoutstanding => 10,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -105,7 +108,8 @@ subtest 'total_outstanding() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => -10,
|
||||
amountoutstanding => -10
|
||||
amountoutstanding => -10,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -116,7 +120,8 @@ subtest 'total_outstanding() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => -10,
|
||||
amountoutstanding => -10
|
||||
amountoutstanding => -10,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -127,7 +132,8 @@ subtest 'total_outstanding() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => -100,
|
||||
amountoutstanding => -100
|
||||
amountoutstanding => -100,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -146,7 +152,7 @@ subtest 'is_credit() and is_debit() tests' => sub {
|
|||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $account = $patron->account;
|
||||
|
||||
my $credit = $account->add_credit({ amount => 100, user_id => $patron->id });
|
||||
my $credit = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' });
|
||||
|
||||
ok( $credit->is_credit, 'is_credit detects credits' );
|
||||
ok( !$credit->is_debit, 'is_debit detects credits' );
|
||||
|
|
@ -156,6 +162,7 @@ subtest 'is_credit() and is_debit() tests' => sub {
|
|||
borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
interface => 'commandline',
|
||||
})->store;
|
||||
|
||||
ok( !$debit->is_credit, 'is_credit detects debits' );
|
||||
|
|
@ -173,13 +180,14 @@ subtest 'apply() tests' => sub {
|
|||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $account = $patron->account;
|
||||
|
||||
my $credit = $account->add_credit( { amount => 100, user_id => $patron->id } );
|
||||
my $credit = $account->add_credit( { amount => 100, user_id => $patron->id, interface => 'commandline' } );
|
||||
|
||||
my $debit_1 = Koha::Account::Line->new(
|
||||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
amountoutstanding => 10
|
||||
amountoutstanding => 10,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -187,7 +195,8 @@ subtest 'apply() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 100,
|
||||
amountoutstanding => 100
|
||||
amountoutstanding => 100,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -237,18 +246,19 @@ subtest 'apply() tests' => sub {
|
|||
'->apply() can only be used with credits';
|
||||
|
||||
$debits = Koha::Account::Lines->search({ accountlines_id => $credit->id });
|
||||
my $credit_3 = $account->add_credit({ amount => 1 });
|
||||
my $credit_3 = $account->add_credit({ amount => 1, interface => 'commandline' });
|
||||
throws_ok
|
||||
{ $credit_3->apply({ debits => $debits }); }
|
||||
'Koha::Exceptions::Account::IsNotDebit',
|
||||
'->apply() can only be applied to credits';
|
||||
|
||||
my $credit_2 = $account->add_credit({ amount => 20 });
|
||||
my $credit_2 = $account->add_credit({ amount => 20, interface => 'commandline' });
|
||||
my $debit_3 = Koha::Account::Line->new(
|
||||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 100,
|
||||
amountoutstanding => 100
|
||||
amountoutstanding => 100,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -296,6 +306,7 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub
|
|||
itemnumber => $item->itemnumber,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
interface => 'commandline',
|
||||
})->store;
|
||||
|
||||
$issue->delete;
|
||||
|
|
@ -333,7 +344,8 @@ subtest 'adjust() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "F",
|
||||
amount => 10,
|
||||
amountoutstanding => 10
|
||||
amountoutstanding => 10,
|
||||
interface => 'commandline',
|
||||
}
|
||||
)->store;
|
||||
|
||||
|
|
@ -341,21 +353,22 @@ subtest 'adjust() tests' => sub {
|
|||
{ borrowernumber => $patron->id,
|
||||
accounttype => "FU",
|
||||
amount => 100,
|
||||
amountoutstanding => 100
|
||||
amountoutstanding => 100,
|
||||
interface => 'commandline'
|
||||
}
|
||||
)->store;
|
||||
|
||||
my $credit = $account->add_credit( { amount => 40, user_id => $patron->id } );
|
||||
my $credit = $account->add_credit( { amount => 40, user_id => $patron->id, interface => 'commandline' } );
|
||||
|
||||
throws_ok { $debit_1->adjust( { amount => 50, type => 'bad' } ) }
|
||||
throws_ok { $debit_1->adjust( { amount => 50, type => 'bad', interface => 'commandline' } ) }
|
||||
qr/Update type not recognised/, 'Exception thrown for unrecognised type';
|
||||
|
||||
throws_ok { $debit_1->adjust( { amount => 50, type => 'fine_update' } ) }
|
||||
throws_ok { $debit_1->adjust( { amount => 50, type => 'fine_update', interface => 'commandline' } ) }
|
||||
qr/Update type not allowed on this accounttype/,
|
||||
'Exception thrown for type conflict';
|
||||
|
||||
# Increment an unpaid fine
|
||||
$debit_2->adjust( { amount => 150, type => 'fine_update' } )->discard_changes;
|
||||
$debit_2->adjust( { amount => 150, type => 'fine_update', interface => 'commandline' } )->discard_changes;
|
||||
|
||||
is( $debit_2->amount * 1, 150, 'Fine amount was updated in full' );
|
||||
is( $debit_2->amountoutstanding * 1, 150, 'Fine amountoutstanding was update in full' );
|
||||
|
|
@ -381,7 +394,7 @@ subtest 'adjust() tests' => sub {
|
|||
t::lib::Mocks::mock_preference( 'FinesLog', 1 );
|
||||
|
||||
# Increment the partially paid fine
|
||||
$debit_2->adjust( { amount => 160, type => 'fine_update' } )->discard_changes;
|
||||
$debit_2->adjust( { amount => 160, type => 'fine_update', interface => 'commandline' } )->discard_changes;
|
||||
|
||||
is( $debit_2->amount * 1, 160, 'Fine amount was updated in full' );
|
||||
is( $debit_2->amountoutstanding * 1, 120, 'Fine amountoutstanding was updated by difference' );
|
||||
|
|
@ -395,7 +408,7 @@ subtest 'adjust() tests' => sub {
|
|||
is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' );
|
||||
|
||||
# Decrement the partially paid fine, less than what was paid
|
||||
$debit_2->adjust( { amount => 50, type => 'fine_update' } )->discard_changes;
|
||||
$debit_2->adjust( { amount => 50, type => 'fine_update', interface => 'commandline' } )->discard_changes;
|
||||
|
||||
is( $debit_2->amount * 1, 50, 'Fine amount was updated in full' );
|
||||
is( $debit_2->amountoutstanding * 1, 10, 'Fine amountoutstanding was updated by difference' );
|
||||
|
|
@ -407,7 +420,7 @@ subtest 'adjust() tests' => sub {
|
|||
is( $THIS_offset->type, 'fine_decrease', 'Adjust type stored correctly' );
|
||||
|
||||
# Decrement the partially paid fine, more than what was paid
|
||||
$debit_2->adjust( { amount => 30, type => 'fine_update' } )->discard_changes;
|
||||
$debit_2->adjust( { amount => 30, type => 'fine_update', interface => 'commandline' } )->discard_changes;
|
||||
is( $debit_2->amount * 1, 30, 'Fine amount was updated in full' );
|
||||
is( $debit_2->amountoutstanding * 1, 0, 'Fine amountoutstanding was zeroed (payment was 40)' );
|
||||
|
||||
|
|
@ -438,10 +451,11 @@ subtest 'checkout() tests' => sub {
|
|||
my $checkout = AddIssue( $patron->unblessed, $item->barcode );
|
||||
|
||||
my $line = $account->add_debit({
|
||||
amount => 10,
|
||||
item_id => $item->itemnumber,
|
||||
issue_id => $checkout->issue_id,
|
||||
type => 'fine',
|
||||
amount => 10,
|
||||
interface => 'commandline',
|
||||
item_id => $item->itemnumber,
|
||||
issue_id => $checkout->issue_id,
|
||||
type => 'fine',
|
||||
});
|
||||
|
||||
my $line_checkout = $line->checkout;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ subtest 'get_balance() tests' => sub {
|
|||
accounttype => "N", # New card
|
||||
amountoutstanding => 50,
|
||||
manager_id => $patron->borrowernumber,
|
||||
branchcode => $library->id
|
||||
branchcode => $library->id,
|
||||
interface => 'test',
|
||||
}
|
||||
)->store();
|
||||
$account_line_1->discard_changes;
|
||||
|
|
@ -82,7 +83,8 @@ subtest 'get_balance() tests' => sub {
|
|||
accounttype => "N", # New card
|
||||
amountoutstanding => 50.01,
|
||||
manager_id => $patron->borrowernumber,
|
||||
branchcode => $library->id
|
||||
branchcode => $library->id,
|
||||
interface => 'test',
|
||||
}
|
||||
)->store();
|
||||
$account_line_2->discard_changes;
|
||||
|
|
@ -128,7 +130,7 @@ subtest 'get_balance() tests' => sub {
|
|||
|
||||
# add a credit
|
||||
my $credit_line = $account->add_credit(
|
||||
{ amount => 10, user_id => $patron->id, library_id => $library->id } );
|
||||
{ amount => 10, user_id => $patron->id, library_id => $library->id, interface => 'test' } );
|
||||
# re-read from the DB
|
||||
$credit_line->discard_changes;
|
||||
$tx = $t->ua->build_tx( GET => "/api/v1/patrons/$patron_id/account" );
|
||||
|
|
@ -184,6 +186,7 @@ subtest 'add_credit() tests' => sub {
|
|||
accounttype => "N", # New card
|
||||
amountoutstanding => 10,
|
||||
manager_id => $patron->borrowernumber,
|
||||
interface => 'test',
|
||||
}
|
||||
)->store();
|
||||
my $debit_2 = Koha::Account::Line->new(
|
||||
|
|
@ -194,6 +197,7 @@ subtest 'add_credit() tests' => sub {
|
|||
accounttype => "N", # New card
|
||||
amountoutstanding => 15,
|
||||
manager_id => $patron->borrowernumber,
|
||||
interface => 'test',
|
||||
}
|
||||
)->store();
|
||||
|
||||
|
|
@ -220,6 +224,7 @@ subtest 'add_credit() tests' => sub {
|
|||
accounttype => "N", # New card
|
||||
amountoutstanding => 100,
|
||||
manager_id => $patron->borrowernumber,
|
||||
interface => 'test',
|
||||
}
|
||||
)->store();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue