From 530b122f1eec0cd16cd8136bab6c7714ba1a1a0b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 1 Apr 2021 04:37:47 +0200 Subject: [PATCH] FIX: Periodicity by default on fiscal year, according to the date, we have plus 1 year added --- htdocs/core/lib/accounting.lib.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 20ffa3f52b6..789a84df04d 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2019 Eric Seigne +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2019 Eric Seigne * * 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 @@ -257,8 +257,8 @@ function getDefaultDatesForTransfer() $periodbydefaultontransfer = $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER; isset($periodbydefaultontransfer) ? $periodbydefaultontransfer : 0; if ($periodbydefaultontransfer == 2) { - $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())."'"; + $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())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); if ($res->num_rows > 0) { @@ -268,6 +268,9 @@ function getDefaultDatesForTransfer() } else { $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $year_start = dol_print_date(dol_now(), '%Y'); + if ($conf->global->SOCIETE_FISCAL_MONTH_START > dol_print_date(dol_now(), '%m')) { + $year_start = $year_start - 1; + } $year_end = $year_start + 1; $month_end = $month_start - 1; if ($month_end < 1)