Fix: Le rapport de rsultat fonctionne correctement dans les 2 modes (crances-dette ou recettes-dpenses)
This commit is contained in:
parent
8f10b07960
commit
9b61ced76a
@ -39,13 +39,14 @@ $modecompta = $conf->compta->mode;
|
||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
|
||||
|
||||
print_fiche_titre("Détail recettes-dépenses par client/fournisseur",($year?" <a href='clientfourn.php?year=".($year-1)."'>".img_previous()."</a> Année $year <a href='clientfourn.php?year=".($year+1)."'>".img_next()."</a>":""));
|
||||
print_fiche_titre("Résultat exercice, par client/fournisseur",($year?" <a href='clientfourn.php?year=".($year-1)."'>".img_previous()."</a> Année $year <a href='clientfourn.php?year=".($year+1)."'>".img_next()."</a>":""));
|
||||
print '<br>';
|
||||
|
||||
print "Cet état permet de faire un bilan des recettes et dépenses:<br>";
|
||||
if ($modecompta=="CREANCES-DETTES")
|
||||
{
|
||||
print $langs->trans("RulesResultDue");
|
||||
print '(Voir le rapport <a href="clientfourn.php?year='.$year.'&modecompta=RECETTES-DEPENSES">recettes-dépenses</a> pour n\'inclure que les factures effectivement payées).<br>';
|
||||
print '(Voir le rapport en <a href="clientfourn.php?year='.$year.'&modecompta=RECETTES-DEPENSES">recettes-dépenses</a> pour n\'inclure que les factures effectivement payées).<br>';
|
||||
print '<br>';
|
||||
}
|
||||
else {
|
||||
@ -58,7 +59,7 @@ else {
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="10%"> </td><td>'.$langs->trans("Element").'</td>';
|
||||
print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
|
||||
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
@ -66,24 +67,27 @@ print "</tr>\n";
|
||||
/*
|
||||
* Factures clients
|
||||
*/
|
||||
if ($conf->compta->mode == 'CREANCES-DETTES') {
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$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 .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
|
||||
if ($_GET["year"]) {
|
||||
$sql .= " AND f.datef between '".$_GET["year"]."-01-01 00:00:00' and '".$_GET["year"]."-12-31 23:59:59'";
|
||||
if ($year) {
|
||||
$sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT 'Fournisseurs' as nom, '0' as idp, sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p ";
|
||||
$sql .= "left join ".MAIN_DB_PREFIX."facture as f ";
|
||||
$sql .= "on f.rowid = p.fk_facture";
|
||||
if ($_GET["year"]) {
|
||||
$sql .= " AND p.datep between '".$_GET["year"]."-01-01 00:00:00' and '".$_GET["year"]."-12-31 23:59:59'";
|
||||
/*
|
||||
* Liste des paiements par société (les anciens paiements ne sont pas inclus
|
||||
* car n'était pas liés sur les vieilles versions)
|
||||
*/
|
||||
$sql = "SELECT s.nom as nom, s.idp as idp, sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$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 f.fk_soc = s.idp AND f.rowid = pf.fk_facture AND pf.fk_paiement = p.rowid";
|
||||
if ($year) {
|
||||
$sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
}
|
||||
$sql .= " GROUP BY nom ASC";
|
||||
|
||||
$sql .= " GROUP BY nom";
|
||||
$sql .= " ORDER BY nom";
|
||||
|
||||
print '<tr><td colspan="4">Facturation clients</td></tr>';
|
||||
|
||||
@ -98,9 +102,9 @@ if ($result) {
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print "<td>".$langs->trans("Factures")." <a href=\"../facture.php?socidp=$objp->idp\">$objp->nom</td>\n";
|
||||
print "<td>".$langs->trans("Bills")." <a href=\"../facture.php?socidp=$objp->idp\">$objp->nom</td>\n";
|
||||
|
||||
print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
|
||||
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
|
||||
|
||||
$total_ht = $total_ht + $objp->amount_ht;
|
||||
@ -112,31 +116,73 @@ if ($result) {
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
// Ajoute paiements anciennes version non liés par paiement_facture
|
||||
if ($modecompta != 'CREANCES-DETTES') {
|
||||
$sql = "SELECT 'Autres' as nom, '0' as idp, sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$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'";
|
||||
}
|
||||
$sql .= " GROUP BY nom";
|
||||
$sql .= " ORDER BY nom";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print "<td>".$langs->trans("Bills")." ".$langs->trans("Other")."\n";
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
|
||||
|
||||
$total_ht = $total_ht + $objp->amount_ht;
|
||||
$total_ttc = $total_ttc + $objp->amount_ttc;
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
print '<tr>';
|
||||
print '<td colspan="3" align="right">'.price($total_ht).'</td>';
|
||||
print '<td align="right">'.price($total_ttc).'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price($total_ht).'</td>';
|
||||
print '<td colspan="3" align="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
/*
|
||||
* Frais, factures fournisseurs.
|
||||
*/
|
||||
if ($conf->compta->mode == 'CREANCES-DETTES') {
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT s.nom, s.idp, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
|
||||
$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 = 1";
|
||||
if ($_GET["year"]) {
|
||||
$sql .= " AND f.datef between '".$_GET["year"]."-01-01 00:00:00' and '".$_GET["year"]."-12-31 23:59:59'";
|
||||
if ($year) {
|
||||
$sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT 'Fournisseurs' as nom, '0' as idp, sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p ";
|
||||
$sql .= "left join ".MAIN_DB_PREFIX."facture_fourn as f ";
|
||||
$sql .= "on f.rowid = p.fk_facture_fourn";
|
||||
if ($_GET["year"]) {
|
||||
$sql .= " AND p.datep between '".$_GET["year"]."-01-01 00:00:00' and '".$_GET["year"]."-12-31 23:59:59'";
|
||||
$sql = "SELECT s.nom, s.idp, sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql .= " ON f.rowid = p.fk_facture_fourn";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " ON f.fk_soc = s.idp";
|
||||
$sql .= " WHERE 1=1";
|
||||
if ($year) {
|
||||
$sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
}
|
||||
$sql .= " GROUP BY nom ASC, idp";
|
||||
$sql .= " GROUP BY nom, idp";
|
||||
$sql .= " ORDER BY nom, idp";
|
||||
|
||||
print '<tr><td colspan="4">Facturation fournisseurs</td></tr>';
|
||||
$subtotal_ht = 0;
|
||||
@ -154,7 +200,7 @@ if ($result) {
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print "<td>".$langs->trans("Bills")." <a href=\"../../fourn/facture/index.php?socid=".$objp->idp."\">$objp->nom</a></td>\n";
|
||||
|
||||
print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
|
||||
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
|
||||
|
||||
$total_ht = $total_ht - $objp->amount_ht;
|
||||
@ -170,109 +216,151 @@ if ($result) {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print '<tr>';
|
||||
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td align="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
/*
|
||||
* Charges sociales
|
||||
*/
|
||||
|
||||
$subtotal = 0;
|
||||
print '<tr><td colspan="4">Prestations/Charges déductibles</td></tr>';
|
||||
|
||||
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
|
||||
$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 .= " GROUP BY c.libelle DESC";
|
||||
|
||||
if ( $db->query($sql) ) {
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object();
|
||||
|
||||
$total_ht = $total_ht - $obj->amount;
|
||||
$total_ttc = $total_ttc - $obj->amount;
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount;
|
||||
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td>'.$obj->nom.'</td>';
|
||||
print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print '<tr>';
|
||||
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td align="right" colspan="2">Résultat</td>';
|
||||
print '<td class="border" align="right">'.price($total_ht).'</td>';
|
||||
print '<td class="border" align="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
/*
|
||||
* Charges sociales non déductibles
|
||||
*/
|
||||
|
||||
$subtotal = 0;
|
||||
print '<tr><td colspan="4">Prestations/Charges NON déductibles</td></tr>';
|
||||
|
||||
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
|
||||
$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'";
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
|
||||
$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 .= " GROUP BY c.libelle";
|
||||
}
|
||||
$sql .= " GROUP BY c.libelle DESC";
|
||||
|
||||
if ( $db->query($sql) ) {
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object();
|
||||
|
||||
$total_ht = $total_ht - $obj->amount;
|
||||
$total_ttc = $total_ttc - $obj->amount;
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount;
|
||||
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td>'.$obj->nom.'</td>';
|
||||
print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT c.libelle as nom, sum(p.amount) as amount";
|
||||
$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 .= " GROUP BY c.libelle";
|
||||
}
|
||||
$result=$db->query($sql);
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$var=false;
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total_ht = $total_ht - $obj->amount;
|
||||
$total_ttc = $total_ttc - $obj->amount;
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount;
|
||||
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td>'.$obj->nom.'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td colspan="3">'.$langs->trans("None").'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print '<tr>';
|
||||
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
/*
|
||||
* Charges sociales déductibles
|
||||
*/
|
||||
|
||||
print '<tr><td colspan="4">Prestations/Charges déductibles</td></tr>';
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT c.libelle as nom, sum(s.amount) as amount";
|
||||
$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 .= " GROUP BY c.libelle DESC";
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT c.libelle as nom, sum(p.amount) as amount";
|
||||
$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 .= " GROUP BY c.libelle";
|
||||
}
|
||||
$result=$db->query($sql);
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$var=false;
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total_ht = $total_ht - $obj->amount;
|
||||
$total_ttc = $total_ttc - $obj->amount;
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount;
|
||||
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td>'.$obj->nom.'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td colspan="3">'.$langs->trans("None").'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print '<tr>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Total
|
||||
|
||||
print "<tr>";
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td align="right" colspan="2">Résultat</td>';
|
||||
print '<td class="border" align="right">'.price($total_ht).'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td class="border" align="right">'.price($total_ht).'</td>';
|
||||
print '<td class="border" align="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -54,7 +54,7 @@ $modecompta = $conf->compta->mode;
|
||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
|
||||
|
||||
$title="Résultat comptable (HT), résumé annuel";
|
||||
$title="Résultat exercice, résumé annuel";
|
||||
$lien=($year_start?"<a href='index.php?year_start=".($year_start-1)."'>".img_previous()."</a> <a href='index.php?year_start=".($year_start+1)."'>".img_next()."</a>":"");
|
||||
print_fiche_titre($title,$lien);
|
||||
print '<br>';
|
||||
@ -76,21 +76,22 @@ else {
|
||||
/*
|
||||
* Factures clients
|
||||
*/
|
||||
if ($conf->compta->mode == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
|
||||
$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 = 1";
|
||||
} else {
|
||||
$sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p ";
|
||||
$sql .= "left join ".MAIN_DB_PREFIX."facture as f ";
|
||||
$sql .= "on f.rowid = p.fk_facture";
|
||||
$sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " ON f.rowid = p.fk_facture";
|
||||
$sql .= " WHERE 1=1";
|
||||
}
|
||||
if ($socidp)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
|
||||
$result=$db->query($sql);
|
||||
@ -115,15 +116,16 @@ else {
|
||||
/*
|
||||
* Frais, factures fournisseurs.
|
||||
*/
|
||||
if ($conf->compta->mode == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
|
||||
$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 = 1";
|
||||
} else {
|
||||
$sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p ";
|
||||
$sql .= "left join ".MAIN_DB_PREFIX."facture_fourn as f ";
|
||||
$sql .= "on f.rowid = p.fk_facture_fourn";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql .= " ON f.rowid = p.fk_facture_fourn";
|
||||
$sql .= " WHERE 1=1";
|
||||
}
|
||||
if ($socidp)
|
||||
{
|
||||
@ -180,19 +182,19 @@ for ($mois = 1 ; $mois < 13 ; $mois++)
|
||||
{
|
||||
print '<td align="right" width="10%"> ';
|
||||
$case = strftime("%Y-%m",mktime(1,1,1,$mois,1,$annee));
|
||||
if ($encaiss[$case]>0)
|
||||
if ($encaiss_ttc[$case]>0)
|
||||
{
|
||||
print price($encaiss[$case]);
|
||||
$totentrees[$annee]+=$encaiss[$case];
|
||||
print price($encaiss_ttc[$case]);
|
||||
$totentrees[$annee]+=$encaiss_ttc[$case];
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
print '<td align="right" width="10%"> ';
|
||||
$case = strftime("%Y-%m",mktime(1,1,1,$mois,1,$annee));
|
||||
if ($decaiss[$case]>0)
|
||||
if ($decaiss_ttc[$case]>0)
|
||||
{
|
||||
print price($decaiss[$case]);
|
||||
$totsorties[$annee]+=$decaiss[$case];
|
||||
print price($decaiss_ttc[$case]);
|
||||
$totsorties[$annee]+=$decaiss_ttc[$case];
|
||||
}
|
||||
print "</td>";
|
||||
}
|
||||
@ -201,7 +203,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++)
|
||||
}
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]><td><b>".$langs->trans("Total")."</b></td>";
|
||||
print "<tr $bc[$var]><td><b>".$langs->trans("TotalTTC")."</b></td>";
|
||||
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
{
|
||||
print '<td align="right">'.price($totentrees[$annee]).'</td><td align="right">'.price($totsorties[$annee]).'</td>';
|
||||
|
||||
@ -79,7 +79,7 @@ else {
|
||||
print '<br>';
|
||||
|
||||
|
||||
if ($conf->compta->mode == 'CREANCES-DETTES') {
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT sum(f.total) as amount, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE f.fk_statut = 1";
|
||||
@ -197,17 +197,17 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
print "<tr><td align=\"right\"><b>".$langs->trans("Total")." :</b></td>";
|
||||
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
{
|
||||
print "<td align=\"right\"><b>".($total[$annee]?price($total[$annee]):" ")."</b></td>";
|
||||
print "<td align=\"right\" nowrap><b>".($total[$annee]?price($total[$annee]):" ")."</b></td>";
|
||||
|
||||
// Pourcentage evol
|
||||
if ($total[$annee-1]) {
|
||||
if ($annee <= $year_current) {
|
||||
if ($total[$annee-1]) {
|
||||
$percent=(round(($total[$annee]-$total[$annee-1])/$total[$annee-1],4)*100);
|
||||
print '<td align="right"><b>'.($percent>=0?"+$percent":"$percent").'%</b></td>';
|
||||
print '<td align="right" nowrap><b>'.($percent>=0?"+$percent":"$percent").'%</b></td>';
|
||||
}
|
||||
else
|
||||
print '<td align="center">+Inf%</td>';
|
||||
print '<td align="center" nowrap>+Inf%</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -228,17 +228,16 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
|
||||
}
|
||||
print "</tr>\n";
|
||||
/* en mode recettes/dépenses, il faut compléter avec les montants facturés non réglés
|
||||
* et les propales signées mais pas facturées
|
||||
* en effet, en recettes-dépenses, on comptabilise lorsque le montant est sur le compte
|
||||
* donc il est intéressant d'avoir une vision de ce qui va arriver
|
||||
*/
|
||||
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
||||
|
||||
/*
|
||||
*
|
||||
* Facture non réglées
|
||||
*
|
||||
*/
|
||||
* En mode recettes/dépenses, on complète avec les montants facturés non réglés
|
||||
* et les propales signées mais pas facturées. En effet, en recettes-dépenses,
|
||||
* on comptabilise lorsque le montant est sur le compte donc il est intéressant
|
||||
* d'avoir une vision de ce qui va arriver.
|
||||
*/
|
||||
if ($modecompta != 'CREANCES-DETTES') {
|
||||
|
||||
// Factures non réglées
|
||||
|
||||
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total_ttc, sum(pf.amount) as am";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
|
||||
|
||||
@ -21,7 +21,7 @@ VATPayed=VAT payed
|
||||
SocialContributions=Social contributions
|
||||
AccountancyTreasuryArea=Accountancy/Treasury area
|
||||
NewPayment=New payment
|
||||
RulesResultDue=- Les dépenses de charges ne sont pas incluses.<br>- Il se base sur la date de validation des factures.<br>- Il inclut les factures dues, qu'elles soient payées ou non<br>
|
||||
RulesResultInOut=- Les dépenses de charges ne sont pas incluses.<br>- Il se base sur les paiements des factures effectivement réalisés<br>
|
||||
RulesResultDue=Cet état permet de faire un bilan des recettes et dépenses:<br>- Il se base sur la date de validation pour les factures, les dates d'échéances pour les charges.<br>- Il inclut les factures et charges dues, qu'elles soient payées ou non.<br>
|
||||
RulesResultInOut=Cet état permet de faire un bilan des recettes et dépenses:<br>- Il se base sur les paiements effectivement réalisées des factures et charges.<br>
|
||||
RulesCADue=- Il se base sur la date de validation des factures.<br>- Il se base sur les factures dues, qu'elles soient payées ou non<br>
|
||||
RulesCAIn=- Il se base sur la date des paiements de factures<br>- Il se base sur les paiements des factures effectivement réalisés<br>
|
||||
|
||||
@ -22,7 +22,7 @@ SocialContributions=Charges sociales
|
||||
AccountancyTreasuryArea=Espace Compta/Tréso
|
||||
NewPayment=Nouveau paiement
|
||||
ListPayment=Liste des paiements
|
||||
RulesResultDue=- Les dépenses de charges ne sont pas incluses.<br>- Il se base sur la date de validation des factures.<br>- Il inclut les factures dues, qu'elles soient payées ou non<br>
|
||||
RulesResultInOut=- Les dépenses de charges ne sont pas incluses.<br>- Il se base sur les paiements des factures effectivement réalisés<br>
|
||||
RulesCADue=- Il se base sur la date de validation des factures.<br>- Il se base sur les factures dues, qu'elles soient payées ou non<br>
|
||||
RulesCAIn=- Il se base sur la date des paiements de factures<br>- Il se base sur les paiements des factures effectivement réalisés<br>
|
||||
RulesResultDue=- Il se base sur la date de validation pour les factures, les dates d'échéances pour les charges.<br>- Il inclut les factures et charges dues, qu'elles soient payées ou non.<br>
|
||||
RulesResultInOut=- Il se base sur les paiements effectivement réalisées des factures et charges.<br>
|
||||
RulesCADue=- Il se base sur la date de validation des factures.<br>- Il se base sur les factures dues, qu'elles soient payées ou non.<br>
|
||||
RulesCAIn=- Il se base sur la date des paiements de factures<br>- Il se base sur les paiements des factures effectivement réalisés.<br>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user