|
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 681-688
sub CanBookBeIssued {
Link Here
|
| 681 |
my $override_high_holds = $params->{override_high_holds} || 0; |
682 |
my $override_high_holds = $params->{override_high_holds} || 0; |
| 682 |
|
683 |
|
| 683 |
my $item = Koha::Items->find({barcode => $barcode }); |
684 |
my $item = Koha::Items->find({barcode => $barcode }); |
|
|
685 |
|
| 684 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
686 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
| 685 |
unless ( $item ) { |
687 |
unless ( $item_object ) { |
| 686 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
688 |
$issuingimpossible{UNKNOWN_BARCODE} = 1; |
| 687 |
} |
689 |
} |
| 688 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
690 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
|
Lines 690-700
sub CanBookBeIssued {
Link Here
|
| 690 |
my $item_unblessed = $item->unblessed; # Transition... |
692 |
my $item_unblessed = $item->unblessed; # Transition... |
| 691 |
my $issue = $item->checkout; |
693 |
my $issue = $item->checkout; |
| 692 |
my $biblio = $item->biblio; |
694 |
my $biblio = $item->biblio; |
|
|
695 |
|
| 693 |
my $biblioitem = $biblio->biblioitem; |
696 |
my $biblioitem = $biblio->biblioitem; |
| 694 |
my $effective_itemtype = $item->effective_itemtype; |
697 |
my $effective_itemtype = $item->effective_itemtype; |
| 695 |
my $dbh = C4::Context->dbh; |
698 |
my $dbh = C4::Context->dbh; |
| 696 |
my $patron_unblessed = $patron->unblessed; |
699 |
my $patron_unblessed = $patron->unblessed; |
| 697 |
|
700 |
|
|
|
701 |
my $library = Koha::Libraries->find( _GetCircControlBranch($item, $patron_unblessed) ); |
| 698 |
# |
702 |
# |
| 699 |
# DUE DATE is OK ? -- should already have checked. |
703 |
# DUE DATE is OK ? -- should already have checked. |
| 700 |
# |
704 |
# |
|
Lines 711-716
sub CanBookBeIssued {
Link Here
|
| 711 |
# Offline circ calls AddIssue directly, doesn't run through here |
715 |
# Offline circ calls AddIssue directly, doesn't run through here |
| 712 |
# So issuingimpossible should be ok. |
716 |
# So issuingimpossible should be ok. |
| 713 |
} |
717 |
} |
|
|
718 |
|
| 719 |
my $fees = Koha::Fees->new( |
| 720 |
{ |
| 721 |
patron => $patron, |
| 722 |
library => $library, |
| 723 |
item => $item_object, |
| 724 |
to_date => $duedate, |
| 725 |
} |
| 726 |
); |
| 727 |
|
| 714 |
if ($duedate) { |
728 |
if ($duedate) { |
| 715 |
my $today = $now->clone(); |
729 |
my $today = $now->clone(); |
| 716 |
$today->truncate( to => 'minute'); |
730 |
$today->truncate( to => 'minute'); |
|
Lines 1324-1329
sub AddIssue {
Link Here
|
| 1324 |
); |
1338 |
); |
| 1325 |
} |
1339 |
} |
| 1326 |
else { |
1340 |
else { |
|
|
1341 |
unless ($datedue) { |
| 1342 |
my $itype = $item_object->effective_itemtype; |
| 1343 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
| 1344 |
|
| 1345 |
} |
| 1346 |
$datedue->truncate( to => 'minute' ); |
| 1347 |
|
| 1348 |
my $patron = Koha::Patrons->find( $borrower ); |
| 1349 |
my $library = Koha::Libraries->find( $branch ); |
| 1350 |
my $fees = Koha::Fees->new( |
| 1351 |
{ |
| 1352 |
patron => $patron, |
| 1353 |
library => $library, |
| 1354 |
item => $item_object, |
| 1355 |
to_date => $datedue, |
| 1356 |
} |
| 1357 |
); |
| 1358 |
|
| 1327 |
# it's NOT a renewal |
1359 |
# it's NOT a renewal |
| 1328 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1360 |
if ( $actualissue and not $switch_onsite_checkout ) { |
| 1329 |
# This book is currently on loan, but not to the person |
1361 |
# This book is currently on loan, but not to the person |
|
Lines 1441-1447
sub AddIssue {
Link Here
|
| 1441 |
|
1473 |
|
| 1442 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
1474 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
| 1443 |
if ( $itemtype ) { |
1475 |
if ( $itemtype ) { |
| 1444 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => $issuedate, to => $datedue } ); |
1476 |
my $daily_charge = $fees->rental_charge_daily(); |
| 1445 |
if ( $daily_charge > 0 ) { |
1477 |
if ( $daily_charge > 0 ) { |
| 1446 |
AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0; |
1478 |
AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0; |
| 1447 |
$charge += $daily_charge; |
1479 |
$charge += $daily_charge; |
|
Lines 2840-2845
sub AddRenewal {
Link Here
|
| 2840 |
my $patron = Koha::Patrons->find( $borrowernumber ) or return; # FIXME Should do more than just return |
2872 |
my $patron = Koha::Patrons->find( $borrowernumber ) or return; # FIXME Should do more than just return |
| 2841 |
my $patron_unblessed = $patron->unblessed; |
2873 |
my $patron_unblessed = $patron->unblessed; |
| 2842 |
|
2874 |
|
|
|
2875 |
my $library = Koha::Libraries->find( $branch ); |
| 2876 |
|
| 2877 |
|
| 2843 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
2878 |
if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { |
| 2844 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } ); |
2879 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } ); |
| 2845 |
} |
2880 |
} |
|
Lines 2857-2862
sub AddRenewal {
Link Here
|
| 2857 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item_unblessed, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
2892 |
$datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item_unblessed, $patron_unblessed), $patron_unblessed, 'is a renewal'); |
| 2858 |
} |
2893 |
} |
| 2859 |
|
2894 |
|
|
|
2895 |
|
| 2896 |
my $fees = Koha::Fees->new( |
| 2897 |
{ |
| 2898 |
patron => $patron, |
| 2899 |
library => $library, |
| 2900 |
item => $item_object, |
| 2901 |
to_date => dt_from_string( $datedue ), |
| 2902 |
} |
| 2903 |
); |
| 2904 |
|
| 2860 |
# Update the issues record to have the new due date, and a new count |
2905 |
# Update the issues record to have the new due date, and a new count |
| 2861 |
# of how many times it has been renewed. |
2906 |
# of how many times it has been renewed. |
| 2862 |
my $renews = $issue->renewals + 1; |
2907 |
my $renews = $issue->renewals + 1; |
|
Lines 2881-2887
sub AddRenewal {
Link Here
|
| 2881 |
# Charge a new daily rental fee, if applicable |
2926 |
# Charge a new daily rental fee, if applicable |
| 2882 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
2927 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
| 2883 |
if ( $itemtype ) { |
2928 |
if ( $itemtype ) { |
| 2884 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => dt_from_string($lastreneweddate), to => $datedue } ); |
2929 |
my $daily_charge = $fees->rental_charge_daily(); |
| 2885 |
if ( $daily_charge > 0 ) { |
2930 |
if ( $daily_charge > 0 ) { |
| 2886 |
my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; |
2931 |
my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; |
| 2887 |
AddIssuingCharge( $issue, $daily_charge, $type_desc ) |
2932 |
AddIssuingCharge( $issue, $daily_charge, $type_desc ) |