'29' => \&handle_renew,
'37' => \&handle_payment,
'63' => \&handle_patron_info,
+ '65' => \&handle_renew_all,
'XS' => \&handle_end_session
};
}, $circ_details);
}
+sub handle_renew_all {
+ my ($session, $message) = @_;
+ my $config = $session->config;
+
+ my $patron_barcode = $SC->get_field_value($message, 'AA');
+ my $fee_ack = $SC->get_field_value($message, 'BO');
+
+ my $patron_details = OpenILS::Application::SIP2::Patron->get_patron_details(
+ $session, barcode => $patron_barcode
+ );
+
+ return {
+ code => '66',
+ fixed_fields => [
+ 0, # ok
+ $SC->count4(0), # renewed count
+ $SC->count4(0), # unrenewed count
+ $SC->sipdate, # transaction date
+ ],
+ fields => [
+ {AA => $patron_barcode},
+ {AO => $config->{institution}},
+ ]
+ } unless $patron_details;
+
+ my $circ_details = OpenILS::Application::SIP2::Checkout->renew_all(
+ $session, $patron_details, fee_ack => $fee_ack
+ );
+
+ my $screen_msg = $circ_details->{screen_msg};
+ my @renewed = @{$circ_details->{items_renewed}};
+ my @unrenewed = @{$circ_details->{items_unrenewed}};
+
+ return {
+ code => '66',
+ fixed_fields => [
+ 1, # ok
+ $SC->count4(scalar(@renewed)),
+ $SC->count4(scalar(@unrenewed)),
+ $SC->sipdate,
+ ],
+ fields => [
+ {AA => $patron_barcode},
+ {AO => $config->{institution}},
+ @{ [ map { {BM => $_} } @renewed ] },
+ @{ [ map { {BN => $_} } @unrenewed ] },
+ $screen_msg ? {AF => $screen_msg} : ()
+ ]
+ };
+}
+
+
sub handle_checkin {
my ($session, $message) = @_;
my $config = $session->config;
return $circ_details;
}
+sub renew_all {
+ my ($class, $session, $patron_details, %params) = @_;
+
+ my $circ_details = {};
+
+ my @circ_ids = (
+ @{$patron_details->{items_out_ids}},
+ @{$patron_details->{items_overdue_ids}}
+ );
+
+ my @renewed;
+ my @unrenewed;
+ for my $circ_id (@circ_ids) {
+
+ my $circ = $session->editor->retrieve_action_circulation([
+ $circ_id, {flesh => 1, flesh_fields => {circ => ['target_copy']}}]);
+
+ my $item_barcode = $circ->target_copy->barcode;
+
+ my $detail = $class->checkout($session,
+ item_barcode => $item_barcode,
+ fee_ack => $params{fee_ack},
+ is_renew => 1
+ );
+
+ if ($detail->{ok}) {
+ push(@renewed, $item_barcode);
+ } else {
+ push(@unrenewed, $item_barcode);
+ }
+ }
+
+ $circ_details->{items_renewed} = \@renewed;
+ $circ_details->{items_unrenewed} = \@unrenewed;
+
+ return $circ_details;
+}
+
# Returns 1 if the checkout should be performed again with override.
# Returns 0 if there's nothing left to do (final success / error)
# Updates $circ_details along the way.
my ($session, $circ_details, $override, %params) = @_;
my $config = $session->config;
+ my $action = $params{is_renew} ? 'renew' : 'checkout';
+
my $args = {
copy_barcode => $params{item_barcode},
# During renewal, the circ API will confirm the specified
patron_barcode => $params{patron_barcode}
};
- my $method = $params{is_renew} ?
+ my $method = $action eq 'renew' ?
'open-ils.circ.renew' : 'open-ils.circ.checkout.full';
$method .= '.override' if $override;
}
if (!$override) {
- if ($config->{"checkout.override.$textcode"}) {
+ if ($config->{"$action.override.$textcode"}) {
# Event type is configured for override;
return 1;
$circ_details->{screen_msg} = 'This item is already checked out';
} else {
- $circ_details->{screen_msg} = # TODO messages
- 'Patron is not allowed to check out the selected item';
+ $circ_details->{screen_msg} = # TODO messages / renew
+ 'Patron is not allowed to checkout the selected item';
}
}