From c8162e67852ffc6dc6611d462a9710f84a74e119 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 8 Jul 2021 21:35:25 +0200 Subject: [PATCH 1/3] FIX Accountancy - constant ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY --- htdocs/accountancy/customer/index.php | 12 ++++--- htdocs/accountancy/supplier/index.php | 12 ++++--- htdocs/societe/card.php | 48 +++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index dde599a1462..e6b4e95df07 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -201,11 +201,13 @@ if ($action == 'validatehistory') { } } - // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) - if (!empty($objp->company_code_sell)) { - $objp->code_sell_t = $objp->company_code_sell; - $objp->aarowid_suggest = $objp->aarowid_thirdparty; - $suggestedaccountingaccountfor = ''; + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_sell)) { + $objp->code_sell_t = $objp->company_code_sell; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } } if ($objp->aarowid_suggest > 0) { diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index b5c6804c7d6..818455ce979 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -202,11 +202,13 @@ if ($action == 'validatehistory') { } } - // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) - if (!empty($objp->company_code_buy)) { - $objp->code_buy_t = $objp->company_code_buy; - $objp->aarowid_suggest = $objp->aarowid_thirdparty; - $suggestedaccountingaccountfor = ''; + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_buy)) { + $objp->code_buy_t = $objp->company_code_buy; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } } if ($objp->aarowid_suggest > 0) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ba4023dbba9..53efb132352 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -495,10 +495,22 @@ if (empty($reshook)) { $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } } // Incoterms @@ -1058,10 +1070,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->default_lang = GETPOST('default_lang'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } } $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : ''); @@ -1785,10 +1809,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } } //Incoterms From 76d02ecd7723fbec5ce862845a8c38f66b5cdc10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 21:53:24 +0200 Subject: [PATCH 2/3] Update card.php --- htdocs/societe/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 53efb132352..475c1c57082 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -497,7 +497,7 @@ if (empty($reshook)) { if (GETPOSTISSET('accountancy_code_sell')) { $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; @@ -506,7 +506,7 @@ if (empty($reshook)) { if (GETPOSTISSET('accountancy_code_buy')) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; @@ -1072,7 +1072,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_sell')) { $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; @@ -1081,7 +1081,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_buy')) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; From e5bc32bb7c2973008dd118ac9cf428cc03d90dd7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 21:55:35 +0200 Subject: [PATCH 3/3] Update card.php --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 475c1c57082..76ae78fdb51 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1811,7 +1811,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_sell')) { $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; @@ -1820,7 +1820,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_buy')) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy;