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

(-)a/Koha/Account.pm (-9 / +9 lines)
Lines 87-104 sub pay { Link Here
87
87
88
    my $userenv = C4::Context->userenv;
88
    my $userenv = C4::Context->userenv;
89
89
90
    Koha::Exceptions::Account::PaymentTypeRequired->throw()
90
    unless ( $type eq 'WRITEOFF' ) {
91
      if ( C4::Context->preference("RequirePaymentType")
91
        Koha::Exceptions::Account::PaymentTypeRequired->throw()
92
        && !defined($payment_type) );
92
            if ( C4::Context->preference("RequirePaymentType")
93
            && !defined($payment_type) );
93
94
94
    my $av = Koha::AuthorisedValues->search_with_library_limits({ category => 'PAYMENT_TYPE', authorised_value => $payment_type });
95
        my $av = Koha::AuthorisedValues->search_with_library_limits(
96
            { category => 'PAYMENT_TYPE', authorised_value => $payment_type } );
95
97
96
    if ( !$av->count && C4::Context->preference("RequirePaymentType")) {
98
        if ( !$av->count && C4::Context->preference("RequirePaymentType") ) {
97
        Koha::Exceptions::Account::InvalidPaymentType->throw(
99
            Koha::Exceptions::Account::InvalidPaymentType->throw( error => 'Invalid payment type' );
98
            error => 'Invalid payment type'
100
        }
99
        );
100
    }
101
    }
101
102
    my $manager_id = $userenv ? $userenv->{number} : undef;
102
    my $manager_id = $userenv ? $userenv->{number} : undef;
103
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
103
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
104
    my $payment = $self->payin_amount(
104
    my $payment = $self->payin_amount(
(-)a/t/db_dependent/Koha/Account.t (-2 / +11 lines)
Lines 691-697 subtest 'reconcile_balance' => sub { Link Here
691
691
692
subtest 'pay() tests' => sub {
692
subtest 'pay() tests' => sub {
693
693
694
    plan tests => 8;
694
    plan tests => 9;
695
695
696
    $schema->storage->txn_begin;
696
    $schema->storage->txn_begin;
697
697
Lines 727-732 subtest 'pay() tests' => sub { Link Here
727
    'Koha::Exceptions::Account::InvalidPaymentType',
727
    'Koha::Exceptions::Account::InvalidPaymentType',
728
      'Exception thrown for InvalidPaymentType:1 + payment_type:FOOBAR';
728
      'Exception thrown for InvalidPaymentType:1 + payment_type:FOOBAR';
729
729
730
    my $writeoff_id = $account->pay(
731
        {
732
            amount    => 10,
733
            interface => 'intranet',
734
            type      => 'WRITEOFF',
735
        }
736
    )->{payment_id};
737
    my $writeoff = Koha::Account::Lines->find($writeoff_id);
738
    is( $writeoff->payment_type, undef, "Writeoff should not have a payment_type " );
739
730
    t::lib::Mocks::mock_preference( 'RequirePaymentType', 0 );
740
    t::lib::Mocks::mock_preference( 'RequirePaymentType', 0 );
731
    my $context = Test::MockModule->new('C4::Context');
741
    my $context = Test::MockModule->new('C4::Context');
732
    $context->mock( 'userenv', { branch => $library->id } );
742
    $context->mock( 'userenv', { branch => $library->id } );
733
- 

Return to bug 34620