浏览代码

Better position of error check

Laurent Destailleur 7 年之前
父节点
当前提交
284e6f1ad3
共有 2 个文件被更改,包括 20 次插入20 次删除
  1. 10 10
      htdocs/accountancy/journal/purchasesjournal.php
  2. 10 10
      htdocs/accountancy/journal/sellsjournal.php

+ 10 - 10
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();

+ 10 - 10
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();