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

(-)a/Koha/Account.pm (-9 / +9 lines)
Lines 60-67 Koha::Account->new( { patron_id => $borrowernumber } )->pay( Link Here
60
        note        => $note,
60
        note        => $note,
61
        description => $description,
61
        description => $description,
62
        library_id  => $branchcode,
62
        library_id  => $branchcode,
63
        lines        => $lines, # Arrayref of Koha::Account::Line objects to pay
63
        lines       => $lines, # Arrayref of Koha::Account::Line objects to pay
64
        account_type => $type,  # accounttype code
64
        credit_type => $type,  # credit_type_code code
65
        offset_type => $offset_type,    # offset type code
65
        offset_type => $offset_type,    # offset type code
66
    }
66
    }
67
);
67
);
Lines 78-84 sub pay { Link Here
78
    my $lines         = $params->{lines};
78
    my $lines         = $params->{lines};
79
    my $type          = $params->{type} || 'payment';
79
    my $type          = $params->{type} || 'payment';
80
    my $payment_type  = $params->{payment_type} || undef;
80
    my $payment_type  = $params->{payment_type} || undef;
81
    my $account_type  = $params->{account_type};
81
    my $credit_type   = $params->{credit_type};
82
    my $offset_type   = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
82
    my $offset_type   = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
83
    my $cash_register = $params->{cash_register};
83
    my $cash_register = $params->{cash_register};
84
84
Lines 215-221 sub pay { Link Here
215
        last unless $balance_remaining > 0;
215
        last unless $balance_remaining > 0;
216
    }
216
    }
217
217
218
    $account_type ||=
218
    $credit_type ||=
219
      $type eq 'writeoff'
219
      $type eq 'writeoff'
220
      ? 'W'
220
      ? 'W'
221
      : 'Pay';
221
      : 'Pay';
Lines 228-234 sub pay { Link Here
228
            date              => dt_from_string(),
228
            date              => dt_from_string(),
229
            amount            => 0 - $amount,
229
            amount            => 0 - $amount,
230
            description       => $description,
230
            description       => $description,
231
            accounttype       => $account_type,
231
            credit_type_code  => $credit_type,
232
            payment_type      => $payment_type,
232
            payment_type      => $payment_type,
233
            amountoutstanding => 0 - $balance_remaining,
233
            amountoutstanding => 0 - $balance_remaining,
234
            manager_id        => $manager_id,
234
            manager_id        => $manager_id,
Lines 263-269 sub pay { Link Here
263
                    borrowernumber    => $self->{patron_id},
263
                    borrowernumber    => $self->{patron_id},
264
                    amount            => 0 - $amount,
264
                    amount            => 0 - $amount,
265
                    amountoutstanding => 0 - $balance_remaining,
265
                    amountoutstanding => 0 - $balance_remaining,
266
                    accounttype       => $account_type,
266
                    credit_type_code  => $credit_type,
267
                    accountlines_paid => \@fines_paid,
267
                    accountlines_paid => \@fines_paid,
268
                    manager_id        => $manager_id,
268
                    manager_id        => $manager_id,
269
                }
269
                }
