From 284e6f1ad3640e9bd9971b74576568c6d72d21c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Feb 2018 13:39:06 +0100 Subject: [PATCH] Better position of error check --- .../accountancy/journal/purchasesjournal.php | 20 +++++++++---------- htdocs/accountancy/journal/sellsjournal.php | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index e7ab6adbba4..ec21937c8ff 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -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(); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 4ed70d41c4b..5088841b3d1 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -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();