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' no_html = 1 %]</title>
7
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' no_html = 1 %]</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 142-147 function moneyFormat(textObj) { Link Here
142
            <!-- default to paying all -->
143
            <!-- default to paying all -->
143
        <input name="paid" id="paid" value="[% amountoutstanding %]" />
144
        <input name="paid" id="paid" value="[% amountoutstanding %]" />
144
    </li>
145
    </li>
146
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
147
    [% IF payment_types %]
148
        <li>
149
            <label for="payment_type">Payment type: </label>
150
            <select name="payment_type" id="payment_type>">
151
                <option value=""></option>
152
                [% FOREACH pt IN payment_types %]
153
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
154
                [% END %]
155
            </select>
156
        </li>
157
    [% END %]
145
</ol>
158
</ol>
146
</fieldset>
159
</fieldset>
147
160
Lines 209-218 function moneyFormat(textObj) { Link Here
209
        <!-- default to paying all -->
222
        <!-- default to paying all -->
210
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
223
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
211
    </li>
224
    </li>
225
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
226
    [% IF payment_types %]
227
        <li>
228
            <label for="payment_type">Payment type: </label>
229
            <select name="payment_type" id="payment_type>">
230
                <option value=""></option>
231
                [% FOREACH pt IN payment_types %]
232
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
233
                [% END %]
234
            </select>
235
        </li>
236
    [% END %]
212
    <li>
237
    <li>
213
        <label for="selected_accts_notes">Note: </label>
238
        <label for="selected_accts_notes">Note: </label>
214
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
239
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
215
    </li>
240
    </li>
241
    [% IF payment_types.count %]
242
        <li>
243
            <label for="payment_type">Payment type: </label>
244
            <select name="payment_type" id="payment_type>">
245
                <option value=""></option>
246
                [% FOREACH pt IN payment_types %]
247
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
248
                [% END %]
249
            </select>
250
        </li>
251
    [% END %]
216
    </ol>
252
    </ol>
217
    </fieldset>
253
    </fieldset>
218
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
254
    <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 123-132 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
123
            my $line = Koha::Account::Lines->find($accountlines_id);
127
            my $line = Koha::Account::Lines->find($accountlines_id);
124
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
128
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
125
                {
129
                {
126
                    lines      => [$line],
130
                    lines        => [$line],
127
                    amount     => $total_paid,
131
                    amount       => $total_paid,
128
                    library_id => $branch,
132
                    library_id   => $branch,
129
                    note       => $payment_note
133
                    note         => $payment_note,
134
                    payment_type => $payment_type,
130
                }
135
                }
131
            );
136
            );
132
            print $input->redirect(
137
            print $input->redirect(
Lines 154-174 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
154
                    }
159
                    }
155
                  )->pay(
160
                  )->pay(
156
                    {
161
                    {
157
                        amount => $total_paid,
162
                        amount       => $total_paid,
158
                        lines  => \@lines,
163
                        lines        => \@lines,
159
                        note   => $note,
164
                        note         => $note,
165
                        payment_type => $payment_type,
160
                    }
166
                    }
161
                  );
167
                  );
162
            }
168
            }
163
            else {
169
            else {
164
                my $note = $input->param('selected_accts_notes');
170
                my $note = $input->param('selected_accts_notes');
165
                Koha::Account->new( { patron_id => $borrowernumber } )
171
                Koha::Account->new( { patron_id => $borrowernumber } )->pay(
166
                  ->pay( { amount => $total_paid, note => $note } );
172
                    {
173
                        amount       => $total_paid,
174
                        note         => $note,
175
                        payment_type => $payment_type,
176
                    }
177
                );
167
            }
178
            }
168
179
169
            print $input->redirect(
180
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
170
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
171
            );
172
        }
181
        }
173
    }
182
    }
174
} else {
183
} 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