Martin Renvoize
086927c976
This patch adds handling to allow for the use of the session cash register by default if it has been set, otherwise it defaults to '-- None --' and requires the end user to select the register to proceed with the sale. Test plan 1/ Enable cash registers via the 'UseCashRegisters' system preference 2/ Enable point of sale via the 'EnablePointOfSale' system preference 3/ Navigate to the point of sale page 4/ Note that if you are logged in at a branch with no cash registers yet defined, then an alert should appear 5/ Note that when you are logged in at a branch with cash regsiters defined, but without a cash register associated with your session then the cash 'Cash register' select box is populated with '-- None --' and you are required to select a register prior to submission 6/ Note that upon selection, the '-- None --' option is disabled 7/ Note that when you have a register associated with your session then the 'Cash register' select box is pre-populated with that register. 8/ Signoff Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
69 lines
1.9 KiB
Perl
Executable file
69 lines
1.9 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
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 },
|
|
{}, $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;
|