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

(-)a/C4/SIP/ILS/Transaction/FeePayment.pm (-1 / +1 lines)
Lines 50-56 sub pay { Link Here
50
    my $is_writeoff          = shift;
50
    my $is_writeoff          = shift;
51
    my $disallow_overpayment = shift;
51
    my $disallow_overpayment = shift;
52
52
53
    my $type = $is_writeoff ? 'writeoff' : 'payment';
53
    my $type = $is_writeoff ? 'writeoff' : 'PAYMENT';
54
54
55
    warn("RECORD:$borrowernumber::$amt");
55
    warn("RECORD:$borrowernumber::$amt");
56
56
(-)a/Koha/Account.pm (-7 / +7 lines)
Lines 76-82 sub pay { Link Here
76
    my $note          = $params->{note} || q{};
76
    my $note          = $params->{note} || q{};
77
    my $library_id    = $params->{library_id};
77
    my $library_id    = $params->{library_id};
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 $credit_type   = $params->{credit_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';
Lines 218-224 sub pay { Link Here
218
    $credit_type ||=
218
    $credit_type ||=
219
      $type eq 'writeoff'
219
      $type eq 'writeoff'
220
      ? 'W'
220
      ? 'W'
221
      : 'Pay';
221
      : 'PAYMENT';
222
222
223
    $description ||= $type eq 'writeoff' ? 'Writeoff' : q{};
223
    $description ||= $type eq 'writeoff' ? 'Writeoff' : q{};
224
224
Lines 323-329 my $credit_line = Koha::Account->new({ patron_id => $patron_id })->add_credit( Link Here
323
323
324
$credit_type can be any of:
324
$credit_type can be any of:
325
  - 'CREDIT'
325
  - 'CREDIT'
326
  - 'payment'
326
  - 'PAYMENT'
327
  - 'forgiven'
327
  - 'forgiven'
328
  - 'LOST_RETURN'
328
  - 'LOST_RETURN'
329
  - 'writeoff'
329
  - 'writeoff'
Lines 343-349 sub add_credit { Link Here
343
    my $library_id    = $params->{library_id};
343
    my $library_id    = $params->{library_id};
344
    my $cash_register = $params->{cash_register};
344
    my $cash_register = $params->{cash_register};
345
    my $payment_type  = $params->{payment_type};
345
    my $payment_type  = $params->{payment_type};
346
    my $type          = $params->{type} || 'payment';
346
    my $type          = $params->{type} || 'PAYMENT';
347
    my $item_id       = $params->{item_id};
347
    my $item_id       = $params->{item_id};
348
348
349
    unless ( $interface ) {
349
    unless ( $interface ) {
Lines 398-404 sub add_credit { Link Here
398
                    amount         => $amount,
398
                    amount         => $amount,
399
                    borrowernumber => $self->{patron_id},
399
                    borrowernumber => $self->{patron_id},
400
                }
400
                }
401
            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
401
            ) if grep { $type eq $_ } ('PAYMENT', 'writeoff') ;
402
402
403
            if ( C4::Context->preference("FinesLog") ) {
403
            if ( C4::Context->preference("FinesLog") ) {
404
                logaction(
404
                logaction(
Lines 719-725 our $offset_type = { Link Here
719
    'CREDIT'           => 'Manual Credit',
719
    'CREDIT'           => 'Manual Credit',
720
    'FORGIVEN'         => 'Writeoff',
720
    'FORGIVEN'         => 'Writeoff',
721
    'LOST_RETURN'      => 'Lost Item',
721
    'LOST_RETURN'      => 'Lost Item',
722
    'payment'          => 'Payment',
722
    'PAYMENT'          => 'Payment',
723
    'writeoff'         => 'Writeoff',
723
    'writeoff'         => 'Writeoff',
724
    'ACCOUNT'          => 'Account Fee',
724
    'ACCOUNT'          => 'Account Fee',
725
    'ACCOUNT_RENEW'    => 'Account Fee',
725
    'ACCOUNT_RENEW'    => 'Account Fee',
Lines 742-748 our $account_type_credit = { Link Here
742
    'CREDIT'           => 'CREDIT',
742
    'CREDIT'           => 'CREDIT',
743
    'FORGIVEN'         => 'FORGIVEN',
743
    'FORGIVEN'         => 'FORGIVEN',
744
    'LOST_RETURN'      => 'LOST_RETURN',
744
    'LOST_RETURN'      => 'LOST_RETURN',
745
    'payment'          => 'Pay',
745
    'PAYMENT'          => 'PAYMENT',
746
    'writeoff'         => 'W'
746
    'writeoff'         => 'W'
747
};
747
};
748
748
(-)a/Koha/REST/V1/Patrons/Account.pm (-2 / +2 lines)
Lines 94-100 sub add_credit { Link Here
94
    my $body    = $c->validation->param('body');
94
    my $body    = $c->validation->param('body');
95
95
96
    return try {
96
    return try {
97
        my $credit_type = $body->{credit_type} || 'payment';    # default to 'payment'
97
        my $credit_type = $body->{credit_type} || 'PAYMENT';    # default to 'PAYMENT'
98
        my $amount = $body->{amount};                           # mandatory, validated by openapi
98
        my $amount = $body->{amount};                           # mandatory, validated by openapi
99
99
100
        unless ( $amount > 0 ) {  # until we support newer JSON::Validator and thus minimumExclusive
100
        unless ( $amount > 0 ) {  # until we support newer JSON::Validator and thus minimumExclusive
Lines 109-115 sub add_credit { Link Here
109
109
110
        my $credit = $account->add_credit(
110
        my $credit = $account->add_credit(
111
            {   amount       => $amount,
111
            {   amount       => $amount,
112
                credit_type  => $credit_type,
112
                type         => $credit_type,
113
                payment_type => $payment_type,
113
                payment_type => $payment_type,
114
                description  => $description,
114
                description  => $description,
115
                note         => $note,
115
                note         => $note,
(-)a/api/v1/swagger/definitions/patron_account_credit.json (-1 / +1 lines)
Lines 3-9 Link Here
3
  "properties": {
3
  "properties": {
4
    "credit_type": {
4
    "credit_type": {
5
      "type": "string",
5
      "type": "string",
6
      "description": "Type of credit ('CREDIT', 'FORGIVEN', 'LOST_RETURN', 'payment', 'writeoff' )"
6
      "description": "Type of credit ('CREDIT', 'FORGIVEN', 'LOST_RETURN', 'PAYMENT', 'writeoff' )"
7
    },
7
    },
8
    "amount": {
8
    "amount": {
9
      "type": "number",
9
      "type": "number",
(-)a/installer/data/mysql/atomicupdate/bug_23805_credit.perl (-2 / +8 lines)
Lines 36-43 if ( CheckVersion($DBversion) ) { Link Here
36
              is_system
36
              is_system
37
            )
37
            )
38
            VALUES
38
            VALUES
39
              ('Pay', 'Payment', 0, 1),
39
              ('PAYMENT', 'Payment', 0, 1),
40
              ('PAY', 'Payment', 0, 1),
41
              ('W', 'Writeoff', 0, 1),
40
              ('W', 'Writeoff', 0, 1),
42
              ('WO', 'Writeoff', 0, 1),
41
              ('WO', 'Writeoff', 0, 1),
43
              ('FORGIVEN', 'Forgiven', 1, 1),
42
              ('FORGIVEN', 'Forgiven', 1, 1),
Lines 89-94 if ( CheckVersion($DBversion) ) { Link Here
89
        }
88
        }
90
    );
89
    );
91
90
91
    # Update accountype 'Pay' to 'PAYMENT'
92
    $dbh->do(
93
        qq{
94
          UPDATE accountlines SET accounttype = 'PAYMENT' WHERE accounttype = 'Pay' OR accounttype = 'PAY'
95
        }
96
    );
97
92
    # Populating credit_type_code
98
    # Populating credit_type_code
93
    $dbh->do(
99
    $dbh->do(
94
        qq{
100
        qq{
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc (-2 / +1 lines)
Lines 2-11 Link Here
2
    <span>
2
    <span>
3
    [%- IF account.credit_type_code -%]
3
    [%- IF account.credit_type_code -%]
4
        [%- SWITCH account.credit_type_code -%]
4
        [%- SWITCH account.credit_type_code -%]
5
            [%- CASE 'Pay'              -%]Payment
5
            [%- CASE 'PAYMENT'          -%]Payment
6
            [%- CASE 'W'                -%]Writeoff
6
            [%- CASE 'W'                -%]Writeoff
7
            [%- CASE 'FORGIVEN'         -%]Forgiven
7
            [%- CASE 'FORGIVEN'         -%]Forgiven
8
            [%- CASE 'PAY'              -%]Payment
9
            [%- CASE 'WO'               -%]Writeoff
8
            [%- CASE 'WO'               -%]Writeoff
10
            [%- CASE 'CREDIT'           -%]Credit
9
            [%- CASE 'CREDIT'           -%]Credit
11
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
10
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc (-2 / +1 lines)
Lines 173-182 Link Here
173
    <span>
173
    <span>
174
    [%- IF account.credit_type_code -%]
174
    [%- IF account.credit_type_code -%]
175
        [%- SWITCH account.credit_type_code -%]
175
        [%- SWITCH account.credit_type_code -%]
176
            [%- CASE 'Pay'              -%]Payment
176
            [%- CASE 'PAYMENT'          -%]Payment
177
            [%- CASE 'W'                -%]Writeoff
177
            [%- CASE 'W'                -%]Writeoff
178
            [%- CASE 'FORGIVEN'         -%]Forgiven
178
            [%- CASE 'FORGIVEN'         -%]Forgiven
179
            [%- CASE 'PAY'              -%]Payment
180
            [%- CASE 'WO'               -%]Writeoff
179
            [%- CASE 'WO'               -%]Writeoff
181
            [%- CASE 'CREDIT'           -%]Credit
180
            [%- CASE 'CREDIT'           -%]Credit
182
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
181
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
(-)a/members/pay.pl (-1 / +1 lines)
Lines 240-246 sub payselected { Link Here
240
    my $parameters = shift;
240
    my $parameters = shift;
241
241
242
    my @params = @{ $parameters->{params} };
242
    my @params = @{ $parameters->{params} };
243
    my $type = $parameters->{type} || 'payment';
243
    my $type = $parameters->{type} || 'PAYMENT';
244
244
245
    my $amt    = 0;
245
    my $amt    = 0;
246
    my @lines_to_pay;
246
    my @lines_to_pay;
(-)a/members/paycollect.pl (-1 / +1 lines)
Lines 40-46 my $input = CGI->new(); Link Here
40
my $payment_id          = $input->param('payment_id');
40
my $payment_id          = $input->param('payment_id');
41
my $writeoff_individual = $input->param('writeoff_individual');
41
my $writeoff_individual = $input->param('writeoff_individual');
42
my $change_given        = $input->param('change_given');
42
my $change_given        = $input->param('change_given');
43
my $type                = scalar $input->param('type') || 'payment';
43
my $type                = scalar $input->param('type') || 'PAYMENT';
44
44
45
my $updatecharges_permissions = ($writeoff_individual || $type eq 'writeoff') ? 'writeoff' : 'remaining_permissions';
45
my $updatecharges_permissions = ($writeoff_individual || $type eq 'writeoff') ? 'writeoff' : 'remaining_permissions';
46
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
(-)a/reports/cash_register_stats.pl (-3 / +3 lines)
Lines 72-78 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 credit_type_code IN ('Pay','CREDIT') };
75
        $whereTType = q{ AND credit_type_code IN ('PAYMENT','CREDIT') };
76
    } elsif ($transaction_type eq 'FORW') {
76
    } elsif ($transaction_type eq 'FORW') {
77
        $whereTType = q{ AND credit_type_code IN ('FORGIVEN','W') };
77
        $whereTType = q{ AND credit_type_code IN ('FORGIVEN','W') };
78
    } else {
78
    } else {
Lines 121-131 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->{credit_type_code} !~ /^C$|^CR$|^Pay$/)){
124
            if($transaction_type eq 'ACT' && ($row->{credit_type_code} !~ /^CREDIT$|^PAYMENT$/)){
125
                pop @loopresult;
125
                pop @loopresult;
126
                next;
126
                next;
127
            }
127
            }
128
            if($row->{credit_type_code} =~ /^C$|^CR$/){
128
            if($row->{credit_type_code} =~ /^CREDIT$/){
129
                $grantotal -= abs($row->{amount});
129
                $grantotal -= abs($row->{amount});
130
                $row->{amount} = '-' . $row->{amount};
130
                $row->{amount} = '-' . $row->{amount};
131
            }elsif($row->{credit_type_code} eq 'FORGIVEN' || $row->{credit_type_code} eq 'W'){
131
            }elsif($row->{credit_type_code} eq 'FORGIVEN' || $row->{credit_type_code} eq 'W'){
(-)a/t/db_dependent/Accounts.t (-2 / +2 lines)
Lines 417-423 subtest "More Koha::Account::pay tests" => sub { Link Here
417
417
418
    my $stat = $schema->resultset('Statistic')->search({
418
    my $stat = $schema->resultset('Statistic')->search({
419
        branch  => $branch,
419
        branch  => $branch,
420
        type    => 'payment'
420
        type    => 'PAYMENT'
421
    }, { order_by => { -desc => 'datetime' } })->next();
421
    }, { order_by => { -desc => 'datetime' } })->next();
422
422
423
    ok( defined $stat, "There's a payment log that matches the branch" );
423
    ok( defined $stat, "There's a payment log that matches the branch" );
Lines 471-477 subtest "Even more Koha::Account::pay tests" => sub { Link Here
471
471
472
    my $stat = $schema->resultset('Statistic')->search({
472
    my $stat = $schema->resultset('Statistic')->search({
473
        branch  => $branch,
473
        branch  => $branch,
474
        type    => 'payment'
474
        type    => 'PAYMENT'
475
    }, { order_by => { -desc => 'datetime' } })->next();
475
    }, { order_by => { -desc => 'datetime' } })->next();
476
476
477
    ok( defined $stat, "There's a payment log that matches the branch" );
477
    ok( defined $stat, "There's a payment log that matches the branch" );
(-)a/t/db_dependent/Circulation.t (-4 / +4 lines)
Lines 2210-2216 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2210
        # Write off the debt
2210
        # Write off the debt
2211
        my $credit = $account->add_credit(
2211
        my $credit = $account->add_credit(
2212
            {   amount => $account->balance,
2212
            {   amount => $account->balance,
2213
                type   => 'payment',
2213
                type   => 'PAYMENT',
2214
                interface => 'test',
2214
                interface => 'test',
2215
            }
2215
            }
2216
        );
2216
        );
Lines 2334-2340 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2334
        my $payment_amount = 27;
2334
        my $payment_amount = 27;
2335
        my $payment        = $account->add_credit(
2335
        my $payment        = $account->add_credit(
2336
            {   amount => $payment_amount,
2336
            {   amount => $payment_amount,
2337
                type   => 'payment',
2337
                type   => 'PAYMENT',
2338
                interface => 'test',
2338
                interface => 'test',
2339
            }
2339
            }
2340
        );
2340
        );
Lines 2363-2369 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2363
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
2363
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
2364
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2364
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2365
2365
2366
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_RETURN)' );
2366
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PROCESSING - PAYMENT (LOST_RETURN)' );
2367
2367
2368
        $lost_fee_line->discard_changes;
2368
        $lost_fee_line->discard_changes;
2369
        is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
2369
        is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
Lines 2438-2444 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2438
        my $payment_amount = 27;
2438
        my $payment_amount = 27;
2439
        my $payment        = $account->add_credit(
2439
        my $payment        = $account->add_credit(
2440
            {   amount => $payment_amount,
2440
            {   amount => $payment_amount,
2441
                type   => 'payment',
2441
                type   => 'PAYMENT',
2442
                interface => 'test',
2442
                interface => 'test',
2443
            }
2443
            }
2444
        );
2444
        );
(-)a/t/db_dependent/ILSDI_Services.t (-1 / +1 lines)
Lines 200-206 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
200
            source => 'Accountline',
200
            source => 'Accountline',
201
            value  => {
201
            value  => {
202
                borrowernumber    => $brwr->{borrowernumber},
202
                borrowernumber    => $brwr->{borrowernumber},
203
                credit_type_code  => 'Pay',
203
                credit_type_code  => 'PAYMENT',
204
                amountoutstanding => 10
204
                amountoutstanding => 10
205
            }
205
            }
206
        }
206
        }
(-)a/t/db_dependent/Koha/Account.t (-4 / +4 lines)
Lines 180-186 subtest 'add_credit() tests' => sub { Link Here
180
                description => 'Payment of 25',
180
                description => 'Payment of 25',
181
                library_id  => $patron->branchcode,
181
                library_id  => $patron->branchcode,
182
                note        => 'not really important',
182
                note        => 'not really important',
183
                type        => 'payment',
183
                type        => 'PAYMENT',
184
                user_id     => $patron->id
184
                user_id     => $patron->id
185
            }
185
            }
186
        );
186
        );
Lines 192-198 subtest 'add_credit() tests' => sub { Link Here
192
            description => 'Payment of 25',
192
            description => 'Payment of 25',
193
            library_id  => $patron->branchcode,
193
            library_id  => $patron->branchcode,
194
            note        => 'not really important',
194
            note        => 'not really important',
195
            type        => 'payment',
195
            type        => 'PAYMENT',
196
            user_id     => $patron->id,
196
            user_id     => $patron->id,
197
            interface   => 'commandline'
197
            interface   => 'commandline'
198
        }
198
        }
Lines 201-207 subtest 'add_credit() tests' => sub { Link Here
201
    is( $account->balance, -25, 'Patron has a balance of -25' );
201
    is( $account->balance, -25, 'Patron has a balance of -25' );
202
    is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' );
202
    is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' );
203
    is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' );
203
    is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' );
204
    is( $line_1->credit_type_code, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' );
204
    is( $line_1->credit_type_code, $Koha::Account::account_type_credit->{'PAYMENT'}, 'Account type is correctly set' );
205
205
206
    # Enable logs
206
    # Enable logs
207
    t::lib::Mocks::mock_preference( 'FinesLog', 1 );
207
    t::lib::Mocks::mock_preference( 'FinesLog', 1 );
Lines 219-225 subtest 'add_credit() tests' => sub { Link Here
219
    is( $account->balance, -62, 'Patron has a balance of -25' );
219
    is( $account->balance, -62, 'Patron has a balance of -25' );
220
    is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' );
220
    is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' );
221
    is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' );
221
    is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' );
222
    is( $line_2->credit_type_code, $Koha::Account::account_type_credit->{'payment'}, 'Account type is correctly set' );
222
    is( $line_2->credit_type_code, $Koha::Account::account_type_credit->{'PAYMENT'}, 'Account type is correctly set' );
223
223
224
    # offsets have the credit_id set to accountlines_id, and debit_id is undef
224
    # offsets have the credit_id set to accountlines_id, and debit_id is undef
225
    my $offset_1 = Koha::Account::Offsets->search({ credit_id => $line_1->id })->next;
225
    my $offset_1 = Koha::Account::Offsets->search({ credit_id => $line_1->id })->next;
(-)a/t/db_dependent/Koha/Account/Lines.t (-1 / +1 lines)
Lines 571-577 subtest "void() tests" => sub { Link Here
571
    $line1->_result->discard_changes();
571
    $line1->_result->discard_changes();
572
    $line2->_result->discard_changes();
572
    $line2->_result->discard_changes();
573
573
574
    is( $account_payment->credit_type_code, 'Pay', 'Voided payment credit_type_code is still Pay' );
574
    is( $account_payment->credit_type_code, 'PAYMENT', 'Voided payment credit_type_code is still PAYMENT' );
575
    is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
575
    is( $account_payment->status, 'VOID', 'Voided payment status is VOID' );
576
    is( $account_payment->amount+0, 0, 'Voided payment amount is 0' );
576
    is( $account_payment->amount+0, 0, 'Voided payment amount is 0' );
577
    is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );
577
    is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' );
(-)a/t/db_dependent/api/v1/patrons_accounts.t (-2 / +1 lines)
Lines 113-119 subtest 'get_balance() tests' => sub { Link Here
113
            note         => 'He paid!',
113
            note         => 'He paid!',
114
            description  => 'Finally!',
114
            description  => 'Finally!',
115
            library_id   => $patron->branchcode,
115
            library_id   => $patron->branchcode,
116
            account_type => 'Pay',
116
            account_type => 'PAYMENT',
117
            offset_type  => 'Payment'
117
            offset_type  => 'Payment'
118
        }
118
        }
119
    );
119
    );
120
- 

Return to bug 23805