@@ -, +, @@
sip_cli_emulator.pl -a
-p -su -sp -l --patron -m checkout --item
check out the item.
---
C4/SIP/ILS.pm | 6 +++++-
C4/SIP/ILS/Item.pm | 5 ++++-
C4/SIP/ILS/Patron.pm | 2 ++
C4/SIP/ILS/Transaction/Checkout.pm | 13 +++++++++++++
C4/SIP/Sip/MsgType.pm | 5 +++--
5 files changed, 27 insertions(+), 4 deletions(-)
--- a/C4/SIP/ILS.pm
+++ a/C4/SIP/ILS.pm
@@ -126,7 +126,7 @@ sub offline_ok {
# the response.
#
sub checkout {
- my ($self, $patron_id, $item_id, $sc_renew) = @_;
+ my ( $self, $patron_id, $item_id, $sc_renew, $sc_fee_acknowledged ) = @_;
my ($patron, $item, $circ);
$circ = new ILS::Transaction::Checkout;
@@ -134,6 +134,8 @@ sub checkout {
$circ->patron($patron = new ILS::Patron $patron_id);
$circ->item($item = new ILS::Item $item_id);
+ my $charge = $circ->fee();
+
if (!$patron) {
$circ->screen_msg("Invalid Patron");
} elsif (!$patron->charge_ok) {
@@ -146,6 +148,8 @@ sub checkout {
} elsif ($item->{patron} && ($item->{patron} ne $patron_id)) {
# I can't deal with this right now
$circ->screen_msg("Item checked out to another patron");
+ } elsif ( !$sc_fee_acknowledged && $charge ) {
+ $circ->screen_msg( sprintf("There is a charge of %.2f to check out this item. Please confirm.", $charge ) );
} else {
$circ->do_checkout();
if ($circ->ok){
--- a/C4/SIP/ILS/Item.pm
+++ a/C4/SIP/ILS/Item.pm
@@ -92,7 +92,10 @@ sub new {
my $it = C4::Context->preference('item-level_itypes') ? $item->{itype} : $item->{itemtype};
my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it );
- $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype;
+ if ($itemtype) {
+ $item->{sip_media_type} = $itemtype->sip_media_type();
+ $item->{fee} = $itemtype->rentalcharge();
+ }
# check if its on issue and if so get the borrower
my $issue = GetItemIssue($item->{'itemnumber'});
--- a/C4/SIP/ILS/Patron.pm
+++ a/C4/SIP/ILS/Patron.pm
@@ -68,6 +68,7 @@ sub new {
%ilspatron = (
getmemberdetails_object => $kp,
name => $kp->{firstname} . " " . $kp->{surname},
+ ils_id => $kp->{borrowernumber},
id => $kp->{cardnumber}, # to SIP, the id is the BARCODE, not userid
password => $pw,
ptype => $kp->{categorycode}, # 'A'dult. Whatever.
@@ -132,6 +133,7 @@ sub new {
# 1 means read/write
my %fields = (
+ ils_id => 0,
id => 0,
name => 0,
address => 0,
--- a/C4/SIP/ILS/Transaction/Checkout.pm
+++ a/C4/SIP/ILS/Transaction/Checkout.pm
@@ -20,6 +20,8 @@ use C4::Circulation;
use C4::Members;
use C4::Reserves qw(ModReserveFill);
use C4::Debug;
+use C4::Circulation qw( GetIssuingCharges );
+
use parent qw(ILS::Transaction);
our $debug;
@@ -125,6 +127,7 @@ sub do_checkout {
$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);
+ $self->{fee_amount} = GetIssuingCharges($itemnumber, $borrower);
my $due_dt = AddIssue($borrower, $barcode, $overridden_duedate, 0);
if ($due_dt) {
$self->{due} = $due_dt->clone();
@@ -137,5 +140,15 @@ sub do_checkout {
return $self;
}
+sub fee {
+ my ($self) = @_;
+
+ my ($charge) = GetIssuingCharges( $self->{item}->{itemnumber}, $self->{patron}->{ils_id} );
+
+ if ($charge > 0 ) {
+ return sprintf( "%.2f", $charge );
+ }
+}
+
1;
__END__
--- a/C4/SIP/Sip/MsgType.pm
+++ a/C4/SIP/Sip/MsgType.pm
@@ -511,7 +511,7 @@ sub handle_checkout {
$patron_id = $fields->{(FID_PATRON_ID)};
$item_id = $fields->{(FID_ITEM_ID)};
-
+ my $sc_fee_acknowledged = $fields->{ (FID_FEE_ACK) } eq 'Y';
if ($no_block eq 'Y') {
# Off-line transactions need to be recorded, but there's
@@ -525,7 +525,7 @@ sub handle_checkout {
} else {
# 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);
+ $status = $ils->checkout( $patron_id, $item_id, $sc_renewal_policy, $sc_fee_acknowledged );
}
$item = $status->item;
@@ -585,6 +585,7 @@ sub handle_checkout {
$resp .= add_field(FID_INST_ID, $inst);
$resp .= add_field(FID_PATRON_ID, $patron_id);
$resp .= add_field(FID_ITEM_ID, $item_id);
+ $resp .= maybe_add( FID_FEE_AMT, $status->fee() );
# If the item is valid, provide the title, otherwise
# leave it blank
--