From 64975b3b9eb4d017c0de9f33b442b414f86fef4c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Jan 2019 22:27:55 +0100 Subject: [PATCH] NEW: When you create product or service, sell accountancy account by default are proposed --- htdocs/accountancy/admin/defaultaccounts.php | 4 ++- htdocs/langs/en_US/accountancy.lang | 2 ++ htdocs/product/card.php | 30 ++++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 2f41dfa4bfd..1cd00627aa3 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2019 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos GarcĂ­a * Copyright (C) 2014 Juanjo Menent @@ -55,6 +55,8 @@ $list_account_main = array ( $list_account = array ( 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT', 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'ACCOUNTING_VAT_BUY_ACCOUNT', diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 144caf49dde..c85593925f5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -155,6 +155,8 @@ ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscript ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for bought products (used if not defined in the product sheet) ACCOUNTING_PRODUCT_SOLD_ACCOUNT=Accounting account by default for the sold products (used if not defined in the product sheet) +ACCOUNTING_PRODUCT_SOLD_ACCOUNT_INTRA=Accounting account by default for the sold products in CEE (used if not defined in the product sheet) +ACCOUNTING_PRODUCT_SOLD_ACCOUNT_EXPORT=Accounting account by default for the sold products export out of CEE (used if not defined in the product sheet) ACCOUNTING_SERVICE_BUY_ACCOUNT=Accounting account by default for the bought services (used if not defined in the service sheet) ACCOUNTING_SERVICE_SOLD_ACCOUNT=Accounting account by default for the sold services (used if not defined in the service sheet) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 512a5caa322..46f57193eb2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1176,7 +1176,13 @@ else // Accountancy_code_sell print ''.$langs->trans("ProductAccountancySellCode").''; print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, ''); + if($type = 0) + { + $accountancy_code_sell = (GETPOST('accountancy_code_sell','alpha')?(GETPOST('accountancy_code_sell','alpha')):$conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); + } else { + $accountancy_code_sell = (GETPOST('accountancy_code_sell','alpha')?(GETPOST('accountancy_code_sell','alpha')):$conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, ''); print ''; // Accountancy_code_sell_intra @@ -1184,20 +1190,32 @@ else { print ''.$langs->trans("ProductAccountancySellIntraCode").''; print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_sell_intra'), 'accountancy_code_sell_intra', 1, null, 1, 1, ''); - print ''; + if($type = 0) + { + $accountancy_code_sell_intra = (GETPOST('accountancy_code_sell_intra','alpha')?(GETPOST('accountancy_code_sell_intra','alpha')):$conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); + } else { + $accountancy_code_sell_intra = GETPOST('accountancy_code_sell_intra','alpha'); + } + print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, ''); + print ''; } // Accountancy_code_sell_export print ''.$langs->trans("ProductAccountancySellExportCode").''; print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_sell_export'), 'accountancy_code_sell_export', 1, null, 1, 1, ''); - print ''; + if($type = 0) + { + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export','alpha')?(GETPOST('accountancy_code_sell_export','alpha')):$conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); + } else { + $accountancy_code_sell_export = GETPOST('accountancy_code_sell_export','alpha'); + } + print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, ''); + print ''; // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, ''); + print $formaccounting->select_account(GETPOST('accountancy_code_buy','alpha'), 'accountancy_code_buy', 1, null, 1, 1, ''); print ''; } else // For external software