Merge pull request #11744 from andreubisquerra/master

Control errors before validate invoice in TakePOS
This commit is contained in:
Laurent Destailleur 2019-08-26 17:24:03 +02:00 committed by GitHub
commit 7009f036a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -72,3 +72,5 @@ BasicPhoneLayout=Use basic layout for phones
SetupOfTerminalNotComplete=Setup of terminal %s is not complete
DirectPayment=Direct payment
DirectPaymentButton=Direct cash payment button
InvoiceIsAlreadyValidated=Invoice is already validated
NoLinesToBill=No lines to bill

View File

@ -161,7 +161,17 @@ if ($action == 'valid' && $user->rights->facture->creer)
$invoice->update($user);
}
if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1")
if ($invoice->statut != Facture::STATUS_DRAFT)
{
dol_syslog("Sale already validated");
dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1);
}
elseif (count($invoice->lines)==0)
{
dol_syslog("Sale without lines");
dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
}
elseif (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1")
{
$invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]});
}