From 7bb5ac40950447edc311687827b4d6402b6423bb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 5 May 2022 16:48:01 +0200 Subject: [PATCH 1/2] FIX Accountancy - Add an option to disable use of sub-account on deposit line --- htdocs/accountancy/admin/defaultaccounts.php | 31 +++++++++++++++++++- htdocs/accountancy/journal/sellsjournal.php | 16 +++++----- htdocs/langs/en_US/accountancy.lang | 1 + 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index c99503f95f6..cd95b033445 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -95,10 +95,11 @@ if ($conf->loan->enabled) { $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'; } +$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; if ($conf->societe->enabled) { +$list_account[] = '---Deposits---'; $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; } -$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; /* * Actions @@ -134,6 +135,20 @@ if ($action == 'update') { } } +if ($action == 'setdisableauxiliaryaccountoncustomerdeposit') { + $setDisableAuxiliaryAccountOnCustomerDeposit = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT", $setDisableAuxiliaryAccountOnCustomerDeposit, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View @@ -231,6 +246,20 @@ foreach ($list_account as $key) { } } +if ($conf->societe->enabled) { + print ''; + print '' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . ''; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; +} print "\n"; print "\n"; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 7cc7f0effbc..a4cda49af64 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -418,9 +418,11 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; - if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + } } else { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -897,12 +899,12 @@ if (empty($action) || $action == 'view') { print ""; // Subledger account print ""; - if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { - if (($accountoshow == "") || $accountoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - } else { + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { print length_accounta($tabcompany[$key]['code_compta']); } + } elseif (($accountoshow == "") || $accountoshow == 'NotDefined') { + print '' . $langs->trans("ThirdpartyAccountNotDefined") . ''; } print ''; $companystatic->id = $tabcompany[$key]['id']; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8283da55f41..3fe49b25900 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -182,6 +182,7 @@ DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscriptions ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT=Accounting account by default to register customer deposit +UseAuxiliaryAccountOnCustomerDeposit=Use sub-accounts on customer deposit lines ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for the bought products (used if not defined in the product sheet) ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT=Accounting account by default for the bought products in EEC (used if not defined in the product sheet) From fb97f7db29a0df64c11a9696d57cd34b2f760ccf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 5 May 2022 14:59:49 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/accountancy/admin/defaultaccounts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index cd95b033445..6d7d92ce22b 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -97,7 +97,7 @@ if ($conf->loan->enabled) { } $list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; if ($conf->societe->enabled) { -$list_account[] = '---Deposits---'; + $list_account[] = '---Deposits---'; $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; }