Lines 360-366 sub add_credit { Link Here
360
360
361
    my $schema = Koha::Database->new->schema;
361
    my $schema = Koha::Database->new->schema;
362
362
363
    my $account_type = $Koha::Account::account_type_credit->{$type};
363
    my $credit_type = $Koha::Account::account_type_credit->{$type};
364
    my $line;
364
    my $line;
365
365
366
    $schema->txn_do(
366
    $schema->txn_do(
Lines 372-378 sub add_credit { Link Here
372
                    date              => \'NOW()',
372
                    date              => \'NOW()',
373
                    amount            => $amount,
373
                    amount            => $amount,
374
                    description       => $description,
374
                    description       => $description,
375
                    accounttype       => $account_type,
375
                    credit_type_code  => $credit_type,
376
                    amountoutstanding => $amount,
376
                    amountoutstanding => $amount,
377
                    payment_type      => $payment_type,
377
                    payment_type      => $payment_type,
378
                    note              => $note,
378
                    note              => $note,
Lines 410-416 sub add_credit { Link Here
410
                            amount            => $amount,
410
                            amount            => $amount,
411
                            description       => $description,
411
                            description       => $description,
412
                            amountoutstanding => $amount,
412
                            amountoutstanding => $amount,
413
                            accounttype       => $account_type,
413
                            credit_type_code  => $credit_type,
414
                            note              => $note,
414
                            note              => $note,
415
                            itemnumber        => $item_id,
415
                            itemnumber        => $item_id,
416
                            manager_id        => $user_id,
416
                            manager_id        => $user_id,
(-)a/Koha/Account/Line.pm (-1 / +1 lines)
Lines 150-156 sub void { Link Here
150
                            amount            => $self->amount,
150
                            amount            => $self->amount,
151
                            amountoutstanding => $self->amountoutstanding,
151
                            amountoutstanding => $self->amountoutstanding,
152
                            description       => $self->description,
152
                            description       => $self->description,
153
                            accounttype       => $self->accounttype,
153
                            credit_type_code  => $self->credit_type_code,
154
                            payment_type      => $self->payment_type,
154
                            payment_type      => $self->payment_type,
155
                            note              => $self->note,
155
                            note              => $self->note,
156
                            itemnumber        => $self->itemnumber,
156
                            itemnumber        => $self->itemnumber,
(-)a/Koha/REST/V1/Patrons/Account.pm (-2 / +2 lines)
Lines 227-233 sub _to_model { Link Here
227
227
228
our $to_api_mapping = {
228
our $to_api_mapping = {
229
    accountlines_id   => 'account_line_id',
229
    accountlines_id   => 'account_line_id',
230
    accounttype       => 'account_type',
230
    credit_type_code  => 'credit_type',
231
    debit_type_code   => 'debit_type',
231
    debit_type_code   => 'debit_type',
232
    amountoutstanding => 'amount_outstanding',
232
    amountoutstanding => 'amount_outstanding',
233
    borrowernumber    => 'patron_id',
233
    borrowernumber    => 'patron_id',
Lines 244-250 our $to_api_mapping = { Link Here
244
244
245
our $to_model_mapping = {
245
our $to_model_mapping = {
246
    account_line_id    => 'accountlines_id',
246
    account_line_id    => 'accountlines_id',
247
    account_type       => 'accounttype',
247
    credit_type        => 'credit_type_code',
248
    debit_type         => 'debit_type_code',
248
    debit_type         => 'debit_type_code',
249
    amount_outstanding => 'amountoutstanding',
249
    amount_outstanding => 'amountoutstanding',
250
    checkout_id        => 'issue_id',
250
    checkout_id        => 'issue_id',
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc (-3 / +3 lines)
Lines 1-7 Link Here
1
[%- BLOCK account_type_description -%]
1
[%- BLOCK account_type_description -%]
2
    <span>
2
    <span>
3
    [%- IF account.accounttype -%]
3
    [%- IF account.credit_type_code -%]
4
        [%- SWITCH account.accounttype -%]
4
        [%- SWITCH account.credit_type_code -%]
5
            [%- CASE 'Pay'              -%]Payment
5
            [%- CASE 'Pay'              -%]Payment
6
            [%- CASE 'W'                -%]Writeoff
6
            [%- CASE 'W'                -%]Writeoff
7
            [%- CASE 'FOR'              -%]Forgiven
7
            [%- CASE 'FOR'              -%]Forgiven
Lines 9-15 Link Here
9
            [%- CASE 'WO'               -%]Writeoff
9
            [%- CASE 'WO'               -%]Writeoff
10
            [%- CASE 'C'                -%]Credit
10
            [%- CASE 'C'                -%]Credit
11
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
11
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
12
            [%- CASE                    -%][% account.accounttype | html %]
12
            [%- CASE                    -%][% account.credit_type.description | html %]
13
        [%- END -%]
13
        [%- END -%]
14
    [%- ELSIF account.debit_type_code -%]
14
    [%- ELSIF account.debit_type_code -%]
15
       [%- SWITCH account.debit_type_code -%]
15
       [%- SWITCH account.debit_type_code -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt (-1 / +1 lines)
Lines 159-165 Link Here
159
                <td>[% loopresul.branchname | html %]</td>
159
                <td>[% loopresul.branchname | html %]</td>
160
                <td>[% loopresul.date | $KohaDates %]</td>
160
                <td>[% loopresul.date | $KohaDates %]</td>
161
                <td>
161
                <td>
162
                    [% IF loopresul.accounttype == "ACT" %]
162
                    [% IF loopresul.credit_type == "ACT" %]
163
                        <span>All payments to the library</span>
163
                        <span>All payments to the library</span>
164
                    [% ELSE %]
164
                    [% ELSE %]
165
                        [%- PROCESS account_type_description account=loopresul -%]
165
                        [%- PROCESS account_type_description account=loopresul -%]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc (-3 / +3 lines)
Lines 171-178 Link Here
171
171
172
[%- BLOCK account_type_description -%]
172
[%- BLOCK account_type_description -%]
173
    <span>
173
    <span>
174
    [%- IF account.accounttype -%]
174
    [%- IF account.credit_type_code -%]
175
        [%- SWITCH account.accounttype -%]
175
        [%- SWITCH account.credit_type_code -%]
176
            [%- CASE 'Pay'              -%]Payment
176
            [%- CASE 'Pay'              -%]Payment
177
            [%- CASE 'W'                -%]Writeoff
177
            [%- CASE 'W'                -%]Writeoff
178
            [%- CASE 'FOR'              -%]Forgiven
178
            [%- CASE 'FOR'              -%]Forgiven
Lines 180-186 Link Here
180
            [%- CASE 'WO'               -%]Writeoff
180
            [%- CASE 'WO'               -%]Writeoff
181
            [%- CASE 'C'                -%]Credit
181
            [%- CASE 'C'                -%]Credit
182
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
182
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
183
            [%- CASE                    -%][% account.accounttype | html %]
183
            [%- CASE                    -%][% account.credit_type.description | html %]
184
        [%- END -%]
184
        [%- END -%]
185
    [%- ELSIF account.debit_type_code -%]
185
    [%- ELSIF account.debit_type_code -%]
186
       [%- SWITCH account.debit_type_code -%]
186
       [%- SWITCH account.debit_type_code -%]
(-)a/reports/cash_register_stats.pl (-9 / +8 lines)
Lines 72-86 if ($do_it) { Link Here
72
    if ($transaction_type eq 'ALL') { #All Transactons
72
    if ($transaction_type eq 'ALL') { #All Transactons
73
        $whereTType = q{};
73
        $whereTType = q{};
74
    } elsif ($transaction_type eq 'ACT') { #Active
74
    } elsif ($transaction_type eq 'ACT') { #Active
75
        $whereTType = q{ AND accounttype IN ('Pay','C') };
75
        $whereTType = q{ AND credit_type_code IN ('Pay','C') };
76
    } elsif ($transaction_type eq 'FORW') {
76
    } elsif ($transaction_type eq 'FORW') {
77
        $whereTType = q{ AND accounttype IN ('FOR','W') };
77
        $whereTType = q{ AND credit_type_code IN ('FOR','W') };
78
    } else {
78
    } else {
79
        if ( any { $transaction_type eq $_->code } @debit_types ) {
79
        if ( any { $transaction_type eq $_->code } @debit_types ) {
80
            $whereTType = q{ AND debit_type_code = ? };
80
            $whereTType = q{ AND debit_type_code = ? };
81
            push @extra_params, $transaction_type;
81
            push @extra_params, $transaction_type;
82
        } else {
82
        } else {
83
            $whereTType = q{ AND accounttype = ? };
83
            $whereTType = q{ AND credit_type_code = ? };
84
            push @extra_params, $transaction_type;
84
            push @extra_params, $transaction_type;
85
        }
85
        }
86
    }
86
    }
Lines 96-102 if ($do_it) { Link Here
96
    SELECT round(amount,2) AS amount, description,
96
    SELECT round(amount,2) AS amount, description,
97
        bo.surname AS bsurname, bo.firstname AS bfirstname, m.surname AS msurname, m.firstname AS mfirstname,
97
        bo.surname AS bsurname, bo.firstname AS bfirstname, m.surname AS msurname, m.firstname AS mfirstname,
98
        bo.cardnumber, br.branchname, bo.borrowernumber,
98
        bo.cardnumber, br.branchname, bo.borrowernumber,
99
        al.borrowernumber, DATE(al.date) as date, al.accounttype, al.debit_type_code, al.amountoutstanding, al.note,
99
        al.borrowernumber, DATE(al.date) as date, al.credit_type_code, al.debit_type_code, al.amountoutstanding, al.note,
100
        bi.title, bi.biblionumber, i.barcode, i.itype
100
        bi.title, bi.biblionumber, i.barcode, i.itype
101
        FROM accountlines al
101
        FROM accountlines al
102
        LEFT JOIN borrowers bo ON (al.borrowernumber = bo.borrowernumber)
102
        LEFT JOIN borrowers bo ON (al.borrowernumber = bo.borrowernumber)
Lines 121-134 if ($do_it) { Link Here
121
            $row->{date} = dt_from_string($row->{date}, 'sql');
121
            $row->{date} = dt_from_string($row->{date}, 'sql');
122
122
123
            push (@loopresult, $row);
123
            push (@loopresult, $row);
124
            if($transaction_type eq 'ACT' && ($row->{accounttype} !~ /^C$|^CR$|^Pay$/)){
124
            if($transaction_type eq 'ACT' && ($row->{credit_type_code} !~ /^C$|^CR$|^Pay$/)){
125
                pop @loopresult;
125
                pop @loopresult;
126
                next;
126
                next;
127
            }
127
            }
128
            if($row->{accounttype} =~ /^C$|^CR$/){
128
            if($row->{credit_type_code} =~ /^C$|^CR$/){
129
                $grantotal -= abs($row->{amount});
129
                $grantotal -= abs($row->{amount});
130
                $row->{amount} = '-' . $row->{amount};
130
                $row->{amount} = '-' . $row->{amount};
131
            }elsif($row->{accounttype} eq 'FORW' || $row->{accounttype} eq 'W'){
131
            }elsif($row->{credit_type_code} eq 'FORW' || $row->{credit_type_code} eq 'W'){
132
            }else{
132
            }else{
133
                $grantotal += abs($row->{amount});
133
                $grantotal += abs($row->{amount});
134
            }
134
            }
Lines 155-161 if ($do_it) { Link Here
155
                        $row->{bfirstname} . ' ' . $row->{bsurname},
155
                        $row->{bfirstname} . ' ' . $row->{bsurname},
156
                        $row->{branchname},
156
                        $row->{branchname},
157
                        $row->{date},
157
                        $row->{date},
158
                        $row->{accounttype},
158
                        $row->{credit_type},
159
                        $row->{debit_type},
159
                        $row->{debit_type},
160
                        $row->{note},
160
                        $row->{note},
161
                        $row->{amount},
161
                        $row->{amount},
162
- 

Return to bug 23805