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