Bugzilla – Attachment 118358 Details for
Bug 27971
The VOID method should be updated to respect double-entry accounting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27971: Update void method to use double entry accounting
Bug-27971-Update-void-method-to-use-double-entry-a.patch (text/plain), 4.29 KB, created by
Martin Renvoize (ashimema)
on 2021-03-17 09:12:57 UTC
(
hide
)
Description:
Bug 27971: Update void method to use double entry accounting
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-17 09:12:57 UTC
Size:
4.29 KB
patch
obsolete
>From 4f9ad7745720368ec8d6781aa0a1850b7a4c9bae Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 17 Mar 2021 09:10:17 +0000 >Subject: [PATCH] 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. >--- > Koha/Account/Line.pm | 78 +++++++++++++++++++++++++++++++++++++------- > 1 file changed, 66 insertions(+), 12 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 2cc81993ef..95654d9f1b 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -219,17 +219,39 @@ as 'void' by updating it's status to "VOID". > =cut > > sub void { >- my ($self) = @_; >+ my ($self, $params) = @_; > >- # Make sure it is a payment we are voiding >- return unless $self->amount < 0; >+ # Make sure it is a credit we are voiding >+ unless ( $self->is_credit ) { >+ Koha::Exceptions::Account::IsNotCredit->throw( >+ error => 'Account line ' . $self->id . 'is not a credit' ); >+ } >+ >+ # Make sure it is not already voided >+ if ( $self->status && $self->status eq 'VOID' ) { >+ Koha::Exceptions::Account->throw( >+ error => 'Account line ' . $self->id . 'is already void' ); >+ } >+ >+ # Check for mandatory parameters >+ my @mandatory = ( 'staff_id', 'branch' ); >+ for my $param (@mandatory) { >+ unless ( defined( $params->{$param} ) ) { >+ Koha::Exceptions::MissingParameter->throw( >+ error => "The $param parameter is mandatory" ); >+ } >+ } > >+ # Find any applied offsets for the credit so we may reverse them > my @account_offsets = > Koha::Account::Offsets->search( > { credit_id => $self->id, amount => { '<' => 0 } } ); > >+ my $void; > $self->_result->result_source->schema->txn_do( > sub { >+ >+ # Reverse any applied payments > foreach my $account_offset (@account_offsets) { > my $fee_paid = > Koha::Account::Lines->find( $account_offset->debit_id ); >@@ -251,6 +273,45 @@ sub void { > )->store(); > } > >+ # A 'void' is a 'debit' >+ $void = Koha::Account::Line->new( >+ { >+ date => \'NOW()', >+ amount => $self->amount * -1, >+ debit_type_code => 'VOID', >+ status => 'ADDED', >+ amountoutstanding => 0, >+ manager_id => $params->{staff_id}, >+ borrowernumber => $self->borrowernumber, >+ interface => 'intranet', >+ branchcode => $params->{branch}, >+ } >+ )->store(); >+ >+ Koha::Account::Offset->new( >+ { >+ debit_id => $void->accountlines_id, >+ type => 'VOID', >+ amount => $self->amount * -1 >+ } >+ )->store(); >+ >+ # Link void to payment >+ Koha::Account::Offset->new( >+ { credit_id => $self->id, >+ debit_id => $void->id, >+ amount => $self->amount, >+ type => 'VOID' >+ } >+ )->store(); >+ $self->set( >+ { >+ status => 'VOID', >+ amountoutstanding => 0 >+ } >+ ); >+ $self->store(); >+ > if ( C4::Context->preference("FinesLog") ) { > logaction( > "FINES", 'VOID', >@@ -273,18 +334,11 @@ sub void { > ) > ); > } >- >- $self->set( >- { >- status => 'VOID', >- amountoutstanding => 0, >- amount => 0, >- } >- ); >- $self->store(); > } > ); > >+ $void->discard_changes; >+ return $void; > } > > =head3 cancel >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27971
:
118358
|
118419
|
118420
|
118422
|
118423
|
118504
|
118505
|
118613
|
118614
|
118624
|
118625
|
119201
|
119202