From 8d962bbcf53e664e4d83c6e0f92bf6313b8a4595 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 18 Sep 2019 15:22:39 +0100 Subject: [PATCH] Bug 23445: Add previous transactions option https://bugs.koha-community.org/show_bug.cgi?id=23442 --- .../prog/en/modules/pos/register.tt | 148 ++++++++++++++++++ pos/register.pl | 27 ++++ 2 files changed, 175 insertions(+) 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 5bd3a9dee6..49bd50b840 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -123,6 +123,117 @@ [% END %] + + [% IF trange_f %] +

Older transactions

+ + + + + + + + + + + + [% FOREACH accountline IN past_accountlines %] + [% IF accountline.is_credit %] + [% FOREACH credit IN accountline.credit_offsets %] + [% IF credit.debit %] + + + + + + + + + + [% END %] + [% END %] + [% ELSE %] + [% FOREACH debit IN accountline.debit_offsets %] + [% IF debit.credit %] + + + + + + + + + + [% END %] + [% END %] + [% END %] + [% END %] + + + + + + + + +
+ Receipt ID + + Transaction + + Account type + + Description of charges + + Item + + Transaction + + Actions +
[% accountline.accountlines_id %]{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }[%- PROCESS account_type_description account=credit.debit -%][%- IF credit.debit.description %][% credit.debit.description | html %][% END %] +  [% IF ( credit.debit.itemnumber ) %][% credit.debit.item.biblio.title | html %][%- END -%][% credit.debit.amount | $Price %] + [% IF ( CAN_user_cash_management_refund_cash_registers ) %] + + [% END %] +
[% accountline.accountlines_id %]{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }[%- PROCESS account_type_description account=debit.credit -%][%- IF debit.credit.description %][% debit.credit.description | html %][% END %] +  [% IF ( debit.credit.itemnumber ) %][% debit.credit.item.biblio.title | html %][% END %][% debit.credit.amount | $Price %]
Total income: [% past_accountlines.total * -1 | $Price %]
+ + + + + + + + + [% FOREACH cashup IN register.cashups %] + + + + + + [% END %] + +
Cashup dateBankedActions
[% cashup.timestamp | $KohaDates with_hours => 1 %][% cashup.amount | $Price %]View transactions
+ [% ELSE %] + [% IF register.cashups %] +

Older transactions

+
+
+ Please select a date range to display transactions for: +
    +
  1. + + + + + [% INCLUDE 'date-format.inc' %] +
  2. +
+
+ +
+ [% END %] + [% END %]
@@ -186,6 +297,7 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %] + [% INCLUDE 'calendar.inc' %] [% END %] diff --git a/pos/register.pl b/pos/register.pl index 67864bbb36..e9133ce5ce 100755 --- a/pos/register.pl +++ b/pos/register.pl @@ -27,6 +27,7 @@ use C4::Context; use Koha::Account::Lines; use Koha::Cash::Registers; use Koha::Database; +use Koha::DateUtils; my $q = CGI->new(); @@ -71,6 +72,32 @@ $template->param( accountlines => $accountlines ); +my $transactions_range_from = $q->param('trange_f'); +my $last_cashup = $cash_register->last_cashup; +my $transactions_range_to = + $q->param('trange_t') ? $q->param('trange_t') + : $last_cashup ? $last_cashup->timestamp + : ''; +$template->param( trange_t => $transactions_range_to ); +if ($transactions_range_from) { + $template->param( trange_f => $transactions_range_from ); + + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + my $start = dt_from_string($transactions_range_from); + my $end = dt_from_string($transactions_range_to); + my $past_accountlines = Koha::Account::Lines->search( + { + register_id => $registerid, + timestamp => { + -between => [ + $dtf->format_datetime($start), $dtf->format_datetime($end) + ] + } + } + ); + $template->param( past_accountlines => $past_accountlines ); +} + my $op = $q->param('op') // ''; if ( $op eq 'cashup' ) { $cash_register->add_cashup( -- 2.20.1