Amélioration des rapports recettes-dépenses.
This commit is contained in:
parent
6d1818c6f0
commit
80454234c2
@ -34,31 +34,46 @@ if (!$user->rights->compta->resultat->lire)
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$year=$_GET["year"];
|
$year=$_GET["year"];
|
||||||
$month=$_GET["month"];
|
|
||||||
if (! $year) { $year = strftime("%Y", time()); }
|
if (! $year) { $year = strftime("%Y", time()); }
|
||||||
|
$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("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 '<br>';
|
print '<br>';
|
||||||
|
|
||||||
print "<table class=\"noborder\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
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 ' (<a href="clientfourn.php?year='.$year.'&modecompta=RECETTES-DEPENSES">Voir le rapport sur les factures effectivement payées uniquement</a>).<br>';
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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 '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td width="10%"> </td><td>Elément</td>';
|
print '<td width="10%"> </td><td>Elément</td>';
|
||||||
print "<td align=\"right\">Montant HT</td>";
|
print "<td align=\"right\">".$langs->trans("AmountHT")."</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";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
|
$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) {
|
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 '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
|
||||||
}
|
}
|
||||||
|
if ($modecompta != 'CREANCES-DETTES') {
|
||||||
|
$sql .= " AND f.paye = 1";
|
||||||
|
}
|
||||||
$sql .= " GROUP BY s.nom ASC";
|
$sql .= " GROUP BY s.nom ASC";
|
||||||
|
|
||||||
|
|
||||||
@ -88,20 +103,23 @@ if ($result) {
|
|||||||
}
|
}
|
||||||
$db->free();
|
$db->free();
|
||||||
} else {
|
} else {
|
||||||
print $db->error();
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
print '<tr><td colspan="3" align="right">'.price($total).'</td></tr>';
|
print '<tr><td colspan="3" align="right">'.price($total).'</td></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";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f WHERE f.fk_soc = s.idp";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
|
||||||
|
$sql .= " WHERE f.fk_soc = s.idp";
|
||||||
if ($year) {
|
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 '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
|
||||||
}
|
}
|
||||||
|
if ($modecompta != 'CREANCES-DETTES') {
|
||||||
|
$sql .= " AND f.paye = 1";
|
||||||
|
}
|
||||||
$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>';
|
||||||
@ -118,7 +136,7 @@ if ($result) {
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print "<tr $bc[$var]><td> </td>";
|
print "<tr $bc[$var]><td> </td>";
|
||||||
print "<td>Factures <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)."</td>\n";
|
||||||
|
|
||||||
@ -130,13 +148,12 @@ if ($result) {
|
|||||||
}
|
}
|
||||||
$db->free();
|
$db->free();
|
||||||
} else {
|
} else {
|
||||||
print $db->error();
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
|
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Charges sociales
|
* Charges sociales
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$subtotal = 0;
|
$subtotal = 0;
|
||||||
@ -168,7 +185,7 @@ if ( $db->query($sql) ) {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print $db->error();
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
|
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
|
||||||
|
|
||||||
@ -176,7 +193,6 @@ print '<tr><td align="right" colspan="2">R
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Charges sociales non déductibles
|
* Charges sociales non déductibles
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$subtotal = 0;
|
$subtotal = 0;
|
||||||
@ -208,7 +224,7 @@ if ( $db->query($sql) ) {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print $db->error();
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
|
print '<tr><td colspan="3" align="right">'.price($subtotal).'</td></tr>';
|
||||||
|
|
||||||
|
|||||||
@ -36,25 +36,44 @@ if ($user->societe_id > 0)
|
|||||||
$socidp = $user->societe_id;
|
$socidp = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$year_current = $_GET["year"];;
|
$year_current = $_GET["year"];
|
||||||
if (! $year_current) { $year_current = strftime("%Y", time()); }
|
if (! $year_current) { $year_current = strftime("%Y", time()); }
|
||||||
|
$modecompta = $conf->compta->mode;
|
||||||
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
print_titre("Résultat comptable, résumé annuel");
|
print_titre("Résultat comptable, résumé annuel");
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
print "Ce rapport présente la balance entre les recettes et les dépenses facturées aux clients ou fournisseurs. Les dépenses de charges ne sont pas incluses.<br>\n";
|
||||||
|
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 ' (<a href="index.php?year='.$year.'&modecompta=RECETTES-DEPENSES">Voir le rapport sur les factures effectivement payées uniquement</a>).<br>';
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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 '<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, date_format(f.datef,'%Y-%m') as dm";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||||
if ($year) {
|
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
|
||||||
$sql .= " AND f.datef between '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
|
if ($_GET["year"]) {
|
||||||
|
$sql .= " AND f.datef between '".$_GET["year"]."-01-01 00:00:00' and '".$_GET["year"]."-12-31 23:59:59'";
|
||||||
}
|
}
|
||||||
if ($socidp)
|
if ($socidp)
|
||||||
{
|
{
|
||||||
$sql .= " WHERE f.fk_soc = $socidp";
|
$sql .= " AND f.fk_soc = $socidp";
|
||||||
|
}
|
||||||
|
if ($modecompta != 'CREANCES-DETTES') {
|
||||||
|
$sql .= " AND f.paye = 1";
|
||||||
}
|
}
|
||||||
$sql .= " GROUP BY dm DESC";
|
$sql .= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($db->query($sql))
|
if ($db->query($sql))
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows();
|
||||||
@ -67,18 +86,25 @@ if ($db->query($sql))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print $db->error();
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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, date_format(f.datef,'%Y-%m') as dm";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f WHERE f.fk_soc = s.idp";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
|
||||||
if ($year) {
|
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut = 1";
|
||||||
$sql .= " AND f.datef between '$year-01-01 00:00:00' and '$year-12-31 23:59:59'";
|
if ($_GET["year"]) {
|
||||||
|
$sql .= " AND f.datef between '".$_GET["year"]."-01-01 00:00:00' and '".$_GET["year"]."-12-31 23:59:59'";
|
||||||
}
|
}
|
||||||
if ($socidp)
|
if ($socidp)
|
||||||
{
|
{
|
||||||
$sql .= " AND f.fk_soc = $socidp";
|
$sql .= " AND f.fk_soc = $socidp";
|
||||||
}
|
}
|
||||||
|
if ($modecompta != 'CREANCES-DETTES') {
|
||||||
|
$sql .= " AND f.paye = 1";
|
||||||
|
}
|
||||||
$sql .= " GROUP BY dm DESC";
|
$sql .= " GROUP BY dm DESC";
|
||||||
|
|
||||||
if ($db->query($sql))
|
if ($db->query($sql))
|
||||||
@ -93,10 +119,15 @@ if ($db->query($sql))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print $db->error();
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">';
|
/*
|
||||||
|
* Charges sociales
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre"><td rowspan=2>'.$langs->trans("Month").'</td>';
|
print '<tr class="liste_titre"><td rowspan=2>'.$langs->trans("Month").'</td>';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user