View | Details | Raw Unified | Return to bug 33176
Collapse All | Expand All

(-)a/Koha/Account.pm (+4 lines)
Lines 105-110 sub pay { Link Here
105
        }
105
        }
106
    );
106
    );
107
107
108
    Koha::Exceptions::Account::PaymentTypeRequired->throw()
109
      if ( C4::Context->preference("RequirePaymentType")
110
        && !defined($payment_type) );
111
108
    # NOTE: Pay historically always applied as much credit as it could to all
112
    # NOTE: Pay historically always applied as much credit as it could to all
109
    # existing outstanding debits, whether passed specific debits or otherwise.
113
    # existing outstanding debits, whether passed specific debits or otherwise.
110
    if ( $payment->amountoutstanding ) {
114
    if ( $payment->amountoutstanding ) {
(-)a/Koha/Exceptions/Account.pm (+4 lines)
Lines 47-52 use Exception::Class ( Link Here
47
    'Koha::Exceptions::Account::RegisterRequired' => {
47
    'Koha::Exceptions::Account::RegisterRequired' => {
48
        isa         => 'Koha::Exceptions::Account',
48
        isa         => 'Koha::Exceptions::Account',
49
        description => 'Account transaction requires a cash register'
49
        description => 'Account transaction requires a cash register'
50
    },
51
    'Koha::Exceptions::Account::PaymentTypeRequired' => {
52
        isa         => 'Koha::Exceptions::Account',
53
        description => 'Account transaction requires a payment type'
50
    }
54
    }
51
);
55
);
52
56
(-)a/t/db_dependent/Koha/Account.t (-3 / +15 lines)
Lines 691-707 subtest 'reconcile_balance' => sub { Link Here
691
691
692
subtest 'pay() tests' => sub {
692
subtest 'pay() tests' => sub {
693
693
694
    plan tests => 6;
694
    plan tests => 7;
695
695
696
    $schema->storage->txn_begin;
696
    $schema->storage->txn_begin;
697
697
698
    # Disable renewing upon fine payment
698
    # Disable renewing upon fine payment
699
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
699
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
700
700
701
701
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
702
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
702
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
703
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
703
    my $account = $patron->account;
704
    my $account = $patron->account;
704
705
706
    t::lib::Mocks::mock_preference( 'RequirePaymentType', 1 );
707
    throws_ok {
708
        $account->pay(
709
            {
710
                amount       => 5,
711
                interface    => 'intranet'
712
            }
713
        );
714
    }
715
    'Koha::Exceptions::Account::PaymentTypeRequired',
716
      'Exception thrown for RequirePaymentType:1 + payment_type:undef';
717
718
    t::lib::Mocks::mock_preference( 'RequirePaymentType', 0 );
705
    my $context = Test::MockModule->new('C4::Context');
719
    my $context = Test::MockModule->new('C4::Context');
706
    $context->mock( 'userenv', { branch => $library->id } );
720
    $context->mock( 'userenv', { branch => $library->id } );
707
721
Lines 714-720 subtest 'pay() tests' => sub { Link Here
714
    my $credit_2    = Koha::Account::Lines->find( $credit_2_id );
728
    my $credit_2    = Koha::Account::Lines->find( $credit_2_id );
715
729
716
    is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' );
730
    is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' );
717
718
    # Enable cash registers
731
    # Enable cash registers
719
    t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 );
732
    t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 );
720
    throws_ok {
733
    throws_ok {
721
- 

Return to bug 33176