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 106-111 $(document).ready(function() { Link Here
106
          [% CASE 'CR' %]Credit
107
          [% CASE 'CR' %]Credit
107
          [% CASE %][% account.accounttype %]
108
          [% CASE %][% account.accounttype %]
108
        [%- END -%]
109
        [%- END -%]
110
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %]
109
        [%- IF account.description %], [% account.description %][% END %]
111
        [%- IF account.description %], [% account.description %][% END %]
110
        &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
        &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>
111
      <td>[% account.note | html_line_break %]</td>
113
      <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 147-152 function moneyFormat(textObj) { Link Here
147
            <!-- default to paying all -->
148
            <!-- default to paying all -->
148
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" />
149
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" />
149
    </li>
150
    </li>
151
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
152
    [% IF payment_types %]
153
        <li>
154
            <label for="payment_type">Payment type: </label>
155
            <select name="payment_type" id="payment_type>">
156
                <option value=""></option>
157
                [% FOREACH pt IN payment_types %]
158
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
159
                [% END %]
160
            </select>
161
        </li>
162
    [% END %]
150
</ol>
163
</ol>
151
</fieldset>
164
</fieldset>
152
165
Lines 211-220 function moneyFormat(textObj) { Link Here
211
        <!-- default to paying all -->
224
        <!-- default to paying all -->
212
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
225
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
213
    </li>
226
    </li>
227
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
228
    [% IF payment_types %]
229
        <li>
230
            <label for="payment_type">Payment type: </label>
231
            <select name="payment_type" id="payment_type>">
232
                <option value=""></option>
233
                [% FOREACH pt IN payment_types %]
234
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
235
                [% END %]
236
            </select>
237
        </li>
238
    [% END %]
214
    <li>
239
    <li>
215
        <label for="selected_accts_notes">Note: </label>
240
        <label for="selected_accts_notes">Note: </label>
216
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
241
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
217
    </li>
242
    </li>
243
    [% IF payment_types.count %]
244
        <li>
245
            <label for="payment_type">Payment type: </label>
246
            <select name="payment_type" id="payment_type>">
247
                <option value=""></option>
248
                [% FOREACH pt IN payment_types %]
249
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
250
                [% END %]
251
            </select>
252
        </li>
253
    [% END %]
218
    </ol>
254
    </ol>
219
    </fieldset>
255
    </fieldset>
220
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
256
    <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 126-131 Link Here
126
                                            [% CASE 'CR' %]Credit
127
                                            [% CASE 'CR' %]Credit
127
                                            [% CASE %][% ACCOUNT_LINE.accounttype %]
128
                                            [% CASE %][% ACCOUNT_LINE.accounttype %]
128
                                          [%- END -%]
129
                                          [%- END -%]
130
                                          [%- IF ACCOUNT_LINE.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', ACCOUNT_LINE.payment_type, 1) %][% END %]
129
                                          [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
131
                                          [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %]
130
                                          [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
132
                                          [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %]
131
                                        </td>
133
                                        </td>
(-)a/members/paycollect.pl (-16 / +24 lines)
Lines 17-38 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;
32
31
use Koha::Patron::Images;
33
use Koha::Patron::Images;
32
use Koha::Patrons;
34
use Koha::Patrons;
33
use Koha::Account;
35
use Koha::Account;
34
35
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
37
use Koha::AuthorisedValues;
36
38
37
my $input = CGI->new();
39
my $input = CGI->new();
38
40
Lines 70-75 my $writeoff = $input->param('writeoff_individual'); Link Here
70
my $select_lines = $input->param('selected');
72
my $select_lines = $input->param('selected');
71
my $select       = $input->param('selected_accts');
73
my $select       = $input->param('selected_accts');
72
my $payment_note = uri_unescape scalar $input->param('payment_note');
74
my $payment_note = uri_unescape scalar $input->param('payment_note');
75
my $payment_type = scalar $input->param('payment_type');
73
my $accountlines_id;
76
my $accountlines_id;
74
77
75
if ( $individual || $writeoff ) {
78
if ( $individual || $writeoff ) {
Lines 120-129 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
120
            my $line = Koha::Account::Lines->find($accountlines_id);
123
            my $line = Koha::Account::Lines->find($accountlines_id);
121
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
124
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
122
                {
125
                {
123
                    lines      => [$line],
126
                    lines        => [$line],
124
                    amount     => $total_paid,
127
                    amount       => $total_paid,
125
                    library_id => $branch,
128
                    library_id   => $branch,
126
                    note       => $payment_note
129
                    note         => $payment_note,
130
                    payment_type => $payment_type,
127
                }
131
                }
128
            );
132
            );
129
            print $input->redirect(
133
            print $input->redirect(
Lines 151-171 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
151
                    }
155
                    }
152
                  )->pay(
156
                  )->pay(
153
                    {
157
                    {
154
                        amount => $total_paid,
158
                        amount       => $total_paid,
155
                        lines  => \@lines,
159
                        lines        => \@lines,
156
                        note   => $note,
160
                        note         => $note,
161
                        payment_type => $payment_type,
157
                    }
162
                    }
158
                  );
163
                  );
159
            }
164
            }
160
            else {
165
            else {
161
                my $note = $input->param('selected_accts_notes');
166
                my $note = $input->param('selected_accts_notes');
162
                Koha::Account->new( { patron_id => $borrowernumber } )
167
                Koha::Account->new( { patron_id => $borrowernumber } )->pay(
163
                  ->pay( { amount => $total_paid, note => $note } );
168
                    {
169
                        amount       => $total_paid,
170
                        note         => $note,
171
                        payment_type => $payment_type,
172
                    }
173
                );
164
            }
174
            }
165
175
166
            print $input->redirect(
176
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
167
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
168
            );
169
        }
177
        }
170
    }
178
    }
171
} else {
179
} else {
(-)a/t/db_dependent/Accounts.t (-3 / +5 lines)
Lines 136-142 $dbh->do(q|DELETE FROM accountlines|); Link Here
136
136
137
subtest "Koha::Account::pay tests" => sub {
137
subtest "Koha::Account::pay tests" => sub {
138
138
139
    plan tests => 12;
139
    plan tests => 13;
140
140
141
    # Create a borrower
141
    # Create a borrower
142
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
142
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
Lines 174-180 subtest "Koha::Account::pay tests" => sub { Link Here
174
    my $borrowernumber = $borrower->borrowernumber;
174
    my $borrowernumber = $borrower->borrowernumber;
175
    my $data = '20.00';
175
    my $data = '20.00';
176
    my $payment_note = '$20.00 payment note';
176
    my $payment_note = '$20.00 payment note';
177
    $account->pay( { amount => $data, note => $payment_note } );
177
    my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } );
178
179
    my $accountline = Koha::Account::Lines->find( $id );
180
    is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" );
178
181
179
    # There is now $280 in the account
182
    # There is now $280 in the account
180
    $sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?");
183
    $sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?");
181
- 

Return to bug 18786