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 Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
cd5212ac2f
commit
b15a15df9e
3 changed files with 23 additions and 2 deletions
|
@ -105,6 +105,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 ) {
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -691,17 +691,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 } );
|
||||
|
||||
|
@ -714,7 +728,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 {
|
||||
|
|
Loading…
Reference in a new issue