Bug 27971

Summary: The VOID method should be updated to respect double-entry accounting
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: Fines and feesAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi (tcohen) <tomascohen>
Severity: enhancement    
Priority: P5 - low CC: andrew, fridolin.somers, jonathan.druart, kyle, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Prior to this patch, the VOID action would reverse payments and set the original credit to '0'. With this patch, we bring the void action in line with other actions that can take place on the accounts system. The original credit amount is kept for audit purposes, we add a VOID line to the accountlines and offset it against the original credit (so that the amount outstanding is zero) and we reverse all the original offsets the credit may have been made against and record these reversals. This all helps in future audits and gives additional detail for Koha's other internal processes (Like automated refunds having to discount void payments - See bug 28421)
Version(s) released in:
21.05.00
Circulation function:
Bug Depends on: 24300    
Bug Blocks: 28664, 27995, 28421, 28663    
Attachments: Bug 27971: Update void method to use double entry accounting
Bug 27971: Update void method to use double entry accounting
Bug 27971: Enhance unit tests
Bug 27971: Update void method to use double entry accounting
Bug 27971: Enhance unit tests
Bug 27971: Update void method to use double entry accounting
Bug 27971: Enhance unit tests
Bug 27971: Update void method to use double entry accounting
Bug 27971: Enhance unit tests
Bug 27971: Update void method to use double entry accounting
Bug 27971: Enhance unit tests
Bug 27971: Update void method to use double entry accounting
Bug 27971: Enhance unit tests

Description Martin Renvoize (ashimema) 2021-03-17 08:38:13 UTC
All other account line methods respect the double-entry accounting method, except for 'adjust' which acts on lines that are not yet finalised.

In such a method, any action upon an account line should have a corresponding opposite line in the ledger.  Currently, the VOID method updates the original payment/credit line to an amount outstanding of zero, but there is not corresponding void line that offsets it.
Comment 1 Martin Renvoize (ashimema) 2021-03-17 09:12:57 UTC
Created attachment 118358 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.
Comment 2 Martin Renvoize (ashimema) 2021-03-17 16:25:27 UTC
Created attachment 118419 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.

Test plan
1/ Apply the database update
2/ Add some debts to a borrower account
3/ Pay those debts
4/ Void the payment
5/ A new 'VOID' line should appear on the account for the full amount of
the original payment.
6/ Payments should have all been reversed
7/ t/db_dependent/Koha/Account/Line.t should still pass
8/ Signoff
Comment 3 Martin Renvoize (ashimema) 2021-03-17 16:25:29 UTC
Created attachment 118420 [details] [review]
Bug 27971: Enhance unit tests

This patch adds some additional unit tests for extra functionality
included with this patchset.

Test plan
1/ t/db_dependent/Koha/Account/Line.t should pass
Comment 4 Kyle M Hall (khall) 2021-03-17 16:43:45 UTC
Created attachment 118422 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.

Test plan
1/ Apply the database update
2/ Add some debts to a borrower account
3/ Pay those debts
4/ Void the payment
5/ A new 'VOID' line should appear on the account for the full amount of
the original payment.
6/ Payments should have all been reversed
7/ t/db_dependent/Koha/Account/Line.t should still pass
8/ Signoff

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 5 Kyle M Hall (khall) 2021-03-17 16:43:52 UTC
Created attachment 118423 [details] [review]
Bug 27971: Enhance unit tests

This patch adds some additional unit tests for extra functionality
included with this patchset.

Test plan
1/ t/db_dependent/Koha/Account/Line.t should pass

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Martin Renvoize (ashimema) 2021-03-19 10:26:01 UTC
Created attachment 118504 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.

Test plan
1/ Apply the database update
2/ Add some debts to a borrower account
3/ Pay those debts
4/ Void the payment
5/ A new 'VOID' line should appear on the account for the full amount of
the original payment.
6/ Payments should have all been reversed
7/ t/db_dependent/Koha/Account/Line.t should still pass
8/ Signoff

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Martin Renvoize (ashimema) 2021-03-19 10:26:04 UTC
Created attachment 118505 [details] [review]
Bug 27971: Enhance unit tests

This patch adds some additional unit tests for extra functionality
included with this patchset.

Test plan
1/ t/db_dependent/Koha/Account/Line.t should pass

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Martin Renvoize (ashimema) 2021-03-19 10:26:19 UTC
Rebased
Comment 9 Martin Renvoize (ashimema) 2021-03-22 15:58:56 UTC
Created attachment 118613 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.

Test plan
1/ Apply the database update
2/ Add some debts to a borrower account
3/ Pay those debts
4/ Void the payment
5/ A new 'VOID' line should appear on the account for the full amount of
the original payment.
6/ Payments should have all been reversed
7/ t/db_dependent/Koha/Account/Line.t should still pass
8/ Signoff

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Martin Renvoize (ashimema) 2021-03-22 15:58:59 UTC
Created attachment 118614 [details] [review]
Bug 27971: Enhance unit tests

This patch adds some additional unit tests for extra functionality
included with this patchset.

Test plan
1/ t/db_dependent/Koha/Account/Line.t should pass

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Tomás Cohen Arazi (tcohen) 2021-03-22 21:00:55 UTC
Created attachment 118624 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.

Test plan
1/ Apply the database update
2/ Add some debts to a borrower account
3/ Pay those debts
4/ Void the payment
5/ A new 'VOID' line should appear on the account for the full amount of
the original payment.
6/ Payments should have all been reversed
7/ t/db_dependent/Koha/Account/Line.t should still pass
8/ Signoff

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 12 Tomás Cohen Arazi (tcohen) 2021-03-22 21:00:59 UTC
Created attachment 118625 [details] [review]
Bug 27971: Enhance unit tests

This patch adds some additional unit tests for extra functionality
included with this patchset.

Test plan
1/ t/db_dependent/Koha/Account/Line.t should pass

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Tomás Cohen Arazi (tcohen) 2021-03-22 21:01:52 UTC
Simple change, works as advertised.. The upgrade works as well.
Comment 14 Martin Renvoize (ashimema) 2021-04-06 11:09:54 UTC
Created attachment 119201 [details] [review]
Bug 27971: Update void method to use double entry accounting

This patch adds double-entry accounting to the Koha::Account::Line->void method.

This results in the addition of a VOID debit type line that is offset
against the original credit type line that is being voided. This allows
us to accurately record when the void took place, at what branch and by
whome the void was triggered.

Test plan
1/ Apply the database update
2/ Add some debts to a borrower account
3/ Pay those debts
4/ Void the payment
5/ A new 'VOID' line should appear on the account for the full amount of
the original payment.
6/ Payments should have all been reversed
7/ t/db_dependent/Koha/Account/Line.t should still pass
8/ Signoff

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 15 Martin Renvoize (ashimema) 2021-04-06 11:09:57 UTC
Created attachment 119202 [details] [review]
Bug 27971: Enhance unit tests

This patch adds some additional unit tests for extra functionality
included with this patchset.

Test plan
1/ t/db_dependent/Koha/Account/Line.t should pass

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 16 Martin Renvoize (ashimema) 2021-04-06 11:10:24 UTC
Tree re-arranged slightly to put bugs that need backporting before these enhancements that don't.

Rebased to accommodate the above.
Comment 17 Jonathan Druart 2021-04-08 09:59:51 UTC
Blocked by bug 27927.
Comment 18 Jonathan Druart 2021-04-23 09:55:51 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 19 Fridolin Somers 2021-04-30 07:50:36 UTC
Enhancement not pushed to 20.11.x