Lines 443-449
sub recordpayment_selectaccts {
Link Here
|
443 |
{ |
443 |
{ |
444 |
amount => $amount, |
444 |
amount => $amount, |
445 |
lines => \@lines, |
445 |
lines => \@lines, |
446 |
note => $note |
446 |
note => $note, |
447 |
} |
447 |
} |
448 |
); |
448 |
); |
449 |
} |
449 |
} |
Lines 452-518
sub recordpayment_selectaccts {
Link Here
|
452 |
# fills in |
452 |
# fills in |
453 |
sub makepartialpayment { |
453 |
sub makepartialpayment { |
454 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; |
454 |
my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; |
455 |
my $manager_id = 0; |
|
|
456 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
457 |
if (!$amount || $amount < 0) { |
458 |
return; |
459 |
} |
460 |
$payment_note //= ""; |
461 |
my $dbh = C4::Context->dbh; |
462 |
|
463 |
my $nextaccntno = getnextacctno($borrowernumber); |
464 |
my $newamtos = 0; |
465 |
|
466 |
my $data = $dbh->selectrow_hashref( |
467 |
'SELECT * FROM accountlines WHERE accountlines_id=?',undef,$accountlines_id); |
468 |
my $new_outstanding = $data->{amountoutstanding} - $amount; |
469 |
|
470 |
my $update = 'UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? '; |
471 |
$dbh->do( $update, undef, $new_outstanding, $accountlines_id); |
472 |
|
473 |
if ( C4::Context->preference("FinesLog") ) { |
474 |
logaction("FINES", 'MODIFY', $borrowernumber, Dumper({ |
475 |
action => 'fee_payment', |
476 |
borrowernumber => $borrowernumber, |
477 |
old_amountoutstanding => $data->{'amountoutstanding'}, |
478 |
new_amountoutstanding => $new_outstanding, |
479 |
amount_paid => $data->{'amountoutstanding'} - $new_outstanding, |
480 |
accountlines_id => $data->{'accountlines_id'}, |
481 |
accountno => $data->{'accountno'}, |
482 |
manager_id => $manager_id, |
483 |
})); |
484 |
} |
485 |
|
486 |
# create new line |
487 |
my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' |
488 |
. 'description, accounttype, amountoutstanding, itemnumber, manager_id, note) ' |
489 |
. ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)'; |
490 |
|
491 |
$dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, |
492 |
'', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note); |
493 |
|
455 |
|
494 |
UpdateStats({ |
456 |
my $line = Koha::Account::Lines->find( $accountlines_id ); |
495 |
branch => $branch, |
|
|
496 |
type => 'payment', |
497 |
amount => $amount, |
498 |
borrowernumber => $borrowernumber, |
499 |
accountno => $accountno |
500 |
}); |
501 |
|
457 |
|
502 |
if ( C4::Context->preference("FinesLog") ) { |
458 |
return Koha::Account->new( |
503 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
459 |
{ |
504 |
action => 'create_payment', |
460 |
patron_id => $borrowernumber, |
505 |
borrowernumber => $user, |
461 |
} |
506 |
accountno => $nextaccntno, |
462 |
)->pay( |
507 |
amount => 0 - $amount, |
463 |
{ |
508 |
accounttype => 'Pay', |
464 |
amount => $amount, |
509 |
itemnumber => $data->{'itemnumber'}, |
465 |
lines => [ $line ], |
510 |
accountlines_paid => [ $data->{'accountlines_id'} ], |
466 |
note => $payment_note, |
511 |
manager_id => $manager_id, |
467 |
library_id => $branch, |
512 |
})); |
468 |
} |
513 |
} |
469 |
); |
514 |
|
470 |
|
515 |
return; |
|
|
516 |
} |
471 |
} |
517 |
|
472 |
|
518 |
=head2 WriteOffFee |
473 |
=head2 WriteOffFee |
519 |
- |
|
|