From d12c1f6a25ad74a11d2b57447791e5fba78e921a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 21 Aug 2020 14:09:46 +0100 Subject: [PATCH] Bug 26172: (follow-up) Summary by payment_type This patch alters the modal so that the totals are broken down by payment type's available on the system. Signed-off-by: Sally Signed-off-by: Jonathan Druart --- Koha/Cash/Register/Action.pm | 28 ++++++++----------- .../prog/en/modules/pos/register.tt | 8 ++++-- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Koha/Cash/Register/Action.pm b/Koha/Cash/Register/Action.pm index 23b9f6ffb3..2836d4a32e 100644 --- a/Koha/Cash/Register/Action.pm +++ b/Koha/Cash/Register/Action.pm @@ -98,15 +98,15 @@ sub cashup_summary { my $outgoing_transactions = $self->register->accountlines->search( { %{$conditions}, credit_type_code => undef }, - { select => 'accountlines_id' } ); + ); my $income_transactions = $self->register->accountlines->search( { %{$conditions}, debit_type_code => undef }, - { select => 'accountlines_id' } ); + ); my $income_summary = Koha::Account::Offsets->search( { 'me.credit_id' => - { '-in' => $income_transactions->_resultset->as_query }, + { '-in' => $income_transactions->_resultset->get_column('accountlines_id')->as_query }, 'me.debit_id' => { '!=' => undef } }, { @@ -120,7 +120,7 @@ sub cashup_summary { my $outgoing_summary = Koha::Account::Offsets->search( { 'me.debit_id' => - { '-in' => $outgoing_transactions->_resultset->as_query }, + { '-in' => $outgoing_transactions->_resultset->get_column('accountlines_id')->as_query }, 'me.credit_id' => { '!=' => undef } }, { @@ -145,20 +145,14 @@ sub cashup_summary { credit_type => { description => $_->get_column('credit_description') } } } $outgoing_summary->as_list; + $summary = { - from_date => $previous ? $previous->timestamp : undef, - to_date => $self->timestamp, - income => \@income, - outgoing => \@outgoing, - total => ( $outgoing_transactions->total * -1 ) + - ( $income_transactions->total * -1 ), - bankable => ( - $outgoing_transactions->search( { payment_type => 'CASH' } ) - ->total * -1 - ) + ( - $income_transactions->search( { payment_type => 'CASH' } )->total * - -1 - ) + from_date => $previous ? $previous->timestamp : undef, + to_date => $self->timestamp, + income => \@income, + outgoing => \@outgoing, + income_transactions => $income_transactions, + outgoing_transactions => $outgoing_transactions, }; return $summary; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt index 9003e3ffd6..2c0edb3cb3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -342,12 +342,14 @@ Total - [% register.last_cashup.cashup_summary.total | $Price %] + [% ( register.last_cashup.cashup_summary.outgoing_transactions.total + register.last_cashup.cashup_summary.income_transactions.total) * -1 | $Price %] + [% FOREACH pt IN payment_types %] - Bankable - [% register.last_cashup.cashup_summary.bankable | $Price %] + [% pt.lib %] + [% ( register.last_cashup.cashup_summary.outgoing_transactions.total( payment_type => pt.authorised_value ) + register.last_cashup.cashup_summary.income_transactions.total( payment_type => pt.authorised_value )) * -1 | $Price %] + [% END %] -- 2.39.5