@@ -, +, @@ behaviour --- Koha/Account.pm | 4 +++- Koha/Account/Line.pm | 8 ++++++++ Koha/Schema/Result/Accountline.pm | 8 +++++++- t/db_dependent/Koha/Account.t | 8 +++++--- 4 files changed, 23 insertions(+), 5 deletions(-) --- a/Koha/Account.pm +++ a/Koha/Account.pm @@ -519,7 +519,9 @@ sub lines { $account->reconcile_balance(); -Find outstanding credits and use them to pay outstanding debits +Find outstanding credits and use them to pay outstanding debits. +Currently, this implicitly uses the 'First In First Out' rule for +applying credits against debits. =cut --- a/Koha/Account/Line.pm +++ a/Koha/Account/Line.pm @@ -241,4 +241,12 @@ sub _type { return 'Accountline'; } +=head3 object_class (internal) + +=cut + +sub object_class { + return 'Koha::Account::Line'; +} + 1; --- a/Koha/Schema/Result/Accountline.pm +++ a/Koha/Schema/Result/Accountline.pm @@ -238,7 +238,13 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-16 17:00:24 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pygYYKxFDRLX97PyeUeLvg +# +sub koha_objects_class { + 'Koha::Account::Lines'; +} +sub koha_object_class { + 'Koha::Account::Line'; +} -# You can replace this text with custom content, and it will be preserved on regeneration 1; --- a/t/db_dependent/Koha/Account.t +++ a/t/db_dependent/Koha/Account.t @@ -269,7 +269,7 @@ subtest 'reconcile_balance' => sub { $schema->storage->txn_rollback; }; - subtest 'same debit than credit' => sub { + subtest 'same debit as credit' => sub { plan tests => 6; @@ -309,7 +309,7 @@ subtest 'reconcile_balance' => sub { subtest 'more debit than credit' => sub { - plan tests => 6; + plan tests => 7; $schema->storage->txn_begin; @@ -327,7 +327,7 @@ subtest 'reconcile_balance' => sub { 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; + my $line5 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 5, amountoutstanding => 5 })->store; # Paid Off Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store; @@ -343,6 +343,8 @@ subtest 'reconcile_balance' => sub { is( $account->outstanding_debits->total_outstanding, 5, 'Outstanding debits sum 5' ); is( $account->outstanding_credits->total_outstanding, 0, 'Outstanding credits sum 0' ); + is( $line5->get_from_storage->amountoutstanding, '5.000000', 'First In First Out method of payment selection used'); + $schema->storage->txn_rollback; }; }; --