@@ -, +, @@ --- C4/SIP/ILS.pm | 5 ++++- C4/SIP/ILS/Transaction.pm | 1 + C4/SIP/ILS/Transaction/Checkout.pm | 13 +++++++++++++ C4/SIP/ILS/Transaction/Renew.pm | 11 +++++++++++ C4/SIP/Sip/MsgType.pm | 22 +++++++++++++--------- 5 files changed, 42 insertions(+), 10 deletions(-) --- a/C4/SIP/ILS.pm +++ a/C4/SIP/ILS.pm @@ -126,13 +126,16 @@ sub offline_ok { # the response. # sub checkout { - my ($self, $patron_id, $item_id, $sc_renew) = @_; + my ($self, $patron_id, $item_id, $sc_renew, $fee_ack) = @_; my ($patron, $item, $circ); $circ = C4::SIP::ILS::Transaction::Checkout->new(); # BEGIN TRANSACTION $circ->patron($patron = C4::SIP::ILS::Patron->new( $patron_id)); $circ->item($item = C4::SIP::ILS::Item->new( $item_id)); + if ($fee_ack) { + $circ->fee_ack($fee_ack); + } if (!$patron) { $circ->screen_msg("Invalid Patron"); --- a/C4/SIP/ILS/Transaction.pm +++ a/C4/SIP/ILS/Transaction.pm @@ -21,6 +21,7 @@ my %fields = ( sip_currency => 'USD', # FIXME: why hardcoded? screen_msg => '', print_line => '', + fee_ack => 'N', ); our $AUTOLOAD; --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ a/C4/SIP/ILS/Transaction/Checkout.pm @@ -90,9 +90,14 @@ sub do_checkout { } elsif ($confirmation eq 'HIGHHOLDS') { $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate}; $self->screen_msg('Loan period reduced for high-demand item'); + } elsif ($confirmation eq 'RENTALCHARGE') { + if ($self->{fee_ack} ne 'Y') { + $noerror = 0; + } } else { $self->screen_msg($needsconfirmation->{$confirmation}); $noerror = 0; + syslog('LOG_DEBUG', "Blocking checkout Reason:$confirmation"); } } } @@ -106,6 +111,14 @@ sub do_checkout { $self->screen_msg("Item is on hold shelf for another patron."); $noerror = 0; } + my ($fee, undef) = GetIssuingCharges($itemnumber, $self->{patron}->{borrowernumber}); + if ( $fee > 0 ) { + $self->{sip_fee_type} = '06'; + $self->{fee_amount} = sprintf '%.2f', $fee; + if ($self->{fee_ack} eq 'N' ) { + $noerror = 0; + } + } unless ($noerror) { $debug and warn "cannot issue: " . Dumper($issuingimpossible) . "\n" . Dumper($needsconfirmation); $self->ok(0); --- a/C4/SIP/ILS/Transaction/Renew.pm +++ a/C4/SIP/ILS/Transaction/Renew.pm @@ -32,6 +32,17 @@ sub do_renew_for { my $self = shift; my $borrower = shift; my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber}); + if ($renewokay) { # ok so far check charges + my ($fee, undef) = GetIssuingCharges($self->{item}->{itemnumber}, $self->{patron}->{borrowernumber}); + if ($fee > 0) { + $self->{sip_fee_type} = '06'; + $self->{fee_amount} = sprintf '%.2f',$fee; + if ($self->{fee_ack} eq 'N') { + $renewokay = 0; + } + } + + } if ($renewokay){ $self->{due} = undef; my $due_date = AddIssue( $borrower, $self->{item}->id, undef, 0 ); --- a/C4/SIP/Sip/MsgType.pm +++ a/C4/SIP/Sip/MsgType.pm @@ -511,6 +511,7 @@ sub handle_checkout { $patron_id = $fields->{(FID_PATRON_ID)}; $item_id = $fields->{(FID_ITEM_ID)}; + my $fee_ack = $fields->{(FID_FEE_ACK)}; if ($no_block eq 'Y') { @@ -525,7 +526,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, $fee_ack); } $item = $status->item; @@ -567,17 +568,10 @@ sub handle_checkout { $resp .= maybe_add(FID_MEDIA_TYPE, $item->sip_media_type); $resp .= maybe_add(FID_ITEM_PROPS, $item->sip_item_properties); - # Financials - if ($status->fee_amount) { - $resp .= add_field(FID_FEE_AMT, $status->fee_amount); - $resp .= maybe_add(FID_CURRENCY, $status->sip_currency); - $resp .= maybe_add(FID_FEE_TYPE, $status->sip_fee_type); - $resp .= maybe_add(FID_TRANSACTION_ID, - $status->transaction_id); } } - } else { + else { # Checkout failed # Checkout Response: not ok, no renewal, don't know mag. media, # no desensitize @@ -607,6 +601,16 @@ sub handle_checkout { } } } + if ($protocol_version >= 2) { + # Financials : return irrespective of ok status + if ($status->fee_amount) { + $resp .= add_field(FID_FEE_AMT, $status->fee_amount); + $resp .= maybe_add(FID_CURRENCY, $status->sip_currency); + $resp .= maybe_add(FID_FEE_TYPE, $status->sip_fee_type); + $resp .= maybe_add(FID_TRANSACTION_ID, + $status->transaction_id); + } + } $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); return(CHECKOUT); --