Bugzilla – Attachment 88781 Details for
Bug 22200
Forgiving a fine (FOR) does not create a FORGIVEN credit line
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22200: (follow-up) Wrap accountline creation in a transaction
Bug-22200-follow-up-Wrap-accountline-creation-in-a.patch (text/plain), 3.98 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-04-25 13:28:50 UTC
(
hide
)
Description:
Bug 22200: (follow-up) Wrap accountline creation in a transaction
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-04-25 13:28:50 UTC
Size:
3.98 KB
patch
obsolete
>From 24ad17b29e4e9472920c93fd6c94c8a05178011e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 25 Apr 2019 12:35:24 +0100 >Subject: [PATCH] Bug 22200: (follow-up) Wrap accountline creation in a > transaction > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Circulation.pm | 72 ++++++++++++++++++++++++++--------------------- > 1 file changed, 40 insertions(+), 32 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 51dde19697..94e9dfa708 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2338,45 +2338,53 @@ sub _FixOverduesOnReturn { > return; > } > >- # check for overdue fine >- my $accountlines = Koha::Account::Lines->search( >- { >- borrowernumber => $borrowernumber, >- itemnumber => $item, >- accounttype => 'OVERDUE', >- status => 'UNRETURNED' >- } >- ); >- return 0 unless $accountlines->count; # no warning, there's just nothing to fix >+ my $schema = Koha::Database->schema; > >- my $accountline = $accountlines->next; >- if ($exemptfine) { >- my $amountoutstanding = $accountline->amountoutstanding; >+ my $result = $schema->txn_do( >+ sub { >+ # check for overdue fine >+ my $accountlines = Koha::Account::Lines->search( >+ { >+ borrowernumber => $borrowernumber, >+ itemnumber => $item, >+ accounttype => 'OVERDUE', >+ status => 'UNRETURNED' >+ } >+ ); >+ return 0 unless $accountlines->count; # no warning, there's just nothing to fix > >- my $account = Koha::Account->new({patron_id => $borrowernumber}); >- my $credit = $account->add_credit( >- { >- amount => $amountoutstanding, >- user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, >- library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, >- interface => C4::Context->interface, >- type => 'forgiven', >- item_id => $item >- } >- ); >+ my $accountline = $accountlines->next; >+ if ($exemptfine) { >+ my $amountoutstanding = $accountline->amountoutstanding; > >- $credit->apply({ debits => $accountlines->reset, offset_type => 'Forgiven' }); >+ my $account = Koha::Account->new({patron_id => $borrowernumber}); >+ my $credit = $account->add_credit( >+ { >+ amount => $amountoutstanding, >+ user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, >+ library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, >+ interface => C4::Context->interface, >+ type => 'forgiven', >+ item_id => $item >+ } >+ ); > >- $accountline->status('FORGIVEN'); >+ $credit->apply({ debits => $accountlines->reset, offset_type => 'Forgiven' }); >+ >+ $accountline->status('FORGIVEN'); >+ >+ if (C4::Context->preference("FinesLog")) { >+ &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); >+ } >+ } else { >+ $accountline->status('RETURNED'); >+ } > >- if (C4::Context->preference("FinesLog")) { >- &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); >+ return $accountline->store(); > } >- } else { >- $accountline->status('RETURNED'); >- } >+ ); > >- return $accountline->store(); >+ return $result; > } > > =head2 _FixAccountForLostAndReturned >-- >2.21.0
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 22200
:
84339
|
85219
|
88269
|
88270
|
88271
|
88273
|
88304
|
88305
|
88718
|
88719
|
88750
|
88759
|
88760
|
88761
|
88779
|
88780
| 88781