Bonjour,
Ci-joint un patch qui permet le support des exercices décalés et des
exercices exceptionnels (longs et courts) pour le rapport compta
"résultat / exercice par société"
Avec ce patch, on peut passer year=2006-06-01 (début d'un exercice)
(J'ai veillé à la comptaibilité arrière, donc je n'ai pas renommé le
paramètre)
On peut également passer exlen=18 par exemple pour un exercice de 18
mois.
Idéalement, il faudrait que l'on puisse paramètrer la date de clôture
dans le paramètrage société, et que celle ci serve de base pour l'appel
de l'url dans le menu... mais je n'ai pas le début de l'idée de la façon
de procéder, donc si quelqu'un se propose ;-)
++
Gael
--- compta/resultat/clientfourn.php.orig 2007-06-06 17:31:29.000000000 +0200
+++ compta/resultat/clientfourn.php 2007-06-06 18:51:59.000000000 +0200
@@ -39,6 +39,31 @@
$year=$_GET["year"];
if (! $year) { $year = strftime("%Y", time()); }
+
+// quelques calculs de date préalables... et on utilise la bdd pour ça, c'est plus facile !
+// 1. on se positionne sur le lendemain de la date de clôture
+$flen=strlen($year);
+switch ($flen) {
+ case 10:
+ $periodStart="'".substr($year,0,4).'-'.substr($year,5,2).'-'.substr($year,8,2)."'";
+ break;
+ case 7:
+ $periodStart="'".substr($year,0,4).'-'.substr($year,5,2).'-01'."'";
+ break;
+ case 4:
+ $periodStart='"'.$year.'-01-01';
+ break;
+}
+$periodEnd=$periodStart . ' + INTERVAL 1 YEAR - INTERVAL 1 SECOND ';
+$periodPrev=$periodStart . ' - INTERVAL 1 YEAR';
+$periodNext=$periodStart . ' + INTERVAL 1 YEAR';
+$sql="SELECT $periodStart AS start, $periodEnd AS end, $periodPrev AS prev, $periodNext AS next";
+// print_r($sql);
+$result = $db->query($sql);
+if ($result) {
+ $periode = $db->fetch_object($result);
+}
+
$modecompta = $conf->compta->mode;
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
@@ -54,7 +79,7 @@
$nom="Bilan des recettes et dépenses, détail";
$nom.=' (Voir le rapport en <a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=RECETTES-DEPENSES">recettes-dépenses</a> pour n\'inclure que les factures effectivement payées)';
$period=$langs->trans("Year")." ".$year;
- $periodlink='<a href='.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
+ $periodlink='<a href='.$_SERVER["PHP_SELF"].'?year='.($periode->prev).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($periode->next).'&modecompta='.$modecompta.'">'.img_next().'</a>';
$description=$langs->trans("RulesResultDue");
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
@@ -63,7 +88,7 @@
$nom="Bilan des recettes et dépenses, détail";
$nom.=' (Voir le rapport en <a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=CREANCES-DETTES">créances-dettes</a> pour inclure les factures non encore payée)';
$period=$langs->trans("Year")." ".$year;
- $periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
+ $periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($periode->prev).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($periode->next).'&modecompta='.$modecompta.'">'.img_next().'</a>';
$description=$langs->trans("RulesResultInOut");
$builddate=time();
$exportlink=$langs->trans("NotYetAvailable");
@@ -88,7 +113,7 @@
$sql = "SELECT s.nom, s.idp, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut in (1,2)";
- if ($year) $sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ if ($year) $sql .= " AND f.datef between '".$periode->start."' and '".$periode->end."'";
} else {
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
@@ -97,7 +122,7 @@
$sql = "SELECT s.nom as nom, s.idp as idp, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = s.idp";
- if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ if ($year) $sql .= " AND p.datep between '".$periode->start."' and '".$periode->end."'";
}
if ($socid) $sql .= " AND f.fk_soc = $socid";
$sql .= " GROUP BY nom";
@@ -136,7 +161,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql .= " WHERE pf.rowid IS NULL";
- if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ if ($year) $sql .= " AND p.datep between '".$periode->start."' and '".$periode->end."'";
$sql .= " GROUP BY nom";
$sql .= " ORDER BY nom";
@@ -191,7 +216,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut in (1,2)";
if ($year) {
- $sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ $sql .= " AND f.datef between '".$periode->start."' and '".$periode->end."'";
}
} else {
$sql = "SELECT s.nom, s.idp, date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
@@ -202,7 +227,7 @@
$sql .= " ON f.fk_soc = s.idp";
$sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
if ($year) {
- $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ $sql .= " AND p.datep between '".$periode->start."' and '".$periode->end."'";
}
}
if ($socid)
@@ -271,7 +296,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut in (1,2)";
if ($year) {
- $sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ $sql .= " AND f.datef between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm DESC";
@@ -307,7 +332,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_statut in (1,2)";
if ($year) {
- $sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ $sql .= " AND f.datef between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm DESC";
@@ -347,7 +372,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql .= " WHERE amount > 0";
if ($year) {
- $sql .= " AND t.datev between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ $sql .= " AND t.datev between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm DESC";
@@ -385,7 +410,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql .= " WHERE amount < 0";
if ($year) {
- $sql .= " AND t.datev between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
+ $sql .= " AND t.datev between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm DESC";
@@ -434,7 +459,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
$sql .= " WHERE s.fk_type = c.id AND c.deductible=0";
if ($year) {
- $sql .= " AND s.date_ech between '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
+ $sql .= " AND s.date_ech between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY c.libelle";
}
@@ -443,7 +468,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s, ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = s.rowid AND s.fk_type = c.id AND c.deductible=0";
if ($year) {
- $sql .= " AND p.datep between '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
+ $sql .= " AND p.datep between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY c.libelle";
}
@@ -497,7 +522,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
$sql .= " WHERE s.fk_type = c.id AND c.deductible=1";
if ($year) {
- $sql .= " AND s.date_ech between '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
+ $sql .= " AND s.date_ech between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY c.libelle DESC";
}
@@ -506,7 +531,7 @@
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s, ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = s.rowid AND s.fk_type = c.id AND c.deductible=1";
if ($year) {
- $sql .= " AND p.datep between '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
+ $sql .= " AND p.datep between '".$periode->start."' and '".$periode->end."'";
}
$sql .= " GROUP BY c.libelle";
}
_______________________________________________
Dolibarr-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/dolibarr-dev