Amlioration des rapports recettes-dpenses.

This commit is contained in:
Laurent Destailleur 2005-01-17 20:26:12 +00:00
parent 56ba90b604
commit 3db36beba3
2 changed files with 61 additions and 28 deletions

View File

@ -45,12 +45,12 @@ print '<br>';
if ($modecompta=="CREANCES-DETTES") if ($modecompta=="CREANCES-DETTES")
{ {
print 'Il se base sur la date de validation des factures et inclut les factures dues, qu\'elles soient payées ou non'; print 'Il se base sur la date de validation des factures et inclut les factures dues, qu\'elles soient payées ou non';
print ' (<a href="clientfourn.php?year='.$year.'&modecompta=RECETTES-DEPENSES">Voir le rapport sur les factures effectivement payées uniquement</a>).<br>'; 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 '<br>'; print '<br>';
} }
else { else {
print 'Il se base sur la date de validation des factures et n\'inclut que les factures effectivement payées'; print 'Il se base sur la date de validation des factures et n\'inclut que les factures effectivement payées';
print ' (<a href="clientfourn.php?year='.$year.'&modecompta=CREANCES-DETTES">Voir le rapport en créances-dettes qui inclut les factures non encore payée</a>).<br>'; print ' (Voir le rapport en <a href="clientfourn.php?year='.$year.'&modecompta=CREANCES-DETTES">créances-dettes</a> pour inclure les factures non encore payée).<br>';
print '<br>'; print '<br>';
} }
@ -59,13 +59,14 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="10%">&nbsp;</td><td>Elément</td>'; print '<td width="10%">&nbsp;</td><td>Elément</td>';
print "<td align=\"right\">".$langs->trans("AmountHT")."</td>"; print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>";
print "</tr>\n"; print "</tr>\n";
/* /*
* Factures clients * 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 .= " 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"; $sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
if ($year) { if ($year) {
@ -94,9 +95,11 @@ if ($result) {
print "<tr $bc[$var]><td>&nbsp</td>"; print "<tr $bc[$var]><td>&nbsp</td>";
print "<td>Factures <a href=\"../facture.php?socidp=$objp->idp\">$objp->nom</td>\n"; 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"; print "</tr>\n";
$i++; $i++;
} }
@ -105,13 +108,16 @@ if ($result) {
} else { } else {
dolibarr_print_error($db); 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. * 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 .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.idp"; $sql .= " WHERE f.fk_soc = s.idp";
if ($year) { if ($year) {
@ -123,7 +129,8 @@ if ($modecompta != 'CREANCES-DETTES') {
$sql .= " GROUP BY s.nom ASC, s.idp"; $sql .= " GROUP BY s.nom ASC, s.idp";
print '<tr><td colspan="4">Facturation fournisseurs</td></tr>'; print '<tr><td colspan="4">Facturation fournisseurs</td></tr>';
$subtotal = 0; $subtotal_ht = 0;
$subtotal_ttc = 0;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows(); $num = $db->num_rows();
@ -138,10 +145,13 @@ if ($result) {
print "<tr $bc[$var]><td>&nbsp</td>"; 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>".$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; $total_ht = $total_ht - $objp->amount_ht;
$subtotal = $subtotal + $objp->amount; $total_ttc = $total_ttc - $objp->amount_ttc;
$subtotal_ht = $subtotal_ht + $objp->amount_ht;
$subtotal_ttc = $subtotal_ttc + $objp->amount_ttc;
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
@ -150,7 +160,10 @@ if ($result) {
} else { } else {
dolibarr_print_error($db); 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 * Charges sociales
@ -174,8 +187,10 @@ if ( $db->query($sql) ) {
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object(); $obj = $db->fetch_object();
$total = $total - $obj->amount; $total_ht = $total_ht - $obj->amount;
$subtotal = $subtotal + $obj->amount; $total_ttc = $total_ttc - $obj->amount;
$subtotal_ht = $subtotal_ht + $obj->amount;
$subtotal_ttc = $subtotal_ttc + $obj->amount;
$var = !$var; $var = !$var;
print "<tr $bc[$var]><td>&nbsp</td>"; print "<tr $bc[$var]><td>&nbsp</td>";
@ -187,9 +202,15 @@ if ( $db->query($sql) ) {
} else { } else {
dolibarr_print_error($db); 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">Résultat</td><td class="border" align="right">'.price($total).'</td></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 * Charges sociales non déductibles
@ -213,22 +234,32 @@ if ( $db->query($sql) ) {
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object(); $obj = $db->fetch_object();
$total = $total - $obj->amount; $total_ht = $total_ht - $obj->amount;
$subtotal = $subtotal + $obj->amount; $total_ttc = $total_ttc - $obj->amount;
$subtotal_ht = $subtotal_ht + $obj->amount;
$subtotal_ttc = $subtotal_ttc + $obj->amount;
$var = !$var; $var = !$var;
print "<tr $bc[$var]><td>&nbsp</td>"; print "<tr $bc[$var]><td>&nbsp</td>";
print '<td>'.$obj->nom.'</td>'; print '<td>'.$obj->nom.'</td>';
print '<td align="right">'.price($obj->amount).'</td>'; print '<td align="right">'.price($obj->amount).'</td>';
print '<td align="right">'.price($obj->amount).'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
} else { } else {
dolibarr_print_error($db); 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">Résultat</td><td class="border" align="right">'.price($total).'</td></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>';
print "</table>"; print "</table>";

View File

@ -48,19 +48,19 @@ print "Ce rapport pr
if ($modecompta=="CREANCES-DETTES") if ($modecompta=="CREANCES-DETTES")
{ {
print 'Il se base sur la date de validation des factures et inclut les factures dues, qu\'elles soient payées ou non'; print 'Il se base sur la date de validation des factures et inclut les factures dues, qu\'elles soient payées ou non';
print ' (<a href="index.php?year='.$year.'&modecompta=RECETTES-DEPENSES">Voir le rapport sur les factures effectivement payées uniquement</a>).<br>'; print ' (Voir le rapport <a href="index.php?year='.$year.'&modecompta=RECETTES-DEPENSES">recettes-dépenses</a> pour n\'inclure que les factures effectivement payées).<br>';
print '<br>'; print '<br>';
} }
else { else {
print 'Il se base sur la date de validation des factures et n\'inclut que les factures effectivement payées'; print 'Il se base sur la date de validation des factures et n\'inclut que les factures effectivement payées';
print ' (<a href="index.php?year='.$year.'&modecompta=CREANCES-DETTES">Voir le rapport en créances-dettes qui inclut les factures non encore payée</a>).<br>'; print ' (Voir le rapport en <a href="index.php?year='.$year.'&modecompta=CREANCES-DETTES">créances-dettes</a> pour inclure les factures non encore payée).<br>';
print '<br>'; print '<br>';
} }
/* /*
* Factures clients * 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 .= " 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"; $sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
if ($_GET["year"]) { if ($_GET["year"]) {
@ -80,8 +80,9 @@ if ($db->query($sql))
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($i); $row = $db->fetch_object($i);
$encaiss[$row[1]] = $row[0]; $encaiss[$row->dm] = $row->amount_ht;
$encaiss_ttc[$row->dm] = $row->amount_ttc;
$i++; $i++;
} }
} }
@ -92,7 +93,7 @@ else {
/* /*
* Frais, factures fournisseurs. * 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 .= " 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"; $sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
if ($_GET["year"]) { if ($_GET["year"]) {
@ -113,8 +114,9 @@ if ($db->query($sql))
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($i); $row = $db->fetch_object($i);
$decaiss[$row[1]] = $row[0]; $decaiss[$row->dm] = $row->amount_ht;
$decaiss_ttc[$row->dm] = $row->amount_ttc;
$i++; $i++;
} }
} }