From f17d1492734118f80bad5497aed353027d5960a6 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Tue, 12 Jul 2022 07:46:31 -0400 Subject: [PATCH] Bug 12225: Re-implement no block flag for checkouts Test Plan ( assuming Koha Testing Docker or kohadevbox ): 1) Check out master 2) Start the SIP server ( edit the SIP config koha instutution to be "CPL" instead of "kohalibrary" ) 3) Telnet to 6001 4) Send 9300CNkoha|COkoha|CPCPL| 5) Send 11YY20220711 16350220250711 163502AOCPL|AA23529000035676|AB39999000001396|ACkoha|BON|BIN| 6) Note the due date for the checkout in Koha is not in the year 2025: Henry Acevedo (23529000035676) checked out Philippics. by Cicero, Marcus Tullius. 39999000001396 7) Apply this patch set 8) Restart all the things! 9) Check in the checkout 10) Repeat steps 3 through 5 11) Note the due date is now in 2025! Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 51eb6e65540e0440a28c80343319a8a895d509df) Signed-off-by: Lucas Gass --- C4/SIP/ILS.pm | 4 ++-- C4/SIP/ILS/Transaction/Checkout.pm | 22 +++++++++++++++++++++- C4/SIP/Sip/MsgType.pm | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index e6c75671be..ff9ee74067 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -121,7 +121,7 @@ sub offline_ok { # the response. # sub checkout { - my ( $self, $patron_id, $item_id, $sc_renew, $fee_ack, $account ) = @_; + my ( $self, $patron_id, $item_id, $sc_renew, $fee_ack, $account, $no_block_due_date ) = @_; my ( $patron, $item, $circ ); $circ = C4::SIP::ILS::Transaction::Checkout->new(); # BEGIN TRANSACTION @@ -153,7 +153,7 @@ sub checkout { $circ->screen_msg("Item checked out to another patron"); } else { - $circ->do_checkout($account); + $circ->do_checkout($account, $no_block_due_date); if ( $circ->ok ) { # If the item is already associated with this patron, then diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index b9fa51979e..c1c1e18eeb 100644 --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ b/C4/SIP/ILS/Transaction/Checkout.pm @@ -17,7 +17,7 @@ use C4::SIP::ILS::Transaction; use C4::Context; use C4::Circulation qw( AddIssue GetIssuingCharges CanBookBeIssued ); use C4::Members; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use parent qw(C4::SIP::ILS::Transaction); @@ -41,6 +41,7 @@ sub new { 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; @@ -49,6 +50,18 @@ sub do_checkout { my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout}; my ($issuingimpossible, $needsconfirmation) = _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 if (keys %{$issuingimpossible}) { foreach (keys %{$issuingimpossible}) { @@ -113,10 +126,17 @@ sub do_checkout { $noerror = 0; } } + + if ( $no_block_due_date ) { + $overridden_duedate = $no_block_due_date; + $noerror = 1; + } + unless ($noerror) { $self->ok(0); return $self; } + # can issue my $issue = AddIssue( $patron->unblessed, $barcode, $overridden_duedate, 0 ); $self->{due} = $self->duedatefromissue($issue, $itemnumber); diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 0de5f1facc..74e7dfff24 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -532,7 +532,7 @@ sub handle_checkout { # not a lot we can do about it siplog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} ); - $status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date ); + $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack, $account, $nb_due_date ); } else { # Does the transaction date really matter for items that are -- 2.39.5