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