From 84c1f17d337ee437295f91dfdf1741f724c0e6d8 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 | 135 ++++++++++++++++++ pos/register.pl | 29 ++++ 2 files changed, 164 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 0f1715c7b6..a5c3684a91 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,103 @@ [% 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 %] + + + + + + + + +
+ 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 %]
+ [% ELSE %] + [% IF register.cashups %] +

Older transactions

+
+
+ Please select a date range to display transactions for: +
    +
  1. + + + + + [% INCLUDE 'date-format.inc' %] +
  2. +
+
+ + +
+ [% END %] + [% END %]
@@ -208,6 +305,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 382aeab44c..e5b2e2b110 100755 --- a/pos/register.pl +++ b/pos/register.pl @@ -24,8 +24,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(); @@ -71,6 +73,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