1 package Koha
::Cash
::Register
::Action
;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use base
qw(Koha::Object);
30 Koha::Cash::Register::Action - Koha cashregister::action Object class
40 Return the manager linked to this cash register::action
46 my $rs = $self->_result->manager;
48 return Koha
::Patron
->_new_from_dbic($rs);
53 Return the register linked to this cash register::action
59 my $rs = $self->_result->register;
60 return Koha
::Cash
::Register
->_new_from_dbic($rs);
65 my $cashup_summary = $action->cashup_summary;
67 Return a hashref containing a summary of transactions that make up this cashup action.
74 my $prior_cashup = Koha
::Cash
::Register
::Actions
->search(
77 'timestamp' => { '<' => $self->timestamp },
78 register_id
=> $self->register_id
81 order_by
=> { '-desc' => [ 'timestamp', 'id' ] },
91 [ $prior_cashup->timestamp, $self->timestamp ]
94 : { 'date' => { '<' => $self->timestamp } };
96 my $outgoing_transactions = $self->register->accountlines->search(
97 { %{$conditions}, credit_type_code
=> undef },
99 my $income_transactions = $self->register->accountlines->search(
100 { %{$conditions}, debit_type_code
=> undef },
103 my $income_summary = Koha
::Account
::Offsets
->search(
106 { '-in' => [ $income_transactions->get_column('accountlines_id') ] },
107 'me.debit_id' => { '!=' => undef }
110 join => { 'debit' => 'debit_type_code' },
111 group_by
=> [ 'debit.debit_type_code', 'debit_type_code.description' ],
112 order_by
=> { '-asc' => 'debit.debit_type_code' },
113 'select' => [ { sum
=> 'me.amount' }, 'debit.debit_type_code', 'debit_type_code.description' ],
114 'as' => [ 'total', 'debit_type_code', 'debit_description' ],
118 my $outgoing_summary = Koha
::Account
::Offsets
->search(
121 { '-in' => [ $outgoing_transactions->get_column('accountlines_id') ] },
122 'me.credit_id' => { '!=' => undef }
125 join => { 'credit' => 'credit_type_code' },
126 group_by
=> [ 'credit.credit_type_code', 'credit_type_code.description' ],
127 order_by
=> { '-asc' => 'credit.credit_type_code' },
128 'select' => [ { sum
=> 'me.amount' }, 'credit.credit_type_code', 'credit_type_code.description' ],
129 'as' => [ 'total', 'credit_type_code', 'credit_description' ],
135 total
=> $_->get_column('total'),
136 debit_type_code
=> $_->get_column('debit_type_code'),
137 debit_type
=> { description
=> $_->get_column('debit_description') }
139 } $income_summary->as_list;
142 total
=> $_->get_column('total'),
143 credit_type_code
=> $_->get_column('credit_type_code'),
144 credit_type
=> { description
=> $_->get_column('credit_description') }
146 } $outgoing_summary->as_list;
149 from_date
=> $prior_cashup?
$prior_cashup->timestamp : undef,
150 to_date
=> $self->timestamp,
152 outgoing
=> \
@outgoing,
153 income_transactions
=> $income_transactions,
154 outgoing_transactions
=> $outgoing_transactions,
160 =head2 Internal methods
169 return 'CashRegisterAction';
176 Martin Renvoize <martin.renvoize@ptfs-europe.com>