@@ -, +, @@ disallow_overpayment="1" for the login to be used in this test. patron's balance is less --- C4/SIP/ILS.pm | 4 ++-- C4/SIP/ILS/Transaction/FeePayment.pm | 18 ++++++++++++------ C4/SIP/Sip/MsgType.pm | 3 ++- Koha/Account/Lines.pm | 10 ++++++++++ etc/SIPconfig.xml | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) --- a/C4/SIP/ILS.pm +++ a/C4/SIP/ILS.pm @@ -247,7 +247,7 @@ sub end_patron_session { } sub pay_fee { - my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff) = @_; + my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment ) = @_; my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); @@ -258,7 +258,7 @@ sub pay_fee { $trans->screen_msg('Invalid patron barcode.'); return $trans; } - my $ok = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff ); + my $ok = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff, $disallow_overpayment ); $trans->ok($ok); return $trans; --- a/C4/SIP/ILS/Transaction/FeePayment.pm +++ a/C4/SIP/ILS/Transaction/FeePayment.pm @@ -42,12 +42,13 @@ sub new { } sub pay { - my $self = shift; - my $borrowernumber = shift; - my $amt = shift; - my $sip_type = shift; - my $fee_id = shift; - my $is_writeoff = shift; + my $self = shift; + my $borrowernumber = shift; + my $amt = shift; + my $sip_type = shift; + my $fee_id = shift; + my $is_writeoff = shift; + my $disallow_overpayment = shift; my $type = $is_writeoff ? 'writeoff' : undef; @@ -55,6 +56,11 @@ sub pay { my $account = Koha::Account->new( { patron_id => $borrowernumber } ); + if ($disallow_overpayment) { + my $balance = $patron->account_balance(); + return 0 if $account->balance < $amt; + } + if ($fee_id) { my $fee = Koha::Account::Lines->find($fee_id); if ( $fee && $fee->amountoutstanding == $amt ) { --- a/C4/SIP/Sip/MsgType.pm +++ a/C4/SIP/Sip/MsgType.pm @@ -1068,6 +1068,7 @@ sub handle_fee_paid { my $status; my $resp = FEE_PAID_RESP; + my $disallow_overpayment = $server->{account}->{disallow_overpayment}; my $payment_type_writeoff = $server->{account}->{payment_type_writeoff}; my $is_writeoff = $pay_type eq $payment_type_writeoff; @@ -1080,7 +1081,7 @@ sub handle_fee_paid { $ils->check_inst_id( $inst_id, "handle_fee_paid" ); - $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff ); + $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment ); $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp; $resp .= add_field( FID_INST_ID, $inst_id ); --- a/Koha/Account/Lines.pm +++ a/Koha/Account/Lines.pm @@ -36,6 +36,16 @@ Koha::Account::Lines - Koha Account Line Object set class =cut +=head3 amount_outstanding + +=cut + +sub amount_outstanding { + my ( $self ) = @_; + + return $self->_resultset()->get_column('amountoutstanding')->sum(); +} + =head3 type =cut --- a/etc/SIPconfig.xml +++ a/etc/SIPconfig.xml @@ -44,7 +44,7 @@ - + --