From 636b636e3a8d1236bc67df8a9fc8ff35a2afab1b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 23 Jan 2020 16:05:06 +0000 Subject: [PATCH] Bug 24082: Add access to historical transactions Signed-off-by: Kyle M Hall --- .../prog/en/modules/pos/register.tt | 142 ++++++++++++++++++ pos/register.pl | 29 ++++ 2 files changed, 171 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 57dac1750f..c8cabbe457 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -145,6 +145,110 @@ [% END %] + + [% IF register.cashups %] +

Older transactions

+
+
+ Please select a date range to display transactions for: +
    +
  1. + + + + [% IF trange_t %] + + [% ELSE %] + + [% END %] + [% INCLUDE 'date-format.inc' %] +
  2. +
+
+ +
+ + +
+
+ + [% IF trange_f %] + + + + + + + + + + + + [% 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 %] + + + + + + + + +
+ ID + + DATA + + Transaction + + Description + + Price + + Total + + 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 && !(credit.debit.status == 'REFUNDED' ) %] + + [% 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 %]
+ [% END %] + + [% END %]
@@ -227,6 +331,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 343526f257..bb0b601683 100755 --- a/pos/register.pl +++ b/pos/register.pl @@ -23,8 +23,10 @@ use C4::Auth; use C4::Output; use C4::Context; +use Koha::Account::Lines; use Koha::Cash::Registers; use Koha::Database; +use Koha::DateUtils; my $input = CGI->new(); @@ -70,6 +72,33 @@ else { accountlines => $accountlines ); + my $transactions_range_from = $input->param('trange_f'); + my $last_cashup = $cash_register->last_cashup; + my $transactions_range_to = + $input->param('trange_t') ? $input->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 = $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 = $input->param('op') // ''; if ( $op eq 'cashup' ) { $cash_register->add_cashup( -- 2.20.1