From 5df2850dca80b77399cd1f7b0600aae2dbcda93e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 12 Jan 2024 16:49:30 +0100 Subject: [PATCH] FIX Accountancy - Level 3 of binding not working on supplier side (#27462) --- htdocs/accountancy/class/accountingaccount.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 98d58450e7b..d25025f3c76 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2013-2021 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -865,10 +865,14 @@ class AccountingAccount extends CommonObject // Level 3 (define $code_t): Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { - if (!empty($buyer->code_compta_product)) { + if ($type == 'customer' && !empty($buyer->code_compta_product)) { $code_t = $buyer->code_compta_product; $suggestedid = $accountingAccount['thirdparty']; $suggestedaccountingaccountfor = 'thirdparty'; + } elseif ($type == 'supplier' && !empty($seller->code_compta_product)) { + $code_t = $seller->code_compta_product; + $suggestedid = $accountingAccount['thirdparty']; + $suggestedaccountingaccountfor = 'thirdparty'; } }