Lines 353-394
sub chargelostitem{
Link Here
|
353 |
# a charge has been added |
353 |
# a charge has been added |
354 |
# FIXME : if no replacement price, borrower just doesn't get charged? |
354 |
# FIXME : if no replacement price, borrower just doesn't get charged? |
355 |
my $dbh = C4::Context->dbh(); |
355 |
my $dbh = C4::Context->dbh(); |
356 |
my ($borrowernumber, $itemnumber, $amount, $description) = @_; |
356 |
my ($issues, $description) = @_; |
357 |
|
357 |
my $borrowernumber = $issues->{'borrowernumber'}; |
|
|
358 |
my $itemnumber = $issues->{'itemnumber'}; |
359 |
my $replacementprice = $issues->{'replacementprice'}; |
360 |
my $defaultreplacecost = $issues->{'defaultreplacecost'}; |
361 |
my $processfee = $issues->{'processfee'}; |
362 |
my $usedefaultreplacementcost = C4::Context->preference("useDefaultReplacementCost"); |
363 |
my $processingfeenote = C4::Context->preference("ProcessingFeeNote"); |
364 |
|
365 |
if ($usedefaultreplacementcost && $replacementprice == 0){ |
366 |
$replacementprice = $defaultreplacecost; |
367 |
} |
358 |
# first make sure the borrower hasn't already been charged for this item |
368 |
# first make sure the borrower hasn't already been charged for this item |
359 |
my $sth1=$dbh->prepare("SELECT * from accountlines |
369 |
my $sth1=$dbh->prepare("SELECT * from accountlines |
360 |
WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"); |
370 |
WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"); |
361 |
$sth1->execute($borrowernumber,$itemnumber); |
371 |
$sth1->execute($borrowernumber,$itemnumber); |
362 |
my $existing_charge_hashref=$sth1->fetchrow_hashref(); |
372 |
my $existing_charge_hashref=$sth1->fetchrow_hashref(); |
363 |
|
|
|
364 |
# OK, they haven't |
373 |
# OK, they haven't |
|
|
374 |
my $accountline; |
365 |
unless ($existing_charge_hashref) { |
375 |
unless ($existing_charge_hashref) { |
366 |
my $manager_id = 0; |
|
|
367 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
368 |
# This item is on issue ... add replacement cost to the borrower's record and mark it returned |
369 |
# Note that we add this to the account even if there's no replacement price, allowing some other |
370 |
# process (or person) to update it, since we don't handle any defaults for replacement prices. |
371 |
my $accountno = getnextacctno($borrowernumber); |
372 |
my $sth2=$dbh->prepare("INSERT INTO accountlines |
373 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id) |
374 |
VALUES (?,?,now(),?,?,'L',?,?,?)"); |
375 |
$sth2->execute($borrowernumber,$accountno,$amount, |
376 |
$description,$amount,$itemnumber,$manager_id); |
377 |
|
376 |
|
378 |
if ( C4::Context->preference("FinesLog") ) { |
377 |
#add processing fee |
379 |
logaction("FINES", 'CREATE', $borrowernumber, Dumper({ |
378 |
if ($processfee > 0){ |
380 |
action => 'create_fee', |
379 |
manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1); |
381 |
borrowernumber => $borrowernumber, |
380 |
} |
382 |
accountno => $accountno, |
381 |
#add replace cost |
383 |
amount => $amount, |
382 |
if ($replacementprice > 0){ |
384 |
amountoutstanding => $amount, |
383 |
manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1); |
385 |
description => $description, |
|
|
386 |
accounttype => 'L', |
387 |
itemnumber => $itemnumber, |
388 |
manager_id => $manager_id, |
389 |
})); |
390 |
} |
384 |
} |
391 |
|
|
|
392 |
} |
385 |
} |
393 |
} |
386 |
} |
394 |
|
387 |
|
Lines 409-425
should be the empty string.
Link Here
|
409 |
#' |
402 |
#' |
410 |
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function |
403 |
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function |
411 |
# are : |
404 |
# are : |
412 |
# 'C' = CREDIT |
405 |
# 'C' = CREDIT |
413 |
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) |
406 |
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) |
414 |
# 'N' = New Card fee |
407 |
# 'N' = New Card fee |
415 |
# 'F' = Fine |
408 |
# 'F' = Fine |
416 |
# 'A' = Account Management fee |
409 |
# 'A' = Account Management fee |
417 |
# 'M' = Sundry |
410 |
# 'M' = Sundry |
418 |
# 'L' = Lost Item |
411 |
# 'L' = Lost Item |
419 |
# |
412 |
# |
420 |
|
413 |
|
421 |
sub manualinvoice { |
414 |
sub manualinvoice { |
422 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
415 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $skip_notify ) = @_; |
423 |
my $manager_id = 0; |
416 |
my $manager_id = 0; |
424 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
417 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
425 |
my $dbh = C4::Context->dbh; |
418 |
my $dbh = C4::Context->dbh; |
Lines 427-432
sub manualinvoice {
Link Here
|
427 |
my $insert; |
420 |
my $insert; |
428 |
my $accountno = getnextacctno($borrowernumber); |
421 |
my $accountno = getnextacctno($borrowernumber); |
429 |
my $amountleft = $amount; |
422 |
my $amountleft = $amount; |
|
|
423 |
$skip_notify //= 0; |
430 |
|
424 |
|
431 |
if ( ( $type eq 'L' ) |
425 |
if ( ( $type eq 'L' ) |
432 |
or ( $type eq 'F' ) |
426 |
or ( $type eq 'F' ) |
Lines 434-440
sub manualinvoice {
Link Here
|
434 |
or ( $type eq 'N' ) |
428 |
or ( $type eq 'N' ) |
435 |
or ( $type eq 'M' ) ) |
429 |
or ( $type eq 'M' ) ) |
436 |
{ |
430 |
{ |
437 |
$notifyid = 1; |
431 |
$notifyid = 1 unless $skip_notify; |
438 |
} |
432 |
} |
439 |
|
433 |
|
440 |
if ( $itemnum ) { |
434 |
if ( $itemnum ) { |
Lines 473-481
sub manualinvoice {
Link Here
|
473 |
} |
467 |
} |
474 |
|
468 |
|
475 |
sub getcharges { |
469 |
sub getcharges { |
476 |
my ( $borrowerno, $timestamp, $accountno ) = @_; |
470 |
my ( $borrowerno, $accountno ) = @_; |
477 |
my $dbh = C4::Context->dbh; |
471 |
my $dbh = C4::Context->dbh; |
478 |
my $timestamp2 = $timestamp - 1; |
|
|
479 |
my $query = ""; |
472 |
my $query = ""; |
480 |
my $sth = $dbh->prepare( |
473 |
my $sth = $dbh->prepare( |
481 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" |
474 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" |