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 |
365 |
unless ($existing_charge_hashref) { |
374 |
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 |
|
375 |
|
378 |
if ( C4::Context->preference("FinesLog") ) { |
376 |
#add processing fee |
379 |
logaction("FINES", 'CREATE', $borrowernumber, Dumper({ |
377 |
if ($processfee > 0){ |
380 |
action => 'create_fee', |
378 |
manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1); |
381 |
borrowernumber => $borrowernumber, |
379 |
} |
382 |
accountno => $accountno, |
380 |
#add replace cost |
383 |
amount => $amount, |
381 |
if ($replacementprice > 0){ |
384 |
amountoutstanding => $amount, |
382 |
manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1); |
385 |
description => $description, |
|
|
386 |
accounttype => 'L', |
387 |
itemnumber => $itemnumber, |
388 |
manager_id => $manager_id, |
389 |
})); |
390 |
} |
383 |
} |
391 |
|
|
|
392 |
} |
384 |
} |
393 |
} |
385 |
} |
394 |
|
386 |
|
Lines 409-425
should be the empty string.
Link Here
|
409 |
#' |
401 |
#' |
410 |
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function |
402 |
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function |
411 |
# are : |
403 |
# are : |
412 |
# 'C' = CREDIT |
404 |
# 'C' = CREDIT |
413 |
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) |
405 |
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere) |
414 |
# 'N' = New Card fee |
406 |
# 'N' = New Card fee |
415 |
# 'F' = Fine |
407 |
# 'F' = Fine |
416 |
# 'A' = Account Management fee |
408 |
# 'A' = Account Management fee |
417 |
# 'M' = Sundry |
409 |
# 'M' = Sundry |
418 |
# 'L' = Lost Item |
410 |
# 'L' = Lost Item |
419 |
# |
411 |
# |
420 |
|
412 |
|
421 |
sub manualinvoice { |
413 |
sub manualinvoice { |
422 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_; |
414 |
my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $skip_notify ) = @_; |
423 |
my $manager_id = 0; |
415 |
my $manager_id = 0; |
424 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
416 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
425 |
my $dbh = C4::Context->dbh; |
417 |
my $dbh = C4::Context->dbh; |
Lines 427-432
sub manualinvoice {
Link Here
|
427 |
my $insert; |
419 |
my $insert; |
428 |
my $accountno = getnextacctno($borrowernumber); |
420 |
my $accountno = getnextacctno($borrowernumber); |
429 |
my $amountleft = $amount; |
421 |
my $amountleft = $amount; |
|
|
422 |
$skip_notify //= 0; |
430 |
|
423 |
|
431 |
if ( ( $type eq 'L' ) |
424 |
if ( ( $type eq 'L' ) |
432 |
or ( $type eq 'F' ) |
425 |
or ( $type eq 'F' ) |
Lines 434-440
sub manualinvoice {
Link Here
|
434 |
or ( $type eq 'N' ) |
427 |
or ( $type eq 'N' ) |
435 |
or ( $type eq 'M' ) ) |
428 |
or ( $type eq 'M' ) ) |
436 |
{ |
429 |
{ |
437 |
$notifyid = 1; |
430 |
$notifyid = 1 unless $skip_notify; |
438 |
} |
431 |
} |
439 |
|
432 |
|
440 |
if ( $itemnum ) { |
433 |
if ( $itemnum ) { |
Lines 473-481
sub manualinvoice {
Link Here
|
473 |
} |
466 |
} |
474 |
|
467 |
|
475 |
sub getcharges { |
468 |
sub getcharges { |
476 |
my ( $borrowerno, $timestamp, $accountno ) = @_; |
469 |
my ( $borrowerno, $accountno ) = @_; |
477 |
my $dbh = C4::Context->dbh; |
470 |
my $dbh = C4::Context->dbh; |
478 |
my $timestamp2 = $timestamp - 1; |
|
|
479 |
my $query = ""; |
471 |
my $query = ""; |
480 |
my $sth = $dbh->prepare( |
472 |
my $sth = $dbh->prepare( |
481 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" |
473 |
"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" |