|
Lines 289-294
sub void {
Link Here
|
| 289 |
} |
289 |
} |
| 290 |
)->store(); |
290 |
)->store(); |
| 291 |
|
291 |
|
|
|
292 |
# Link void to payment |
| 293 |
$self->set({ |
| 294 |
amountoutstanding => $self->amount, |
| 295 |
status => 'VOID' |
| 296 |
})->store(); |
| 297 |
$self->apply( { debits => [$void] } ); |
| 298 |
|
| 292 |
# Reverse any applied payments |
299 |
# Reverse any applied payments |
| 293 |
foreach my $account_offset (@account_offsets) { |
300 |
foreach my $account_offset (@account_offsets) { |
| 294 |
my $fee_paid = |
301 |
my $fee_paid = |
|
Lines 311-323
sub void {
Link Here
|
| 311 |
)->store(); |
318 |
)->store(); |
| 312 |
} |
319 |
} |
| 313 |
|
320 |
|
| 314 |
# Link void to payment |
|
|
| 315 |
$self->set({ |
| 316 |
amountoutstanding => $self->amount, |
| 317 |
status => 'VOID' |
| 318 |
})->store(); |
| 319 |
$self->apply({ debits => [$void]}); |
| 320 |
|
| 321 |
if ( C4::Context->preference("FinesLog") ) { |
321 |
if ( C4::Context->preference("FinesLog") ) { |
| 322 |
logaction( |
322 |
logaction( |
| 323 |
"FINES", 'VOID', |
323 |
"FINES", 'VOID', |
|
Lines 422-433
sub cancel {
Link Here
|
| 422 |
)->store(); |
422 |
)->store(); |
| 423 |
|
423 |
|
| 424 |
# Link cancellation to charge |
424 |
# Link cancellation to charge |
| 425 |
$cancellation->apply( |
425 |
$cancellation->apply( { debits => [$self] } ); |
| 426 |
{ |
|
|
| 427 |
debits => [$self], |
| 428 |
offset_type => 'CANCELLATION' |
| 429 |
} |
| 430 |
); |
| 431 |
$cancellation->status('APPLIED')->store(); |
426 |
$cancellation->status('APPLIED')->store(); |
| 432 |
|
427 |
|
| 433 |
# Update status of original debit |
428 |
# Update status of original debit |
|
Lines 549-560
sub reduce {
Link Here
|
| 549 |
my $debit_outstanding = $self->amountoutstanding; |
544 |
my $debit_outstanding = $self->amountoutstanding; |
| 550 |
if ( $debit_outstanding >= $params->{amount} ) { |
545 |
if ( $debit_outstanding >= $params->{amount} ) { |
| 551 |
|
546 |
|
| 552 |
$reduction->apply( |
547 |
$reduction->apply( { debits => [$self] } ); |
| 553 |
{ |
|
|
| 554 |
debits => [$self], |
| 555 |
offset_type => uc( $params->{reduction_type} ) |
| 556 |
} |
| 557 |
); |
| 558 |
$reduction->status('APPLIED')->store(); |
548 |
$reduction->status('APPLIED')->store(); |
| 559 |
} |
549 |
} |
| 560 |
else { |
550 |
else { |
|
Lines 565-571
sub reduce {
Link Here
|
| 565 |
{ |
555 |
{ |
| 566 |
credit_id => $reduction->accountlines_id, |
556 |
credit_id => $reduction->accountlines_id, |
| 567 |
debit_id => $self->accountlines_id, |
557 |
debit_id => $self->accountlines_id, |
| 568 |
type => uc( $params->{reduction_type} ), |
558 |
type => 'APPLY', |
| 569 |
amount => 0 |
559 |
amount => 0 |
| 570 |
} |
560 |
} |
| 571 |
)->store(); |
561 |
)->store(); |
|
Lines 583-589
sub reduce {
Link Here
|
| 583 |
=head3 apply |
573 |
=head3 apply |
| 584 |
|
574 |
|
| 585 |
my $debits = $account->outstanding_debits; |
575 |
my $debits = $account->outstanding_debits; |
| 586 |
my $credit = $credit->apply( { debits => $debits, [ offset_type => $offset_type ] } ); |
576 |
my $credit = $credit->apply( { debits => $debits } ); |
| 587 |
|
577 |
|
| 588 |
Applies the credit to a given debits array reference. |
578 |
Applies the credit to a given debits array reference. |
| 589 |
|
579 |
|
|
Lines 593-601
Applies the credit to a given debits array reference.
Link Here
|
| 593 |
|
583 |
|
| 594 |
=item debits - Koha::Account::Lines object set of debits |
584 |
=item debits - Koha::Account::Lines object set of debits |
| 595 |
|
585 |
|
| 596 |
=item offset_type (optional) - a string indicating the offset type (valid values are those from |
|
|
| 597 |
the 'account_offset_types' table) |
| 598 |
|
| 599 |
=back |
586 |
=back |
| 600 |
|
587 |
|
| 601 |
=cut |
588 |
=cut |
|
Lines 604-610
sub apply {
Link Here
|
| 604 |
my ( $self, $params ) = @_; |
591 |
my ( $self, $params ) = @_; |
| 605 |
|
592 |
|
| 606 |
my $debits = $params->{debits}; |
593 |
my $debits = $params->{debits}; |
| 607 |
my $offset_type = $params->{offset_type} // 'Credit Applied'; |
|
|
| 608 |
|
594 |
|
| 609 |
unless ( $self->is_credit ) { |
595 |
unless ( $self->is_credit ) { |
| 610 |
Koha::Exceptions::Account::IsNotCredit->throw( |
596 |
Koha::Exceptions::Account::IsNotCredit->throw( |
|
Lines 645-651
sub apply {
Link Here
|
| 645 |
{ credit_id => $self->id, |
631 |
{ credit_id => $self->id, |
| 646 |
debit_id => $debit->id, |
632 |
debit_id => $debit->id, |
| 647 |
amount => $amount_to_cancel * -1, |
633 |
amount => $amount_to_cancel * -1, |
| 648 |
type => $offset_type, |
634 |
type => 'APPLY' |
| 649 |
} |
635 |
} |
| 650 |
)->store(); |
636 |
)->store(); |
| 651 |
|
637 |
|
|
Lines 778-784
sub payout {
Link Here
|
| 778 |
} |
764 |
} |
| 779 |
)->store(); |
765 |
)->store(); |
| 780 |
|
766 |
|
| 781 |
$self->apply( { debits => [$payout], offset_type => 'PAYOUT' } ); |
767 |
$self->apply( { debits => [$payout] } ); |
| 782 |
$self->status('PAID')->store; |
768 |
$self->status('PAID')->store; |
| 783 |
} |
769 |
} |
| 784 |
); |
770 |
); |