# DEBTS
my ($amount) =
- GetMemberAccountRecords( $borrower->{'borrowernumber'}, $duedate );
+ C4::Members::GetMemberAccountRecords( $borrower->{'borrowernumber'}, $duedate );
if ( C4::Context->preference("IssuingInProcess") ) {
my $amountlimit = C4::Context->preference("noissuescharge");
if ( $amount > $amountlimit && !$inprocess ) {
}
# See if the item is on reserve.
- my ( $restype, $res ) = CheckReserves( $item->{'itemnumber'} );
+ my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} );
if ($restype) {
my $resbor = $res->{'borrowernumber'};
if ( $resbor ne $borrower->{'borrowernumber'} && $restype eq "Waiting" )
# my ($borrower, $flags) = &GetMemberDetails($borrowernumber, 0);
# find which item we issue
my $item = GetItem('', $barcode);
+
+ my $datedue;
# get actual issuing if there is one
my $actualissue = GetItemIssue( $item->{itemnumber});
# See if the item is on reserve.
my ( $restype, $res ) =
- CheckReserves( $item->{'itemnumber'} );
+ C4::Reserves::CheckReserves( $item->{'itemnumber'} );
if ($restype) {
my $resbor = $res->{'borrowernumber'};
if ( $resbor eq $borrower->{'borrowernumber'} ) {
$itype,
$borrower->{'branchcode'}
);
- my $datedue = time + ($loanlength) * 86400;
+ $datedue = time + ($loanlength) * 86400;
my @datearr = localtime($datedue);
my $dateduef =
sprintf("%04d-%02d-%02d", 1900 + $datearr[5], $datearr[4] + 1, $datearr[3]);
&logaction(C4::Context->userenv->{'number'},"CIRCULATION","ISSUE",$borrower->{'borrowernumber'},$biblio->{'biblionumber'})
if C4::Context->preference("IssueLog");
+ return ($datedue);
}
}
if ( $datedue eq "" ) {
my $biblio = GetBiblioFromItemNumber($itemnumber);
- my $borrower = GetMemberDetails( $borrowernumber, 0 );
- my $loanlength = GetLoanLength(
+ my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 );
+ my $loanlength = GetLoanLength(
$borrower->{'categorycode'},
(C4::Context->preference('item-level_itypes')) ? $biblio->{'ccode'} : $biblio->{'itemtype'} ,
$borrower->{'branchcode'}
use ILS::Transaction::RenewAll;
my %supports = (
- 'magnetic media' => 0,
+ 'magnetic media' => 1,
'security inhibit' => 0,
'offline operation' => 0,
"patron status request" => 1,
my ($class, $institution) = @_;
my $type = ref($class) || $class;
my $self = {};
-use Data::Dumper;
-warn " INSTITUTION:";
-warn Dumper($institution);
+#use Data::Dumper;
+#warn " INSTITUTION:";
+#warn Dumper($institution);
syslog("LOG_DEBUG", "new ILS '%s'", $institution->{id});
$self->{institution} = $institution;
sub find_patron {
my $self = shift;
-
+warn "finding patron";
return ILS::Patron->new(@_);
}
sub find_item {
my $self = shift;
-
+warn "find item";
return ILS::Item->new(@_);
}
my ($patron, $item, $circ);
$circ = new ILS::Transaction::Checkout;
-
+warn "checking out";
# BEGIN TRANSACTION
$circ->patron($patron = new ILS::Patron $patron_id);
$circ->item($item = new ILS::Item $item_id);
if (!$patron) {
- $circ->screen_msg("Invalid Patron");
+ $circ->screen_msg("Invalid Patron");
} elsif (!$patron->charge_ok) {
- $circ->screen_msg("Patron Blocked");
+ $circ->screen_msg("Patron Blocked");
} elsif (!$item) {
- $circ->screen_msg("Invalid Item");
- } elsif (@{$item->hold_queue} && ($patron_id ne $item->hold_queue->[0])) {
- $circ->screen_msg("Item on Hold for Another User");
+ $circ->screen_msg("Invalid Item");
+ } elsif ($item->hold_queue && @{$item->hold_queue} && ($patron_id ne $item->hold_queue->[0])) {
+ $circ->screen_msg("Item on Hold for Another User");
} 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");
+ $circ->screen_msg("Item checked out to another patron");
} else {
- $circ->ok(1);
- # If the item is already associated with this patron, then
- # we're renewing it.
- $circ->renew_ok($item->{patron} && ($item->{patron} eq $patron_id));
- $item->{patron} = $patron_id;
- $item->{due_date} = time + (14*24*60*60); # two weeks
- push(@{$patron->{items}}, $item_id);
- $circ->desensitize(!$item->magnetic);
-
- syslog("LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s",
- $patron_id, join(', ', @{$patron->{items}}));
+ $circ->do_checkout();
+ if ($circ->ok){
+ warn "circ is ok";
+ # If the item is already associated with this patron, then
+ # we're renewing it.
+ $circ->renew_ok($item->{patron} && ($item->{patron} eq $patron_id));
+
+ $item->{patron} = $patron_id;
+ $item->{due_date} = time + (14*24*60*60); # two weeks
+# $item->{due_date} = $circ->{due};
+ warn "$item->{due_date}";
+ push(@{$patron->{items}}, $item_id);
+ $circ->desensitize(!$item->magnetic);
+
+ syslog("LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s",
+ $patron_id, join(', ', @{$patron->{items}}));
+ }
+ else {
+ syslog("LOG_DEBUG", "ILS::Checkout Issue failed");
+
+ }
}
# END TRANSACTION
my $trans;
my $patron;
- $trans = new ILS::Transaction::FeePayment;
+# $trans = new ILS::Transaction::FeePayment;
$patron = new ILS::Patron $patron_id;
use ILS::Transaction;
+use C4::Biblio;
+
our %item_db = (
'1565921879' => {
title => "Perl 5 desktop reference",
my ($class, $item_id) = @_;
my $type = ref($class) || $class;
my $self;
-
-
- if (!exists($item_db{$item_id})) {
- syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id);
- return undef;
+ my $item = GetBiblioFromItemNumber( GetItemnumberFromBarcode($item_id) );
+
+ if (! $item) {
+ syslog("LOG_DEBUG", "new ILS::Item('%s'): not found", $item_id);
+ warn "no item $item_id";
+ return undef;
}
+ $item->{'id'} = $item->{'barcode'};
+ $self = $item;
- $self = $item_db{$item_id};
bless $self, $type;
syslog("LOG_DEBUG", "new ILS::Item('%s'): found with title '%s'",
use strict;
use POSIX qw(strftime);
+use Sys::Syslog qw(syslog);
use ILS;
use ILS::Transaction;
+use C4::Circulation;
+use C4::Members;
+
our @ISA = qw(ILS::Transaction);
# Most fields are handled by the Transaction superclass
my $element;
foreach $element (keys %fields) {
- $self->{_permitted}->{$element} = $fields{$element};
+ $self->{_permitted}->{$element} = $fields{$element};
}
@{$self}{keys %fields} = values %fields;
- $self->{'due'} = time() + (60*60*24*14); # two weeks hence
-
+
+# $self->{'due'} = time() + (60*60*24*14); # two weeks hence
+# use Data::Dumper;
+# warn Dumper $self;
return bless $self, $class;
}
+sub do_checkout {
+ my $self = shift;
+ syslog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
+ my $barcode = $self->{item}->id;
+ my $patron_barcode = $self->{patron}->id;
+ warn $patron_barcode;
+ my $borrower = GetMember( $patron_barcode, 'cardnumber' );
+# use Data::Dumper;
+# warn Dumper $borrower;
+ my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued ( $borrower, $barcode, 0, 0, 0, 0 );
+ my $noerror=1;
+ foreach my $impossible ( keys %$issuingimpossible ) {
+ # do something here so we pass these errors
+ $self->screen_msg($issuingimpossible->{$impossible});
+ $noerror = 0;
+ }
+ foreach my $confirmation ( keys %$needsconfirmation ) {
+ if ($confirmation eq 'RENEW_ISSUE'){
+ if (!CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber})){
+ $noerror = 0;
+ warn "cant renew $borrower->{borrowernumber} $self->{item}->{itemnumber}";
+ }
+ }
+ else {
+ $self->screen_msg($needsconfirmation->{$confirmation});
+ $noerror = 0;
+ }
+ }
+
+
+ if ($noerror){
+ warn "can issue";
+ # we can issue
+ my $datedue = AddIssue( $borrower, $barcode, undef, 0 );
+ $self->{'due'} = $datedue;
+ $self->ok(1);
+ }
+ else {
+
+
+ warn "cant issue";
+ use Data::Dumper;
+ warn Dumper $issuingimpossible;
+ warn Dumper $needsconfirmation;
+ $self->ok(0);
+ }
+ return $self;
+
+}
+
1;
## Test this by checking out exactly the same book a second time.
## The only difference should be that the "Renewal OK" flag should now
## be 'Y'.
-#$test = clone($checkout_test_template);
-#$test->{id} = 'Checkout: patron renewal';
-#$test->{pat} = qr/^121YNY$datepat/;
-#
-#push @tests, $test;
+$test = clone($checkout_test_template);
+$test->{id} = 'Checkout: patron renewal';
+$test->{pat} = qr/^121YNY$datepat/;
+
+push @tests, $test;
# NOW check it in
our $user_inet = 'N';
# Valid item barcode and corresponding title
-our $item_barcode = '26000204';
-our $item_title = 'A community of writers :';
+our $item_barcode = '37000000012023';
+our $item_title = 'The not-just-anybody family.';
our $item_owner = 'kohalibrary';
# Another valid item