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

(-)a/Koha/Account.pm (-34 / +3 lines)
Lines 64-70 Koha::Account->new( { patron_id => $borrowernumber } )->pay( Link Here
64
        library_id  => $branchcode,
64
        library_id  => $branchcode,
65
        lines       => $lines, # Arrayref of Koha::Account::Line objects to pay
65
        lines       => $lines, # Arrayref of Koha::Account::Line objects to pay
66
        credit_type => $type,  # credit_type_code code
66
        credit_type => $type,  # credit_type_code code
67
        offset_type => $offset_type,    # offset type code
68
        item_id     => $itemnumber,     # pass the itemnumber if this is a credit pertianing to a specific item (i.e LOST_FOUND)
67
        item_id     => $itemnumber,     # pass the itemnumber if this is a credit pertianing to a specific item (i.e LOST_FOUND)
69
    }
68
    }
70
);
69
);
Lines 81-87 sub pay { Link Here
81
    my $lines         = $params->{lines};
80
    my $lines         = $params->{lines};
82
    my $type          = $params->{type} || 'PAYMENT';
81
    my $type          = $params->{type} || 'PAYMENT';
83
    my $payment_type  = $params->{payment_type} || undef;
82
    my $payment_type  = $params->{payment_type} || undef;
84
    my $offset_type   = $params->{offset_type} || $type eq 'WRITEOFF' ? 'Writeoff' : 'Payment';
85
    my $cash_register = $params->{cash_register};
83
    my $cash_register = $params->{cash_register};
86
    my $item_id       = $params->{item_id};
84
    my $item_id       = $params->{item_id};
87
85
Lines 239-246 sub add_credit { Link Here
239
                my $account_offset = Koha::Account::Offset->new(
237
                my $account_offset = Koha::Account::Offset->new(
240
                    {
238
                    {
241
                        credit_id => $line->id,
239
                        credit_id => $line->id,
242
                        type   => $Koha::Account::offset_type->{$credit_type} // $Koha::Account::offset_type->{CREDIT},
240
                        type      => 'CREATE',
243
                        amount => $amount
241
                        amount    => $amount
244
                    }
242
                    }
245
                )->store();
243
                )->store();
246
244
Lines 456-462 sub add_debit { Link Here
456
    my $transaction_type = $params->{transaction_type};
454
    my $transaction_type = $params->{transaction_type};
457
    my $item_id          = $params->{item_id};
455
    my $item_id          = $params->{item_id};
458
    my $issue_id         = $params->{issue_id};
456
    my $issue_id         = $params->{issue_id};
459
    my $offset_type      = $Koha::Account::offset_type->{$debit_type} // 'Manual Debit';
460
457
461
    my $line;
458
    my $line;
462
    my $schema = Koha::Database->new->schema;
459
    my $schema = Koha::Database->new->schema;
Lines 493-499 sub add_debit { Link Here
493
                my $account_offset = Koha::Account::Offset->new(
490
                my $account_offset = Koha::Account::Offset->new(
494
                    {
491
                    {
495
                        debit_id => $line->id,
492
                        debit_id => $line->id,
496
                        type     => $offset_type,
493
                        type     => 'CREATE',
497
                        amount   => $amount
494
                        amount   => $amount
498
                    }
495
                    }
499
                )->store();
496
                )->store();
Lines 771-803 sub reconcile_balance { Link Here
771
768
772
1;
769
1;
773
770
774
=head2 Name mappings
775
776
=head3 $offset_type
777
778
=cut
779
780
our $offset_type = {
781
    'CREDIT'           => 'Manual Credit',
782
    'FORGIVEN'         => 'Writeoff',
783
    'LOST_FOUND'       => 'Lost Item Found',
784
    'OVERPAYMENT'      => 'Overpayment',
785
    'PAYMENT'          => 'Payment',
786
    'WRITEOFF'         => 'Writeoff',
787
    'ACCOUNT'          => 'Account Fee',
788
    'ACCOUNT_RENEW'    => 'Account Fee',
789
    'RESERVE'          => 'Reserve Fee',
790
    'PROCESSING'       => 'Processing Fee',
791
    'LOST'             => 'Lost Item',
792
    'RENT'             => 'Rental Fee',
793
    'RENT_DAILY'       => 'Rental Fee',
794
    'RENT_RENEW'       => 'Rental Fee',
795
    'RENT_DAILY_RENEW' => 'Rental Fee',
796
    'OVERDUE'          => 'OVERDUE',
797
    'RESERVE_EXPIRED'  => 'Hold Expired',
798
    'PAYOUT'           => 'PAYOUT',
799
};
800
801
=head1 AUTHORS
771
=head1 AUTHORS
802
772
803
=encoding utf8
773
=encoding utf8
804
- 

Return to bug 22435