Bugzilla – Attachment 128005 Details for
Bug 16223
Automatically remove any borrower debarments after a payment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16223: Call DelDebarmentsAfterPayment from Koha::Account::Line::apply
0001-Bug-16223-Call-DelDebarmentsAfterPayment-from-Koha-A.patch (text/plain), 4.59 KB, created by
Emmi Takkinen
on 2021-11-25 12:36:11 UTC
(
hide
)
Description:
Bug 16223: Call DelDebarmentsAfterPayment from Koha::Account::Line::apply
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2021-11-25 12:36:11 UTC
Size:
4.59 KB
patch
obsolete
>From de94af8b5aa88ad574072ae13d11883852312438 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Wed, 10 Nov 2021 11:45:00 +0200 >Subject: [PATCH] Bug 16223: Call DelDebarmentsAfterPayment from > Koha::Account::Line::apply > >Calling function from Koha::Account::pay missed several payment cases. >Moving it to Koha::Account::Line::apply should cover all payments. Also >reworked tests no just to test DelDebarmentsAfterPayment but to test >if debartments are lifted after pay. > >To test repeat test plan from previous patches. >Also prove t/db_dependent/Patron/Borrower_Debartments.t > >Sponsored-by: Koha-Suomi Oy >--- > Koha/Account.pm | 2 - > Koha/Account/Line.pm | 2 + > t/db_dependent/Patron/Borrower_Debarments.t | 56 +++++++++++++++++---- > 3 files changed, 48 insertions(+), 12 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 36f5b93298..50454b21db 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -102,8 +102,6 @@ sub pay { > } > ); > >- Koha::Patron::Debarments::DelDebarmentsAfterPayment({ borrowernumber => $self->{patron_id} }); >- > # NOTE: Pay historically always applied as much credit as it could to all > # existing outstanding debits, whether passed specific debits or otherwise. > if ( $payment->amountoutstanding ) { >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 9b402a1b39..85dc393158 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -701,6 +701,8 @@ sub apply { > } > }); > >+ Koha::Patron::Debarments::DelDebarmentsAfterPayment({ borrowernumber => $self->borrowernumber }); >+ > return $self; > } > >diff --git a/t/db_dependent/Patron/Borrower_Debarments.t b/t/db_dependent/Patron/Borrower_Debarments.t >index 74616a19f1..b3427e42d0 100755 >--- a/t/db_dependent/Patron/Borrower_Debarments.t >+++ b/t/db_dependent/Patron/Borrower_Debarments.t >@@ -197,22 +197,58 @@ is( Koha::Patrons->find($borrowernumber3)->debarredcomment, > > # Test removing debartments after payment > my $debarmentsRulesPref = C4::Context->preference("DebarmentsToLiftAfterPayment"); >-C4::Context->set_preference("DebarmentsToLiftAfterPayment", "Test debarment:\n outstanding: 0\nTest debarment 2:"); >+C4::Context->set_preference("DebarmentsToLiftAfterPayment", "Test debarment:\n outstanding: 0\nTest debarment 2:\n outstanding: 2"); > >-AddDebarment({ >- borrowernumber => $borrowernumber, >+my $register = $builder->build_object( { class => 'Koha::Cash::Registers' } ); >+my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+my $account = $patron2->account; >+my $fine = $account->add_debit( >+ { >+ amount => '5.00', >+ type => 'OVERDUE', >+ interface => 'cron' >+ } >+); >+ >+Koha::Patron::Debarments::AddDebarment({ >+ borrowernumber => $patron2->borrowernumber, > comment => 'Test debarment', > }); >-AddDebarment({ >- borrowernumber => $borrowernumber, >+Koha::Patron::Debarments::AddDebarment({ >+ borrowernumber => $patron2->borrowernumber, > comment => 'Test debarment 2', > }); > >-$debarments = GetDebarments({ borrowernumber => $borrowernumber }); >+$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron2->borrowernumber }); > is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); > >-DelDebarmentsAfterPayment({ borrowernumber => $borrowernumber }); >-C4::Context->set_preference("DebarmentsToLiftAfterPayment", $debarmentsRulesPref); >+my $payment1 = $account->pay( >+ { >+ cash_register => $register->id, >+ amount => '4.00', >+ credit_type => 'PAYMENT', >+ lines => [$fine] >+ } >+); >+ >+$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron2->borrowernumber }); >+is( @$debarments, 1, "GetDebarments returns 1 debarment after first payment" ); >+my $debarment_comment; >+foreach my $debarment (@$debarments){ >+ $debarment_comment = $debarment->{comment}; >+} >+is( $debarment_comment, "Test debarment", "Returned debartments comment is 'Test debarment'" ); >+ >+my $payment2 = $account->pay( >+ { >+ cash_register => $register->id, >+ amount => '1.00', >+ credit_type => 'PAYMENT', >+ lines => [$fine] >+ } >+); >+ >+$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron2->borrowernumber }); >+is( @$debarments, 0, "GetDebarments returns 0 debarments after second payment" ); > >-$debarments = GetDebarments({ borrowernumber => $borrowernumber }); >-is( @$debarments, 0, "GetDebarments returns 0 debarments after payment" ); >\ No newline at end of file >+=cut >\ No newline at end of file >-- >2.25.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 16223
:
50078
|
50084
|
99697
|
99698
|
104399
|
104400
|
114272
|
114273
|
118526
|
118572
|
118574
|
118575
|
122768
|
122769
|
127252
|
128005
|
132284
|
132285
|
132286
|
132287
|
143388
|
143389
|
143390
|
143462
|
143670
|
143671
|
143672
|
143688
|
143689
|
143690
|
143765
|
143766
|
143767
|
143768
|
143769
|
143770
|
143936
|
146051
|
146052
|
146053
|
146054
|
146055
|
146056
|
146057
|
148307
|
148308
|
148309
|
148310
|
148311
|
148312
|
148313
|
150024
|
150025
|
150026
|
150027
|
150028
|
150029
|
153024
|
153025
|
153026
|
153027
|
153028
|
153029
|
155644
|
155645
|
155646
|
155647
|
155648
|
155649
|
155650
|
156841
|
156842
|
156843
|
156844
|
156845
|
156846
|
156847
|
156848
|
156849
|
156850