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
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
Lines 77-82 Link Here
77
          [% CASE 'CR' %]Credit
78
          [% CASE 'CR' %]Credit
78
          [% CASE %][% account.accounttype %]
79
          [% CASE %][% account.accounttype %]
79
        [%- END -%]
80
        [%- END -%]
81
        [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %]
80
        [%- IF account.description %], [% account.description %][% END %]
82
        [%- IF account.description %], [% account.description %][% END %]
81
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.item.biblio.title |html %]</a>[% END %]</td>
83
        &nbsp;[% IF ( account.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber %]&amp;itemnumber=[% account.itemnumber %]">[% account.item.biblio.title |html %]</a>[% END %]</td>
82
      <td>[% account.note | html_line_break %]</td>
84
      <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
[% SET footerjs = 1 %]
4
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
6
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
Lines 85-90 Link Here
85
            <!-- default to paying all -->
86
            <!-- default to paying all -->
86
        <input name="paid" id="paid" value="[% amountoutstanding %]" />
87
        <input name="paid" id="paid" value="[% amountoutstanding %]" />
87
    </li>
88
    </li>
89
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
90
    [% IF payment_types %]
91
        <li>
92
            <label for="payment_type">Payment type: </label>
93
            <select name="payment_type" id="payment_type">
94
                <option value=""></option>
95
                [% FOREACH pt IN payment_types %]
96
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
97
                [% END %]
98
            </select>
99
        </li>
100
    [% END %]
88
</ol>
101
</ol>
89
</fieldset>
102
</fieldset>
90
103
Lines 152-161 Link Here
152
        <!-- default to paying all -->
165
        <!-- default to paying all -->
153
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
166
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
154
    </li>
167
    </li>
168
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
169
    [% IF payment_types %]
170
        <li>
171
            <label for="payment_type">Payment type: </label>
172
            <select name="payment_type" id="payment_type">
173
                <option value=""></option>
174
                [% FOREACH pt IN payment_types %]
175
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
176
                [% END %]
177
            </select>
178
        </li>
179
    [% END %]
155
    <li>
180
    <li>
156
        <label for="selected_accts_notes">Note: </label>
181
        <label for="selected_accts_notes">Note: </label>
157
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
182
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes %]</textarea>
158
    </li>
183
    </li>
184
    [% IF payment_types.count %]
185
        <li>
186
            <label for="payment_type">Payment type: </label>
187
            <select name="payment_type" id="payment_type">
188
                <option value=""></option>
189
                [% FOREACH pt IN payment_types %]
190
                    <option value="[% pt.authorised_value %]">[% pt.lib %]</option>
191
                [% END %]
192
            </select>
193
        </li>
194
    [% END %]
159
    </ol>
195
    </ol>
160
    </fieldset>
196
    </fieldset>
161
    <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
197
    <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 (-15 / +24 lines)
Lines 19-38 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use URI::Escape;
21
use URI::Escape;
22
use CGI qw ( -utf8 );
23
22
use C4::Context;
24
use C4::Context;
23
use C4::Auth;
25
use C4::Auth;
24
use C4::Output;
26
use C4::Output;
25
use CGI qw ( -utf8 );
26
use C4::Members;
27
use C4::Members;
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Accounts;
29
use C4::Accounts;
29
use C4::Koha;
30
use C4::Koha;
31
30
use Koha::Patrons;
32
use Koha::Patrons;
33
use Koha::Patron::Images;
34
use Koha::Patron::Categories;
35
use Koha::AuthorisedValues;
31
use Koha::Account;
36
use Koha::Account;
32
use Koha::Token;
37
use Koha::Token;
33
38
34
use Koha::Patron::Categories;
35
36
my $input = CGI->new();
39
my $input = CGI->new();
37
40
38
my $updatecharges_permissions = $input->param('writeoff_individual') ? 'writeoff' : 'remaining_permissions';
41
my $updatecharges_permissions = $input->param('writeoff_individual') ? 'writeoff' : 'remaining_permissions';
Lines 66-71 my $writeoff = $input->param('writeoff_individual'); Link Here
66
my $select_lines = $input->param('selected');
69
my $select_lines = $input->param('selected');
67
my $select       = $input->param('selected_accts');
70
my $select       = $input->param('selected_accts');
68
my $payment_note = uri_unescape scalar $input->param('payment_note');
71
my $payment_note = uri_unescape scalar $input->param('payment_note');
72
my $payment_type = scalar $input->param('payment_type');
69
my $accountlines_id;
73
my $accountlines_id;
70
74
71
if ( $individual || $writeoff ) {
75
if ( $individual || $writeoff ) {
Lines 118-127 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
118
            my $line = Koha::Account::Lines->find($accountlines_id);
122
            my $line = Koha::Account::Lines->find($accountlines_id);
119
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
123
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
120
                {
124
                {
121
                    lines      => [$line],
125
                    lines        => [$line],
122
                    amount     => $total_paid,
126
                    amount       => $total_paid,
123
                    library_id => $branch,
127
                    library_id   => $branch,
124
                    note       => $payment_note
128
                    note         => $payment_note,
129
                    payment_type => $payment_type,
125
                }
130
                }
126
            );
131
            );
127
            print $input->redirect(
132
            print $input->redirect(
Lines 149-169 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
149
                    }
154
                    }
150
                  )->pay(
155
                  )->pay(
151
                    {
156
                    {
152
                        amount => $total_paid,
157
                        amount       => $total_paid,
153
                        lines  => \@lines,
158
                        lines        => \@lines,
154
                        note   => $note,
159
                        note         => $note,
160
                        payment_type => $payment_type,
155
                    }
161
                    }
156
                  );
162
                  );
157
            }
163
            }
158
            else {
164
            else {
159
                my $note = $input->param('selected_accts_notes');
165
                my $note = $input->param('selected_accts_notes');
160
                Koha::Account->new( { patron_id => $borrowernumber } )
166
                Koha::Account->new( { patron_id => $borrowernumber } )->pay(
161
                  ->pay( { amount => $total_paid, note => $note } );
167
                    {
168
                        amount       => $total_paid,
169
                        note         => $note,
170
                        payment_type => $payment_type,
171
                    }
172
                );
162
            }
173
            }
163
174
164
            print $input->redirect(
175
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
165
"/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"
166
            );
167
        }
176
        }
168
    }
177
    }
169
} else {
178
} 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