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