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

(-)a/Koha/Cash/Register.pm (-1 / +1 lines)
Lines 220-226 sub add_cashup { Link Here
220
    my $rs = $self->_result->add_to_cash_register_actions(
220
    my $rs = $self->_result->add_to_cash_register_actions(
221
        {
221
        {
222
            code       => 'CASHUP',
222
            code       => 'CASHUP',
223
            manager_id => $params->{user_id},
223
            manager_id => $params->{staff_id},
224
            amount     => $params->{amount}
224
            amount     => $params->{amount}
225
        }
225
        }
226
    )->discard_changes;
226
    )->discard_changes;
(-)a/installer/data/mysql/account_offset_types.sql (+3 lines)
Lines 7-12 INSERT INTO account_offset_types ( type ) VALUES Link Here
7
('Manual Credit'),
7
('Manual Credit'),
8
('Manual Debit'),
8
('Manual Debit'),
9
('Reverse Payment'),
9
('Reverse Payment'),
10
('REFUND'),
11
('LINK'),
12
('PAYOUT'),
10
('Forgiven'),
13
('Forgiven'),
11
('Dropbox'),
14
('Dropbox'),
12
('Account Fee'),
15
('Account Fee'),
(-)a/installer/data/mysql/atomicupdate/bug_24082.perl (+22 lines)
Line 0 Link Here
1
$DBversion = 'XXX';    # will be replaced by the RM
2
if ( CheckVersion($DBversion) ) {
3
4
    $dbh->do(qq{
5
        INSERT IGNORE permissions (module_bit, code, description)
6
        VALUES
7
        (25, 'refund_cash_registers', 'Perform refund actions from cash registers')
8
    });
9
10
    $dbh->do(q{
11
        INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'REFUND' );
12
    });
13
    $dbh->do(q{
14
        INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'LINK' );
15
    });
16
    $dbh->do(q{
17
        INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'PAYOUT' );
18
    });
19
20
    SetVersion($DBversion);
21
    print "Upgrade to $DBversion done (Bug 23442 - Add a refund option to the point of sale system)\n";
22
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc (+3 lines)
Lines 7-12 Link Here
7
            [%- CASE 'FORGIVEN'         -%]Forgiven
7
            [%- CASE 'FORGIVEN'         -%]Forgiven
8
            [%- CASE 'CREDIT'           -%]Credit
8
            [%- CASE 'CREDIT'           -%]Credit
9
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
9
            [%- CASE 'LOST_RETURN'      -%]Lost item fee refund
10
            [%- CASE 'Refund'           -%]Refund
10
            [%- CASE                    -%][% account.credit_type.description | html %]
11
            [%- CASE                    -%][% account.credit_type.description | html %]
11
        [%- END -%]
12
        [%- END -%]
12
    [%- ELSIF account.debit_type_code -%]
13
    [%- ELSIF account.debit_type_code -%]
Lines 24-29 Link Here
24
           [%- CASE 'RENT_DAILY_RENEW' -%]Rewewal of daily rental item
25
           [%- CASE 'RENT_DAILY_RENEW' -%]Rewewal of daily rental item
25
           [%- CASE 'RESERVE'          -%]Hold fee
26
           [%- CASE 'RESERVE'          -%]Hold fee
26
           [%- CASE 'RESERVE_EXPIRED'  -%]Hold waiting too long
27
           [%- CASE 'RESERVE_EXPIRED'  -%]Hold waiting too long
28
           [%- CASE 'Payout'           -%]Payout
27
           [%- CASE                    -%][% account.debit_type.description | html %]
29
           [%- CASE                    -%][% account.debit_type.description | html %]
28
       [%- END -%]
30
       [%- END -%]
29
    [%- END -%]
31
    [%- END -%]
Lines 49-54 Link Here
49
        [%- CASE 'UNRETURNED' -%]<span> (Accruing)</span>
51
        [%- CASE 'UNRETURNED' -%]<span> (Accruing)</span>
50
        [%- CASE 'RETURNED'   -%]<span> (Returned)</span>
