Koha/pos/pay.pl
Martin Renvoize 5b26e55750 Bug 28181: Filter out archived debit types in point of sale
The filter for only displaying un-archived debit types on the point of
sale page had been missed.

NOTE: It would be beneficial to move this to a default filter in the
Koha:: objects search method for both debit_types and credit_types.. but
I opted for the quick fix here to resolve the bug and will impliment
default filtering in a subsequent enhancement bug.

Test plan
1/ Archive a debit type that is marked as 'Can be sold'
2/ Go to the point of sale page and confirm the above debit type appears
3/ Apply the patch
4/ Confirm the debit type no longer appears in the point of sale page.

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-05-10 15:46:54 +02:00

87 lines
2.6 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2020 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 3 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, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI;
use JSON qw( from_json );
use C4::Auth qw/:DEFAULT get_session/;
use C4::Output;
use C4::Context;
use Koha::Account::DebitTypes;
use Koha::AuthorisedValues;
use Koha::Cash::Registers;
use Koha::Charges::Sales;
use Koha::Database;
use Koha::Libraries;
my $input = CGI->new();
my $sessionID = $input->cookie('CGISESSID');
my $session = get_session($sessionID);
my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user(
{
template_name => 'pos/pay.tt',
query => $input,
type => 'intranet',
flagsrequired => { cash_management => 'takepayment' },
}
);
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
my $library_id = C4::Context->userenv->{'branch'};
my $registerid = $input->param('registerid');
my $invoice_types =
Koha::Account::DebitTypes->search_with_library_limits(
{ can_be_sold => 1, archived => 0 },
{}, $library_id );
$template->param( invoice_types => $invoice_types );
my $total_paid = $input->param('paid');
if ( $total_paid and $total_paid ne '0.00' ) {
my $cash_register = Koha::Cash::Registers->find( { id => $registerid } );
my $payment_type = $input->param('payment_type');
my $sale = Koha::Charges::Sales->new(
{
cash_register => $cash_register,
staff_id => $logged_in_user->id
}
);
my @sales = $input->multi_param('sales');
for my $item (@sales) {
$item = from_json $item;
$sale->add_item($item);
}
my $payment = $sale->purchase( { payment_type => $payment_type } );
$template->param(
payment_id => $payment->accountlines_id,
collected => scalar $input->param('collected'),
change => scalar $input->param('change')
);
}
output_html_with_http_headers( $input, $cookie, $template->output );
1;