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

(-)a/Koha/Cash/Register/Action.pm (+99 lines)
Lines 48-53 sub manager { Link Here
48
    return Koha::Patron->_new_from_dbic($rs);
48
    return Koha::Patron->_new_from_dbic($rs);
49
}
49
}
50
50
51
=head3 register
52
53
Return the register linked to this cash register::action
54
55
=cut
56
57
sub register {
58
    my ($self) = @_;
59
    my $rs = $self->_result->register;
60
    return unless $rs;
61
    return Koha::Cash::Register->_new_from_dbic($rs);
62
}
63
64
=head3 cashup_summary
65
66
  my $cashup_summary = $action->cashup_summary;
67
68
Return a hashref containing a summary of transactions that make up this cashup action.
69
70
=cut
71
72
sub cashup_summary {
73
    my ($self) = @_;
74
    my $summary;
75
    my $prior_cashup = Koha::Cash::Register::Actions->search(
76
        {
77
            'code'      => 'CASHUP',
78
            'timestamp' => { '<' => $self->timestamp },
79
            register_id => $self->register_id
80
        },
81
        {
82
            order_by => { '-desc' => [ 'timestamp', 'id' ] },
83
            rows     => 1
84
        }
85
    );
86
87
    my $previous = $prior_cashup->single;
88
89
    my $conditions =
90
      $previous
91
      ? {
92
        'date' => {
93
            '-between' =>
94
              [ $previous->_result->get_column('timestamp'), $self->timestamp ]
95
        }
96
      }
97
      : { 'date' => { '<' => $self->timestamp } };
98
99
    my $outgoing_transactions = $self->register->accountlines->search(
100
        { %{$conditions}, credit_type_code => undef },
101
        { select => 'accountlines_id' } );
102
    my $income_transactions = $self->register->accountlines->search(
103
        { %{$conditions}, debit_type_code => undef },
104
        { select => 'accountlines_id' } );
105
106
    my $income_summary = Koha::Account::Offsets->search(
107
        {
108
            'me.credit_id' =>
109
              { '-in' => $income_transactions->_resultset->as_query },
110
            'me.debit_id' => { '!=' => undef }
111
        },
112
        {
113
            join      => 'debit',
114
            group_by  => 'debit.debit_type_code',
115
            'select' => [ { sum => 'me.amount' }, 'debit.debit_type_code' ],
116
            'as'     => [ 'total', 'debit_code' ],
117
        }
118
    );
119
120
    my $outgoing_summary = Koha::Account::Offsets->search(
121
        {
122
            'me.debit_id' =>
123
              { '-in' => $outgoing_transactions->_resultset->as_query },
124
            'me.credit_id' => { '!=' => undef }
125
        },
126
        {
127
            join      => 'credit',
128
            group_by  => 'credit.credit_type_code',
129
            'select' => [ { sum => 'me.amount' }, 'credit.credit_type_code' ],
130
            'as'     => [ 'total', 'credit_code' ],
131
        }
132
    );
133
134
    my @income   = map { $_->unblessed } $income_summary->as_list;
135
    my @outgoing = map { $_->unblessed } $outgoing_summary->as_list;
136
    $summary = {
137
        from_date => $previous ? $previous->timestamp : undef,
138
        to_date   => $self->timestamp,
139
        income    => \@income,
140
        outgoing  => \@outgoing,
141
        total => $outgoing_transactions->total + $income_transactions->total,
142
        bankable =>
143
          $outgoing_transactions->search( { payment_type => 'CASH' } )->total +
144
          $income_transactions->search( { payment_type => 'CASH' } )->total
145
    };
146
147
    return $summary;
148
}
149
51
=head2 Internal methods
150
=head2 Internal methods
52
151
53
=cut
152
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-2 / +54 lines)
Lines 39-45 Link Here
39
            <h2>Summary</h2>
39
            <h2>Summary</h2>
40
            <ul>
40
            <ul>
41
                [% IF register.last_cashup %]
41
                [% IF register.last_cashup %]
42
                <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</li>
42
                <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] (<a data-toggle="modal" href="#cashupSummaryModal" class="button">Summary</a>)</li>
43
                
43
                [% END %]
44
                [% END %]
44
                <li>Float: [% register.starting_float | $Price %]</li>
45
                <li>Float: [% register.starting_float | $Price %]</li>
45
                <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
46
                <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
Lines 283-288 Link Here
283
        </form> <!-- /#refund_form -->
284
        </form> <!-- /#refund_form -->
284
    </div> <!-- /#issueRefundModal -->
285
    </div> <!-- /#issueRefundModal -->
285
286
287
    <!-- Cashup summary modal -->
288
    [% IF register.last_cashup %]
289
    <div class="modal" id="cashupSummaryModal" tabindex="-1" role="dialog" aria-labelledby="cashupSummaryLabel">
290
        <div class="modal-dialog" role="document">
291
            <div class="modal-content">
292
                <div class="modal-header">
293
                    <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
294
                    <h4 class="modal-title" id="cashupSummaryLabel">Cashup summary for <em>[% register.description | html %]</em> between [% register.last_cashup.cashup_summary.from_date %] and [% register.last_cashup.cashup_summary.to_date %]</h4>
295
                </div>
296
                <div class="modal-body">
297
                    <table>
298
                        <thead>
299
                            <tr>
300
                                <th>Type</th>
301
                                <th>Total</th>
302
                            </tr>
303
                        </thead>
304
                        <tbody>
305
                            [%- FOREACH out IN register.last_cashup.cashup_summary.outgoing -%]
306
                            <tr>
307
                                <td>[% out.credit_code %]</td>
308
                                <td>[% out.total | $Price %]</td>
309
                            </tr>
310
                            [%- END -%]
311
                            [%- FOREACH in IN register.last_cashup.cashup_summary.income -%]
312
                            <tr>
313
                                <td>[% in.debit_code %]</td>
314
                                <td>[% in.total | $Price %]</td>
315
                            </tr>
316
                            [%- END -%]
317
                        </tbody>
318
                        <tfoot>
319
                            <tr>
320
                                <td>Total</td>
321
                                <td>[% register.last_cashup.cashup_summary.total | $Price %]</td>
322
                            </tr>
323
                            <tr>
324
                                <td>Bankable</td>
325
                                <td>[% register.last_cashup.cashup_summary.bankable | $Price %]</td>
326
                            </tr>
327
328
                        </tfoot>
329
                    </table>
330
                </div> <!-- /.modal-body -->
331
                <div class="modal-footer">
332
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
333
                </div> <!-- /.modal-footer -->
334
            </div> <!-- /.modal-content -->
335
        </div> <!-- /.modal-dialog -->
336
    </div> <!-- /#cashupSummaryModal -->
337
    [% END %]
338
286
[% MACRO jsinclude BLOCK %]
339
[% MACRO jsinclude BLOCK %]
287
    [% INCLUDE 'datatables.inc' %]
340
    [% INCLUDE 'datatables.inc' %]
288
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
341
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
289
- 

Return to bug 26172