From 6c0c1a988191c7aa090c5eee190098edc4acbfb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Nov 2023 19:09:34 +0100 Subject: [PATCH] Add option ACCOUNTANCY_FISCAL_PERIOD_MODE to support 2 mode for fiscal year --- htdocs/accountancy/index.php | 12 ++++---- htdocs/accountancy/journal/bankjournal.php | 30 ++++++++++--------- .../journal/expensereportsjournal.php | 30 ++++++++++--------- .../accountancy/journal/purchasesjournal.php | 30 ++++++++++--------- htdocs/accountancy/journal/sellsjournal.php | 30 ++++++++++--------- htdocs/accountancy/journal/variousjournal.php | 30 ++++++++++--------- 6 files changed, 87 insertions(+), 75 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index f8401072123..0c5be4b49c4 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -146,11 +146,13 @@ if (isModEnabled('accounting')) { print "
\n"; print "
\n"; - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescFiscalPeriod", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("FiscalPeriod").'', $s); - print $s; - print "
\n"; + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescFiscalPeriod", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("FiscalPeriod").'', $s); + print $s; + print "
\n"; + } $step++; $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}'); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 536e510195e..eeeb28d5179 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1065,21 +1065,23 @@ if (empty($action) || $action == 'view') { $desc = ''; - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) - // Fiscal period test - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->nb == 0) { - print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); - $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); - print $desc; - print '
'; + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) + // Fiscal period test + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->nb == 0) { + print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); + print $desc; + print '
'; + } + } else { + dol_print_error($db); } - } else { - dol_print_error($db); } // Bank test diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index e624a07108c..39fa8d8e050 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -564,21 +564,23 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) - // Fiscal period test - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->nb == 0) { - print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); - $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); - print $desc; - print '
'; + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) + // Fiscal period test + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->nb == 0) { + print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); + print $desc; + print '
'; + } + } else { + dol_print_error($db); } - } else { - dol_print_error($db); } // Button to write into Ledger diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 69db686615f..214b548949b 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -937,21 +937,23 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) - // Fiscal period test - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->nb == 0) { - print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); - $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); - print $desc; - print '
'; + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) + // Fiscal period test + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->nb == 0) { + print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); + print $desc; + print '
'; + } + } else { + dol_print_error($db); } - } else { - dol_print_error($db); } // Button to write into Ledger diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index f2dfb091edb..9a4e5561f46 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -994,21 +994,23 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) - // Fiscal period test - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->nb == 0) { - print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); - $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); - print $desc; - print '
'; + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) + // Fiscal period test + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->nb == 0) { + print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); + print $desc; + print '
'; + } + } else { + dol_print_error($db); } - } else { - dol_print_error($db); } // Button to write into Ledger diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index f32bfb73037..f7d1831ee87 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -214,21 +214,23 @@ $varlink = 'id_journal=' . $id_journal; journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); -// Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) -// Fiscal period test -$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); -$resql = $db->query($sql); -if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->nb == 0) { - print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); - $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); - print $desc; - print '
'; +if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) + // Fiscal period test + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->nb == 0) { + print '
'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); + $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'', $desc); + print $desc; + print '
'; + } + } else { + dol_print_error($db); } -} else { - dol_print_error($db); } if ($object->nature == 4) { // Bank journal