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

(-)a/Koha/Account.pm (+2 lines)
Lines 72-77 sub pay { Link Here
72
    my $library_id   = $params->{library_id};
72
    my $library_id   = $params->{library_id};
73
    my $lines        = $params->{lines};
73
    my $lines        = $params->{lines};
74
    my $type         = $params->{type} || 'payment';
74
    my $type         = $params->{type} || 'payment';
75
    my $payment_type = $params->{payment_type} || undef;
75
    my $account_type = $params->{account_type};
76
    my $account_type = $params->{account_type};
76
    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
77
    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
77
78
Lines 215-220 sub pay { Link Here
215
            amount            => 0 - $amount,
216
            amount            => 0 - $amount,
216
            description       => $description,
217
            description       => $description,
217
            accounttype       => $account_type,
218
            accounttype       => $account_type,
219
            payment_type      => $payment_type,
218
            amountoutstanding => 0 - $balance_remaining,
220
            amountoutstanding => 0 - $balance_remaining,
219
            manager_id        => $manager_id,
221
            manager_id        => $manager_id,
220
            note              => $note,
222
            note              => $note,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (+2 lines)
Lines 1-6 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE ColumnsSettings %]
3
[% USE ColumnsSettings %]
4
[% USE AuthorisedValues %]
4
[% USE Price %]
5
[% USE Price %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
7
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
Lines 107-112 $(document).ready(function() { Link Here
107
          [% CASE 'CR' %]Credit
108
          [% CASE 'CR' %]Credit
108
          [% CASE %][% account.accounttype %]
109
          [% CASE %][% account.accounttype %]
109
        [%- END -%]
110
        [%- END -%]
111
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %]
110
        [%- IF account.description %], [% account.description %][% END %]
112
        [%- IF account.description %], [% account.description %][% END %]
111
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.title |html %]</a>[% END %]</td>
113
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.title |html %]</a>[% END %]</td>
112
      <td>[% account.note | html_line_break %]</td>
114
      <td>[% account.note | html_line_break %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+36 lines)
Lines 1-5 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE AuthorisedValues %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% borrower.firstname %] [% borrower.surname %]</title>
5
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% borrower.firstname %] [% borrower.surname %]</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 148-153 function moneyFormat(textObj) { Link Here
148
            <!-- default to paying all -->
149
            <!-- default to paying all -->
149
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" />
150
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" />
150
    </li>
151
    </li>
152
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
153
    [% IF payment_types %]
154
        <li>
155
            <label for="payment_type">Payment type: </label>
156
            <select name="payment_type" id="payment_type>">
157
                <option value=""></option>
158
                [% FOREACH pt IN payment_types %]
159
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
160
                [% END %]
161
            </select>
162
        </li>
163
    [% END %]
151
</ol>
164
</ol>
152
</fieldset>
165
</fieldset>
153
166
Lines 214-223 function moneyFormat(textObj) { Link Here
214
        <!-- default to paying all -->
227
        <!-- default to paying all -->
215
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
228
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
216
    </li>
229
    </li>
230
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
231
    [% IF payment_types %]
232
        <li>
233
            <label for="payment_type">Payment type: </label>
234
            <select name="payment_type" id="payment_type>">
235
                <option value=""></option>
236
                [% FOREACH pt IN payment_types %]
237
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
238
                [% END %]
239
            </select>
240
        </li>
241
    [% END %]
217
    <li>
242
    <li>
218
        <label for="selected_accts_notes">Note: </label>
243
        <label for="selected_accts_notes">Note: </label>
219
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
244
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
220
    </li>
245
    </li>
246
    [% IF payment_types.count %]
247
        <li>
248
            <label for="payment_type">Payment type: </label>
249
            <select name="payment_type" id="payment_type>">
250
                <option value=""></option>
251
                [% FOREACH pt IN payment_types %]
252
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
253
                [% END %]
254
            </select>
255
        </li>
256
    [% END %]
221
    </ol>
257
    </ol>
222
    </fieldset>
258
    </fieldset>
223
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
259
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt (+2 lines)
Lines 1-5 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE AuthorisedValues %]
3
[% USE Price %]
4
[% USE Price %]
4
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
5
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
5
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
6
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
Lines 127-132 Link Here
127
                                            [% CASE 'CR' %]Credit
128
                                            [% CASE 'CR' %]Credit
128
                                            [% CASE %][% ACCOUNT_LINE.accounttype %]
129
                                            [% CASE %][% ACCOUNT_LINE.accounttype %]
129
                                          [%- END -%]
130
                                          [%- END -%]
131
                                          [%- IF ACCOUNT_LINE.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', ACCOUNT_LINE.payment_type, 1) %][% END %]
130
                                          [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
132
                                          [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
131
                                          [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
133
                                          [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
132
                                        </td>
134
                                        </td>
(-)a/members/paycollect.pl (-18 / +27 lines)
Lines 17-40 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
21
22
use URI::Escape;
22
use URI::Escape;
23
use CGI qw ( -utf8 );
24
23
use C4::Context;
25
use C4::Context;
24
use C4::Auth;
26
use C4::Auth;
25
use C4::Output;
27
use C4::Output;
26
use CGI qw ( -utf8 );
27
use C4::Members;
28
use C4::Members;
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use C4::Accounts;
30
use C4::Accounts;
30
use C4::Koha;
31
use C4::Koha;
31
use Koha::Patron::Images;
32
32
use Koha::Patrons;
33
use Koha::Patrons;
34
use Koha::Patron::Images;
35
use Koha::Patron::Categories;
36
37
use Koha::AuthorisedValues;
33
use Koha::Account;
38
use Koha::Account;
34
use Koha::Token;
39
use Koha::Token;
35
40
36
use Koha::Patron::Categories;
37
38
my $input = CGI->new();
41
my $input = CGI->new();
39
42
40
my $updatecharges_permissions = $input->param('writeoff_individual') ? 'writeoff' : 'remaining_permissions';
43
my $updatecharges_permissions = $input->param('writeoff_individual') ? 'writeoff' : 'remaining_permissions';
Lines 71-76 my $writeoff = $input->param('writeoff_individual'); Link Here
71
my $select_lines = $input->param('selected');
74
my $select_lines = $input->param('selected');
72
my $select       = $input->param('selected_accts');
75
my $select       = $input->param('selected_accts');
73
my $payment_note = uri_unescape scalar $input->param('payment_note');
76
my $payment_note = uri_unescape scalar $input->param('payment_note');
77
my $payment_type = scalar $input->param('payment_type');
74
my $accountlines_id;
78
my $accountlines_id;
75
79
76
if ( $individual || $writeoff ) {
80
if ( $individual || $writeoff ) {
Lines 127-136 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
127
            my $line = Koha::Account::Lines->find($accountlines_id);
131
            my $line = Koha::Account::Lines->find($accountlines_id);
128
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
132
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
129
                {
133
                {
130
                    lines      => [$line],
134
                    lines        => [$line],
131
                    amount     => $total_paid,
135
                    amount       => $total_paid,
132
                    library_id => $branch,
136
                    library_id   => $branch,
133
                    note       => $payment_note
137
                    note         => $payment_note,
138
                    payment_type => $payment_type,
134
                }
139
                }
135
            );
140
            );
136
            print $input->redirect(
141
            print $input->redirect(
Lines 158-178 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
158
                    }
163
                    }
159
                  )->pay(
164
                  )->pay(
160
                    {
165
                    {
161
                        amount => $total_paid,
166
                        amount       => $total_paid,
162
                        lines  => \@lines,
167
                        lines        => \@lines,
163
                        note   => $note,
168
                        note         => $note,
169
                        payment_type => $payment_type,
164
                    }
170
                    }
165
                  );
171
                  );
166
            }
172
            }
167
            else {
173
            else {
168
                my $note = $input->param('selected_accts_notes');
174
                my $note = $input->param('selected_accts_notes');
169
                Koha::Account->new( { patron_id => $borrowernumber } )
175
                Koha::Account->new( { patron_id => $borrowernumber } )->pay(
170
                  ->pay( { amount => $total_paid, note => $note } );
176
                    {
177
                        amount       => $total_paid,
178
                        note         => $note,
179
                        payment_type => $payment_type,
180
                    }
181
                );
171
            }
182
            }
172
183
173
            print $input->redirect(
184
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
174
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
175
            );
176
        }
185
        }
177
    }
186
    }
178
} else {
187
} else {
(-)a/t/db_dependent/Accounts.t (-3 / +5 lines)
Lines 137-143 $dbh->do(q|DELETE FROM accountlines|); Link Here
137
137
138
subtest "Koha::Account::pay tests" => sub {
138
subtest "Koha::Account::pay tests" => sub {
139
139
140
    plan tests => 12;
140
    plan tests => 13;
141
141
142
    # Create a borrower
142
    # Create a borrower
143
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
143
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
Lines 175-181 subtest "Koha::Account::pay tests" => sub { Link Here
175
    my $borrowernumber = $borrower->borrowernumber;
175
    my $borrowernumber = $borrower->borrowernumber;
176
    my $data = '20.00';
176
    my $data = '20.00';
177
    my $payment_note = '$20.00 payment note';
177
    my $payment_note = '$20.00 payment note';
178
    $account->pay( { amount => $data, note => $payment_note } );
178
    my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } );
179
180
    my $accountline = Koha::Account::Lines->find( $id );
181
    is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" );
179
182
180
    # There is now $280 in the account
183
    # There is now $280 in the account
181
    $sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?");
184
    $sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?");
182
- 

Return to bug 18786