52
        [%- CASE 'RETURNED'   -%]<span> (Returned)</span>
51
        [%- CASE 'REPLACED'   -%]<span> (Replaced)</span>
53
        [%- CASE 'REPLACED'   -%]<span> (Replaced)</span>
54
        [%- CASE 'REFUNDED'   -%]<span> (Refunded)</span>
52
        [%- CASE 'FORGIVEN'   -%]<span> (Forgiven)</span>
55
        [%- CASE 'FORGIVEN'   -%]<span> (Forgiven)</span>
53
        [%- CASE 'VOID'       -%]<span> (Voided)</span>
56
        [%- CASE 'VOID'       -%]<span> (Voided)</span>
54
        [%- CASE 'LOST'       -%]<span> (Lost)</span>
57
        [%- CASE 'LOST'       -%]<span> (Lost)</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc (-1 / +1 lines)
Lines 1-6 Link Here
1
<div id="navmenu">
1
<div id="navmenu">
2
    <div id="navmenulist">
2
    <div id="navmenulist">
3
        [% IF ( CAN_user_cash_management_cashup_cash_registers ) %]
3
        [% IF ( CAN_user_cash_management_cashup_cash_registers || CAN_user_cash_management_refund_cash_registers ) %]
4
        <h5>Point of sale</h5>
4
        <h5>Point of sale</h5>
5
        <ul>
5
        <ul>
6
            <li><a href="/cgi-bin/koha/pos/register.pl">Register details</a></li>
6
            <li><a href="/cgi-bin/koha/pos/register.pl">Register details</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-9 / +260 lines)
Lines 26-34 Link Here
26
                You must have at least one cash register associated with this branch before you can record payments.
26
                You must have at least one cash register associated with this branch before you can record payments.
27
            </div>
27
            </div>
28
            [% ELSE %]
28
            [% ELSE %]
29
            [% IF ( CAN_user_cash_management_cashup_cash_registers ) %]
29
            <div id="toolbar" class="btn-toolbar">
30
            <div id="toolbar" class="btn-toolbar">
30
                <a id="cashup" href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default"><i class="fa fa-money"></i> Record cashup</a>
31
                <a id="cashup" href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default"><i class="fa fa-money"></i> Record cashup</a>
31
            </div>
32
            </div>
33
            [% END %]
32
34
33
            <h1>Register transaction details for [% register.name | html %]</h1>
35
            <h1>Register transaction details for [% register.name | html %]</h1>
34
36
Lines 51-69 Link Here
51
            <table id="sales" class="table_sales">
53
            <table id="sales" class="table_sales">
52
                <thead>
54
                <thead>
53
                    <th>
55
                    <th>
54
                        Receipt ID
56
                        ID
57
                    </th>
58
                    <th>
59
                        DATA
55
                    </th>
60
                    </th>
56
                    <th>
61
                    <th>
57
                        Transaction
62
                        Transaction
58
                    </th>
63
                    </th>
59
                    <th>
64
                    <th>
60
                        Description of charges
65
                        Description
61
                    </th>
66
                    </th>
62
                    <th>
67
                    <th>
63
                        Item
68
                        Price
64
                    </th>
69
                    </th>
65
                    <th>
70
                    <th>
66
                        Transaction
71
                        Total
67
                    </th>
72
                    </th>
68
                    <th>
73
                    <th>
69
                        Actions
74
                        Actions
Lines 73-98 Link Here
73
                    [% FOREACH accountline IN accountlines %]
78
                    [% FOREACH accountline IN accountlines %]
74
                        [% IF accountline.is_credit %]
79
                        [% IF accountline.is_credit %]
75
                            [% FOREACH credit IN accountline.credit_offsets %]
80
                            [% FOREACH credit IN accountline.credit_offsets %]
81
                            [% IF credit.debit %]
82
                            <tr>
83
                                <td>
84
                                    [% accountline.accountlines_id %]
85
                                </td>
86
                                <td>
