Bugzilla – Attachment 128875 Details for
Bug 29759
Refund credit when cancelling an article request
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29759: Make cancelling an AR refund
Bug-29759-Make-cancelling-an-AR-refund.patch (text/plain), 1.97 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-22 21:21:08 UTC
(
hide
)
Description:
Bug 29759: Make cancelling an AR refund
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-22 21:21:08 UTC
Size:
1.97 KB
patch
obsolete
>From 9a71396e9af5110ccc0c45fd418dd45db0d9a754 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 22 Dec 2021 18:17:37 -0300 >Subject: [PATCH] Bug 29759: Make cancelling an AR refund > >This patch makes the Koha::ArticleRequest->cancel method perform a >refund if it applies. > >The sequence is: >- Find refundable (potentially partial) payments against the fee >- Generate a refund for the refundable amount >- Reduce the fee to zero >=> RESULT: the patron owes nothing, any credits applied to the debit are >refunded. > >1. Apply the unit tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/ArticleRequest.t >=> FAIL: Nothing is refunded >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! Refunds take place! >5. Try on the UI >=> SUCCESS: All good >6. Sign off :-D >--- > Koha/ArticleRequest.pm | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > >diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm >index 09b19455ae..83c88bee8c 100644 >--- a/Koha/ArticleRequest.pm >+++ b/Koha/ArticleRequest.pm >@@ -138,6 +138,34 @@ sub cancel { > $self->notes($notes) if $notes; > $self->store(); > $self->notify(); >+ >+ my $debit = $self->debit; >+ >+ if ( $debit ) { >+ # fees found, refund >+ my $account = $self->borrower->account; >+ >+ my $total_reversible = $debit->debit_offsets->filter_by_reversible->total; >+ if ( $total_reversible ) { >+ >+ $account->add_credit( >+ { >+ amount => abs $total_reversible, >+ interface => C4::Context->interface, >+ type => 'REFUND', >+ } >+ ); >+ } >+ >+ if ( $debit->amountoutstanding ) { >+ $debit->reduce({ >+ reduction_type => 'REFUND', >+ amount => $debit->amountoutstanding, >+ interface => C4::Context->interface, >+ })->discard_changes; >+ } >+ } >+ > return $self; > } > >-- >2.32.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 29759
:
128874
|
128875
|
129162
|
129163
|
129181
|
129182
|
129297
|
129298
|
129302
|
129303
|
129304
|
130093
|
130094
|
130095
|
130096