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

(-)a/Koha/Account.pm (-18 / +31 lines)
Lines 70-84 Koha::Account->new( { patron_id => $borrowernumber } )->pay( Link Here
70
sub pay {
70
sub pay {
71
    my ( $self, $params ) = @_;
71
    my ( $self, $params ) = @_;
72
72
73
    my $amount       = $params->{amount};
73
    my $amount        = $params->{amount};
74
    my $description  = $params->{description};
74
    my $description   = $params->{description};
75
    my $note         = $params->{note} || q{};
75
    my $note          = $params->{note} || q{};
76
    my $library_id   = $params->{library_id};
76
    my $library_id    = $params->{library_id};
77
    my $lines        = $params->{lines};
77
    my $lines         = $params->{lines};
78
    my $type         = $params->{type} || 'payment';
78
    my $type          = $params->{type} || 'payment';
79
    my $payment_type = $params->{payment_type} || undef;
79
    my $payment_type  = $params->{payment_type} || undef;
80
    my $account_type = $params->{account_type};
80
    my $account_type  = $params->{account_type};
81
    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
81
    my $offset_type   = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
82
    my $cash_register = $params->{cash_register};
82
83
83
    my $userenv = C4::Context->userenv;
84
    my $userenv = C4::Context->userenv;
84
85
Lines 86-91 sub pay { Link Here
86
87
87
    my $manager_id = $userenv ? $userenv->{number} : 0;
88
    my $manager_id = $userenv ? $userenv->{number} : 0;
88
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
89
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
90
    Koha::Exceptions::Account::RegisterRequired->throw()
91
      if ( C4::Context->preference("UseCashRegisters")
92
        && !defined($cash_register)
93
        && ( $interface ne 'opac' ) );
89
94
90
    my @fines_paid; # List of account lines paid on with this payment
95
    my @fines_paid; # List of account lines paid on with this payment
91
96
Lines 227-232 sub pay { Link Here
227
            manager_id        => $manager_id,
232
            manager_id        => $manager_id,
228
            interface         => $interface,
233
            interface         => $interface,
229
            branchcode        => $library_id,
234
            branchcode        => $library_id,
235
            cash_register     => $cash_register,
230
            note              => $note,
236
            note              => $note,
231
        }
237
        }
232
    )->store();
238
    )->store();
Lines 327-341 sub add_credit { Link Here
327
    my ( $self, $params ) = @_;
333
    my ( $self, $params ) = @_;
328
334
329
    # amount is passed as a positive value, but we store credit as negative values
335
    # amount is passed as a positive value, but we store credit as negative values
330
    my $amount       = $params->{amount} * -1;
336
    my $amount        = $params->{amount} * -1;
331
    my $description  = $params->{description} // q{};
337
    my $description   = $params->{description} // q{};
332
    my $note         = $params->{note} // q{};
338
    my $note          = $params->{note} // q{};
333
    my $user_id      = $params->{user_id};
339
    my $user_id       = $params->{user_id};
334
    my $interface    = $params->{interface};
340
    my $interface     = $params->{interface};
335
    my $library_id   = $params->{library_id};
341
    my $library_id    = $params->{library_id};
336
    my $payment_type = $params->{payment_type};
342
    my $cash_register = $params->{cash_register};
337
    my $type         = $params->{type} || 'payment';
343
    my $payment_type  = $params->{payment_type};
338
    my $item_id      = $params->{item_id};
344
    my $type          = $params->{type} || 'payment';
345
    my $item_id       = $params->{item_id};
339
346
340
    unless ( $interface ) {
347
    unless ( $interface ) {
341
        Koha::Exceptions::MissingParameter->throw(
348
        Koha::Exceptions::MissingParameter->throw(
Lines 343-348 sub add_credit { Link Here
343
        );
350
        );
344
    }
351
    }
345
352
353
    Koha::Exceptions::Account::RegisterRequired->throw()
354
      if ( C4::Context->preference("UseCashRegisters")
355
        && !defined($cash_register)
356
        && ( $payment_type eq 'CASH' ) );
357
346
    my $schema = Koha::Database->new->schema;
358
    my $schema = Koha::Database->new->schema;
347
359
348
    my $account_type = $Koha::Account::account_type_credit->{$type};
360
    my $account_type = $Koha::Account::account_type_credit->{$type};
Lines 364-369 sub add_credit { Link Here
364
                    manager_id        => $user_id,
376
                    manager_id        => $user_id,
365
                    interface         => $interface,
377
                    interface         => $interface,
366
                    branchcode        => $library_id,
378
                    branchcode        => $library_id,
379
                    cash_register     => $cash_register,
367
                    itemnumber        => $item_id,
380
                    itemnumber        => $item_id,
368
                }
381
                }
369
            )->store();
382
            )->store();
(-)a/Koha/Exceptions/Account.pm (-1 / +10 lines)
Lines 41-48 use Exception::Class ( Link Here
41
    'Koha::Exceptions::Account::UnrecognisedType' => {
41
    'Koha::Exceptions::Account::UnrecognisedType' => {
42
        isa         => 'Koha::Exceptions::Account',
42
        isa         => 'Koha::Exceptions::Account',
43
        description => 'Account type was not recognised'
43
        description => 'Account type was not recognised'
44
    },
45
    'Koha::Exceptions::Account::RegisterRequired' => {
46
        isa         => 'Koha::Exceptions::Account',
47
        description => 'Account transaction requires a cash register'
44
    }
48
    }
45
46
);
49
);
47
50
48
=head1 NAME
51
=head1 NAME
Lines 81-84 Exception to be used when a passed credit or debit is not of a recognised type. Link Here
81
84
82
=cut
85
=cut
83
86
87
=head2 Koha::Exceptions::Account::RegisterRequired
88
89
Exception to be used when UseCashRegisters is enabled and one is not passed for a transaction.
90
91
=cut
92
84
1;
93
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (+31 lines)
Lines 122-127 Link Here
122
            </select>