87
                                    { "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }
88
                                </td>
89
                                <td></td>
90
                                <td>
91
                                    [%- PROCESS account_type_description account=credit.debit -%]
92
                                    [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
93
                                    [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&amp;itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
94
                                </td>
95
                                <td>
96
                                    [% credit.debit.amount | $Price %]
97
                                </td>
98
                                <td></td>
99
                                <td>
100
                                    [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
101
                                    <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
102
                                    [% END %]
103
                                </td>
104
                            </tr>
105
                            [% END %]
106
                            [% END %]
107
                        [% ELSE %]
108
                            [% FOREACH debit IN accountline.debit_offsets %]
109
                            [% IF debit.credit %]
110
                            <tr>
111
                                <td>
112
                                    [% accountline.accountlines_id %]
113
                                </td>
114
                                <td>
115
                                    { "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }
116
                                </td>
117
                                <td></td>
118
                                <td>
119
                                    [%- PROCESS account_type_description account=debit.credit -%]
120
                                </td>
121
                                <td>
122
                                    [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
123
                                    [%- IF ( debit.credit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&amp;itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>)[%- END -%]
124
                                </td>
125
                                <td>
126
                                    [% debit.credit.amount | $Price %]
127
                                </td>
128
                                <td></td>
129
                            </tr>
130
                            [% END %]
131
                            [% END %]
132
                        [% END %]
133
                    [% END %]
134
                </tbody>
135
                <tfoot>
136
                    <tr>
137
                        <td colspan="5">Total income: </td>
138
                        <td>[% accountlines.total * -1 | $Price %]</td>
139
                        <td></td>
140
                    </tr>
141
                </tfoot>
142
            </table>
143
            [% END %]
144
145
            [% IF trange_f %]
146
            <h2>Older transactions</h2>
147
            <table id="past_sales" class="past_sales_table">
148
                <thead>
149
                    <th>
150
                        ID
151
                    </th>
152
                    <th>
153
                        DATA
154
                    </th>
155
                    <th>
156
                        Transaction
157
                    </th>
158
                    <th>
159
                        Description
160
                    </th>
161
                    <th>
162
                        Price
163
                    </th>
164
                    <th>
165
                        Total
166
                    </th>
167
                    <th>
168
                        Actions
169
                    </th>
170
                </thead>
171
                <tbody>
172
                    [% FOREACH accountline IN past_accountlines %]
173
                        [% IF accountline.is_credit %]
174
                            [% FOREACH credit IN accountline.credit_offsets %]
175
                            [% IF credit.debit %]
76
                            <tr>
176
                            <tr>
77
                                <td>[% accountline.accountlines_id %]</td>
177
                                <td>[% accountline.accountlines_id %]</td>
78
                                <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
178
                                <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
79
                                <td>[%- PROCESS account_type_description account=credit.debit -%]</td>
179
                                <td></td>
180
                                <td>[%- PROCESS account_type_description account=credit.debit -%]
181
                                    [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
182
                                    [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&amp;itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
183
                                </td>
80
                                <td>[% credit.debit.amount | $Price %]</td>
184
                                <td>[% credit.debit.amount | $Price %]</td>
81
                                <td></td>
185
                                <td></td>
186
                                <td>
187
                                    [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
188
                                    <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
189
                                    [% END %]
190
                                </td>
191
                            </tr>
192
                            [% END %]
193
                            [% END %]
194
                        [% ELSE %]
195
                            [% FOREACH debit IN accountline.debit_offsets %]
196
                            [% IF debit.credit %]
197
                            <tr>
198
                                <td>[% accountline.accountlines_id %]</td>
199
                                <td>{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
200
                                <td></td>
201
                                <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
202
                                <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
203
        &nbsp;[% IF ( debit.credit.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&amp;itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>[% END %]</td>
204
                                <td>[% debit.credit.amount | $Price %]</td>
82
                                <td></td>
205
                                <td></td>
83
                            </tr>
206
                            </tr>
84
                            [% END %]
207
                            [% END %]
208
                            [% END %]
85
                        [% END %]
209
                        [% END %]
86
                    [% END %]
210
                    [% END %]
87
                </tbody>
211
                </tbody>
88
                <tfoot>
212
                <tfoot>
89
                    <tr>
213
                    <tr>
90
                        <td colspan="4">Total income: </td>
214
                        <td colspan="5">Total income: </td>
91
                        <td>[% accountlines.total * -1 | $Price %]</td>
215
                        <td>[% past_accountlines.total * -1 | $Price %]</td>
92
                        <td></td>
216
                        <td></td>
93
                    </tr>
217
                    </tr>
94
                </tfoot>
218
                </tfoot>
95
            </table>
219
            </table>
220
            [% ELSE %]
221
            [% IF register.cashups %]
222
            <h2>Older transactions</h2>
223
            <form method="GET" action="/cgi-bin/koha/pos/register.pl">
224
			<fieldset class="rows">
225
                            Please select a date range to display transactions for:
226
                            <ol>
227
                                <li>
228
                                    <label for="trange_f">From: </label>
229
                                    <input type="text" size="10" id="from" name="trange_f" />
230
                                    <label class="inline" for="trange_t">To: </label>
231
                                    <input size="10" id="to" name="trange_t" value="[% trange_t | html %]" type="text" />
232
                                    <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
233
                                </li>
234
                            </ol>
235
			</fieldset>
236
	            <input type="submit" value="Display" />
237
            </form>
238
            [% END %]
96
            [% END %]
239
            [% END %]
97
        </div>
240
        </div>
98
241
Lines 103-111 Link Here
103
        </div>
246
        </div>
104
    </div><!-- /.row -->
247
    </div><!-- /.row -->
105
248
249
    <!-- Issue refund modal -->
250
    <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
251
        <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
252
            <input type="hidden" name="accountline" value="" id="refundline">
253
            <div class="modal-dialog" role="document">
254
                <div class="modal-content">
255
                    <div class="modal-header">
256
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
257
                        <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.name | html %]</em></h4>
258
                    </div>
259
                    <div class="modal-body">
260
                        <fieldset class="rows">
261
                            <ol>
262
                                <li>
263
                                    <span id="item" class="label">Item: </span><span></span>
264
                                </li>
265
                                <li>
266
                                    <span id="paid" class="label">Amount paid: </span><span>[% refund.amount | $Price %]</span>
267
                                </li>
268
                                <li>
269
                                    <label class="required" for="amount">Returned to patron: </label>
270
                                    <input type="number" step="0.01" max="[% refund.amount | $Price %]" id="amount" name="amount" value="[% refund.amount | $Price %]" required="required">
271
                                    <span class="required">Required</span>
272
                                </li>
273
                                <li>
274
                                    <label class="required" for="quantity">Quantity: </label>
275
                                    <input type="text" id="quantity" name="quantity" value="[% refund.quantity | html %]" required="required">
276
                                    <span class="required">Required</span>
277
                                </li>
278
                                [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
279
                                [% IF payment_types %]
280
                                <li>
281
                                    <label for="transaction_type">Transaction type: </label>
282
                                    <select name="transaction_type" id="transaction_type">
283
                                        [% FOREACH pt IN payment_types %]
284
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
285
                                        [% END %]
286
                                    </select>
287
                                </li>
288
                                [% END %]
289
                            </ol>
290
                        </fieldset> <!-- /.rows -->
291
                    </div> <!-- /.modal-body -->
292
                    <div class="modal-footer">
293
                        <input type="hidden" name="registerid" value="[% register.id | html %]">
294
                        <input type="hidden" name="op" value="refund">
295
                        <button type="submit" class="btn btn-default">Confirm</button>
296
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
297
                    </div> <!-- /.modal-footer -->
298
                </div> <!-- /.modal-content -->
299
            </div> <!-- /.modal-dialog -->
300
        </form> <!-- /#refund_form -->
301
    </div> <!-- /#issueRefundModal -->
302
106
[% MACRO jsinclude BLOCK %]
303
[% MACRO jsinclude BLOCK %]
107
    [% INCLUDE 'datatables.inc' %]
304
    [% INCLUDE 'datatables.inc' %]
108
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
305
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
306
    [% INCLUDE 'calendar.inc' %]
109
    <script>
307
    <script>
110
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
308
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
111
            orderFixed: [ 0, 'asc'],
309
            orderFixed: [ 0, 'asc'],
Lines 118-136 Link Here
118
                startRender: function ( rows, group ) {
316
                startRender: function ( rows, group ) {
119
                    var details = JSON.parse(rows.data().pluck(1).pop());
317
                    var details = JSON.parse(rows.data().pluck(1).pop());
120
                    return $('<tr class="'+details.type+'"/>')
318
                    return $('<tr class="'+details.type+'"/>')
121
                        .append( '<td colspan="2">'+group+' '+details.description+'</td>' )
319
                        .append( '<td>'+group+'</td>' )
320
                        .append( '<td colspan="2">'+details.description+'</td>' )
122
                        .append( '<td>'+details.amount+'</td>' )
321
                        .append( '<td>'+details.amount+'</td>' )
123
                        .append( '<td><button class="printReceipt" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
322
                        .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
124
                },
323
                },
125
                endRender: null,
324
                endRender: null,
126
            }
325
            }
127
        }));
326
        }));
128
327
328
        var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
329
            orderFixed: [ 0, 'asc'],
330
            columnDefs: [ {
331
                targets: [ 0, 1 ],
332
                visible: false
333
            }],
334
            rowGroup: {
335
                dataSrc: 0,
336
                startRender: function ( rows, group ) {
337
                    var details = JSON.parse(rows.data().pluck(1).pop());
338
                    return $('<tr class="'+details.type+'"/>')
339
                        .append( '<td>'+group+'</td>' )
340
                        .append( '<td colspan="2">'+details.description+'</td>' )
341
                        .append( '<td>'+details.amount+'</td>' )
342
                        .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
343
                },
344
                endRender: null,
345
            }
346
        }));
347
348
        $("#issueRefundModal").on("shown.bs.modal", function(e){
349
           var button = $(e.relatedTarget);
350
           var item = button.data('item');
351
           $("#item + span").replaceWith(item);
352
           var accountline = button.data('accountline');
353
           $('#refundline').val(accountline);
354
           var amount = button.data('amount');
355
           $("#paid + span").replaceWith(amount);
356
           $("#amount").val(amount);
357
           $("#amount").attr("max", amount);
358
           var quantity = button.data('quantity');
359
           $("#quantity").val(quantity);
360
           $("#amount, #quantity, #transaction_type").focus();
361
        });
362
129
        $(".printReceipt").click(function() {
363
        $(".printReceipt").click(function() {
130
            var accountlines_id = $(this).data('accountline');
364
            var accountlines_id = $(this).data('accountline');
131
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
365
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
132
            win.focus();
366
            win.focus();
133
        });
367
        });
368
369
        $(document).ready(function() {
370
            // http://jqueryui.com/demos/datepicker/#date-range
371
            var dates = $( "#from, #to" ).datepicker({
372
                changeMonth: true,
373
                numberOfMonths: 1,
374
                onSelect: function( selectedDate ) {
375
                    var option = this.id == "from" ? "minDate" : "maxDate",
376
                        instance = $( this ).data( "datepicker" );
377
                        date = $.datepicker.parseDate(
378
                            instance.settings.dateFormat ||
379
                            $.datepicker._defaults.dateFormat,
380
                            selectedDate, instance.settings );
381
                    dates.not( this ).datepicker( "option", option, date );
382
                }
383
            });
384
        });
134
    </script>
385
    </script>
135
[% END %]
386
[% END %]
136
387
(-)a/pos/register.pl (-2 / +64 lines)
Lines 24-31 use C4::Auth; Link Here
24
use C4::Output;
24
use C4::Output;
25
use C4::Context;
25
use C4::Context;
26
26
27
use Koha::Account::Lines;
27
use Koha::Cash::Registers;
28
use Koha::Cash::Registers;
28
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils;
29
31
30
my $q = CGI->new();
32
my $q = CGI->new();
31
33
Lines 38-43 my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user( Link Here
38
    }
40
    }
39
);
41
);
40
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
42
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
43
my $schema = Koha::Database->new->schema;
41
44
42
my $library_id = C4::Context->userenv->{'branch'};
45
my $library_id = C4::Context->userenv->{'branch'};
43
my $registerid = $q->param('registerid');
46
my $registerid = $q->param('registerid');
Lines 70-81 $template->param( Link Here
70
    accountlines => $accountlines
73
    accountlines => $accountlines
71
);
74
);
72
75
76
my $transactions_range_from = $q->param('trange_f');
77
my $last_cashup             = $cash_register->last_cashup;
78
my $transactions_range_to =
79
    $q->param('trange_t') ? $q->param('trange_t')
