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