122
            </select>
123
        </li>
123
        </li>
124
    [% END %]
124
    [% END %]
125
    [% IF Koha.Preference('UseCashRegisters') %]
126
    <li>
127
        <label for="cash_register">Cash register: </label>
128
        <select name="cash_register" id="cash_register">
129
            [% FOREACH register IN registers %]
130
              [% IF register.id == registerid %]
131
            <option value="[% register.id %]" selected="selected">[% register.name | html %]</option>
132
              [% ELSE %]
133
            <option value="[% register.id %]">[% register.name | html %]</option>
134
              [% END %]
135
            [% END %]
136
        </select>
137
    </li>
138
    [% END %]
125
</ol>
139
</ol>
126
</fieldset>
140
</fieldset>
127
141
Lines 216-221 Link Here
216
        <label>Change to give: </label>
230
        <label>Change to give: </label>
217
        <span id="change">0.00</span>
231
        <span id="change">0.00</span>
218
    </li>
232
    </li>
233
219
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
234
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
220
    [% IF payment_types %]
235
    [% IF payment_types %]
221
        <li>
236
        <li>
Lines 228-233 Link Here
228
            </select>
243
            </select>
229
        </li>
244
        </li>
230
    [% END %]
245
    [% END %]
246
247
    [% IF Koha.Preference('UseCashRegisters') %]
248
    <li>
249
        <label for="cash_register">Cash register: </label>
250
        <select name="cash_register" id="cash_register">
251
            [% FOREACH register IN registers %]
252
              [% IF register.id == registerid %]
253
            <option value="[% register.id %]" selected="selected">[% register.name | html %]</option>
254
              [% ELSE %]
255
            <option value="[% register.id %]">[% register.name | html %]</option>
256
              [% END %]
257
            [% END %]
258
        </select>
259
    </li>
260
    [% END %]
261
231
    <li>
262
    <li>
232
        <label for="selected_accts_notes">Note: </label>
263
        <label for="selected_accts_notes">Note: </label>
233
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
264
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
(-)a/members/paycollect.pl (-2 / +21 lines)
Lines 28-33 use C4::Members; Link Here
28
use C4::Accounts;
28
use C4::Accounts;
29
use C4::Koha;
29
use C4::Koha;
30
30
31
use Koha::Cash::Registers;
31
use Koha::Patrons;
32
use Koha::Patrons;
32
use Koha::Patron::Categories;
33
use Koha::Patron::Categories;
33
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
Lines 74-79 my $payment_note = uri_unescape scalar $input->param('payment_note'); Link Here
74
my $payment_type = scalar $input->param('payment_type');
75
my $payment_type = scalar $input->param('payment_type');
75
my $accountlines_id;
76
my $accountlines_id;
76
77
78
my $registerid = $input->param('registerid');
79
if ( !$registerid ) {
80
    $registerid = Koha::Cash::Registers->find(
81
        { branch => $library_id, branch_default => 1 },
82
    )->id;
83
}
84
my $registers = Koha::Cash::Registers->search(
85
    { branch   => $library_id, archived => 0 },
86
    { order_by => { '-asc' => 'name' } }
87
);
88
$template->param(
89
    registerid => $registerid,
90
    registers  => $registers,
91
);
92
77
if ( $pay_individual || $writeoff_individual ) {
93
if ( $pay_individual || $writeoff_individual ) {
78
    if ($pay_individual) {
94
    if ($pay_individual) {
79
        $template->param( pay_individual => 1 );
95
        $template->param( pay_individual => 1 );
Lines 130-135 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
130
                    note         => $payment_note,
146
                    note         => $payment_note,
131
                    interface    => C4::Context->interface,
147
                    interface    => C4::Context->interface,
132
                    payment_type => $payment_type,
148
                    payment_type => $payment_type,
149
                    cash_register => $registerid
133
                }
150
                }
134
            );
151
            );
135
            print $input->redirect(
152
            print $input->redirect(
Lines 160-165 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
160
                        note         => $note,
177
                        note         => $note,
161
                        interface    => C4::Context->interface,
178
                        interface    => C4::Context->interface,
162
                        payment_type => $payment_type,
179
                        payment_type => $payment_type,
180
                        cash_register => $registerid
163
                    }
181
                    }
164
                  );
182
                  );
165
            }
183
            }
Lines 171-177 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
171
                        library_id   => $library_id,
189
                        library_id   => $library_id,
172
                        note         => $note,
190
                        note         => $note,
173
                        payment_type => $payment_type,
191
                        payment_type => $payment_type,
174
                        interface    => C4::Context->interface
192
                        interface    => C4::Context->interface,
193
                        payment_type => $payment_type,
194
                        cash_register => $registerid
175
                    }
195
                    }
176
                );
196
                );
177
            }
197
            }
178
- 

Return to bug 23321