@@ -, +, @@
---
Koha/Cash/Register.pm | 2 +-
installer/data/mysql/account_offset_types.sql | 3 +
.../data/mysql/atomicupdate/bug_24082.perl | 22 ++
.../prog/en/includes/accounts.inc | 3 +
.../prog/en/includes/pos-menu.inc | 2 +-
.../prog/en/modules/pos/register.tt | 269 +++++++++++++++++-
pos/register.pl | 66 ++++-
pos/registers.pl | 4 +-
8 files changed, 356 insertions(+), 15 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_24082.perl
--- a/Koha/Cash/Register.pm
+++ a/Koha/Cash/Register.pm
@@ -220,7 +220,7 @@ sub add_cashup {
my $rs = $self->_result->add_to_cash_register_actions(
{
code => 'CASHUP',
- manager_id => $params->{user_id},
+ manager_id => $params->{staff_id},
amount => $params->{amount}
}
)->discard_changes;
--- a/installer/data/mysql/account_offset_types.sql
+++ a/installer/data/mysql/account_offset_types.sql
@@ -7,6 +7,9 @@ INSERT INTO account_offset_types ( type ) VALUES
('Manual Credit'),
('Manual Debit'),
('Reverse Payment'),
+('REFUND'),
+('LINK'),
+('PAYOUT'),
('Forgiven'),
('Dropbox'),
('Account Fee'),
--- a/installer/data/mysql/atomicupdate/bug_24082.perl
+++ a/installer/data/mysql/atomicupdate/bug_24082.perl
@@ -0,0 +1,22 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if ( CheckVersion($DBversion) ) {
+
+ $dbh->do(qq{
+ INSERT IGNORE permissions (module_bit, code, description)
+ VALUES
+ (25, 'refund_cash_registers', 'Perform refund actions from cash registers')
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'REFUND' );
+ });
+ $dbh->do(q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'LINK' );
+ });
+ $dbh->do(q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'PAYOUT' );
+ });
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 23442 - Add a refund option to the point of sale system)\n";
+}
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
@@ -7,6 +7,7 @@
[%- CASE 'FORGIVEN' -%]Forgiven
[%- CASE 'CREDIT' -%]Credit
[%- CASE 'LOST_RETURN' -%]Lost item fee refund
+ [%- CASE 'Refund' -%]Refund
[%- CASE -%][% account.credit_type.description | html %]
[%- END -%]
[%- ELSIF account.debit_type_code -%]
@@ -24,6 +25,7 @@
[%- CASE 'RENT_DAILY_RENEW' -%]Rewewal of daily rental item
[%- CASE 'RESERVE' -%]Hold fee
[%- CASE 'RESERVE_EXPIRED' -%]Hold waiting too long
+ [%- CASE 'Payout' -%]Payout
[%- CASE -%][% account.debit_type.description | html %]
[%- END -%]
[%- END -%]
@@ -49,6 +51,7 @@
[%- CASE 'UNRETURNED' -%] (Accruing)
[%- CASE 'RETURNED' -%] (Returned)
[%- CASE 'REPLACED' -%] (Replaced)
+ [%- CASE 'REFUNDED' -%] (Refunded)
[%- CASE 'FORGIVEN' -%] (Forgiven)
[%- CASE 'VOID' -%] (Voided)
[%- CASE 'LOST' -%] (Lost)
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/pos-menu.inc
@@ -1,6 +1,6 @@
@@ -103,9 +246,64 @@
+
+
+
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
+ [% INCLUDE 'calendar.inc' %]
[% END %]
--- a/pos/register.pl
+++ a/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 $q = CGI->new();
@@ -38,6 +40,7 @@ my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user(
}
);
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
+my $schema = Koha::Database->new->schema;
my $library_id = C4::Context->userenv->{'branch'};
my $registerid = $q->param('registerid');
@@ -70,12 +73,71 @@ $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 = $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(
{
- user_id => $logged_in_user->id,
- amount => $cash_register->outstanding_accountlines->total
+ staff_id => $logged_in_user->id,
+ amount => $cash_register->outstanding_accountlines->total
+ }
+ );
+}
+elsif ( $op eq 'refund' ) {
+ my $amount = $q->param('amount');
+ my $quantity = $q->param('quantity');
+ my $accountline_id = $q->param('accountline');
+ my $transaction_type = $q->param('transaction_type');
+
+ my $accountline = Koha::Account::Lines->find($accountline_id);
+ $schema->txn_do(
+ sub {
+
+ my $refund = $accountline->reduce(
+ {
+ reduction_type => 'Refund',
+ branch => $library_id,
+ staff_id => $logged_in_user->id,
+ interface => 'intranet',
+ amount => $amount
+ }
+ );
+ my $payout = $refund->payout(
+ {
+ payout_type => $transaction_type,
+ branch => $library_id,
+ staff_id => $logged_in_user->id,
+ cash_register => $cash_register->id,
+ interface => 'intranet',
+ amount => $amount
+ }
+ );
+
}
);
}
--- a/pos/registers.pl
+++ a/pos/registers.pl
@@ -59,8 +59,8 @@ if ( $op eq 'cashup' ) {
for my $register ( $registers->as_list ) {
$register->add_cashup(
{
- user_id => $logged_in_user->id,
- amount => $register->outstanding_accountlines->total
+ staff_id => $logged_in_user->id,
+ amount => $register->outstanding_accountlines->total
}
);
}
--