diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 8b71b118c4e..363fd2ecbb5 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -57,8 +57,8 @@ $list = array( ); $list_binding = array( - 'ACCOUNTING_DATE_START_BINDING', 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', + 'ACCOUNTING_DATE_START_BINDING', ); $error = 0; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 0f09ad76d35..7f76f640101 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -74,6 +74,11 @@ $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_en $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); +// Define begin binding date +if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { + $search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING); +} + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -281,10 +286,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_so $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; -// Define begin binding date -if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; -} // Add search filter like if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 57cdb5ef3a6..6ba6244e037 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -67,6 +67,11 @@ $search_date_endyear = GETPOST('search_date_endyear', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +// Define begin binding date +if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { + $search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING); +} + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (!getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION') ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -240,10 +245,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_f $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; -// Define begin binding date -if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; -} // Add search filter like if (strlen(trim($search_login))) { $sql .= natural_search("u.login", $search_login); @@ -291,6 +292,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { $offset = 0; } } +//print $sql; $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index fc67608e8a8..616b39e7608 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -117,6 +117,11 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +// Define begin binding date +if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { + $search_date_start = $db->idate($conf->global->ACCOUNTING_DATE_START_BINDING); +} + /* * Actions @@ -282,10 +287,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_pr $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; -// Define begin binding date -if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; -} // Add search filter like if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 86f7770e27f..08ec7f062e3 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -280,7 +280,7 @@ function getDefaultDatesForTransfer() $pastmonthyear = 0; // Period by default on transfer (0: previous month | 1: current month | 2: fiscal year) - $periodbydefaultontransfer = (empty($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? 0 : $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER); + $periodbydefaultontransfer = getDolGlobalInt('ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', 0); if ($periodbydefaultontransfer == 2) { // fiscal year $sql = "SELECT date_start, date_end FROM ".MAIN_DB_PREFIX."accounting_fiscalyear"; $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index aabe572a480..f8aabd7773e 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -169,8 +169,8 @@ ACCOUNTING_MANAGE_ZERO=Allow to manage different number of zeros at the end of a BANK_DISABLE_DIRECT_INPUT=Disable direct recording of transaction in bank account ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL=Enable draft export on journal ACCOUNTANCY_COMBO_FOR_AUX=Enable combo list for subsidiary account (may be slow if you have a lot of third parties, break ability to search on a part of value) -ACCOUNTING_DATE_START_BINDING=Define a date to start binding & transfer in accountancy. Below this date, the transactions will not be transferred to accounting. -ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER=On accountancy transfer, what is the period selected by default +ACCOUNTING_DATE_START_BINDING=Disable binding & transfer in accountancy when date is below this date (the transactions before this date will be excluded by default) +ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER=On the page to transfer data into accountancy, what is the period selected by default ACCOUNTING_SELL_JOURNAL=Sales journal - sales and returns ACCOUNTING_PURCHASE_JOURNAL=Purchase journal - purchase and returns