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

(-)a/Koha/Account.pm (+4 lines)
Lines 102-107 sub pay { Link Here
102
        }
102
        }
103
    );
103
    );
104
104
105
    Koha::Exceptions::Account::PaymentTypeRequired->throw()
106
      if ( C4::Context->preference("RequirePaymentType")
107
        && !defined($payment_type) );
108
105
    # NOTE: Pay historically always applied as much credit as it could to all
109
    # NOTE: Pay historically always applied as much credit as it could to all
106
    # existing outstanding debits, whether passed specific debits or otherwise.
110
    # existing outstanding debits, whether passed specific debits or otherwise.
107
    if ( $payment->amountoutstanding ) {
111
    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 665-681 subtest 'reconcile_balance' => sub { Link Here
665
665
666
subtest 'pay() tests' => sub {
666
subtest 'pay() tests' => sub {
667
667
668
    plan tests => 6;
668
    plan tests => 7;
669
669
670
    $schema->storage->txn_begin;
670
    $schema->storage->txn_begin;
671
671
672
    # Disable renewing upon fine payment
672
    # Disable renewing upon fine payment
673
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
673
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
674
674
675
675
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
676
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
676
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
677
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
677
    my $account = $patron->account;
678
    my $account = $patron->account;
678
679
680
    t::lib::Mocks::mock_preference( 'RequirePaymentType', 1 );
681
    throws_ok {
682
        $account->pay(
683
            {
684
                amount       => 5,
685
                interface    => 'intranet'
686
            }
687
        );
688
    }
689
    'Koha::Exceptions::Account::PaymentTypeRequired',
690
      'Exception thrown for RequirePaymentType:1 + payment_type:undef';
691
692
    t::lib::Mocks::mock_preference( 'RequirePaymentType', 0 );
679
    my $context = Test::MockModule->new('C4::Context');
693
    my $context = Test::MockModule->new('C4::Context');
680
    $context->mock( 'userenv', { branch => $library->id } );
694
    $context->mock( 'userenv', { branch => $library->id } );
681
695
Lines 688-694 subtest 'pay() tests' => sub { Link Here
688
    my $credit_2    = Koha::Account::Lines->find( $credit_2_id );
702
    my $credit_2    = Koha::Account::Lines->find( $credit_2_id );
689
703
690
    is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' );
704
    is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' );
691
692
    # Enable cash registers
705
    # Enable cash registers
693
    t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 );
706
    t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 );
694
    throws_ok {
707
    throws_ok {
695
- 

Return to bug 33176