From 94617acef62d38079ed316797700faccd2edc335 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 24 Feb 2016 15:23:32 +0000 Subject: [PATCH] Bug 15902 - Remove use of recordpayment in process_koc.pl Test plan: 1) Apply this patch 2) Create an offline circ payment 3) Process the offline circ payment 4) Payment should show in Koha Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- offline_circ/process_koc.pl | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/offline_circ/process_koc.pl b/offline_circ/process_koc.pl index 8381b1bde2..187516694c 100755 --- a/offline_circ/process_koc.pl +++ b/offline_circ/process_koc.pl @@ -22,6 +22,8 @@ use strict; use warnings; use CGI qw ( -utf8 ); +use Carp; + use C4::Output; use C4::Auth; use C4::Koha; @@ -32,8 +34,9 @@ use C4::Circulation; use C4::Items; use C4::Members; use C4::Stats; -use Koha::Upload; use C4::BackgroundJob; +use Koha::Upload; +use Koha::Account; use Date::Calc qw( Add_Delta_Days Date_to_Days ); @@ -356,17 +359,25 @@ sub kocReturnItem { } sub kocMakePayment { - my ( $circ ) = @_; - my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } ); - recordpayment( $borrower->{'borrowernumber'}, $circ->{'amount'} ); - push @output, { - payment => 1, - amount => $circ->{'amount'}, - firstname => $borrower->{'firstname'}, - surname => $borrower->{'surname'}, - cardnumber => $circ->{'cardnumber'}, - borrower => $borrower->{'borrowernumber'} - }; + my ($circ) = @_; + + my $cardnumber = $circ->{cardnumber}; + my $amount = $circ->{amount}; + + my $patron = Koha::Borrowers->find( { cardnumber => $cardnumber } ); + + Koha::Account->new( { patron_id => $patron->id } ) + ->pay( { amount => $amount } ); + + push @output, + { + payment => 1, + amount => $circ->{'amount'}, + firstname => $patron->firstname, + surname => $patron->surname, + cardnumber => $patron->cardnumber, + borrower => $patron->id, + }; } =head2 _get_borrowernumber_from_barcode -- 2.39.5