From 68e96cf7b4569d7cb5c8bbd2acb98e2ba8468754 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 9 Oct 2024 10:58:56 +0000 Subject: [PATCH] Bug 32934: (QA follow-up) Tidy code for qa script Signed-off-by: Kyle M Hall --- C4/SIP/ILS/Transaction/Checkout.pm | 91 +++++++++++++++--------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index 78ee828db8b..708b6473a92 100644 --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ b/C4/SIP/ILS/Transaction/Checkout.pm @@ -7,7 +7,7 @@ package C4::SIP::ILS::Transaction::Checkout; use warnings; use strict; -use POSIX qw(strftime); +use POSIX qw(strftime); use C4::SIP::Sip qw( siplog ); use Data::Dumper; use CGI qw ( -utf8 ); @@ -24,47 +24,47 @@ use parent qw(C4::SIP::ILS::Transaction); # Most fields are handled by the Transaction superclass my %fields = ( - security_inhibit => 0, - due => undef, - renew_ok => 0, - ); + security_inhibit => 0, + due => undef, + renew_ok => 0, +); sub new { - my $class = shift;; - my $self = $class->SUPER::new(); - foreach my $element (keys %fields) { + my $class = shift; + my $self = $class->SUPER::new(); + foreach my $element ( keys %fields ) { $self->{_permitted}->{$element} = $fields{$element}; } - @{$self}{keys %fields} = values %fields; + @{$self}{ keys %fields } = values %fields; return bless $self, $class; } sub do_checkout { - my $self = shift; - my $account = shift; - my $no_block_due_date = shift; - siplog( 'LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..." ); - my $shelf = $self->{item}->hold_attached; - my $barcode = $self->{item}->id; - my $patron = Koha::Patrons->find( $self->{patron}->{borrowernumber} ); - my $overridden_duedate; # usually passed as undef to AddIssue - my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout}; - my $allow_additional_materials_checkout = $account->{allow_additional_materials_checkout}; - my ( $issuingimpossible, $needsconfirmation, $messages ) = _can_we_issue( $patron, $barcode, 0 ); - - if ( $no_block_due_date ) { - my $year = substr($no_block_due_date,0,4); - my $month = substr($no_block_due_date,4,2); - my $day = substr($no_block_due_date,6,2); - my $hour = substr($no_block_due_date,12,2); - my $minute = substr($no_block_due_date,14,2); - my $second = substr($no_block_due_date,16,2); + my $self = shift; + my $account = shift; + my $no_block_due_date = shift; + siplog( 'LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..." ); + my $shelf = $self->{item}->hold_attached; + my $barcode = $self->{item}->id; + my $patron = Koha::Patrons->find( $self->{patron}->{borrowernumber} ); + my $overridden_duedate; # usually passed as undef to AddIssue + my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout}; + my $allow_additional_materials_checkout = $account->{allow_additional_materials_checkout}; + my ( $issuingimpossible, $needsconfirmation, $messages ) = _can_we_issue( $patron, $barcode, 0 ); + + if ($no_block_due_date) { + my $year = substr( $no_block_due_date, 0, 4 ); + my $month = substr( $no_block_due_date, 4, 2 ); + my $day = substr( $no_block_due_date, 6, 2 ); + my $hour = substr( $no_block_due_date, 12, 2 ); + my $minute = substr( $no_block_due_date, 14, 2 ); + my $second = substr( $no_block_due_date, 16, 2 ); my $iso = "$year-$month-$day $hour:$minute:$second"; $no_block_due_date = dt_from_string( $iso, "iso" ); } - my $noerror=1; # If set to zero we block the issue + my $noerror = 1; # If set to zero we block the issue if ( keys %{$issuingimpossible} ) { foreach ( keys %{$issuingimpossible} ) { @@ -136,30 +136,33 @@ sub do_checkout { } } my $itemnumber = $self->{item}->{itemnumber}; - my ($fee, undef) = GetIssuingCharges($itemnumber, $patron->borrowernumber); + my ( $fee, undef ) = GetIssuingCharges( $itemnumber, $patron->borrowernumber ); if ( $fee > 0 ) { $self->{sip_fee_type} = '06'; - $self->{fee_amount} = sprintf '%.2f', $fee; - if ($self->{fee_ack} eq 'N' ) { + $self->{fee_amount} = sprintf '%.2f', $fee; + if ( $self->{fee_ack} eq 'N' ) { $noerror = 0; } } if ( $noerror == 0 && !$no_block_due_date ) { - $self->ok(0); - return $self; - } + $self->ok(0); + return $self; + } - if ( $no_block_due_date ) { + if ($no_block_due_date) { $overridden_duedate = $no_block_due_date; - my ( $msg, $checkout ) = ProcessOfflineIssue({ - cardnumber => $patron->cardnumber, - barcode => $barcode, - due_date => $no_block_due_date, - timestamp => dt_from_string, - }); - $self->{due} = $self->duedatefromissue($checkout, $itemnumber); + my ( $msg, $checkout ) = ProcessOfflineIssue( + { + cardnumber => $patron->cardnumber, + barcode => $barcode, + due_date => $no_block_due_date, + timestamp => dt_from_string, + } + ); + $self->{due} = $self->duedatefromissue( $checkout, $itemnumber ); } else { + # can issue my $recall_id; foreach ( keys %{$messages} ) { @@ -179,7 +182,7 @@ sub _can_we_issue { my ( $patron, $barcode, $pref ) = @_; my ( $issuingimpossible, $needsconfirmation, $alerts, $messages ) = - CanBookBeIssued( $patron, $barcode, undef, 0, $pref ); + CanBookBeIssued( $patron, $barcode, undef, 0, $pref ); for my $href ( $issuingimpossible, $needsconfirmation ) { # some data is returned using lc keys we only -- 2.39.5 (Apple Git-154)