Bugzilla – Attachment 149617 Details for
Bug 33176
Improve enforcing of RequirePaymentType
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33176: Handle RequirePaymentType
Bug-33176-Handle-RequirePaymentType.patch (text/plain), 3.61 KB, created by
Lucas Gass (lukeg)
on 2023-04-13 17:34:14 UTC
(
hide
)
Description:
Bug 33176: Handle RequirePaymentType
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2023-04-13 17:34:14 UTC
Size:
3.61 KB
patch
obsolete
>From 4890019008843ff7b50fd773030d0c784b91e87e Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 13 Apr 2023 17:28:24 +0000 >Subject: [PATCH] Bug 33176: Handle RequirePaymentType > >Test plan: > >1. Turn on RequirePaymentType >2. Create a manual invocie on a patron account >3. Go to pay it, 'Payment type:' is marked as required. >4. In the inscept the select input ( #payment_type ) with your browser's dev tools. Removed the required attribute. >5. You are able to make the payment without a payment type. >6. Apply patch and restart_all >7. Try 4-5 again. This time you should get a 500 error and the payment should not go through. >8. Turn RequirePaymentType off. Try a payment with a payment type, you shoud be successful. >9. Make sure tests will pass: > >prove -v t/db_dependent/Koha/Account.t >--- > Koha/Account.pm | 4 ++++ > Koha/Exceptions/Account.pm | 4 ++++ > t/db_dependent/Koha/Account.t | 17 +++++++++++++++-- > 3 files changed, 23 insertions(+), 2 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index e37e646596..030802468d 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -102,6 +102,10 @@ sub pay { > } > ); > >+ Koha::Exceptions::Account::PaymentTypeRequired->throw() >+ if ( C4::Context->preference("RequirePaymentType") >+ && !defined($payment_type) ); >+ > # 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/Exceptions/Account.pm b/Koha/Exceptions/Account.pm >index e22d5ee521..26bbac593c 100644 >--- a/Koha/Exceptions/Account.pm >+++ b/Koha/Exceptions/Account.pm >@@ -47,6 +47,10 @@ use Exception::Class ( > 'Koha::Exceptions::Account::RegisterRequired' => { > isa => 'Koha::Exceptions::Account', > description => 'Account transaction requires a cash register' >+ }, >+ 'Koha::Exceptions::Account::PaymentTypeRequired' => { >+ isa => 'Koha::Exceptions::Account', >+ description => 'Account transaction requires a payment type' > } > ); > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index fbdb4414c6..c6c60ea911 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -665,17 +665,31 @@ subtest 'reconcile_balance' => sub { > > subtest 'pay() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; > > $schema->storage->txn_begin; > > # Disable renewing upon fine payment > t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 ); > >+ > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $library = $builder->build_object({ class => 'Koha::Libraries' }); > my $account = $patron->account; > >+ t::lib::Mocks::mock_preference( 'RequirePaymentType', 1 ); >+ throws_ok { >+ $account->pay( >+ { >+ amount => 5, >+ interface => 'intranet' >+ } >+ ); >+ } >+ 'Koha::Exceptions::Account::PaymentTypeRequired', >+ 'Exception thrown for RequirePaymentType:1 + payment_type:undef'; >+ >+ t::lib::Mocks::mock_preference( 'RequirePaymentType', 0 ); > my $context = Test::MockModule->new('C4::Context'); > $context->mock( 'userenv', { branch => $library->id } ); > >@@ -688,7 +702,6 @@ subtest 'pay() tests' => sub { > my $credit_2 = Koha::Account::Lines->find( $credit_2_id ); > > is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' ); >- > # Enable cash registers > t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 ); > throws_ok { >-- >2.30.2
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 33176
:
149617
|
149619
|
150254
|
150255
|
152131
|
152203
|
152204
|
152205
|
152271
|
152272
|
152273