Skip to content
Snippets Groups Projects
Commit 3db36beb authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Amélioration des rapports recettes-dépenses.

parent 56ba90b6
No related branches found
No related tags found
No related merge requests found
......@@ -45,12 +45,12 @@ print '<br>';
if ($modecompta=="CREANCES-DETTES")
{
print 'Il se base sur la date de validation des factures et inclut les factures dues, qu\'elles soient payes ou non';
print ' (<a href="clientfourn.php?year='.$year.'&modecompta=RECETTES-DEPENSES">Voir le rapport sur les factures effectivement payes uniquement</a>).<br>';
print ' (Voir le rapport <a href="clientfourn.php?year='.$year.'&modecompta=RECETTES-DEPENSES">recettes-dpenses</a> pour n\'inclure que les factures effectivement payes).<br>';
print '<br>';
}
else {
print 'Il se base sur la date de validation des factures et n\'inclut que les factures effectivement payes';
print ' (<a href="clientfourn.php?year='.$year.'&modecompta=CREANCES-DETTES">Voir le rapport en crances-dettes qui inclut les factures non encore paye</a>).<br>';
print ' (Voir le rapport en <a href="clientfourn.php?year='.$year.'&modecompta=CREANCES-DETTES">crances-dettes</a> pour inclure les factures non encore paye).<br>';
print '<br>';
}
......@@ -59,13 +59,14 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="10%">&nbsp;</td><td>Elment</td>';
print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>";
print "</tr>\n";
/*
* Factures clients
*/
$sql = "SELECT s.nom,s.idp,sum(f.total) as amount";
$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 = 1";
if ($year) {
......@@ -94,9 +95,11 @@ if ($result) {
print "<tr $bc[$var]><td>&nbsp</td>";
print "<td>Factures <a href=\"../facture.php?socidp=$objp->idp\">$objp->nom</td>\n";
print "<td align=\"right\">".price($objp->amount)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
$total = $total + $objp->amount;
$total_ht = $total_ht + $objp->amount_ht;
$total_ttc = $total_ttc + $objp->amount_ttc;
print "</tr>\n";
$i++;
}
......@@ -105,13 +108,16 @@ if ($result) {
} else {
dolibarr_print_error($db);
}
print '<tr><td colspan="3" align="right">'.price($total).'</td></tr>';
print '<tr>';
print '<td colspan="3" align="right">'.price($total_ht).'</td>';
print '<td align="right">'.price($total_ttc).'</td>';
print '</tr>';
/*
* Frais, factures fournisseurs.
*/
$sql = "SELECT s.nom,s.idp,sum(f.total_ht) as amount";
$sql = "SELECT s.nom, s.idp, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.idp";
if ($year) {
......@@ -123,7 +129,8 @@ if ($modecompta != 'CREANCES-DETTES') {
$sql .= " GROUP BY s.nom ASC, s.idp";
print '<tr><td colspan="4">Facturation fournisseurs</td></tr>';
$subtotal = 0;
$subtotal_ht = 0;
$subtotal_ttc = 0;
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
......@@ -138,10 +145,13 @@ if ($result) {
print "<tr $bc[$var]><td>&nbsp</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)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
$total = $total - $objp->amount;
$subtotal = $subtotal + $objp->amount;
$total_ht = $total_ht - $objp->amount_ht;
$total_ttc = $total_ttc - $objp->amount_ttc;
$subtotal_ht = $subtotal_ht + $objp->amount_ht;
$subtotal_ttc = $subtotal_ttc + $objp->amount_ttc;
print "</tr>\n";
$i++;
}
......@@ -150,7 +160,10 @@ if ($result) {
} else {
dolibarr_print_error($db);
}
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
print '<tr>';
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
print '<td align="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
/*
* Charges sociales
......@@ -174,8 +187,10 @@ if ( $db->query($sql) ) {
while ($i < $num) {
$obj = $db->fetch_object();
$total = $total - $obj->amount;
$subtotal = $subtotal + $obj->amount;
$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>&nbsp</td>";
......@@ -187,9 +202,15 @@ if ( $db->query($sql) ) {
} else {
dolibarr_print_error($db);
}
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
print '<tr>';
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">Rsultat</td><td class="border" align="right">'.price($total).'</td></tr>';
print '<tr><td align="right" colspan="2">Rsultat</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 dductibles
......@@ -213,22 +234,32 @@ if ( $db->query($sql) ) {
while ($i < $num) {
$obj = $db->fetch_object();
$total = $total - $obj->amount;
$subtotal = $subtotal + $obj->amount;
$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>&nbsp</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 {
dolibarr_print_error($db);
}
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
print '<tr>';
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">Rsultat</td><td class="border" align="right">'.price($total).'</td></tr>';
print '<tr><td align="right" colspan="2">Rsultat</td>';
print '<td class="border" align="right">'.price($total_ht).'</td>';
print '<td class="border" align="right">'.price($total_ttc).'</td>';
print '</tr>';
print "</table>";
......
......@@ -48,19 +48,19 @@ print "Ce rapport pr
if ($modecompta=="CREANCES-DETTES")
{
print 'Il se base sur la date de validation des factures et inclut les factures dues, qu\'elles soient payes ou non';
print ' (<a href="index.php?year='.$year.'&modecompta=RECETTES-DEPENSES">Voir le rapport sur les factures effectivement payes uniquement</a>).<br>';
print ' (Voir le rapport <a href="index.php?year='.$year.'&modecompta=RECETTES-DEPENSES">recettes-dpenses</a> pour n\'inclure que les factures effectivement payes).<br>';
print '<br>';
}
else {
print 'Il se base sur la date de validation des factures et n\'inclut que les factures effectivement payes';
print ' (<a href="index.php?year='.$year.'&modecompta=CREANCES-DETTES">Voir le rapport en crances-dettes qui inclut les factures non encore paye</a>).<br>';
print ' (Voir le rapport en <a href="index.php?year='.$year.'&modecompta=CREANCES-DETTES">crances-dettes</a> pour inclure les factures non encore paye).<br>';
print '<br>';
}
/*
* Factures clients
*/
$sql = "SELECT sum(f.total) as amount, date_format(f.datef,'%Y-%m') as dm";
$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";
if ($_GET["year"]) {
......@@ -80,8 +80,9 @@ if ($db->query($sql))
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$encaiss[$row[1]] = $row[0];
$row = $db->fetch_object($i);
$encaiss[$row->dm] = $row->amount_ht;
$encaiss_ttc[$row->dm] = $row->amount_ttc;
$i++;
}
}
......@@ -92,7 +93,7 @@ else {
/*
* Frais, factures fournisseurs.
*/
$sql = "SELECT sum(f.total_ht) as amount, date_format(f.datef,'%Y-%m') as dm";
$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";
if ($_GET["year"]) {
......@@ -113,8 +114,9 @@ if ($db->query($sql))
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$decaiss[$row[1]] = $row[0];
$row = $db->fetch_object($i);
$decaiss[$row->dm] = $row->amount_ht;
$decaiss_ttc[$row->dm] = $row->amount_ttc;
$i++;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment