@@ -, +, @@ payment_type_writeoff="06" in the login portion of the account you will be using for the test. defined earlier, with a payment amount that is *not* equal to the amount outstanding for the fee. payment amount --- C4/SIP/ILS.pm | 7 +++---- C4/SIP/ILS/Transaction/FeePayment.pm | 23 ++++++++++++++++++----- C4/SIP/Sip/MsgType.pm | 5 ++++- etc/SIPconfig.xml | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) --- a/C4/SIP/ILS.pm +++ a/C4/SIP/ILS.pm @@ -247,10 +247,9 @@ sub end_patron_session { } sub pay_fee { - my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency) = @_; - my $trans; + my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff) = @_; - $trans = C4::SIP::ILS::Transaction::FeePayment->new(); + my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); $trans->transaction_id($trans_id); my $patron; @@ -259,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); + my $ok = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff ); $trans->ok($ok); return $trans; --- a/C4/SIP/ILS/Transaction/FeePayment.pm +++ a/C4/SIP/ILS/Transaction/FeePayment.pm @@ -20,7 +20,7 @@ use strict; # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use C4::Accounts qw(recordpayment makepayment); +use C4::Accounts qw(recordpayment makepayment WriteOffFee); use Koha::Account::Lines; use parent qw(C4::SIP::ILS::Transaction); @@ -47,19 +47,32 @@ sub pay { my $amt = shift; my $type = shift; my $fee_id = shift; + my $is_writeoff = shift; warn("RECORD:$borrowernumber::$amt"); - if ($fee_id) { - my $fee = Koha::Account::Lines->find( $fee_id ); + my $fee = $fee_id ? Koha::Account::Lines->find($fee_id) : undef; + + if ($is_writeoff) { # Writeoffs require a fee id to be sent + if ( $fee && $fee->amountoutstanding == $amt ) { + WriteOffFee( $borrowernumber, $fee_id, undef, undef, $amt ); + return 1; + } + else { + return 0; + } + } + + if ($fee_id) { # If a given fee is to be paid, the amount must match. This is a limitation of makepayment if ( $fee && $fee->amountoutstanding == $amt ) { makepayment( $fee_id, $borrowernumber, undef, $amt ); return 1; - } else { + } + else { return 0; } } - else { + else { # Simply pay by amount recordpayment( $borrowernumber, $amt, $type ); return 1; } --- a/C4/SIP/Sip/MsgType.pm +++ a/C4/SIP/Sip/MsgType.pm @@ -1068,6 +1068,9 @@ sub handle_fee_paid { my $status; my $resp = FEE_PAID_RESP; + my $payment_type_writeoff = $server->{account}->{payment_type_writeoff}; + my $is_writeoff = $pay_type eq $payment_type_writeoff; + $fee_amt = $fields->{ (FID_FEE_AMT) }; $inst_id = $fields->{ (FID_INST_ID) }; $patron_id = $fields->{ (FID_PATRON_ID) }; @@ -1077,7 +1080,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 ); + $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff ); $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp; $resp .= add_field( FID_INST_ID, $inst_id ); --- a/etc/SIPconfig.xml +++ a/etc/SIPconfig.xml @@ -36,7 +36,7 @@ - + --