##
-## Checkout(patron_id, item_id, sc_renew):
+## Checkout(patron_id, item_id, sc_renew, fee_ack):
## patron_id & item_id are the identifiers send by the terminal
## sc_renew is the renewal policy configured on the terminal
## returns a status opject that can be queried for the various bits
## of information that the protocol (SIP or NCIP) needs to generate
## the response.
+## fee_ack is the fee_acknowledged field (BO) sent from the sc
+## when doing chargeable loans.
##
sub checkout {
- my ($self, $patron_id, $item_id, $sc_renew) = @_;
+ my ($self, $patron_id, $item_id, $sc_renew, $fee_ack) = @_;
$sc_renew = 0;
$self->verify_session;
$xact->ok(0);
}
+ # Check for fee and $fee_ack. If there is a fee, and $fee_ack
+ # is 'Y', we proceed, otherwise we reject the checkout.
+ if ($item->fee > 0.0) {
+ $xact->fee_amount($item->fee);
+ $xact->sip_fee_type($item->sip_fee_type);
+ $xact->sip_currency($item->fee_currency);
+ if ($fee_ack && $fee_ack eq 'Y') {
+ $xact->fee_ack(1);
+ } else {
+ $xact->screen_msg('Fee required');
+ $xact->ok(0);
+ return $xact;
+ }
+ }
+
$xact->do_checkout($sc_renew);
$xact->desensitize(!$item->magnetic);
}
sub sip_fee_type {
- return '01'; # FIXME? 01-09 enumerated in spec. We just use O1-other/unknown.
+ my $self = shift;
+ # Return '06' for rental unless the fee is a deposit, or there is
+ # no fee. In the latter cases, return '01'.
+ return ($self->{copy}->deposit_amount > 0.0 && $self->{copy}->deposit =~ /^f/i) ? '06' : '01';
}
-sub fee { # TODO
+sub fee {
my $self = shift;
- return 0;
+ return $self->{copy}->deposit_amount;
}
if ($override_events{$txt} && $method !~ /override$/) {
# Found an event we've been configured to override.
$override = 1;
+ } elsif ($txt =~ /ITEM_(?:DEPOSIT|RENTAL)_FEE_REQUIRED/ && $self->fee_ack) {
+ # Patron acknowledged the fee.
+ $override = 1;
} elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
$self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
return 0;