From 687c99458934f19e62b52bdcd0f7c0ecd167b6ec Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 29 Nov 2018 13:49:27 +0000 Subject: [PATCH] Bug 21896: (QA follow-up) Document and Test for FIFO behaviour A short dicussion lead to the decision to make it explictly clear that this method will implicitly apply credits against debits in a 'First In First Out' manor, meaning oldest outstanding debits will be paid off first. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Account.pm | 4 +++- Koha/Account/Line.pm | 8 ++++++++ Koha/Schema/Result/Accountline.pm | 8 +++++++- t/db_dependent/Koha/Account.t | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 80e8353368..5630f4130e 100644 --- a/Koha/Account.pm +++ b/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 diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 3573e604e6..238029fe8f 100644 --- a/Koha/Account/Line.pm +++ b/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; diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm index 378c14a08e..fd2e03dfee 100644 --- a/Koha/Schema/Result/Accountline.pm +++ b/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; diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index f11a2f2972..16654f6c85 100755 --- a/t/db_dependent/Koha/Account.t +++ b/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; -- 2.19.2