From 160707e2398f12cd4235c1b79aec7f27194be5c1 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 3 Dec 2025 13:13:52 -0500 Subject: [PATCH] Bug 41369: SIP payments have no branchcode For SIP based payments, no branchcode is recorded for the corresponding credit. Koha should be recording the institution id (i.e. branchcode) for SIP payments. Test plan: 1) Apply this patch 2) prove t/db_dependent/SIP/Transaction.t Signed-off-by: David Nind --- C4/SIP/ILS.pm | 4 ++-- C4/SIP/ILS/Transaction/FeePayment.pm | 2 ++ C4/SIP/Sip/MsgType.pm | 4 ++-- t/db_dependent/SIP/Transaction.t | 9 ++++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 1dd3453bd2..174a8eacaf 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -358,7 +358,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, - $disallow_overpayment, $register_id + $disallow_overpayment, $register_id, $inst_id ) = @_; my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); @@ -372,7 +372,7 @@ sub pay_fee { } my $trans_result = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff, $disallow_overpayment, - $register_id + $register_id, $inst_id ); my $ok = $trans_result->{ok}; $trans->ok($ok); diff --git a/C4/SIP/ILS/Transaction/FeePayment.pm b/C4/SIP/ILS/Transaction/FeePayment.pm index d8824f2cad..ff1b801e2e 100644 --- a/C4/SIP/ILS/Transaction/FeePayment.pm +++ b/C4/SIP/ILS/Transaction/FeePayment.pm @@ -50,6 +50,7 @@ sub pay { my $is_writeoff = shift; my $disallow_overpayment = shift; my $register_id = shift; + my $inst_id = shift; my $type = $is_writeoff ? 'WRITEOFF' : 'PAYMENT'; @@ -66,6 +67,7 @@ sub pay { payment_type => 'SIP' . $sip_type, interface => C4::Context->interface, cash_register => $register_id, + library_id => $inst_id, }; if ($fee_id) { diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index d77c8088d1..37cb7d1a7e 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -1237,8 +1237,8 @@ sub handle_fee_paid { $ils->check_inst_id( $inst_id, "handle_fee_paid" ); my $pay_result = $ils->pay_fee( - $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, - $is_writeoff, $disallow_overpayment, $register_id + $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, + $is_writeoff, $disallow_overpayment, $register_id, $ils->institution ); $status = $pay_result->{status}; my $pay_response = $pay_result->{pay_response}; diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index 5196d4b3bf..1d91c693ab 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -129,7 +129,9 @@ subtest fill_holds_at_checkout => sub { subtest "FeePayment->pay tests" => sub { - plan tests => 5; + plan tests => 6; + + my $inst_id = $builder->build_object( { class => 'Koha::Libraries' } )->id; # Create a borrower and add some outstanding debts to their account my $patron = $builder->build( { source => 'Borrower' } ); @@ -152,7 +154,7 @@ subtest "FeePayment->pay tests" => sub { my $pay_type = '00'; # 00 - Cash, 01 - VISA, 02 - Creditcard my $ok = $trans->pay( $patron->{borrowernumber}, 100, $pay_type, $debt1->id, 0, - 0 + 0, undef, $inst_id ); ok( $ok, "FeePayment transaction succeeded" ); $debt1->discard_changes; @@ -163,7 +165,8 @@ subtest "FeePayment->pay tests" => sub { my $offsets = Koha::Account::Offsets->search( { debit_id => $debt1->id, credit_id => { '!=' => undef } } ); is( $offsets->count, 1, "FeePayment produced an offset line correctly" ); my $credit = $offsets->next->credit; - is( $credit->payment_type, 'SIP00', "Payment type was set correctly" ); + is( $credit->payment_type, 'SIP00', "Payment type was set correctly" ); + is( $credit->branchcode, $inst_id, "Branchcode was set correctly" ); }; subtest cancel_hold => sub { -- 2.39.5