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 (-8 / +8 lines)
Lines 79-85 sub pay { Link Here
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';
83
    my $cash_register = $params->{cash_register};
83
    my $cash_register = $params->{cash_register};
84
84
85
    my $userenv = C4::Context->userenv;
85
    my $userenv = C4::Context->userenv;
Lines 216-226 sub pay { Link Here
216
    }
216
    }
217
217
218
    $credit_type ||=
218
    $credit_type ||=
219
      $type eq 'writeoff'
219
      $type eq 'WRITEOFF'
220
      ? 'W'
220
      ? 'WRITEOFF'
221
      : 'PAYMENT';
221
      : 'PAYMENT';
222
222
223
    $description ||= $type eq 'writeoff' ? 'Writeoff' : q{};
223
    $description ||= $type eq 'WRITEOFF' ? 'Writeoff' : q{};
224
224
225
    my $payment = Koha::Account::Line->new(
225
    my $payment = Koha::Account::Line->new(
226
        {
226
        {
Lines 326-332 $credit_type can be any of: Link Here
326
  - 'PAYMENT'
326
  - 'PAYMENT'
327
  - 'forgiven'
327
  - 'forgiven'
328
  - 'LOST_RETURN'
328
  - 'LOST_RETURN'
329
  - 'writeoff'
329
  - 'WRITEOFF'
330
330
331
=cut
331
=cut
332
332
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 720-726 our $offset_type = { Link Here
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',
726
    'RESERVE'          => 'Reserve Fee',
726
    'RESERVE'          => 'Reserve Fee',
Lines 743-749 our $account_type_credit = { Link Here
743
    'FORGIVEN'         => 'FORGIVEN',
743
    'FORGIVEN'         => 'FORGIVEN',
744
    'LOST_RETURN'      => 'LOST_RETURN',
744
    'LOST_RETURN'      => 'LOST_RETURN',
745
    'PAYMENT'          => 'PAYMENT',
745
    'PAYMENT'          => 'PAYMENT',
746
    'writeoff'         => 'W'
746
    'WRITEOFF'         => 'WRITEOFF'
747
};
747
};
748
748
749
=head1 AUTHORS
749
=head1 AUTHORS
(-)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 37-44 if ( CheckVersion($DBversion) ) { Link Here
37
            )
37
            )
38
            VALUES
38
            VALUES
39
              ('PAYMENT', 'Payment', 0, 1),
39
              ('PAYMENT', 'Payment', 0, 1),
40
              ('W', 'Writeoff', 0, 1),
40
              ('WRITEOFF', 'Writeoff', 0, 1),
41
              ('WO', 'Writeoff', 0, 1),
42
              ('FORGIVEN', 'Forgiven', 1, 1),
41
              ('FORGIVEN', 'Forgiven', 1, 1),
43
              ('CREDIT', 'Credit', 1, 1),
42
              ('CREDIT', 'Credit', 1, 1),
44
              ('LOST_RETURN', 'Lost item fee refund', 0, 1)
43
              ('LOST_RETURN', 'Lost item fee refund', 0, 1)
Lines 95-100 if ( CheckVersion($DBversion) ) { Link Here
95
        }
94
        }
96
    );
95
    );
97
96
97
    # Update accountype 'W' to 'WRITEOFF'
98
    $dbh->do(
99
        qq{
100
          UPDATE accountlines SET accounttype = 'WRITEOFF' WHERE accounttype = 'W' OR accounttype = 'WO'
101
        }
102
    );
103
98
    # Populating credit_type_code
104
    # Populating credit_type_code
