diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 6170c02dd4f..bd84c1d6339 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -157,7 +157,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("fiscalmonthstart",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'alpha'),'chaine',0,'',$conf->entity); @@ -547,8 +547,8 @@ if ($action == 'edit' || $action == 'updateedit') print "\n"; - print ''; - print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',0,1) . ''; + print ''; + print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'SOCIETE_FISCAL_MONTH_START',0,1) . ''; print ""; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index c194f21d862..0b52404cd7b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -189,7 +189,8 @@ elseif ($modecompta=="BOOKKEEPING") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0); + $arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All")); + $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0); $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesResultBookkeepingPredefined"); $description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')'; @@ -291,7 +292,7 @@ if ($modecompta == 'BOOKKEEPING') // Loop on detail of all accounts // This make 14 calls for each detail of account (NP, N and month m) - if ($showaccountdetail == 'yes') + if ($showaccountdetail != 'no') { $tmppredefinedgroupwhere="pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'"; $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$charofaccountstring."'"; @@ -310,7 +311,8 @@ if ($modecompta == 'BOOKKEEPING') $resultN=$AccCat->sdc; } - if ($resultN > 0) + + if ($showaccountdetail == 'all' || $resultN > 0) { print ''; print ''; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 4f76f2cdfa6..4917513438a 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2018 Laurent Destailleur * * 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 @@ -56,12 +57,12 @@ $nbofyear=1; $year=GETPOST('year','int'); if (empty($year)) { - $year_current = strftime("%Y",dol_now()); - $month_current = strftime("%m",dol_now()); + $year_current = strftime("%Y", dol_now()); + $month_current = strftime("%m", dol_now()); $year_start = $year_current - ($nbofyear - 1); } else { $year_current = $year; - $month_current = strftime("%m",dol_now()); + $month_current = strftime("%m", dol_now()); $year_start = $year - ($nbofyear - 1); } $date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); @@ -76,6 +77,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end // We define date_start and date_end $year_end=$year_start + ($nbofyear - 1); $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $date_startmonth = $month_start; if (! GETPOST('month')) { if (! GETPOST("year") && $month_start > $month_current) @@ -195,7 +197,8 @@ else if ($modecompta=="BOOKKEEPING") //$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0); + $arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All")); + $period.='     '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0); $periodlink = $textprevyear . " " . $langs->trans("Year") . " " . $start_year . " " . $textnextyear ; $exportlink = ''; $description=$langs->trans("RulesResultBookkeepingPersonalized"). @@ -225,7 +228,16 @@ print ''; print ''.$langs->trans("PreviousPeriod").''; print ''.$langs->trans("SelectedPeriod").''; foreach($months as $k => $v){ - print ''.$langs->trans($v).''; + if (($k+1) >= $date_startmonth) + { + print ''.$langs->trans($v).''; + } +} +foreach($months as $k => $v){ + if (($k+1) < $date_startmonth) + { + print ''.$langs->trans($v).''; + } } print ''; @@ -306,16 +318,35 @@ else if ($modecompta=="BOOKKEEPING") // Detail by month foreach($months as $k => $v) { - foreach($sommes as $code => $det){ - $vars[$code] = $det['M'][$k]; + if (($k+1) >= $date_startmonth) + { + foreach($sommes as $code => $det){ + $vars[$code] = $det['M'][$k]; + } + $result = strtr($formula, $vars); + + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); + + print '' . price($r) . ''; + $sommes[$code]['M'][$k] += $r; } - $result = strtr($formula, $vars); + } + foreach($months as $k => $v) + { + if (($k+1) < $date_startmonth) + { + foreach($sommes as $code => $det){ + $vars[$code] = $det['M'][$k]; + } + $result = strtr($formula, $vars); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1); + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); - print '' . price($r) . ''; - $sommes[$code]['M'][$k] += $r; + print '' . price($r) . ''; + $sommes[$code]['M'][$k] += $r; + } } @@ -418,38 +449,57 @@ else if ($modecompta=="BOOKKEEPING") print '' . price($totCat['NP']) . ''; print '' . price($totCat['N']) . ''; + // Each month foreach($totCat['M'] as $k => $v){ - print '' . price($v) . ''; + if (($k+1) >= $date_startmonth) print '' . price($v) . ''; } + foreach($totCat['M'] as $k => $v){ + if (($k+1) < $date_startmonth) print '' . price($v) . ''; + } + print "\n"; // Loop on detail of all accounts // This make 14 calls for each detail of account (NP, N and month m) - if ($showaccountdetail == 'yes') + if ($showaccountdetail != 'no') { foreach($cpts as $i => $cpt) { $resultNP=$totPerAccount[$cpt['account_number']]['NP']; $resultN=$totPerAccount[$cpt['account_number']]['N']; - print ''; - print ''; - print ''; - print '     ' . length_accountg($cpt['account_number']); - print ' - '; - print $cpt['account_label']; - print ''; - print '' . price($resultNP) . ''; - print '' . price($resultN) . ''; - - // Make one call for each month - foreach($months as $k => $v) + if ($showaccountdetail == 'all' || $resultN > 0) { - $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; - print '' . price($resultM) . ''; - } + print ''; + print ''; + print ''; + print '     ' . length_accountg($cpt['account_number']); + print ' - '; + print $cpt['account_label']; + print ''; + print '' . price($resultNP) . ''; + print '' . price($resultN) . ''; - print "\n"; + // Make one call for each month + foreach($months as $k => $v) + { + if (($k+1) >= $date_startmonth) + { + $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; + print '' . price($resultM) . ''; + } + } + foreach($months as $k => $v) + { + if (($k+1) < $date_startmonth) + { + $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; + print '' . price($resultM) . ''; + } + } + + print "\n"; + } } } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index db7de1a21ad..d0643c717e6 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -33,6 +33,7 @@ AlreadyInGeneralLedger=Already journalized in ledgers NotYetInGeneralLedger=Not yet journalized in ledgers GroupIsEmptyCheckSetup=Group is empty, check setup of the personalized accounting group DetailByAccount=Show detail by account +AccountWithNonZeroValues=Accounts with non zero values MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup