Better position of error check

This commit is contained in:
Laurent Destailleur 2018-02-12 13:39:06 +01:00
parent caa136bed3
commit 284e6f1ad3
2 changed files with 20 additions and 20 deletions

View File

@ -285,6 +285,14 @@ if ($action == 'writebookkeeping') {
continue;
}
// Error if some lines are not binded/ready to be journalized
if ($errorforinvoice[$key] == 'somelinesarenotbound')
{
$error++;
$errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
}
// Thirdparty
if (! $errorforline)
{
@ -499,8 +507,8 @@ if ($action == 'writebookkeeping') {
}
}
// Protection against a bug on line before
if (price2num($totaldebit) != price2num($totalcredit))
// Protection against a bug on lines before
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
{
$error++;
$errorforline++;
@ -508,14 +516,6 @@ if ($action == 'writebookkeeping') {
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
}
// Error if some lines are not binded/ready to be journalized
if ($errorforinvoice[$key] == 'somelinesarenotbound')
{
$error++;
$errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
}
if (! $errorforline)
{
$db->commit();

View File

@ -286,6 +286,14 @@ if ($action == 'writebookkeeping') {
continue;
}
// Error if some lines are not binded/ready to be journalized
if ($errorforinvoice[$key] == 'somelinesarenotbound')
{
$error++;
$errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
}
// Thirdparty
if (! $errorforline)
{
@ -448,8 +456,8 @@ if ($action == 'writebookkeeping') {
}
}
// Protection against a bug on line before
if (price2num($totaldebit) != price2num($totalcredit))
// Protection against a bug on lines before
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
{
$error++;
$errorforline++;
@ -457,14 +465,6 @@ if ($action == 'writebookkeeping') {
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
}
// Error if some lines are not binded/ready to be journalized
if ($errorforinvoice[$key] == 'somelinesarenotbound')
{
$error++;
$errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
}
if (! $errorforline)
{
$db->commit();