View | Details | Raw Unified | Return to bug 23049
Collapse All | Expand All

(-)a/Koha/Account.pm (-34 / +6 lines)
Lines 477-483 sub add_debit { Link Here
477
    my $user_id     = $params->{user_id};
477
    my $user_id     = $params->{user_id};
478
    my $interface   = $params->{interface};
478
    my $interface   = $params->{interface};
479
    my $library_id  = $params->{library_id};
479
    my $library_id  = $params->{library_id};
480
    my $type        = $params->{type};
480
    my $debit_type  = $params->{type};
481
    my $item_id     = $params->{item_id};
481
    my $item_id     = $params->{item_id};
482
    my $issue_id    = $params->{issue_id};
482
    my $issue_id    = $params->{issue_id};
483
483
Lines 488-501 sub add_debit { Link Here
488
488
489
    my $schema = Koha::Database->new->schema;
489
    my $schema = Koha::Database->new->schema;
490
490
491
    unless ( exists($Koha::Account::account_type_debit->{$type}) ) {
492
        Koha::Exceptions::Account::UnrecognisedType->throw(
493
            error => 'Type of debit not recognised'
494
        );
495
    }
496
497
    my $debit_type_code = $Koha::Account::account_type_debit->{$type};
498
499
    my $line;
491
    my $line;
500
    $schema->txn_do(
492
    $schema->txn_do(
501
        sub {
493
        sub {
Lines 507-513 sub add_debit { Link Here
507
                    date              => \'NOW()',
499
                    date              => \'NOW()',
508
                    amount            => $amount,
500
                    amount            => $amount,
509
                    description       => $description,
501
                    description       => $description,
510
                    debit_type_code   => $debit_type_code,
502
                    debit_type_code   => $debit_type,
511
                    amountoutstanding => $amount,
503
                    amountoutstanding => $amount,
512
                    payment_type      => undef,
504
                    payment_type      => undef,
513
                    note              => $note,
505
                    note              => $note,
Lines 516-522 sub add_debit { Link Here
516
                    itemnumber        => $item_id,
508
                    itemnumber        => $item_id,
517
                    issue_id          => $issue_id,
509
                    issue_id          => $issue_id,
518
                    branchcode        => $library_id,
510
                    branchcode        => $library_id,
519
                    ( $type eq 'OVERDUE' ? ( status => 'UNRETURNED' ) : () ),
511
                    ( $debit_type eq 'OVERDUE' ? ( status => 'UNRETURNED' ) : () ),
520
                }
512
                }
521
            )->store();
513
            )->store();
522
514
Lines 524-530 sub add_debit { Link Here
524
            my $account_offset = Koha::Account::Offset->new(
516
            my $account_offset = Koha::Account::Offset->new(
525
                {
517
                {
526
                    debit_id => $line->id,
518
                    debit_id => $line->id,
527
                    type     => $Koha::Account::offset_type->{$type},
519
                    type     => $Koha::Account::offset_type->{$debit_type},
528
                    amount   => $amount
520
                    amount   => $amount
529
                }
521
                }
530
            )->store();
522
            )->store();
Lines 535-546 sub add_debit { Link Here
535
                    $self->{patron_id},
527
                    $self->{patron_id},
536
                    Dumper(
528
                    Dumper(
537
                        {
529
                        {
538
                            action            => "create_$type",
530
                            action            => "create_$debit_type",
539
                            borrowernumber    => $self->{patron_id},
531
                            borrowernumber    => $self->{patron_id},
540
                            amount            => $amount,
532
                            amount            => $amount,
541
                            description       => $description,
533
                            description       => $description,
542
                            amountoutstanding => $amount,
534
                            amountoutstanding => $amount,
543
                            debit_type_code   => $debit_type_code,
535
                            debit_type_code   => $debit_type,
544
                            note              => $note,
536
                            note              => $note,
545
                            itemnumber        => $item_id,
537
                            itemnumber        => $item_id,
546
                            manager_id        => $user_id,
538
                            manager_id        => $user_id,
Lines 733-757 our $account_type_credit = { Link Here
733
    'writeoff'         => 'W'
725
    'writeoff'         => 'W'
734
};
726
};
735
727
736
=head3 $account_type_debit
737
738
=cut
739
740
our $account_type_debit = {
741
    'ACCOUNT'          => 'ACCOUNT',
742
    'ACCOUNT_RENEW'    => 'ACCOUNT_RENEW',
743
    'RESERVE_EXPIRED'  => 'RESERVE_EXPIRED',
744
    'LOST_ITEM'        => 'LOST',
745
    'NEW_CARD'         => 'NEW_CARD',
746
    'OVERDUE'          => 'OVERDUE',
747
    'PROCESSING'       => 'PROCESSING',
748
    'RENT'             => 'RENT',
749
    'RENT_DAILY'       => 'RENT_DAILY',
750
    'RENT_RENEW'       => 'RENT_RENEW',
751
    'RENT_DAILY_RENEW' => 'RENT_DAILY_RENEW',
752
    'RESERVE'          => 'RESERVE',
753
};
754
755
=head1 AUTHORS
728
=head1 AUTHORS
756
729
757
=encoding utf8
730
=encoding utf8
758
- 

Return to bug 23049