From f5473c5228da8dda748386ab64143b7cba8a493e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 9 Jan 2020 13:53:09 +0000 Subject: [PATCH] Bug 23355: Add branch details page This patch adds a new 'branch details' page to the POS system which displays a summary of the cash register transactions for a branch since each register was last cashed up. It also allows for cashing up individual registers or cashing up all registers at a given branch in one transaction. Signed-off-by: Kyle M Hall --- .../prog/en/includes/pos-menu.inc | 1 + .../prog/en/modules/pos/registers.tt | 149 ++++++++++++++++++ .../prog/en/modules/tools/tools-home.tt | 8 + pos/registers.pl | 69 ++++++++ 4 files changed, 227 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/pos/registers.tt create mode 100755 pos/registers.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc index b30beb3422..d8cb71cfd5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc @@ -4,6 +4,7 @@
Point of sale
[% END %] [% IF ( CAN_user_cash_management_manage_cash_registers || CAN_user_parameters_manage_auth_values) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/registers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/registers.tt new file mode 100644 index 0000000000..b06a4f5b0f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/registers.tt @@ -0,0 +1,149 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% USE AuthorisedValues %] +[% USE Price %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Cashup +[% INCLUDE 'doc-head-close.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'circ-search.inc' %] + + + +
+
+
+
+ [% IF ( error_registers ) %] +
+ You must have at least one cash register associated with this branch before you can record payments. +
+ [% ELSE %] + + +

Branch transaction details for [% library.branchname | html %]

+ +

Summary

+ + + + + + + + + + + + + + + [% FOREACH register IN registers %] + + + + + + + + + + [% END %] + + + + + + + + +
+ ID + + Name + + Description + + Last cashup + + Float + + Bankable + + Actions +
+ [% register.id | html %] + + [% register.name | html %] + + [% register.description | html %] + + [%- IF register.last_cashup -%] + [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] ([% register.last_cashup.amount | $Price %]) + [%- ELSE -%] + No last cashup + [%- END -%] + + [% register.starting_float | $Price %] + + [% register.outstanding_accountlines.total * -1 | $Price %] + + Record cashup +
Total bankable:
+ [% END %] +
+
+ +
+ +
+ +
+ +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 732563ce0a..9b2e257326 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -129,6 +129,14 @@
Access files stored on the server, like log files or reports
[% END %] + [% IF ( Koha.Preference('UseCashRegisters') && CAN_user_cash_management_manage_cash_registers ) %] + [% IF ( CAN_user_cash_management_manage_cash_registers ) %] +
Cashup registers
+
Perfrom cashup actions on cash registers
+ [% END %] + [% END %] + +
diff --git a/pos/registers.pl b/pos/registers.pl new file mode 100755 index 0000000000..bf74f9f7af --- /dev/null +++ b/pos/registers.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl +# +# c 2015 PTFS-Europe Ltd +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA +# + +use Modern::Perl; +use CGI; +use C4::Auth; +use C4::Output; +use C4::Context; + +use Koha::Cash::Registers; +use Koha::Database; + +my $q = CGI->new(); + +my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user( + { + template_name => 'pos/registers.tt', + query => $q, + type => 'intranet', + authnotrequired => 0, + } +); +my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in"; + +my $library = Koha::Libraries->find( C4::Context->userenv->{'branch'} ); +$template->param( library => $library ); + +my $registers = Koha::Cash::Registers->search( + { branch => $library->id, archived => 0 }, + { order_by => { '-asc' => 'name' } } +); + +if ( !$registers->count ) { + $template->param( error_registers => 1 ); +} +else { + $template->param( registers => $registers ); +} + +my $op = $q->param('op') // ''; +if ( $op eq 'cashup' ) { + for my $register ( $registers->as_list ) { + $register->add_cashup( + { + user_id => $logged_in_user->id, + amount => $register->outstanding_accountlines->total + } + ); + } +} + +output_html_with_http_headers( $q, $cookie, $template->output ); -- 2.20.1