Browse Source

Bug 16899: Add ability to disallow overpayments

Some SIP services ( such as Comprise ) require that an attempt at
over-paying a patron's account via SIP2 should fail, rather than create
a credit on the account. We should make this a configurable option on a
per-login basis in the SIP2 config file.

Test Plan:
1) Apply this patch
2) Enable the new parameter
   disallow_overpayment="1"
   for the login to be used in this test.
3) Restart your SIP server
4) Create or find a patron with fines
5) Attempt to send a payment via SIP for more than what the
   patron's balance is
6) Note the response indicates a payment failure
7) Attempt to send a payment via SIP for the account balance or
   less
8) Note the response indicates the payment has succeeded
9) Verify in Koha that the payment was processed

Signed-off-by: Rhonda Kuiper <kuiper@roundrocktexas.gov>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
17.11.x
Kyle Hall 6 years ago
committed by Jonathan Druart
parent
commit
22249e4ced
  1. 4
      C4/SIP/ILS.pm
  2. 17
      C4/SIP/ILS/Transaction/FeePayment.pm
  3. 4
      C4/SIP/Sip/MsgType.pm
  4. 2
      etc/SIPconfig.xml

4
C4/SIP/ILS.pm

@ -250,7 +250,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();
@ -261,7 +261,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;

17
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,10 @@ sub pay {
my $account = Koha::Account->new( { patron_id => $borrowernumber } );
if ($disallow_overpayment) {
return 0 if $account->balance < $amt;
}
if ($fee_id) {
my $fee = Koha::Account::Lines->find($fee_id);
if ( $fee ) {

4
C4/SIP/Sip/MsgType.pm

@ -1063,7 +1063,9 @@ 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} || q{};
my $is_writeoff = $pay_type eq $payment_type_writeoff;
$fee_amt = $fields->{ (FID_FEE_AMT) };
@ -1075,7 +1077,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 );

2
etc/SIPconfig.xml

@ -44,7 +44,7 @@
</listeners>
<accounts>
<login id="term1" password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" />
<login id="staff" password="staff" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" disallow_overpayment="1" />
<login id="koha" password="koha" delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
<login id="koha2" password="koha" institution="kohalibrary2" terminator="CR" />
<login id="lpl-sc" password="1234" institution="LPL" />

Loading…
Cancel
Save