Control errors before validate invoice in TakePOS

This commit is contained in:
andreubisquerra 2019-08-24 16:44:06 +02:00
parent 1463302bdd
commit 5d0dbea920
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);
}
else if (count($invoice->lines)==0)
{
dol_syslog("Sale without lines");
dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
}
else if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1")
{
$invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]});
}