80
  : $last_cashup          ? $last_cashup->timestamp
81
  :                         '';
82
$template->param( trange_t => $transactions_range_to );
83
if ($transactions_range_from) {
84
    $template->param( trange_f => $transactions_range_from );
85
86
    my $dtf               = $schema->storage->datetime_parser;
87
    my $start             = dt_from_string($transactions_range_from);
88
    my $end               = dt_from_string($transactions_range_to);
89
    my $past_accountlines = Koha::Account::Lines->search(
90
        {
91
            register_id => $registerid,
92
            timestamp   => {
93
                -between => [
94
                    $dtf->format_datetime($start), $dtf->format_datetime($end)
95
                ]
96
            }
97
        }
98
    );
99
    $template->param( past_accountlines => $past_accountlines );
100
}
101
73
my $op = $q->param('op') // '';
102
my $op = $q->param('op') // '';
74
if ( $op eq 'cashup' ) {
103
if ( $op eq 'cashup' ) {
75
    $cash_register->add_cashup(
104
    $cash_register->add_cashup(
76
        {
105
        {
77
            user_id => $logged_in_user->id,
106
            staff_id => $logged_in_user->id,
78
            amount  => $cash_register->outstanding_accountlines->total
107
            amount   => $cash_register->outstanding_accountlines->total
108
        }
109
    );
110
}
111
elsif ( $op eq 'refund' ) {
112
    my $amount           = $q->param('amount');
113
    my $quantity         = $q->param('quantity');
114
    my $accountline_id   = $q->param('accountline');
115
    my $transaction_type = $q->param('transaction_type');
116
117
    my $accountline = Koha::Account::Lines->find($accountline_id);
118
    $schema->txn_do(
119
        sub {
120
121
            my $refund = $accountline->reduce(
122
                {
123
                    reduction_type => 'Refund',
124
                    branch         => $library_id,
125
                    staff_id       => $logged_in_user->id,
126
                    interface      => 'intranet',
127
                    amount         => $amount
128
                }
129
            );
130
            my $payout = $refund->payout(
131
                {
132
                    payout_type   => $transaction_type,
133
                    branch        => $library_id,
134
                    staff_id      => $logged_in_user->id,
135
                    cash_register => $cash_register->id,
136
                    interface     => 'intranet',
137
                    amount        => $amount
138
                }
139
            );
140
79
        }
141
        }
80
    );
142
    );
81
}
143
}
(-)a/pos/registers.pl (-3 / +2 lines)
Lines 59-66 if ( $op eq 'cashup' ) { Link Here
59
    for my $register ( $registers->as_list ) {
59
    for my $register ( $registers->as_list ) {
60
        $register->add_cashup(
60
        $register->add_cashup(
61
            {
61
            {
62
                user_id => $logged_in_user->id,
62
                staff_id => $logged_in_user->id,
63
                amount  => $register->outstanding_accountlines->total
63
                amount   => $register->outstanding_accountlines->total
64
            }
64
            }
65
        );
65
        );
66
    }
66
    }
67
- 

Return to bug 24082