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

(-)a/Koha/Account.pm (+2 lines)
Lines 73-78 sub pay { Link Here
73
    my $library_id   = $params->{library_id};
73
    my $library_id   = $params->{library_id};
74
    my $lines        = $params->{lines};
74
    my $lines        = $params->{lines};
75
    my $type         = $params->{type} || 'payment';
75
    my $type         = $params->{type} || 'payment';
76
    my $payment_type = $params->{payment_type} || undef;
76
    my $account_type = $params->{account_type};
77
    my $account_type = $params->{account_type};
77
    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
78
    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
78
79
Lines 216-221 sub pay { Link Here
216
            amount            => 0 - $amount,
217
            amount            => 0 - $amount,
217
            description       => $description,
218
            description       => $description,
218
            accounttype       => $account_type,
219
            accounttype       => $account_type,
220
            payment_type      => $payment_type,
219
            amountoutstanding => 0 - $balance_remaining,
221
            amountoutstanding => 0 - $balance_remaining,
220
            manager_id        => $manager_id,
222
            manager_id        => $manager_id,
221
            note              => $note,
223
            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 (+24 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 217-222 function moneyFormat(textObj) { Link Here
217
        <label for="selected_accts_notes">Note: </label>
230
        <label for="selected_accts_notes">Note: </label>
218
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
231
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
219
    </li>
232
    </li>
233
    [% IF payment_types.count %]
234
        <li>
235
            <label for="payment_type">Payment type: </label>
236
            <select name="payment_type" id="payment_type>">
237
                <option value=""></option>
238
                [% FOREACH pt IN payment_types %]
239
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
240
                [% END %]
241
            </select>
242
        </li>
243
    [% END %]
220
    </ol>
244
    </ol>
221
    </fieldset>
245
    </fieldset>
222
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
246
    <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') %]
5
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') %]
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 (-17 / +25 lines)
Lines 17-37 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::Account;
34
use Koha::Account;
33
34
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::AuthorisedValues;
35
37
36
my $input = CGI->new();
38
my $input = CGI->new();
37
39
Lines 61-66 my $writeoff = $input->param('writeoff_individual'); Link Here
61
my $select_lines = $input->param('selected');
63
my $select_lines = $input->param('selected');
62
my $select       = $input->param('selected_accts');
64
my $select       = $input->param('selected_accts');
63
my $payment_note = uri_unescape $input->param('payment_note');
65
my $payment_note = uri_unescape $input->param('payment_note');
66
my $payment_type = scalar $input->param('payment_type');
64
my $accountno;
67
my $accountno;
65
my $accountlines_id;
68
my $accountlines_id;
66
69
Lines 114-123 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
114
            my $line = Koha::Account::Lines->find($accountlines_id);
117
            my $line = Koha::Account::Lines->find($accountlines_id);
115
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
118
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
116
                {
119
                {
117
                    lines      => [$line],
120
                    lines        => [$line],
118
                    amount     => $total_paid,
121
                    amount       => $total_paid,
119
                    library_id => $branch,
122
                    library_id   => $branch,
120
                    note       => $payment_note
123
                    note         => $payment_note,
124
                    payment_type => $payment_type,
121
                }
125
                }
122
            );
126
            );
123
            print $input->redirect(
127
            print $input->redirect(
Lines 139-165 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
139
                    { order_by => 'date' }
143
                    { order_by => 'date' }
140
                );
144
                );
141
145
142
                return Koha::Account->new(
146
                Koha::Account->new(
143
                    {
147
                    {
144
                        patron_id => $borrowernumber,
148
                        patron_id => $borrowernumber,
145
                    }
149
                    }
146
                  )->pay(
150
                  )->pay(
147
                    {
151
                    {
148
                        amount => $total_paid,
152
                        amount       => $total_paid,
149
                        lines  => \@lines,
153
                        lines        => \@lines,
150
                        note   => $note,
154
                        note         => $note,
155
                        payment_type => $payment_type,
151
                    }
156
                    }
152
                  );
157
                  );
153
            }
158
            }
154
            else {
159
            else {
155
                my $note = $input->param('selected_accts_notes');
160
                my $note = $input->param('selected_accts_notes');
156
                Koha::Account->new( { patron_id => $borrowernumber } )
161
                Koha::Account->new( { patron_id => $borrowernumber } )->pay(
157
                  ->pay( { amount => $total_paid, note => $note } );
162
                    {
163
                        amount       => $total_paid,
164
                        note         => $note,
165
                        payment_type => $payment_type,
166
                    }
167
                );
158
            }
168
            }
159
169
160
            print $input->redirect(
170
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
161
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
162
            );
163
        }
171
        }
164
    }
172
    }
165
} else {
173
} 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