|
Lines 50-55
use Koha::Patrons;
Link Here
|
| 50 |
use Koha::Patron::Debarments; |
50 |
use Koha::Patron::Debarments; |
| 51 |
use Koha::Database; |
51 |
use Koha::Database; |
| 52 |
use Koha::Libraries; |
52 |
use Koha::Libraries; |
|
|
53 |
use Koha::Account::Lines; |
| 53 |
use Koha::Holds; |
54 |
use Koha::Holds; |
| 54 |
use Koha::RefundLostItemFeeRule; |
55 |
use Koha::RefundLostItemFeeRule; |
| 55 |
use Koha::RefundLostItemFeeRules; |
56 |
use Koha::RefundLostItemFeeRules; |
|
Lines 2395-2401
sub _FixAccountForLostAndReturned {
Link Here
|
| 2395 |
WHERE (accountlines_id = ?)"); |
2396 |
WHERE (accountlines_id = ?)"); |
| 2396 |
$usth->execute($data->{'accountlines_id'}); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in. |
2397 |
$usth->execute($data->{'accountlines_id'}); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in. |
| 2397 |
#check if any credit is left if so writeoff other accounts |
2398 |
#check if any credit is left if so writeoff other accounts |
| 2398 |
my $nextaccntno = getnextacctno($data->{'borrowernumber'}); |
2399 |
my $nextaccntno = C4::Accounts::getnextacctno($data->{'borrowernumber'}); |
| 2399 |
$amountleft *= -1 if ($amountleft < 0); |
2400 |
$amountleft *= -1 if ($amountleft < 0); |
| 2400 |
if ($amountleft > 0) { |
2401 |
if ($amountleft > 0) { |
| 2401 |
my $msth = $dbh->prepare("SELECT * FROM accountlines WHERE (borrowernumber = ?) |
2402 |
my $msth = $dbh->prepare("SELECT * FROM accountlines WHERE (borrowernumber = ?) |
|
Lines 2425-2435
sub _FixAccountForLostAndReturned {
Link Here
|
| 2425 |
} |
2426 |
} |
| 2426 |
} |
2427 |
} |
| 2427 |
$amountleft *= -1 if ($amountleft > 0); |
2428 |
$amountleft *= -1 if ($amountleft > 0); |
|
|
2429 |
|
| 2430 |
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 2431 |
|
| 2428 |
my $desc = "Item Returned " . $item_id; |
2432 |
my $desc = "Item Returned " . $item_id; |
| 2429 |
$usth = $dbh->prepare("INSERT INTO accountlines |
2433 |
|
| 2430 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) |
2434 |
Koha::Account::Line->new( |
| 2431 |
VALUES (?,?,now(),?,?,'CR',?)"); |
2435 |
{ |
| 2432 |
$usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft); |
2436 |
borrowernumber => $data->{borrowernumber}, |
|
|
2437 |
accountno => $nextaccntno, |
| 2438 |
date => dt_from_string(), |
| 2439 |
amount => 0 - $amount, |
| 2440 |
description => $desc, |
| 2441 |
accounttype => 'CR', |
| 2442 |
amountoutstanding => $amountleft, |
| 2443 |
branchcode => $branchcode, |
| 2444 |
} |
| 2445 |
)->store(); |
| 2446 |
|
| 2433 |
if ($borrowernumber) { |
2447 |
if ($borrowernumber) { |
| 2434 |
# FIXME: same as query above. use 1 sth for both |
2448 |
# FIXME: same as query above. use 1 sth for both |
| 2435 |
$usth = $dbh->prepare("INSERT INTO accountoffsets |
2449 |
$usth = $dbh->prepare("INSERT INTO accountoffsets |
|
Lines 2858-2875
sub AddRenewal {
Link Here
|
| 2858 |
# Charge a new rental fee, if applicable? |
2872 |
# Charge a new rental fee, if applicable? |
| 2859 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2873 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
| 2860 |
if ( $charge > 0 ) { |
2874 |
if ( $charge > 0 ) { |
| 2861 |
my $accountno = getnextacctno( $borrowernumber ); |
2875 |
my $accountno = C4::Accounts::getnextacctno( $borrowernumber ); |
| 2862 |
my $manager_id = 0; |
2876 |
my $manager_id = 0; |
| 2863 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2877 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
| 2864 |
$sth = $dbh->prepare( |
2878 |
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 2865 |
"INSERT INTO accountlines |
2879 |
Koha::Account::Line->new( |
| 2866 |
(date, borrowernumber, accountno, amount, manager_id, |
2880 |
{ |
| 2867 |
description,accounttype, amountoutstanding, itemnumber) |
2881 |
date => dt_from_string(), |
| 2868 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2882 |
borrowernumber => $borrowernumber, |
| 2869 |
); |
2883 |
accountno => $accountno, |
| 2870 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2884 |
amount => $charge, |
| 2871 |
"Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", |
2885 |
manager_id => $manager_id, |
| 2872 |
'Rent', $charge, $itemnumber ); |
2886 |
accounttype => 'Rent', |
|
|
2887 |
amountoutstanding => $charge, |
| 2888 |
itemnumber => $itemnumber, |
| 2889 |
branchcode => $branchcode, |
| 2890 |
description => 'Renewal of Rental Item ' |
| 2891 |
. $biblio->title |
| 2892 |
. " $item->{'barcode'}", |
| 2893 |
} |
| 2894 |
)->store(); |
| 2873 |
} |
2895 |
} |
| 2874 |
|
2896 |
|
| 2875 |
# Send a renewal slip according to checkout alert preferencei |
2897 |
# Send a renewal slip according to checkout alert preferencei |
|
Lines 3194-3212
sub _get_discount_from_rule {
Link Here
|
| 3194 |
|
3216 |
|
| 3195 |
sub AddIssuingCharge { |
3217 |
sub AddIssuingCharge { |
| 3196 |
my ( $itemnumber, $borrowernumber, $charge ) = @_; |
3218 |
my ( $itemnumber, $borrowernumber, $charge ) = @_; |
| 3197 |
my $dbh = C4::Context->dbh; |
3219 |
|
| 3198 |
my $nextaccntno = getnextacctno( $borrowernumber ); |
3220 |
my $nextaccntno = getnextacctno($borrowernumber); |
|
|
3221 |
|
| 3199 |
my $manager_id = 0; |
3222 |
my $manager_id = 0; |
| 3200 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
3223 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
| 3201 |
my $query =" |
3224 |
|
| 3202 |
INSERT INTO accountlines |
3225 |
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 3203 |
(borrowernumber, itemnumber, accountno, |
3226 |
|
| 3204 |
date, amount, description, accounttype, |
3227 |
Koha::Account::Line->new( |
| 3205 |
amountoutstanding, manager_id) |
3228 |
{ |
| 3206 |
VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?) |
3229 |
date => dt_from_string(), |
| 3207 |
"; |
3230 |
borrowernumber => $borrowernumber, |
| 3208 |
my $sth = $dbh->prepare($query); |
3231 |
accountno => $nextaccntno, |
| 3209 |
$sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id ); |
3232 |
amount => $charge, |
|
|
3233 |
manager_id => $manager_id, |
| 3234 |
accounttype => 'Rent', |
| 3235 |
amountoutstanding => $charge, |
| 3236 |
itemnumber => $itemnumber, |
| 3237 |
branchcode => $branchcode, |
| 3238 |
description => 'Rental', |
| 3239 |
} |
| 3240 |
)->store(); |
| 3210 |
} |
3241 |
} |
| 3211 |
|
3242 |
|
| 3212 |
=head2 GetTransfers |
3243 |
=head2 GetTransfers |