Lines 975-980
sub CanBookBeIssued {
Link Here
|
975 |
|
975 |
|
976 |
if ( $rentalConfirmation ){ |
976 |
if ( $rentalConfirmation ){ |
977 |
my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); |
977 |
my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); |
|
|
978 |
my $itemtype = Koha::ItemTypes->find( $item->{itype} ); # GetItem sets effective itemtype |
979 |
$rentalCharge += $itemtype->calc_rental_charge_daily( { from => dt_from_string(), to => $duedate } ); |
978 |
if ( $rentalCharge > 0 ){ |
980 |
if ( $rentalCharge > 0 ){ |
979 |
$needsconfirmation{RENTALCHARGE} = $rentalCharge; |
981 |
$needsconfirmation{RENTALCHARGE} = $rentalCharge; |
980 |
} |
982 |
} |
Lines 1407-1418
sub AddIssue {
Link Here
|
1407 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1409 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1408 |
|
1410 |
|
1409 |
# If it costs to borrow this book, charge it to the patron's account. |
1411 |
# If it costs to borrow this book, charge it to the patron's account. |
1410 |
my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); |
1412 |
my ( $charge ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); |
1411 |
if ( $charge > 0 ) { |
1413 |
if ( $charge > 0 ) { |
1412 |
AddIssuingCharge( $issue, $charge ); |
1414 |
AddIssuingCharge( $issue, $charge ); |
1413 |
$item->{'charge'} = $charge; |
1415 |
$item->{'charge'} = $charge; |
1414 |
} |
1416 |
} |
1415 |
|
1417 |
|
|
|
1418 |
my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); |
1419 |
if ( $itemtype ) { |
1420 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => $issuedate, to => $datedue } ); |
1421 |
if ( $daily_charge > 0 ) { |
1422 |
AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0; |
1423 |
$charge += $daily_charge; |
1424 |
$item->{charge} = $charge; |
1425 |
} |
1426 |
} |
1427 |
|
1416 |
# Record the fact that this book was issued. |
1428 |
# Record the fact that this book was issued. |
1417 |
&UpdateStats( |
1429 |
&UpdateStats( |
1418 |
{ |
1430 |
{ |
Lines 2870-2890
sub AddRenewal {
Link Here
|
2870 |
$renews = $item->{renewals} + 1; |
2882 |
$renews = $item->{renewals} + 1; |
2871 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); |
2883 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); |
2872 |
|
2884 |
|
2873 |
# Charge a new rental fee, if applicable? |
2885 |
# Charge a new rental fee, if applicable |
2874 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2886 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2875 |
if ( $charge > 0 ) { |
2887 |
if ( $charge > 0 ) { |
2876 |
my $accountno = C4::Accounts::getnextacctno( $borrowernumber ); |
2888 |
my $accountno = C4::Accounts::getnextacctno( $borrowernumber ); |
2877 |
my $manager_id = 0; |
2889 |
my $type_desc = "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}"; |
2878 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2890 |
AddIssuingCharge( $issue, $charge, $type_desc ) |
2879 |
$sth = $dbh->prepare( |
2891 |
} |
2880 |
"INSERT INTO accountlines |
2892 |
|
2881 |
(date, borrowernumber, accountno, amount, manager_id, |
2893 |
# Charge a new daily rental fee, if applicable |
2882 |
description,accounttype, amountoutstanding, itemnumber) |
2894 |
my $itemtype = Koha::ItemTypes->find( $item->{itype} ); # GetItem sets effective itemtype |
2883 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2895 |
if ( $itemtype ) { |
2884 |
); |
2896 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => dt_from_string($lastreneweddate), to => $datedue } ); |
2885 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2897 |
if ( $daily_charge > 0 ) { |
2886 |
"Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", |
2898 |
my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; |
2887 |
'Rent', $charge, $itemnumber ); |
2899 |
AddIssuingCharge( $issue, $daily_charge, $type_desc ) |
|
|
2900 |
} |
2901 |
$charge += $daily_charge; |
2888 |
} |
2902 |
} |
2889 |
|
2903 |
|
2890 |
# Send a renewal slip according to checkout alert preferencei |
2904 |
# Send a renewal slip according to checkout alert preferencei |
Lines 3204-3215
sub _get_discount_from_rule {
Link Here
|
3204 |
|
3218 |
|
3205 |
=head2 AddIssuingCharge |
3219 |
=head2 AddIssuingCharge |
3206 |
|
3220 |
|
3207 |
&AddIssuingCharge( $checkout, $charge ) |
3221 |
&AddIssuingCharge( $checkout, $charge, [$type] ) |
3208 |
|
3222 |
|
3209 |
=cut |
3223 |
=cut |
3210 |
|
3224 |
|
3211 |
sub AddIssuingCharge { |
3225 |
sub AddIssuingCharge { |
3212 |
my ( $checkout, $charge ) = @_; |
3226 |
my ( $checkout, $charge, $type ) = @_; |
|
|
3227 |
|
3228 |
$type ||= 'Rental'; |
3213 |
|
3229 |
|
3214 |
# FIXME What if checkout does not exist? |
3230 |
# FIXME What if checkout does not exist? |
3215 |
|
3231 |
|
Lines 3227-3233
sub AddIssuingCharge {
Link Here
|
3227 |
amount => $charge, |
3243 |
amount => $charge, |
3228 |
amountoutstanding => $charge, |
3244 |
amountoutstanding => $charge, |
3229 |
manager_id => $manager_id, |
3245 |
manager_id => $manager_id, |
3230 |
description => 'Rental', |
3246 |
description => $type, |
3231 |
accounttype => 'Rent', |
3247 |
accounttype => 'Rent', |
3232 |
date => \'NOW()', |
3248 |
date => \'NOW()', |
3233 |
} |
3249 |
} |