|
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 2848-2868
sub AddRenewal {
Link Here
|
| 2848 |
$renews = $item->{renewals} + 1; |
2860 |
$renews = $item->{renewals} + 1; |
| 2849 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); |
2861 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); |
| 2850 |
|
2862 |
|
| 2851 |
# Charge a new rental fee, if applicable? |
2863 |
# Charge a new rental fee, if applicable |
| 2852 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2864 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
| 2853 |
if ( $charge > 0 ) { |
2865 |
if ( $charge > 0 ) { |
| 2854 |
my $accountno = getnextacctno( $borrowernumber ); |
2866 |
my $accountno = getnextacctno( $borrowernumber ); |
| 2855 |
my $manager_id = 0; |
2867 |
my $type_desc = "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}"; |
| 2856 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2868 |
AddIssuingCharge( $issue, $charge, $type_desc ) |
| 2857 |
$sth = $dbh->prepare( |
2869 |
} |
| 2858 |
"INSERT INTO accountlines |
2870 |
|
| 2859 |
(date, borrowernumber, accountno, amount, manager_id, |
2871 |
# Charge a new daily rental fee, if applicable |
| 2860 |
description,accounttype, amountoutstanding, itemnumber) |
2872 |
my $itemtype = Koha::ItemTypes->find( $item->{itype} ); # GetItem sets effective itemtype |
| 2861 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2873 |
if ( $itemtype ) { |
| 2862 |
); |
2874 |
my $daily_charge = $itemtype->calc_rental_charge_daily( { from => dt_from_string($lastreneweddate), to => $datedue } ); |
| 2863 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2875 |
if ( $daily_charge > 0 ) { |
| 2864 |
"Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", |
2876 |
my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; |
| 2865 |
'Rent', $charge, $itemnumber ); |
2877 |
AddIssuingCharge( $issue, $daily_charge, $type_desc ) |
|
|
2878 |
} |
| 2879 |
$charge += $daily_charge; |
| 2866 |
} |
2880 |
} |
| 2867 |
|
2881 |
|
| 2868 |
# Send a renewal slip according to checkout alert preferencei |
2882 |
# Send a renewal slip according to checkout alert preferencei |
|
Lines 3182-3193
sub _get_discount_from_rule {
Link Here
|
| 3182 |
|
3196 |
|
| 3183 |
=head2 AddIssuingCharge |
3197 |
=head2 AddIssuingCharge |
| 3184 |
|
3198 |
|
| 3185 |
&AddIssuingCharge( $checkout, $charge ) |
3199 |
&AddIssuingCharge( $checkout, $charge, [$type] ) |
| 3186 |
|
3200 |
|
| 3187 |
=cut |
3201 |
=cut |
| 3188 |
|
3202 |
|
| 3189 |
sub AddIssuingCharge { |
3203 |
sub AddIssuingCharge { |
| 3190 |
my ( $checkout, $charge ) = @_; |
3204 |
my ( $checkout, $charge, $type ) = @_; |
|
|
3205 |
|
| 3206 |
$type ||= 'Rental'; |
| 3191 |
|
3207 |
|
| 3192 |
# FIXME What if checkout does not exist? |
3208 |
# FIXME What if checkout does not exist? |
| 3193 |
|
3209 |
|
|
Lines 3205-3211
sub AddIssuingCharge {
Link Here
|
| 3205 |
amount => $charge, |
3221 |
amount => $charge, |
| 3206 |
amountoutstanding => $charge, |
3222 |
amountoutstanding => $charge, |
| 3207 |
manager_id => $manager_id, |
3223 |
manager_id => $manager_id, |
| 3208 |
description => 'Rental', |
3224 |
description => $type, |
| 3209 |
accounttype => 'Rent', |
3225 |
accounttype => 'Rent', |
| 3210 |
date => \'NOW()', |
3226 |
date => \'NOW()', |
| 3211 |
} |
3227 |
} |