Lines 489-507
sub add_credit {
Link Here
|
489 |
|
489 |
|
490 |
This method allows adding debits to a patron's account |
490 |
This method allows adding debits to a patron's account |
491 |
|
491 |
|
492 |
my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit( |
492 |
my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit( |
493 |
{ |
493 |
{ |
494 |
amount => $amount, |
494 |
amount => $amount, |
495 |
description => $description, |
495 |
description => $description, |
496 |
note => $note, |
496 |
note => $note, |
497 |
user_id => $user_id, |
497 |
user_id => $user_id, |
498 |
interface => $interface, |
498 |
interface => $interface, |
499 |
library_id => $library_id, |
499 |
library_id => $library_id, |
500 |
type => $debit_type, |
500 |
type => $debit_type, |
501 |
item_id => $item_id, |
501 |
transaction_type => $transaction_type, |
502 |
issue_id => $issue_id |
502 |
cash_register => $register_id, |
503 |
} |
503 |
item_id => $item_id, |
504 |
); |
504 |
issue_id => $issue_id |
|
|
505 |
} |
506 |
); |
505 |
|
507 |
|
506 |
$debit_type can be any of: |
508 |
$debit_type can be any of: |
507 |
- ACCOUNT |
509 |
- ACCOUNT |
Lines 517-522
$debit_type can be any of:
Link Here
|
517 |
- RENT_RENEW |
519 |
- RENT_RENEW |
518 |
- RENT_DAILY_RENEW |
520 |
- RENT_DAILY_RENEW |
519 |
- RESERVE |
521 |
- RESERVE |
|
|
522 |
- PAYOUT |
520 |
|
523 |
|
521 |
=cut |
524 |
=cut |
522 |
|
525 |
|
Lines 533-538
sub add_debit {
Link Here
|
533 |
} |
536 |
} |
534 |
} |
537 |
} |
535 |
|
538 |
|
|
|
539 |
# check for cash register if using cash |
540 |
Koha::Exceptions::Account::RegisterRequired->throw() |
541 |
if ( C4::Context->preference("UseCashRegisters") |
542 |
&& defined( $params->{transaction_type} ) |
543 |
&& ( $params->{transaction_type} eq 'CASH' ) |
544 |
&& !defined( $params->{cash_register} ) ); |
545 |
|
536 |
# amount should always be a positive value |
546 |
# amount should always be a positive value |
537 |
my $amount = $params->{amount}; |
547 |
my $amount = $params->{amount}; |
538 |
unless ( $amount > 0 ) { |
548 |
unless ( $amount > 0 ) { |
Lines 540-554
sub add_debit {
Link Here
|
540 |
error => 'Debit amount passed is not positive' ); |
550 |
error => 'Debit amount passed is not positive' ); |
541 |
} |
551 |
} |
542 |
|
552 |
|
543 |
my $description = $params->{description} // q{}; |
553 |
my $description = $params->{description} // q{}; |
544 |
my $note = $params->{note} // q{}; |
554 |
my $note = $params->{note} // q{}; |
545 |
my $user_id = $params->{user_id}; |
555 |
my $user_id = $params->{user_id}; |
546 |
my $interface = $params->{interface}; |
556 |
my $interface = $params->{interface}; |
547 |
my $library_id = $params->{library_id}; |
557 |
my $library_id = $params->{library_id}; |
548 |
my $debit_type = $params->{type}; |
558 |
my $cash_register = $params->{cash_register}; |
549 |
my $item_id = $params->{item_id}; |
559 |
my $debit_type = $params->{type}; |
550 |
my $issue_id = $params->{issue_id}; |
560 |
my $transaction_type = $params->{transaction_type}; |
551 |
my $offset_type = $Koha::Account::offset_type->{$debit_type} // 'Manual Debit'; |
561 |
my $item_id = $params->{item_id}; |
|
|
562 |
my $issue_id = $params->{issue_id}; |
563 |
my $offset_type = $Koha::Account::offset_type->{$debit_type} // 'Manual Debit'; |
552 |
|
564 |
|
553 |
my $line; |
565 |
my $line; |
554 |
my $schema = Koha::Database->new->schema; |
566 |
my $schema = Koha::Database->new->schema; |
Lines 565-577
sub add_debit {
Link Here
|
565 |
description => $description, |
577 |
description => $description, |
566 |
debit_type_code => $debit_type, |
578 |
debit_type_code => $debit_type, |
567 |
amountoutstanding => $amount, |
579 |
amountoutstanding => $amount, |
568 |
payment_type => undef, |
580 |
payment_type => $transaction_type, |
569 |
note => $note, |
581 |
note => $note, |
570 |
manager_id => $user_id, |
582 |
manager_id => $user_id, |
571 |
interface => $interface, |
583 |
interface => $interface, |
572 |
itemnumber => $item_id, |
584 |
itemnumber => $item_id, |
573 |
issue_id => $issue_id, |
585 |
issue_id => $issue_id, |
574 |
branchcode => $library_id, |
586 |
branchcode => $library_id, |
|
|
587 |
register_id => $cash_register, |
575 |
( |
588 |
( |
576 |
$debit_type eq 'OVERDUE' |
589 |
$debit_type eq 'OVERDUE' |
577 |
? ( status => 'UNRETURNED' ) |
590 |
? ( status => 'UNRETURNED' ) |
Lines 669-675
sub payout_amount {
Link Here
|
669 |
my $amount = $params->{amount}; |
682 |
my $amount = $params->{amount}; |
670 |
unless ( $amount > 0 ) { |
683 |
unless ( $amount > 0 ) { |
671 |
Koha::Exceptions::Account::AmountNotPositive->throw( |
684 |
Koha::Exceptions::Account::AmountNotPositive->throw( |
672 |
error => 'Debit amount passed is not positive' ); |
685 |
error => 'Payout amount passed is not positive' ); |
673 |
} |
686 |
} |
674 |
|
687 |
|
675 |
# Amount should always be less than or equal to outstanding credit |
688 |
# Amount should always be less than or equal to outstanding credit |
Lines 696-707
sub payout_amount {
Link Here
|
696 |
{ |
709 |
{ |
697 |
amount => $params->{amount}, |
710 |
amount => $params->{amount}, |
698 |
type => 'PAYOUT', |
711 |
type => 'PAYOUT', |
699 |
payment_type => $params->{payout_type}, |
712 |
transaction_type => $params->{payout_type}, |
700 |
amountoutstanding => $params->{amount}, |
713 |
amountoutstanding => $params->{amount}, |
701 |
manager_id => $params->{staff_id}, |
714 |
manager_id => $params->{staff_id}, |
702 |
interface => $params->{interface}, |
715 |
interface => $params->{interface}, |
703 |
branchcode => $params->{branch}, |
716 |
branchcode => $params->{branch}, |
704 |
register_id => $params->{cash_register} |
717 |
cash_register => $params->{cash_register} |
705 |
} |
718 |
} |
706 |
); |
719 |
); |
707 |
|
720 |
|
Lines 710-715
sub payout_amount {
Link Here
|
710 |
$credit->apply( |
723 |
$credit->apply( |
711 |
{ debits => [$payout], offset_type => 'PAYOUT' } ); |
724 |
{ debits => [$payout], offset_type => 'PAYOUT' } ); |
712 |
$payout->discard_changes; |
725 |
$payout->discard_changes; |
|
|
726 |
last if $payout->amountoutstanding == 0; |
713 |
} |
727 |
} |
714 |
|
728 |
|
715 |
# Set payout as paid |
729 |
# Set payout as paid |
Lines 884-890
our $offset_type = {
Link Here
|
884 |
'RENT_RENEW' => 'Rental Fee', |
898 |
'RENT_RENEW' => 'Rental Fee', |
885 |
'RENT_DAILY_RENEW' => 'Rental Fee', |
899 |
'RENT_DAILY_RENEW' => 'Rental Fee', |
886 |
'OVERDUE' => 'OVERDUE', |
900 |
'OVERDUE' => 'OVERDUE', |
887 |
'RESERVE_EXPIRED' => 'Hold Expired' |
901 |
'RESERVE_EXPIRED' => 'Hold Expired', |
|
|
902 |
'PAYOUT' => 'PAYOUT', |
888 |
}; |
903 |
}; |
889 |
|
904 |
|
890 |
=head1 AUTHORS |
905 |
=head1 AUTHORS |