Lines 59-64
use Koha::RefundLostItemFeeRules;
Link Here
|
59 |
use Koha::Account::Lines; |
59 |
use Koha::Account::Lines; |
60 |
use Koha::Account::Offsets; |
60 |
use Koha::Account::Offsets; |
61 |
use Koha::Config::SysPrefs; |
61 |
use Koha::Config::SysPrefs; |
|
|
62 |
use Koha::Fees; |
62 |
use Carp; |
63 |
use Carp; |
63 |
use List::MoreUtils qw( uniq any ); |
64 |
use List::MoreUtils qw( uniq any ); |
64 |
use Scalar::Util qw( looks_like_number ); |
65 |
use Scalar::Util qw( looks_like_number ); |
Lines 670-682
sub CanBookBeIssued {
Link Here
|
670 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
671 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
671 |
my $override_high_holds = $params->{override_high_holds} || 0; |
672 |
my $override_high_holds = $params->{override_high_holds} || 0; |
672 |
|
673 |
|
673 |
my $item = GetItem(undef, $barcode ); |
674 |
my $item_object = Koha::Items->find( { barcode => $barcode } ); |
|
|
675 |
|
674 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
676 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
675 |
unless ( $item ) { |
677 |
unless ( $item_object ) { |
676 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
678 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
677 |
} |
679 |
} |
678 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
680 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
679 |
|
681 |
|
|
|
682 |
my $item = $item_object->unblessed; |
683 |
$item->{itype} = $item_object->effective_itemtype(); # set the correct itype |
684 |
|
680 |
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
685 |
my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); |
681 |
my $biblio = Koha::Biblios->find( $item->{biblionumber} ); |
686 |
my $biblio = Koha::Biblios->find( $item->{biblionumber} ); |
682 |
my $biblioitem = $biblio->biblioitem; |
687 |
my $biblioitem = $biblio->biblioitem; |
Lines 684-689
sub CanBookBeIssued {
Link Here
|
684 |
my $dbh = C4::Context->dbh; |
689 |
my $dbh = C4::Context->dbh; |
685 |
my $patron_unblessed = $patron->unblessed; |
690 |
my $patron_unblessed = $patron->unblessed; |
686 |
|
691 |
|
|
|
692 |
my $library = Koha::Libraries->find( _GetCircControlBranch($item, $patron_unblessed) ); |
687 |
# |
693 |
# |
688 |
# DUE DATE is OK ? -- should already have checked. |
694 |
# DUE DATE is OK ? -- should already have checked. |
689 |
# |
695 |
# |
Lines 694-705
sub CanBookBeIssued {
Link Here
|
694 |
unless ( $duedate ) { |
700 |
unless ( $duedate ) { |
695 |
my $issuedate = $now->clone(); |
701 |
my $issuedate = $now->clone(); |
696 |
|
702 |
|
697 |
my $branch = _GetCircControlBranch($item, $patron_unblessed); |
703 |
my $branch = $library->id; |
698 |
$duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); |
704 |
$duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); |
699 |
|
705 |
|
700 |
# Offline circ calls AddIssue directly, doesn't run through here |
706 |
# Offline circ calls AddIssue directly, doesn't run through here |
701 |
# So issuingimpossible should be ok. |
707 |
# So issuingimpossible should be ok. |
702 |
} |
708 |
} |
|
|
709 |
|
710 |
my $fees = Koha::Fees->new( |
711 |
{ |
712 |
patron => $patron, |
713 |
library => $library, |
714 |
item => $item_object, |
715 |
to_date => $duedate, |
716 |
} |
717 |
); |
718 |
|
703 |
if ($duedate) { |
719 |
if ($duedate) { |
704 |
my $today = $now->clone(); |
720 |
my $today = $now->clone(); |
705 |
$today->truncate( to => 'minute'); |
721 |
$today->truncate( to => 'minute'); |
Lines 1312-1317
sub AddIssue {
Link Here
|
1312 |
); |
1328 |
); |
1313 |
} |
1329 |
} |
1314 |
else { |
1330 |
else { |
|
|
1331 |
unless ($datedue) { |
1332 |
my $itype = $item_object->effective_itemtype; |
1333 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1334 |
|
1335 |
} |
1336 |
$datedue->truncate( to => 'minute' ); |
1337 |
|
1338 |
my $patron = Koha::Patrons->find( $borrower ); |
1339 |
my $library = Koha::Libraries->find( $branch ); |
1340 |
my $fees = Koha::Fees->new( |
1341 |
{ |
1342 |
patron => $patron, |
1343 |
library => $library, |
1344 |
item => $item_object, |
1345 |
to_date => $datedue, |
1346 |
} |
1347 |
); |
1348 |
|
1315 |
# it's NOT a renewal |
1349 |
# it's NOT a renewal |
1316 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1350 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1317 |
# This book is currently on loan, but not to the person |
1351 |
# This book is currently on loan, but not to the person |
Lines 1429-1435
sub AddIssue {
Link Here
|
1429 |
|
1463 |
|
1430 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
1464 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
1431 |
if ( $itemtype ) { |
1465 |
if ( $itemtype ) { |
1432 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => $issuedate, to => $datedue } ); |
1466 |
my $daily_charge = $fees->rental_charge_daily(); |
1433 |
if ( $daily_charge > 0 ) { |
1467 |
if ( $daily_charge > 0 ) { |
1434 |
AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0; |
1468 |
AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0; |
1435 |
$charge += $daily_charge; |
1469 |
$charge += $daily_charge; |
Lines 2851-2856
sub AddRenewal {
Link Here
|
2851 |
my $patron = Koha::Patrons->find( $borrowernumber ) or return; # FIXME Should do more than just return |
2885 |
my $patron = Koha::Patrons->find( $borrowernumber ) or return; # FIXME Should do more than just return |
2852 |
my $patron_unblessed = $patron->unblessed; |
2886 |
my $patron_unblessed = $patron->unblessed; |
2853 |
|
2887 |
|
|
|
2888 |
my $library = Koha::Libraries->find( $branch ); |
2889 |
|
2890 |
|
2854 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
2891 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
2855 |
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } ); |
2892 |
_CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } ); |
2856 |
} |
2893 |
} |
Lines 2868-2873
sub AddRenewal {
Link Here
|
2868 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
2905 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
2869 |
} |
2906 |
} |
2870 |
|
2907 |
|
|
|
2908 |
|
2909 |
my $fees = Koha::Fees->new( |
2910 |
{ |
2911 |
patron => $patron, |
2912 |
library => $library, |
2913 |
item => $item_object, |
2914 |
to_date => dt_from_string( $datedue ), |
2915 |
} |
2916 |
); |
2917 |
|
2871 |
# Update the issues record to have the new due date, and a new count |
2918 |
# Update the issues record to have the new due date, and a new count |
2872 |
# of how many times it has been renewed. |
2919 |
# of how many times it has been renewed. |
2873 |
my $renews = $issue->renewals + 1; |
2920 |
my $renews = $issue->renewals + 1; |
Lines 2910-2916
sub AddRenewal {
Link Here
|
2910 |
# Charge a new daily rental fee, if applicable |
2957 |
# Charge a new daily rental fee, if applicable |
2911 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
2958 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
2912 |
if ( $itemtype ) { |
2959 |
if ( $itemtype ) { |
2913 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => dt_from_string($lastreneweddate), to => $datedue } ); |
2960 |
my $daily_charge = $fees->rental_charge_daily(); |
2914 |
if ( $daily_charge > 0 ) { |
2961 |
if ( $daily_charge > 0 ) { |
2915 |
my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; |
2962 |
my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; |
2916 |
AddIssuingCharge( $issue, $daily_charge, $type_desc ) |
2963 |
AddIssuingCharge( $issue, $daily_charge, $type_desc ) |