|
Lines 32-37
use Koha::Patrons;
Link Here
|
| 32 |
use Koha::Account::Lines; |
32 |
use Koha::Account::Lines; |
| 33 |
use Koha::Account::Offsets; |
33 |
use Koha::Account::Offsets; |
| 34 |
use Koha::DateUtils qw( dt_from_string ); |
34 |
use Koha::DateUtils qw( dt_from_string ); |
|
|
35 |
use Koha::Exceptions::Account; |
| 35 |
|
36 |
|
| 36 |
=head1 NAME |
37 |
=head1 NAME |
| 37 |
|
38 |
|
|
Lines 340-346
sub add_credit {
Link Here
|
| 340 |
|
341 |
|
| 341 |
my $schema = Koha::Database->new->schema; |
342 |
my $schema = Koha::Database->new->schema; |
| 342 |
|
343 |
|
| 343 |
my $account_type = $Koha::Account::account_type->{$type}; |
344 |
my $account_type = $Koha::Account::account_type_credit->{$type}; |
| 344 |
$account_type .= $sip |
345 |
$account_type .= $sip |
| 345 |
if defined $sip && |
346 |
if defined $sip && |
| 346 |
$type eq 'payment'; |
347 |
$type eq 'payment'; |
|
Lines 423-440
my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit(
Link Here
|
| 423 |
user_id => $user_id, |
424 |
user_id => $user_id, |
| 424 |
library_id => $library_id, |
425 |
library_id => $library_id, |
| 425 |
sip => $sip, |
426 |
sip => $sip, |
| 426 |
payment_type => $payment_type, |
427 |
invoice_type => $invoice_type, |
| 427 |
type => $debit_type, |
428 |
type => $debit_type, |
| 428 |
item_id => $item_id |
429 |
item_id => $item_id |
| 429 |
} |
430 |
} |
| 430 |
); |
431 |
); |
| 431 |
|
432 |
|
| 432 |
$debit_type can be any of: |
433 |
$debit_type can be any of: |
| 433 |
- 'credit' |
434 |
- 'fine' |
| 434 |
- 'payment' |
435 |
- 'lost' |
| 435 |
- 'forgiven' |
436 |
- 'processing' |
| 436 |
- 'lost_item_return' |
437 |
- 'management' |
| 437 |
- 'writeoff' |
438 |
- 'sundry' |
|
|
439 |
- 'card' |
| 438 |
|
440 |
|
| 439 |
=cut |
441 |
=cut |
| 440 |
|
442 |
|
|
Lines 442-464
sub add_debit {
Link Here
|
| 442 |
|
444 |
|
| 443 |
my ( $self, $params ) = @_; |
445 |
my ( $self, $params ) = @_; |
| 444 |
|
446 |
|
| 445 |
# amount is passed as a positive value, but we store debit as negative values |
447 |
# amount should always be a positive value |
| 446 |
my $amount = $params->{amount} * -1; |
448 |
my $amount = $params->{amount}; |
|
|
449 |
|
| 450 |
unless ( $amount > 0 ) { |
| 451 |
Koha::Exceptions::Account::AmountNotPositive->throw( |
| 452 |
error => 'Debit amount passed is not positive' |
| 453 |
); |
| 454 |
} |
| 455 |
|
| 447 |
my $description = $params->{description} // q{}; |
456 |
my $description = $params->{description} // q{}; |
| 448 |
my $note = $params->{note} // q{}; |
457 |
my $note = $params->{note} // q{}; |
| 449 |
my $user_id = $params->{user_id}; |
458 |
my $user_id = $params->{user_id}; |
| 450 |
my $library_id = $params->{library_id}; |
459 |
my $library_id = $params->{library_id}; |
| 451 |
my $sip = $params->{sip}; |
460 |
my $sip = $params->{sip}; |
| 452 |
my $payment_type = $params->{payment_type}; |
461 |
my $invoice_type = $params->{invoice_type}; |
| 453 |
my $type = $params->{type} || 'payment'; |
462 |
my $type = $params->{type}; |
| 454 |
my $item_id = $params->{item_id}; |
463 |
my $item_id = $params->{item_id}; |
| 455 |
|
464 |
|
| 456 |
my $schema = Koha::Database->new->schema; |
465 |
my $schema = Koha::Database->new->schema; |
| 457 |
|
466 |
|
| 458 |
my $account_type = $Koha::Account::account_type->{$type}; |
467 |
unless ( exists($Koha::Account::account_type_debit->{$type}) ) { |
| 459 |
$account_type .= $sip |
468 |
Koha::Exceptions::Account::UnrecognisedType->throw( |
| 460 |
if defined $sip && |
469 |
error => 'Type of debit not recognised' |
| 461 |
$type eq 'payment'; |
470 |
); |
|
|
471 |
} |
| 472 |
|
| 473 |
my $account_type = $Koha::Account::account_type_debit->{$type}; |
| 462 |
|
474 |
|
| 463 |
my $line; |
475 |
my $line; |
| 464 |
|
476 |
|
|
Lines 477-483
sub add_debit {
Link Here
|
| 477 |
description => $description, |
489 |
description => $description, |
| 478 |
accounttype => $account_type, |
490 |
accounttype => $account_type, |
| 479 |
amountoutstanding => $amount, |
491 |
amountoutstanding => $amount, |
| 480 |
payment_type => $payment_type, |
492 |
invoice_type => $invoice_type, |
| 481 |
note => $note, |
493 |
note => $note, |
| 482 |
manager_id => $user_id, |
494 |
manager_id => $user_id, |
| 483 |
itemnumber => $item_id |
495 |
itemnumber => $item_id |
|
Lines 499-505
sub add_debit {
Link Here
|
| 499 |
borrowernumber => $self->{patron_id}, |
511 |
borrowernumber => $self->{patron_id}, |
| 500 |
accountno => $accountno, |
512 |
accountno => $accountno, |
| 501 |
} |
513 |
} |
| 502 |
) if grep { $type eq $_ } ('payment', 'writeoff') ; |
514 |
) if grep { $type eq $_ } ('renew', 'issue', 'localuse', 'return', 'onsite_checkout' ) ; |
| 503 |
|
515 |
|
| 504 |
if ( C4::Context->preference("FinesLog") ) { |
516 |
if ( C4::Context->preference("FinesLog") ) { |
| 505 |
logaction( |
517 |
logaction( |
|
Lines 655-665
our $offset_type = {
Link Here
|
| 655 |
'writeoff' => 'Writeoff' |
667 |
'writeoff' => 'Writeoff' |
| 656 |
}; |
668 |
}; |
| 657 |
|
669 |
|
| 658 |
=head3 $account_type |
670 |
=head3 $account_type_credit |
| 659 |
|
671 |
|
| 660 |
=cut |
672 |
=cut |
| 661 |
|
673 |
|
| 662 |
our $account_type = { |
674 |
our $account_type_credit = { |
| 663 |
'credit' => 'C', |
675 |
'credit' => 'C', |
| 664 |
'forgiven' => 'FOR', |
676 |
'forgiven' => 'FOR', |
| 665 |
'lost_item_return' => 'CR', |
677 |
'lost_item_return' => 'CR', |
|
Lines 667-674
our $account_type = {
Link Here
|
| 667 |
'writeoff' => 'W' |
679 |
'writeoff' => 'W' |
| 668 |
}; |
680 |
}; |
| 669 |
|
681 |
|
|
|
682 |
=head3 $account_type_debit |
| 683 |
|
| 684 |
=cut |
| 685 |
|
| 686 |
our $account_type_debit = { |
| 687 |
'new_card' => 'N', |
| 688 |
'fine' => 'F', |
| 689 |
'fine_updating' => 'FU', |
| 690 |
'account' => 'A', |
| 691 |
'lost' => 'L', |
| 692 |
'sundry' => 'M', |
| 693 |
'processing' => 'PF', |
| 694 |
'rent' => 'R', |
| 695 |
'reserve' => 'Res', |
| 696 |
'overdue' => 'O' |
| 697 |
}; |
| 698 |
|
| 670 |
=head1 AUTHOR |
699 |
=head1 AUTHOR |
| 671 |
|
700 |
|
| 672 |
Kyle M Hall <kyle.m.hall@gmail.com> |
701 |
Kyle M Hall <kyle.m.hall@gmail.com> |
|
|
702 |
Tomás Cohen Arazi <tomascohen@gmail.com> |
| 703 |
Martin Renvoize <martin.renvoize@ptfs-europe.com> |
| 673 |
|
704 |
|
| 674 |
=cut |
705 |
=cut |