Hello,

here is a "special configuration", i'd like to have "0" (zero) as prefix
for all suppliers accouts (quadratus professional app is configured like
that and i don't want to sed 400 -> 0 all the time and reverse).

so here is two patches for that

Éric

-- 
Éric Seigne             | CAP-REL*
eric.sei...@cap-rel.fr  | +33 (0)6 987 444 01
https://cap-rel.fr      | *Réseau Expertise Linux

>From 16fa9a7cd0ff6b8b6367590240dd7bf98741434c Mon Sep 17 00:00:00 2001
From: Eric Seigne <eric.sei...@cap-rel.fr>
Date: Mon, 7 Jan 2019 16:50:47 +0100
Subject: [PATCH 1/2] do not use empty because of account could be '0 = zero'

---
 htdocs/accountancy/journal/purchasesjournal.php | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index 41579cd5cd..f090c52a19 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -7,6 +7,7 @@
  * Copyright (C) 2013-2016  Olivier Geffroy         <j...@jeffinfo.com>
  * Copyright (C) 2013-2016  Florian Henry           <florian.he...@open-concept.pro>
  * Copyright (C) 2018       Frédéric France         <frederic.fra...@netlogic.fr>
+ * Copyright (C) 2018       Eric Seigne		    <eric.sei...@cap-rel.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -139,7 +140,7 @@ if ($result) {
 	$num = $db->num_rows($result);
 
 	// Variables
-	$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined';
+	$cptfour = ( $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "" ) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined';
 	$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
 
 	$i = 0;
@@ -147,7 +148,7 @@ if ($result) {
 		$obj = $db->fetch_object($result);
 
 		// Controls
-		$compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour;
+		$compta_soc = ( $obj->code_compta_fournisseur != "" ) ? $obj->code_compta_fournisseur : $cptfour;
 
 		$compta_prod = $obj->compte;
 		if (empty($compta_prod)) {
@@ -741,7 +742,7 @@ if (empty($action) || $action == 'view') {
 	journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
 
 	// Button to write into Ledger
-	if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
+	if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
 		print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
 		print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
 	}
@@ -876,7 +877,7 @@ if (empty($action) || $action == 'view') {
 				// Account
 				print "<td>";
 				$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
-				if (empty($accountoshow) || $accountoshow == 'NotDefined')
+				if (($accountoshow == "") || $accountoshow == 'NotDefined')
 				{
 					print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>';
 				}
@@ -885,7 +886,7 @@ if (empty($action) || $action == 'view') {
 				// Subledger account
 				print "<td>";
 				$accountoshow = length_accounta($k);
-				if (empty($accountoshow) || $accountoshow == 'NotDefined')
+				if (($accountoshow == "") || $accountoshow == 'NotDefined')
 				{
 					print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
 				}
@@ -911,7 +912,7 @@ if (empty($action) || $action == 'view') {
 				// Account
 				print "<td>";
 				$accountoshow = length_accountg($k);
-				if (empty($accountoshow) || $accountoshow == 'NotDefined')
+				if (($accountoshow == "") || $accountoshow == 'NotDefined')
 				{
 					print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
 				}
@@ -945,7 +946,7 @@ if (empty($action) || $action == 'view') {
 					// Account
 					print "<td>";
 					$accountoshow = length_accountg($k);
-					if (empty($accountoshow) || $accountoshow == 'NotDefined')
+					if (($accountoshow == "") || $accountoshow == 'NotDefined')
 					{
 						print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')'.'</span>';
 					}
@@ -976,7 +977,7 @@ if (empty($action) || $action == 'view') {
 					// Account
 					print "<td>";
 					$accountoshow = length_accountg($k);
-					if (empty($accountoshow) || $accountoshow == 'NotDefined')
+					if (($accountoshow == "") || $accountoshow == 'NotDefined')
 					{
 						print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account'.'</span>';
 					}
-- 
2.11.0

>From 0f312945eabb78f4ac5f6703ffa943ca4296e5ca Mon Sep 17 00:00:00 2001
From: Eric Seigne <eric.sei...@cap-rel.fr>
Date: Mon, 7 Jan 2019 16:55:56 +0100
Subject: [PATCH 2/2] do not use empty because of account could be '0 = zero'

---
 htdocs/accountancy/class/bookkeeping.class.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 70934e01ed..b7c7f94e9b 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -3,6 +3,7 @@
  * Copyright (C) 2015-2017  Alexandre Spangaro  <aspang...@zendsi.com>
  * Copyright (C) 2015-2017  Florian Henry       <florian.he...@open-concept.pro>
  * Copyright (C) 2018       Frédéric France     <frederic.fra...@netlogic.fr>
+ * Copyright (C) 2018       Eric Seigne		<eric.sei...@cap-rel.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -221,7 +222,7 @@ class BookKeeping extends CommonObject
 		if (empty($this->credit)) $this->credit = 0;
 
 		// Check parameters
-		if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined')
+		if (($this->numero_compte == "") || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined')
 		{
 			$langs->loadLangs(array("errors"));
 			if (in_array($this->doc_type, array('bank', 'expense_report')))
-- 
2.11.0

_______________________________________________
Dolibarr-dev mailing list
Dolibarr-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev

Répondre à