Bugzilla – Attachment 74162 Details for
Bug 18790
Add ability to void payments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18790 [QA Followup]: Use a transaction for voiding
Bug-18790-QA-Followup-Use-a-transaction-for-voidin.patch (text/plain), 4.69 KB, created by
Kyle M Hall
on 2018-04-13 12:27:03 UTC
(
hide
)
Description:
Bug 18790 [QA Followup]: Use a transaction for voiding
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2018-04-13 12:27:03 UTC
Size:
4.69 KB
patch
obsolete
>From bff2ddb6fb8793714ef1549fdc7047476a2bd385 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 13 Apr 2018 12:25:51 +0000 >Subject: [PATCH] Bug 18790 [QA Followup]: Use a transaction for voiding > >--- > Koha/Account/Line.pm | 100 +++++++++++++++++++++++++++++---------------------- > 1 file changed, 58 insertions(+), 42 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index e2cb749f67..06608add7e 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -63,52 +63,68 @@ sub void { > return unless $self->accounttype =~ /^Pay/; > > my @account_offsets = >- Koha::Account::Offsets->search( { credit_id => $self->id, type => 'Payment' } ); >- >- foreach my $account_offset (@account_offsets) { >- my $fee_paid = Koha::Account::Lines->find( $account_offset->debit_id ); >- >- next unless $fee_paid; >- >- my $amount_paid = $account_offset->amount * -1; # amount paid is stored as a negative amount >- my $new_amount = $fee_paid->amountoutstanding + $amount_paid; >- $fee_paid->amountoutstanding($new_amount); >- $fee_paid->store(); >+ Koha::Account::Offsets->search( >+ { credit_id => $self->id, type => 'Payment' } ); >+ >+ $self->_result->result_source->schema->txn_do( >+ sub { >+ foreach my $account_offset (@account_offsets) { >+ my $fee_paid = >+ Koha::Account::Lines->find( $account_offset->debit_id ); >+ >+ next unless $fee_paid; >+ >+ my $amount_paid = $account_offset->amount * >+ -1; # amount paid is stored as a negative amount >+ my $new_amount = $fee_paid->amountoutstanding + $amount_paid; >+ $fee_paid->amountoutstanding($new_amount); >+ $fee_paid->store(); >+ >+ Koha::Account::Offset->new( >+ { >+ credit_id => $self->id, >+ debit_id => $fee_paid->id, >+ amount => $amount_paid, >+ type => 'Void Payment', >+ } >+ )->store(); >+ } > >- Koha::Account::Offset->new( >- { >- credit_id => $self->id, >- debit_id => $fee_paid->id, >- amount => $amount_paid, >- type => 'Void Payment', >+ if ( C4::Context->preference("FinesLog") ) { >+ logaction( >+ "FINES", 'VOID', >+ $self->borrowernumber, >+ Dumper( >+ { >+ action => 'void_payment', >+ borrowernumber => $self->borrowernumber, >+ , >+ amount => $self->amount, >+ amountoutstanding => $self->amountoutstanding, >+ description => $self->description, >+ accounttype => $self->accounttype, >+ payment_type => $self->payment_type, >+ note => $self->note, >+ itemnumber => $self->itemnumber, >+ manager_id => $self->manager_id, >+ offsets => >+ [ map { $_->unblessed } @account_offsets ], >+ } >+ ) >+ ); > } >- )->store(); >- } >- >- if ( C4::Context->preference("FinesLog") ) { >- logaction("FINES", 'VOID', $self->borrowernumber, Dumper({ >- action => 'void_payment', >- borrowernumber => $self->borrowernumber,, >- amount => $self->amount, >- amountoutstanding => $self->amountoutstanding, >- description => $self->description, >- accounttype => $self->accounttype, >- payment_type => $self->payment_type, >- note => $self->note, >- itemnumber => $self->itemnumber, >- manager_id => $self->manager_id, >- offsets => [ map { $_->unblessed } @account_offsets ], >- })); >- } >- >- $self->set( >- { >- accounttype => 'VOID', >- amountoutstanding => 0, >- amount => 0, >+ >+ $self->set( >+ { >+ accounttype => 'VOID', >+ amountoutstanding => 0, >+ amount => 0, >+ } >+ ); >+ $self->store(); > } > ); >- $self->store(); >+ > } > > =head3 _type >-- >2.15.1 (Apple Git-101)
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 18790
:
64210
|
65468
|
65932
|
67478
|
69158
|
69159
|
69161
|
72017
|
72018
|
72019
|
72020
|
72021
|
72035
|
72036
|
72037
|
74157
|
74158
|
74159
|
74160
|
74161
| 74162 |
74576