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

(-)a/Koha/Account.pm (-20 / +33 lines)
Lines 71-86 Koha::Account->new( { patron_id => $borrowernumber } )->pay( Link Here
71
sub pay {
71
sub pay {
72
    my ( $self, $params ) = @_;
72
    my ( $self, $params ) = @_;
73
73
74
    my $amount       = $params->{amount};
74
    my $amount        = $params->{amount};
75
    my $sip          = $params->{sip};
75
    my $sip           = $params->{sip};
76
    my $description  = $params->{description};
76
    my $description   = $params->{description};
77
    my $note         = $params->{note} || q{};
77
    my $note          = $params->{note} || q{};
78
    my $library_id   = $params->{library_id};
78
    my $library_id    = $params->{library_id};
79
    my $lines        = $params->{lines};
79
    my $lines         = $params->{lines};
80
    my $type         = $params->{type} || 'payment';
80
    my $type          = $params->{type} || 'payment';
81
    my $payment_type = $params->{payment_type} || undef;
81
    my $payment_type  = $params->{payment_type} || undef;
82
    my $account_type = $params->{account_type};
82
    my $account_type  = $params->{account_type};
83
    my $offset_type  = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
83
    my $offset_type   = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment';
84
    my $cash_register = $params->{cash_register};
84
85
85
    my $userenv = C4::Context->userenv;
86
    my $userenv = C4::Context->userenv;
86
87
Lines 88-93 sub pay { Link Here
88
89
89
    my $manager_id = $userenv ? $userenv->{number} : 0;
90
    my $manager_id = $userenv ? $userenv->{number} : 0;
90
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
91
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
92
    Koha::Exceptions::Account::RegisterRequired->throw()
93
      if ( C4::Context->preference("UseCashRegisters")
94
        && !defined($cash_register)
95
        && ( $interface ne 'opac' ) );
91
96
92
    my @fines_paid; # List of account lines paid on with this payment
97
    my @fines_paid; # List of account lines paid on with this payment
93
98
Lines 229-234 sub pay { Link Here
229
            manager_id        => $manager_id,
234
            manager_id        => $manager_id,
230
            interface         => $interface,
235
            interface         => $interface,
231
            branchcode        => $library_id,
236
            branchcode        => $library_id,
237
            cash_register     => $cash_register,
232
            note              => $note,
238
            note              => $note,
233
        }
239
        }
234
    )->store();
240
    )->store();
Lines 330-345 sub add_credit { Link Here
330
    my ( $self, $params ) = @_;
336
    my ( $self, $params ) = @_;
331
337
332
    # amount is passed as a positive value, but we store credit as negative values
338
    # amount is passed as a positive value, but we store credit as negative values
333
    my $amount       = $params->{amount} * -1;
339
    my $amount        = $params->{amount} * -1;
334
    my $description  = $params->{description} // q{};
340
    my $description   = $params->{description} // q{};
335
    my $note         = $params->{note} // q{};
341
    my $note          = $params->{note} // q{};
336
    my $user_id      = $params->{user_id};
342
    my $user_id       = $params->{user_id};
337
    my $interface    = $params->{interface};
343
    my $interface     = $params->{interface};
338
    my $library_id   = $params->{library_id};
344
    my $library_id    = $params->{library_id};
339
    my $sip          = $params->{sip};
345
    my $cash_register = $params->{cash_register};
340
    my $payment_type = $params->{payment_type};
346
    my $sip           = $params->{sip};
341
    my $type         = $params->{type} || 'payment';
347
    my $payment_type  = $params->{payment_type};
342
    my $item_id      = $params->{item_id};
348
    my $type          = $params->{type} || 'payment';
349
    my $item_id       = $params->{item_id};
343
350
344
    unless ( $interface ) {
351
    unless ( $interface ) {
345
        Koha::Exceptions::MissingParameter->throw(
352
        Koha::Exceptions::MissingParameter->throw(
Lines 347-352 sub add_credit { Link Here
347
        );
354
        );
348
    }
355
    }
349
356
357
    Koha::Exceptions::Account::RegisterRequired->throw()
358
      if ( C4::Context->preference("UseCashRegisters")
359
        && !defined($cash_register)
360
        && ( $payment_type eq 'CASH' ) );
361
350
    my $schema = Koha::Database->new->schema;
362
    my $schema = Koha::Database->new->schema;
351
363
352
    my $account_type = $Koha::Account::account_type_credit->{$type};
364
    my $account_type = $Koha::Account::account_type_credit->{$type};
Lines 372-377 sub add_credit { Link Here
372
                    manager_id        => $user_id,
384
                    manager_id        => $user_id,
373
                    interface         => $interface,
385
                    interface         => $interface,
374
                    branchcode        => $library_id,
386
                    branchcode        => $library_id,
387
                    cash_register     => $cash_register,
375
                    itemnumber        => $item_id,
388
                    itemnumber        => $item_id,
376
                }
389
                }
377
            )->store();
390
            )->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 73-78 my $payment_note = uri_unescape scalar $input->param('payment_note'); Link Here
73
my $payment_type = scalar $input->param('payment_type');
74
my $payment_type = scalar $input->param('payment_type');
74
my $accountlines_id;
75
my $accountlines_id;
75
76
77
my $registerid = $input->param('registerid');
78
if ( !$registerid ) {
79
    $registerid = Koha::Cash::Registers->find(
80
        { branch => $library_id, branch_default => 1 },
81
    )->id;
82
}
83
my $registers = Koha::Cash::Registers->search(
84
    { branch   => $library_id, archived => 0 },
85
    { order_by => { '-asc' => 'name' } }
86
);
87
$template->param(
88
    registerid => $registerid,
89
    registers  => $registers,
90
);
91
76
if ( $pay_individual || $writeoff_individual ) {
92
if ( $pay_individual || $writeoff_individual ) {
77
    if ($pay_individual) {
93
    if ($pay_individual) {
78
        $template->param( pay_individual => 1 );
94
        $template->param( pay_individual => 1 );
Lines 129-134 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
129
                    note         => $payment_note,
145
                    note         => $payment_note,
130
                    interface    => C4::Context->interface,
146
                    interface    => C4::Context->interface,
131
                    payment_type => $payment_type,
147
                    payment_type => $payment_type,
148
                    cash_register => $registerid
132
                }
149
                }
133
            );
150
            );
134
            print $input->redirect(
151
            print $input->redirect(
Lines 159-164 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
159
                        note         => $note,
176
                        note         => $note,
160
                        interface    => C4::Context->interface,
177
                        interface    => C4::Context->interface,
161
                        payment_type => $payment_type,
178
                        payment_type => $payment_type,
179
                        cash_register => $registerid
162
                    }
180
                    }
163
                  );
181
                  );
164
            }
182
            }
Lines 170-176 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
170
                        library_id   => $library_id,
188
                        library_id   => $library_id,
171
                        note         => $note,
189
                        note         => $note,
172
                        payment_type => $payment_type,
190
                        payment_type => $payment_type,
173
                        interface    => C4::Context->interface
191
                        interface    => C4::Context->interface,
192
                        payment_type => $payment_type,
193
                        cash_register => $registerid
174
                    }
194
                    }
175
                );
195
                );
176
            }
196
            }
177
- 

Return to bug 23321