Lines 198-204
sub DebitLostItem {
Link Here
|
198 |
$params->{amount} = $item->replacementprice(); |
198 |
$params->{amount} = $item->replacementprice(); |
199 |
$params->{itemnumber} = $item->itemnumber(); |
199 |
$params->{itemnumber} = $item->itemnumber(); |
200 |
$params->{issue_id} = $issue->issue_id(); |
200 |
$params->{issue_id} = $issue->issue_id(); |
201 |
$params->{description} = "Lost Item " . $issue->item()->biblio()->title() . " " . $issue->item()->barcode(); |
201 |
$params->{description} = |
|
|
202 |
"Lost Item " |
203 |
. $issue->item()->biblio()->title() . " " |
204 |
. $issue->item()->barcode(); |
202 |
|
205 |
|
203 |
#TODO: Shouldn't we have a default replacement price as a syspref? |
206 |
#TODO: Shouldn't we have a default replacement price as a syspref? |
204 |
if ( $params->{amount} ) { |
207 |
if ( $params->{amount} ) { |
Lines 442-448
sub RecalculateAccountBalance {
Link Here
|
442 |
my $debits = |
445 |
my $debits = |
443 |
Koha::Database->new()->schema->resultset('AccountDebit') |
446 |
Koha::Database->new()->schema->resultset('AccountDebit') |
444 |
->search( { borrowernumber => $borrower->borrowernumber() } ); |
447 |
->search( { borrowernumber => $borrower->borrowernumber() } ); |
445 |
my $amount_outstanding = $debits->get_column('amount_outstanding')->sum() || 0; |
448 |
my $amount_outstanding = $debits->get_column('amount_outstanding')->sum() |
|
|
449 |
|| 0; |
446 |
|
450 |
|
447 |
my $credits = |
451 |
my $credits = |
448 |
Koha::Database->new()->schema->resultset('AccountCredit') |
452 |
Koha::Database->new()->schema->resultset('AccountCredit') |
Lines 475-487
sub VoidCredit {
Link Here
|
475 |
my $credit = $schema->resultset('AccountCredit')->find($id); |
479 |
my $credit = $schema->resultset('AccountCredit')->find($id); |
476 |
|
480 |
|
477 |
foreach my $offset ( $credit->account_offsets() ) { |
481 |
foreach my $offset ( $credit->account_offsets() ) { |
478 |
my $debit = $offset->debit(); |
482 |
my $debit = $offset->debit(); |
479 |
|
483 |
|
480 |
$debit->amount_outstanding( $debit->amount_outstanding() - $offset->amount() ); |
484 |
$debit->amount_outstanding( |
481 |
$debit->updated_on( get_timestamp() ); |
485 |
$debit->amount_outstanding() - $offset->amount() ); |
482 |
$debit->update(); |
486 |
$debit->updated_on( get_timestamp() ); |
|
|
487 |
$debit->update(); |
483 |
|
488 |
|
484 |
Koha::Database->new()->schema->resultset('AccountOffset')->create( |
489 |
Koha::Database->new()->schema->resultset('AccountOffset')->create( |
485 |
{ |
490 |
{ |
486 |
amount => $offset->amount() * -1, |
491 |
amount => $offset->amount() * -1, |
487 |
debit_id => $debit->id(), |
492 |
debit_id => $debit->id(), |
Lines 489-495
sub VoidCredit {
Link Here
|
489 |
created_on => get_timestamp(), |
494 |
created_on => get_timestamp(), |
490 |
type => Koha::Accounts::OffsetTypes::Void(), |
495 |
type => Koha::Accounts::OffsetTypes::Void(), |
491 |
} |
496 |
} |
492 |
); |
497 |
); |
493 |
} |
498 |
} |
494 |
|
499 |
|
495 |
$credit->amount_voided( $credit->amount_paid ); |
500 |
$credit->amount_voided( $credit->amount_paid ); |
Lines 520-540
sub NormalizeBalances {
Link Here
|
520 |
|
525 |
|
521 |
my $schema = Koha::Database->new()->schema(); |
526 |
my $schema = Koha::Database->new()->schema(); |
522 |
|
527 |
|
523 |
my @credits = |
528 |
my @credits = $schema->resultset('AccountCredit')->search( |
524 |
$schema->resultset('AccountCredit')->search( |
|
|
525 |
{ |
529 |
{ |
526 |
borrowernumber => $borrower->borrowernumber(), |
530 |
borrowernumber => $borrower->borrowernumber(), |
527 |
amount_remaining => { '>' => '0' } |
531 |
amount_remaining => { '>' => '0' } |
528 |
} |
532 |
} |
529 |
); |
533 |
); |
530 |
|
534 |
|
531 |
my @debits = |
535 |
my @debits = $schema->resultset('AccountDebit')->search( |
532 |
$schema->resultset('AccountDebit')->search( |
|
|
533 |
{ |
536 |
{ |
534 |
borrowernumber => $borrower->borrowernumber(), |
537 |
borrowernumber => $borrower->borrowernumber(), |
535 |
amount_outstanding => { '>' => '0' } |
538 |
amount_outstanding => { '>' => '0' } |
536 |
} |
539 |
} |
537 |
); |
540 |
); |
538 |
|
541 |
|
539 |
foreach my $credit (@credits) { |
542 |
foreach my $credit (@credits) { |
540 |
foreach my $debit (@debits) { |
543 |
foreach my $debit (@debits) { |