99
    $dbh->do(
105
    $dbh->do(
100
        qq{
106
        qq{
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc (-2 / +1 lines)
Lines 3-11 Link Here
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 'PAYMENT'          -%]Payment
5
            [%- CASE 'PAYMENT'          -%]Payment
6
            [%- CASE 'W'                -%]Writeoff
6
            [%- CASE 'WRITEOFF'         -%]Writeoff
7
            [%- CASE 'FORGIVEN'         -%]Forgiven
7
            [%- CASE 'FORGIVEN'         -%]Forgiven
8
            [%- CASE 'WO'               -%]Writeoff
9
            [%- CASE 'CREDIT'           -%]Credit
8
            [%- CASE 'CREDIT'           -%]Credit
10
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
9
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
11
            [%- CASE                    -%][% account.credit_type.description | html %]
10
            [%- CASE                    -%][% account.credit_type.description | html %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc (-2 / +1 lines)
Lines 174-182 Link Here
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 'PAYMENT'          -%]Payment
176
            [%- CASE 'PAYMENT'          -%]Payment
177
            [%- CASE 'W'                -%]Writeoff
177
            [%- CASE 'WRITEOFF'         -%]Writeoff
178
            [%- CASE 'FORGIVEN'         -%]Forgiven
178
            [%- CASE 'FORGIVEN'         -%]Forgiven
179
            [%- CASE 'WO'               -%]Writeoff
180
            [%- CASE 'CREDIT'           -%]Credit
179
            [%- CASE 'CREDIT'           -%]Credit
181
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
180
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
182
            [%- CASE                    -%][% account.credit_type.description | html %]
181
            [%- CASE                    -%][% account.credit_type.description | html %]
(-)a/members/pay.pl (-3 / +3 lines)
Lines 84-90 elsif ( $input->param('payselected') ) { Link Here
84
    payselected({ params => \@names });
84
    payselected({ params => \@names });
85
}
85
}
86
elsif ( $input->param('writeoff_selected') ) {
86
elsif ( $input->param('writeoff_selected') ) {
87
    payselected({ params => \@names, type => 'writeoff' });
87
    payselected({ params => \@names, type => 'WRITEOFF' });
88
}
88
}
89
elsif ( $input->param('woall') ) {
89
elsif ( $input->param('woall') ) {
90
    writeoff_all(@names);
90
    writeoff_all(@names);
Lines 116-122 elsif ( $input->param('confirm_writeoff') ) { Link Here
116
            {
116
            {
117
                amount     => $amount,
117
                amount     => $amount,
118
                lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
118
                lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
119
                type       => 'writeoff',
119
                type       => 'WRITEOFF',
120
                note       => $payment_note,
120
                note       => $payment_note,
121
                interface  => C4::Context->interface,
121
                interface  => C4::Context->interface,
122
                library_id => $branch,
122
                library_id => $branch,
Lines 223-229 sub writeoff_all { Link Here
223
                {
223
                {
224
                    amount => $amount,
224
                    amount => $amount,
225
                    lines  => [ scalar Koha::Account::Lines->find($accountlines_id) ],
225
                    lines  => [ scalar Koha::Account::Lines->find($accountlines_id) ],
226
                    type   => 'writeoff',
226
                    type   => 'WRITEOFF',
227
                    note   => $payment_note,
227
                    note   => $payment_note,
228
                    interface  => C4::Context->interface,
228
                    interface  => C4::Context->interface,
229
                    library_id => $branch,
229
                    library_id => $branch,
(-)a/reports/cash_register_stats.pl (-2 / +2 lines)
Lines 74-80 if ($do_it) { Link Here
74
    } elsif ($transaction_type eq 'ACT') { #Active
74
    } elsif ($transaction_type eq 'ACT') { #Active
75
        $whereTType = q{ AND credit_type_code IN ('PAYMENT','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','WRITEOFF') };
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 = ? };
Lines 128-134 if ($do_it) { Link Here
128
            if($row->{credit_type_code} =~ /^CREDIT$/){
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 'WRITEOFF'){
132
            }else{
132
            }else{
133
                $grantotal += abs($row->{amount});
133
                $grantotal += abs($row->{amount});
134
            }
134
            }
(-)a/t/db_dependent/Accounts.t (-4 / +4 lines)
Lines 364-370 subtest "Koha::Account::pay writeoff tests" => sub { Link Here
364
        {
364
        {
365
            lines  => [$line],
365
            lines  => [$line],
366
            amount => 42,
366
            amount => 42,
367
            type   => 'writeoff',
367
            type   => 'WRITEOFF',
368
        }
368
        }
369
    );
369
    );
370
370
Lines 374-380 subtest "Koha::Account::pay writeoff tests" => sub { Link Here
374
374
375
    my $writeoff = Koha::Account::Lines->find( $id );
375
    my $writeoff = Koha::Account::Lines->find( $id );
376
376
377
    is( $writeoff->credit_type_code, 'W', 'Type is correct for writeoff' );
377
    is( $writeoff->credit_type_code, 'WRITEOFF', 'Type is correct for WRITEOFF' );
378
    is( $writeoff->description, 'Writeoff', 'Description is correct' );
378
    is( $writeoff->description, 'Writeoff', 'Description is correct' );
379
    is( $writeoff->amount, '-42.000000', 'Amount is correct' );
379
    is( $writeoff->amount, '-42.000000', 'Amount is correct' );
380
};
380
};
Lines 1064-1070 subtest "Payment notice tests" => sub { Link Here
1064
    my $id = $account->pay( { amount => 1 } );
1064
    my $id = $account->pay( { amount => 1 } );
1065
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' );
1065
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' );
1066
1066
1067
    $id = $account->pay( { amount => 1, type => 'writeoff' } );
1067
    $id = $account->pay( { amount => 1, type => 'WRITEOFF' } );
1068
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' );
1068
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' );
1069
1069
1070
    t::lib::Mocks::mock_preference('UseEmailReceipts', '1');
1070
    t::lib::Mocks::mock_preference('UseEmailReceipts', '1');
Lines 1080-1086 subtest "Payment notice tests" => sub { Link Here
1080
    $letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.');
1080
    $letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.');
1081
    $letter->store();
1081
    $letter->store();
1082
1082
1083
    $id = $account->pay( { amount => 13, type => 'writeoff' } );
1083
    $id = $account->pay( { amount => 13, type => 'WRITEOFF' } );
1084
    $notice = Koha::Notice::Messages->search()->next();
1084
    $notice = Koha::Notice::Messages->search()->next();
1085
    is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' );
1085
    is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' );
1086
    is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' );
1086
    is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' );
(-)a/t/db_dependent/Circulation.t (-3 / +2 lines)
Lines 2148-2154 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2148
        # Write off the debt
2148
        # Write off the debt
2149
        my $credit = $account->add_credit(
2149
        my $credit = $account->add_credit(
2150
            {   amount => $account->balance,
2150
            {   amount => $account->balance,
2151
                type   => 'writeoff',
2151
                type   => 'WRITEOFF',
2152
                interface => 'test',
2152
                interface => 'test',
2153
            }
2153
            }
2154
        );
2154
        );
Lines 2345-2351 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2345
        my $write_off_amount = 25;
2345
        my $write_off_amount = 25;
2346
        my $write_off        = $account->add_credit(
2346
        my $write_off        = $account->add_credit(
2347
            {   amount => $write_off_amount,
2347
            {   amount => $write_off_amount,
2348
                type   => 'writeoff',
2348
                type   => 'WRITEOFF',
2349
                interface => 'test',
2349
                interface => 'test',
2350
            }
2350
            }
2351
        );
2351
        );
2352
- 

Return to bug 23805