Bugzilla – Attachment 78552 Details for
Bug 21327
Add a Modular Koha Core design
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21327: Implement Core::Circulation in admin and SIP
Bug-21327-Implement-CoreCirculation-in-admin-and-S.patch (text/plain), 14.56 KB, created by
Benjamin Rokseth
on 2018-09-10 21:44:51 UTC
(
hide
)
Description:
Bug 21327: Implement Core::Circulation in admin and SIP
Filename:
MIME Type:
Creator:
Benjamin Rokseth
Created:
2018-09-10 21:44:51 UTC
Size:
14.56 KB
patch
obsolete
>From a3ebd0f6faf660e49da01dd3b5c9d56a20f9465f Mon Sep 17 00:00:00 2001 >From: Benjamin Rokseth <benjamin.rokseth@deichman.no> >Date: Sun, 9 Sep 2018 23:26:24 +0200 >Subject: [PATCH] Bug 21327: Implement Core::Circulation in admin and SIP > >covered: > >C4::SIP::ILS::Transaction::Checkin->do_checkin >C4::SIP::ILS::Transaction::Checkout->do_checkout >C4::SIP::Sip::MsgType->handle_checkout (add branch) >circ/circulation.pl >circ/renew.pl >circ/returns.pl >--- > C4/SIP/ILS/Transaction/Checkin.pm | 18 ++++++++- > C4/SIP/ILS/Transaction/Checkout.pm | 76 ++++++++++++++++++++++---------------- > C4/SIP/Sip/MsgType.pm | 3 +- > circ/circulation.pl | 23 +++++++++++- > circ/renew.pl | 25 ++++++++++++- > circ/returns.pl | 28 +++++++++++++- > 6 files changed, 136 insertions(+), 37 deletions(-) > >diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm >index a35009f..32a8311 100644 >--- a/C4/SIP/ILS/Transaction/Checkin.pm >+++ b/C4/SIP/ILS/Transaction/Checkin.pm >@@ -65,7 +65,23 @@ sub do_checkin { > . substr( $return_date, 16, 2 ); > > $debug and warn "do_checkin() calling AddReturn($barcode, $branch)"; >- my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date); >+ >+ # BEG Core::Circulation OVERRIDE >+ #my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date); >+ use C4::Context; >+ use Koha::Items; >+ use Koha::Libraries; >+ use Class::Load qw(load_optional_class); >+ my $core = C4::Context->config("core_modules")->{sip} or die "Missing core_modules->sip config"; >+ my $class = load_optional_class($core) ? $core : "Core::Circulation::SIP"; >+ my $lib = Koha::Libraries->find($branch); >+ my $item = Koha::Items->find($self->{item}->{itemnumber}); >+ my $circ = $class->new({ item => $item, library => $lib }); >+ my $return = $circ->Checkin($return_date); # SHOULD WE TRUST SIP RETURN DATE? >+ my $messages = $circ->{messages}; >+ my $iteminformation = $circ->{iteminformation}; >+ # END Core::Circulation OVERRIDE >+ > $self->alert(!$return); > # ignoring messages: NotIssued, WasLost, WasTransfered > >diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm >index 23cdec9..c393ac5 100644 >--- a/C4/SIP/ILS/Transaction/Checkout.pm >+++ b/C4/SIP/ILS/Transaction/Checkout.pm >@@ -48,18 +48,31 @@ sub new { > sub do_checkout { > my $self = shift; > syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout..."); >- my $pending = $self->{item}->pending_queue; >- my $shelf = $self->{item}->hold_shelf; >- my $barcode = $self->{item}->id; >- my $patron_barcode = $self->{patron}->id; >- my $overridden_duedate; # usually passed as undef to AddIssue >- $debug and warn "do_checkout: patron (" . $patron_barcode . ")"; >- my $patron = Koha::Patrons->find( { cardnumber => $patron_barcode } ); >- my $borrower = $patron->unblessed; >- $debug and warn "do_checkout borrower: . " . Dumper $borrower; >- my ($issuingimpossible, $needsconfirmation) = _can_we_issue($patron, $barcode, >- C4::Context->preference("AllowItemsOnHoldCheckout") >- ); >+ >+ # BEG Core::Circulation OVERRIDE - Checkout >+ # NOTE: HAD TO ADD BRANCH TO MsgType::handle_checkout and ILS::checkout SINCE THERE IS NO BRANCH CONTEXT IN SIP >+ use Koha::Items; >+ use Koha::Libraries; >+ my $core = C4::Context->config("core_modules")->{sip} or die "Missing core_modules->sip config"; >+ my $class = load_optional_class($core) ? $core : "Core::Circulation::SIP"; >+ my $library = Koha::Libraries->find($self->{branch}); >+ my $item = Koha::Items->find($self->{item}->{itemnumber}); >+ my $patron = Koha::Patrons->find({cardnumber => $self->{patron}->id}); >+ my $circ = $class->new({ >+ item => $item, >+ library => $library, >+ patron => $patron, >+ }); >+ $debug and warn "do_checkout: patron (" . $self->{patron}->id . ")"; >+ my ($issuingimpossible, $needsconfirmation, $alerts, $messages) = $circ->canItemBeIssued(); >+ my $pending = $self->{item}->pending_queue; >+ my $shelf = $self->{item}->hold_shelf; >+ my $overridden_duedate; # usually passed as undef to AddIssue >+ #use Data::Dumper; warn Dumper($circ->{messages}); >+ #use Data::Dumper; warn Dumper($issuingimpossible); >+ #use Data::Dumper; warn Dumper($needsconfirmation); >+ #use Data::Dumper; warn Dumper($messages); >+ # END Core::Circulation OVERRIDE > > my $noerror=1; # If set to zero we block the issue > if (keys %{$issuingimpossible}) { >@@ -74,7 +87,7 @@ sub do_checkout { > if ($confirmation eq 'RENEW_ISSUE'){ > $self->screen_msg("Item already checked out to you: renewing item."); > } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') { >- my $x = $self->{item}->available($patron_barcode); >+ my $x = $self->{item}->available($self->{patron}->id); > if ($x) { > $self->screen_msg("Item was reserved for you."); > } else { >@@ -90,7 +103,7 @@ sub do_checkout { > $noerror = 0; > last; > } elsif ($confirmation eq 'HIGHHOLDS') { >- $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate}; >+ $overridden_duedate = $needsconfirmation->{HIGHHOLDS}->{returndate}; > $self->screen_msg('Loan period reduced for high-demand item'); > } elsif ($confirmation eq 'RENTALCHARGE') { > if ($self->{fee_ack} ne 'Y') { >@@ -106,6 +119,7 @@ sub do_checkout { > } > } > } >+ # TODO: THIS SHOULD NOT BE HANDLED HERE > my $itemnumber = $self->{item}->{itemnumber}; > foreach (@$shelf) { > $debug and warn "shelf has ($_->{itemnumber} for $_->{borrowernumber}). this is ($itemnumber, $self->{patron}->{borrowernumber})"; >@@ -116,6 +130,7 @@ sub do_checkout { > $self->screen_msg("Item is on hold shelf for another patron."); > $noerror = 0; > } >+ # TODO: WE DONT USE ISSUING CHARGES > my ($fee, undef) = GetIssuingCharges($itemnumber, $self->{patron}->{borrowernumber}); > if ( $fee > 0 ) { > $self->{sip_fee_type} = '06'; >@@ -129,23 +144,22 @@ sub do_checkout { > $self->ok(0); > return $self; > } >- # Fill any reserves the patron had on the item. >- # TODO: this logic should be pulled internal to AddIssue for all Koha. >- $debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]'; >- foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) { >- $debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): " >- . sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate}); >- ModReserveFill($_); >- # TODO: adjust representation in $self->item >- } >- # can issue >- $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n" >- # . "w/ \$borrower: " . Dumper($borrower) >- . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv); >- my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 ); >- $self->{due} = $self->duedatefromissue($issue, $itemnumber); >- >- $self->ok(1); >+ # BEG Core::Circulation OVERRIDE - Checkout >+ # Fill any reserves the patron had on the item. >+ # TODO: this logic should be pulled internal to AddIssue for all Koha. >+ #$debug and warn "pending_queue: " . (@$pending) ? Dumper($pending) : '[]'; >+ #foreach (grep {$_->{borrowernumber} eq $self->{patron}->{borrowernumber}} @$pending) { >+ # $debug and warn "Filling reserve (borrowernumber,biblionumber,reservedate): " >+ # . sprintf("(%s,%s,%s)\n",$_->{borrowernumber},$_->{biblionumber},$_->{reservedate}); >+ # ModReserveFill($_); >+ #} >+ >+ #my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 ); >+ $circ->Checkout(); >+ $self->{due} = $circ->{checkout}->date_due; >+ # END Core::Circulation OVERRIDE >+ >+ $self->ok(1); > return $self; > } > >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index 9ec126e..b8da73e 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -514,7 +514,8 @@ sub handle_checkout { > > # Does the transaction date really matter for items that are > # checkout out while the terminal is online? I'm guessing 'no' >- $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack ); >+ my $branch = $fields->{(FID_CURRENT_LOCN)} ? $fields->{(FID_CURRENT_LOCN)} : $ils->institution; >+ $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $fee_ack, $branch ); > } > > $item = $status->item; >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 5c858f7..26bd6ee 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -421,7 +421,28 @@ if (@$barcodes) { > } > unless($confirm_required) { > my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; >- my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } ); >+ >+ # BEG Core::Circulation OVERRIDE - USE Checkin >+ # my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } ); >+ my $class; >+ { >+ use Class::Load qw(load_optional_class); >+ my $core_modules = C4::Context->config("core_modules"); >+ $core_modules or warn "Missing core_modules config in koha-conf.xml, running default circulation"; >+ $core_modules->{circulation} or warn "Missing core_modules->circulation running default circulation"; >+ $class = $core_modules->{circulation} ? $core_modules->{circulation} : "Core::Community::Circulation"; >+ load_optional_class($class) or die "Failed loading $class, cannot continue"; >+ } >+ my $library = Koha::Libraries->find($branch); >+ my $circ = $class->new({ >+ item => $item, >+ library => $library, >+ patron => $patron, >+ }); >+ $circ->Checkout( $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } ); >+ my $issue = $circ->{checkout}; >+ # END Core::Circulation OVERRIDE >+ > $template_params->{issue} = $issue; > $session->clear('auto_renew'); > $inprocess = 1; >diff --git a/circ/renew.pl b/circ/renew.pl >index 246c266..c0de619 100755 >--- a/circ/renew.pl >+++ b/circ/renew.pl >@@ -92,7 +92,30 @@ if ($barcode) { > } > if ($can_renew) { > my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; >- my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode ); >+ >+ ### BEG Core::Circulation OVERRIDE - Renew >+ # my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode ); >+ my $class; >+ { >+ use Class::Load qw(load_optional_class); >+ my $core_modules = C4::Context->config("core_modules"); >+ $core_modules or warn "Missing core_modules config in koha-conf.xml, running default circulation"; >+ $core_modules->{circulation} or warn "Missing core_modules->circulation running default circulation"; >+ $class = $core_modules->{circulation} ? $core_modules->{circulation} : "Core::Community::Circulation"; >+ load_optional_class($class) or die "Failed loading $class, cannot continue"; >+ } >+ >+ my $library = Koha::Libraries->find($branchcode); >+ my $patron = Koha::Patrons->find($borrower->borrowernumber()); >+ my $itm = Koha::Items->find($item->itemnumber()); >+ my $circ = $class->new({ >+ item => $itm, >+ library => $library, >+ patron => $patron, >+ }); >+ my (undef, $date_due) = $circ->Renew(); >+ ### END Core::Circulation OVERRIDE >+ > $template->param( date_due => $date_due ); > } > } >diff --git a/circ/returns.pl b/circ/returns.pl >index c2f20ef..001c7a7 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -301,10 +301,34 @@ if ($barcode) { > barcode => $barcode, > ); > >+ # BEG Core::Circulation OVERRIDE - Return > > # do the return >- ( $returned, $messages, $issue, $borrower ) = >- AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate ); >+ #( $returned, $messages, $issue, $borrower ) = >+ # AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate ); >+ my $class; >+ { >+ use Class::Load qw(load_optional_class); >+ my $core_modules = C4::Context->config("core_modules"); >+ $core_modules or warn "Missing core_modules config in koha-conf.xml, running default circulation"; >+ $core_modules->{circulation} or warn "Missing core_modules->circulation running default circulation"; >+ $class = $core_modules->{circulation} ? $core_modules->{circulation} : "Core::Community::Circulation"; >+ load_optional_class($class) or die "Failed loading $class, cannot continue"; >+ } >+ if ($item) { >+ my $lib = Koha::Libraries->find($userenv_branch); >+ my $circ = $class->new({ item => $item, library => $lib }); >+ $circ->Checkin( $exemptfine, $dropboxmode, $return_date_override, $dropboxdate ); >+ use Data::Dumper; warn Dumper($circ->{messages}); >+ # TODO: Needs to decide if $self->{checkout} should be emptied upon checkout or not >+ $messages = $circ->{messages}; >+ $issue = $circ->{checkout}; >+ $borrower = $circ->{patron} ? $circ->{patron}->unblessed : undef; >+ $returned = $circ->{error} ? 0 : 1; >+ } else { >+ $messages = { BadBarcode => $barcode }; >+ } >+ # END Core::Circulation OVERRIDE > > if ($returned) { > my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute'); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21327
:
78544
|
78545
|
78546
|
78547
|
78549
|
78550
|
78551
| 78552