From bdf5f29dcc985e3469bf2c20c434c7038ae7fde4 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Fri, 26 Jan 2024 10:55:27 +0100 Subject: [PATCH 1/4] new: separation of expense report from salary accounting code --- htdocs/accountancy/admin/defaultaccounts.php | 4 ++++ htdocs/accountancy/journal/bankjournal.php | 15 ++++++++++----- .../accountancy/journal/expensereportsjournal.php | 12 ++++++------ htdocs/langs/en_US/accountancy.lang | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 982448cebdd..79a4b2f8835 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -51,6 +51,10 @@ $list_account_main = array( 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); +if (isModEnabled('expensereport')) { + $list_account_main[] = 'ACCOUNTING_ACCOUNT_EXPENSEREPORT'; +} + $list_account = array(); $list_account[] = '---Product---'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9e6b39a9b00..d716ad9f3a0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -221,6 +221,7 @@ if ($result) { $account_supplier = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER', 'NotDefined'); // NotDefined is a reserved word $account_customer = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined'); // NotDefined is a reserved word $account_employee = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); // NotDefined is a reserved word + $account_expensereport = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined'); // NotDefined is a reserved word $account_pay_vat = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT', 'NotDefined'); // NotDefined is a reserved word $account_pay_donation = getDolGlobalString('DONATION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word $account_pay_subscription = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word @@ -625,6 +626,9 @@ if (!$error && $action == 'writebookkeeping') { $accountingaccountpayment = new AccountingAccount($db); $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); + $accountingaccountexpensereport = new AccountingAccount($db); + $accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true); + $accountingaccountsuspense = new AccountingAccount($db); $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); @@ -757,8 +761,8 @@ if (!$error && $action == 'writebookkeeping') { } elseif ($tabtype[$key] == 'payment_expensereport') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); - $bookkeeping->label_compte = $accountingaccountpayment->label; + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); + $bookkeeping->label_compte = $accountingaccountexpensereport->label; } elseif ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; @@ -1013,7 +1017,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } elseif ($tabtype[$key] == 'payment') { print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; } elseif ($tabtype[$key] == 'payment_expensereport') { - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; } elseif ($tabtype[$key] == 'payment_salary') { print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; } else { @@ -1135,7 +1139,8 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' - || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { + || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1' + || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSERERPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSERERPORT') == '-1') { print($desc ? '' : '
').'
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); @@ -1294,7 +1299,7 @@ if (empty($action) || $action == 'view') { $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); } if ($tabtype[$key] == 'payment_expensereport') { - $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); } if ($tabtype[$key] == 'payment_salary') { $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 881070ad6fd..077f8f755b1 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -162,7 +162,7 @@ if ($result) { $num = $db->num_rows($result); // Variables - $account_salary = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); + $account_salary = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined'); $account_vat = getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT', 'NotDefined'); $i = 0; @@ -247,7 +247,7 @@ if ($action == 'writebookkeeping' && !$error) { $error = 0; $accountingaccountexpense = new AccountingAccount($db); - $accountingaccountexpense->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); + $accountingaccountexpense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true); foreach ($taber as $key => $val) { // Loop on each expense report $errorforline = 0; @@ -279,7 +279,7 @@ if ($action == 'writebookkeeping' && !$error) { $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); $bookkeeping->label_compte = $accountingaccountexpense->label; $bookkeeping->label_operation = $tabuser[$key]['name']; @@ -590,7 +590,7 @@ if (empty($action) || $action == 'view') { } // Button to write into Ledger - if (!getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1') { print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); @@ -602,7 +602,7 @@ if (empty($action) || $action == 'view') { if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { print ''; } - if (!getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1') { print ''; } else { if ($in_bookkeeping == 'notyet') { @@ -726,7 +726,7 @@ if (empty($action) || $action == 'view') { print "".$expensereportstatic->getNomUrl(1).""; // Account print ""; - $accountoshow = length_accountg(getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT')); + $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT')); if (($accountoshow == "") || $accountoshow == 'NotDefined') { print ''.$langs->trans("MainAccountForUsersNotDefined").''; } else { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index cee9b17d6c0..d8b67a715cd 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -178,6 +178,7 @@ ACCOUNTING_SELL_JOURNAL=Sales journal - sales and returns ACCOUNTING_PURCHASE_JOURNAL=Purchase journal - purchase and returns ACCOUNTING_BANK_JOURNAL=Cash journal - receipts and disbursements ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal +ACCOUNTING_ACCOUNT_EXPENSEREPORT=Default accounting account for "expense reports" ACCOUNTING_MISCELLANEOUS_JOURNAL=General journal ACCOUNTING_HAS_NEW_JOURNAL=Has new Journal ACCOUNTING_INVENTORY_JOURNAL=Inventory journal From 81189c9759beb5319caf6f66ccf6bf6323d78e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:58:28 +0100 Subject: [PATCH 2/4] Disable change on system product_nature element finished value 1 is associed to bom feature (and factory module) it's better to disable the change of the 2 initial value (consider it as system) --- htdocs/admin/dict.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d895854ab2c..5a3364e8077 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -13,6 +13,7 @@ * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2019-2022 Frédéric France * Copyright (C) 2020-2022 Open-Dsi + * Copyright (C) 2024 Charlene Benke * * 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 @@ -2129,7 +2130,12 @@ if ($id > 0) { if ($tabname[$id] == "c_actioncomm") { $canbemodified = 1; } - + + if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) { + $canbedisabled = 0; + $canbemodified = 0; + $iserasable = 0; + } // Build Url. The table is id=, the id of line is rowid= $rowidcol = empty($tabrowid[$id]) ? 'rowid' : $tabrowid[$id]; // If rowidcol not defined From 979003e539023e3cbc18c0396f0c11ddc341e816 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Mar 2024 14:15:47 +0100 Subject: [PATCH 3/4] Update dict.php --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 5a3364e8077..da9b0271b15 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2130,7 +2130,7 @@ if ($id > 0) { if ($tabname[$id] == "c_actioncomm") { $canbemodified = 1; } - + if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) { $canbedisabled = 0; $canbemodified = 0; From 5ff590c646f4f9954159ebfda163cabc379435ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Mar 2024 17:49:43 +0100 Subject: [PATCH 4/4] fix phan --- htdocs/accountancy/admin/categories_list.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 2f1b22cf778..37f065d1c2e 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -328,6 +328,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { // delete // activate if ($action == $acts[0]) { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { @@ -346,6 +347,7 @@ if ($action == $acts[0]) { // disable if ($action == $acts[1]) { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { @@ -364,6 +366,7 @@ if ($action == $acts[1]) { // favorite if ($action == 'activate_favorite') { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { @@ -382,6 +385,7 @@ if ($action == 'activate_favorite') { // disable favorite if ($action == 'disable_favorite') { + $sql = ''; $rowidcol = "rowid"; if ($rowid) {