New: Amélioration rapports TVA
This commit is contained in:
parent
9ba95190e2
commit
dd0eed5d03
@ -687,7 +687,7 @@ else
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>';
|
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>';
|
||||||
$monthstart=! emptpy($conf->global->SOCIETE_FISCAL_MONTH_START)? $conf->global->SOCIETE_FISCAL_MONTH_START : 1;
|
$monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1;
|
||||||
print monthArrayOrSelected($monthstart) . '</td></tr>';
|
print monthArrayOrSelected($monthstart) . '</td></tr>';
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|||||||
@ -89,7 +89,18 @@ print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description'
|
|||||||
print '<td><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
|
print '<td><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
|
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
|
||||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'))."</td></tr>\n";
|
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
|
||||||
|
// Write info on way to count VAT
|
||||||
|
print "<br>\n";
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||||
|
{
|
||||||
|
print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// print nl2br($langs->trans('OptionModeTrueInfoExpert'));
|
||||||
|
}
|
||||||
|
print "</td></tr>\n";
|
||||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
|
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
|
||||||
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
|
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
@ -170,5 +181,4 @@ $db->close();
|
|||||||
|
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -38,6 +38,7 @@ if (!$user->rights->facture->lire)
|
|||||||
|
|
||||||
$year=$_GET["year"];
|
$year=$_GET["year"];
|
||||||
if (! $year) { $year = strftime("%Y", time()); }
|
if (! $year) { $year = strftime("%Y", time()); }
|
||||||
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
$modecompta = $conf->compta->mode;
|
$modecompta = $conf->compta->mode;
|
||||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|||||||
@ -15,14 +15,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/resultat/index.php
|
\file htdocs/compta/resultat/index.php
|
||||||
\brief Page reporting resultat
|
\brief Page reporting resultat
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -48,6 +46,7 @@ if ($user->societe_id > 0)
|
|||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
$modecompta = $conf->compta->mode;
|
$modecompta = $conf->compta->mode;
|
||||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|||||||
@ -15,14 +15,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/stats/cabyuser.php
|
\file htdocs/compta/stats/cabyuser.php
|
||||||
\brief Page reporting CA par utilisateur
|
\brief Page reporting CA par utilisateur
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -31,6 +29,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
|
|||||||
|
|
||||||
$year=$_GET["year"];
|
$year=$_GET["year"];
|
||||||
if (! $year) { $year = strftime("%Y", time()); }
|
if (! $year) { $year = strftime("%Y", time()); }
|
||||||
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
$modecompta = $conf->compta->mode;
|
$modecompta = $conf->compta->mode;
|
||||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,7 @@ $langs->load("companies");
|
|||||||
|
|
||||||
$year=$_GET["year"];
|
$year=$_GET["year"];
|
||||||
if (! $year) { $year = strftime("%Y", time()); }
|
if (! $year) { $year = strftime("%Y", time()); }
|
||||||
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
$modecompta = $conf->compta->mode;
|
$modecompta = $conf->compta->mode;
|
||||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|||||||
@ -15,33 +15,30 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/stats/cumul.php
|
\file htdocs/compta/stats/cumul.php
|
||||||
\brief Page reporting compta chiffre affaire cumulé
|
\brief Page reporting compta chiffre affaire cumulé
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
|
||||||
|
// Sécurité accés client
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sécurité accés client
|
|
||||||
*/
|
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mode='recettes';
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
if ($conf->compta->mode == 'CREANCES-DETTES') { $mode='creances'; }
|
$modecompta = $conf->compta->mode;
|
||||||
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
|
||||||
print_titre("Chiffre d'affaire cumulé (".$langs->trans("Currency".$conf->monnaie)." HT)");
|
print_titre("Chiffre d'affaire cumulé (".$langs->trans("Currency".$conf->monnaie)." HT)");
|
||||||
|
|
||||||
@ -50,7 +47,7 @@ print '<table width="100%"><tr><td valign="top">';
|
|||||||
$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."facture as f";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
$sql .= " WHERE f.fk_statut in (1,2)";
|
$sql .= " WHERE f.fk_statut in (1,2)";
|
||||||
if ($conf->compta->mode != 'CREANCES-DETTES')
|
if ($modecompta != 'CREANCES-DETTES')
|
||||||
{
|
{
|
||||||
$sql .= " AND f.paye = 1";
|
$sql .= " AND f.paye = 1";
|
||||||
}
|
}
|
||||||
@ -67,7 +64,7 @@ print '</td><td valign="top">';
|
|||||||
$sql = "SELECT sum(f.total) as amount, year(f.datef) as dm";
|
$sql = "SELECT sum(f.total) as amount, year(f.datef) as dm";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
$sql .= " WHERE f.fk_statut in (1,2)";
|
$sql .= " WHERE f.fk_statut in (1,2)";
|
||||||
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
if ($modecompta != 'CREANCES-DETTES') {
|
||||||
$sql .= " AND f.paye = 1";
|
$sql .= " AND f.paye = 1";
|
||||||
}
|
}
|
||||||
if ($socid)
|
if ($socid)
|
||||||
|
|||||||
@ -15,33 +15,32 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\file htdocs/compta/stats/exercices.php
|
||||||
|
\brief Page ???
|
||||||
|
\version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require("./lib.inc.php");
|
require("./lib.inc.php");
|
||||||
|
|
||||||
/*
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
*
|
$modecompta = $conf->compta->mode;
|
||||||
*/
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
llxHeader();
|
// Sécurité accés client
|
||||||
|
|
||||||
/*
|
|
||||||
* Sécurité accés client
|
|
||||||
*/
|
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mode='recettes';
|
|
||||||
if ($conf->compta->mode == 'CREANCES-DETTES') { $mode='creances'; }
|
|
||||||
|
|
||||||
|
|
||||||
print_titre("Comparatif CA année en cours avec année précédente (".$langs->trans("Currency".$conf->monnaie)." HT, ".$mode.")");
|
llxHeader();
|
||||||
|
|
||||||
|
print_titre("Comparatif CA année en cours avec année précédente (".$langs->trans("Currency".$conf->monnaie)." HT, ".$modecompta.")");
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
@ -256,5 +255,5 @@ ppt($db, $cyear, $socid);
|
|||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
llxFooter('$Date$ révision $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -47,9 +47,11 @@ if ($user->societe_id > 0)
|
|||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
$modecompta = $conf->compta->mode;
|
$modecompta = $conf->compta->mode;
|
||||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
$html=new Form($db);
|
$html=new Form($db);
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,8 @@ function get_ca_propal ($db, $year, $socid)
|
|||||||
|
|
||||||
function get_ca ($db, $year, $socid)
|
function get_ca ($db, $year, $socid)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT sum(f.amount) as sum FROM ".MAIN_DB_PREFIX."facture as f";
|
$sql = "SELECT sum(f.amount) as sum FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
$sql .= " WHERE f.fk_statut in (1,2)";
|
$sql .= " WHERE f.fk_statut in (1,2)";
|
||||||
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org>
|
* Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -17,21 +17,21 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/tva/clients.php
|
\file htdocs/compta/tva/clients.php
|
||||||
\ingroup compta
|
\ingroup compta
|
||||||
\brief Page des societes
|
\brief Page des societes
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require("../../tva.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/tva.class.php");
|
||||||
|
|
||||||
|
$langs->load("compta");
|
||||||
|
$langs->load("companies");
|
||||||
|
|
||||||
$year=$_GET["year"];
|
$year=$_GET["year"];
|
||||||
if ($year == 0 or $year!=intval(strval($year)))
|
if ($year == 0 or $year!=intval(strval($year)))
|
||||||
@ -50,173 +50,10 @@ if($min == 0 or $min!=floatval(strval($min))){
|
|||||||
//keep min
|
//keep min
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
* Look for collectable VAT clients in the chosen year
|
$modecompta = $conf->compta->mode;
|
||||||
* @param resource Database handle
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
* @param int Year
|
|
||||||
*/
|
|
||||||
function tva_coll($db,$y)
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
|
||||||
{
|
|
||||||
// Si on paye la tva sur les factures dues (non brouillon)
|
|
||||||
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra, sum(f.total) as amount, sum(f.tva) as tva, s.tva_assuj as assuj, s.rowid as socid";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
|
||||||
$sql.= " WHERE ";
|
|
||||||
$sql.= " f.fk_statut in (1,2)";
|
|
||||||
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
|
|
||||||
$sql.= " AND s.rowid = f.fk_soc ";
|
|
||||||
$sql.= " GROUP BY s.rowid";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Si on paye la tva sur les payments
|
|
||||||
|
|
||||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
|
||||||
// n'est pas stocké dans la table des payments.
|
|
||||||
// Seul le module compta expert peut résoudre ce problème.
|
|
||||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
|
||||||
// detail part tva et part ht).
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Tva sur factures payés
|
|
||||||
$sql = "SELECT sum(f.tva) as amount";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
|
||||||
$sql.= " WHERE ";
|
|
||||||
$sql.= " f.paye = 1";
|
|
||||||
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
|
|
||||||
$sql.= " AND date_format(f.datef,'%m') = ".$m;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$list = array();
|
|
||||||
while($assoc = $db->fetch_array($resql)){
|
|
||||||
$list[] = $assoc;
|
|
||||||
}
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get payable VAT
|
|
||||||
* @param resource Database handle
|
|
||||||
* @param int Year
|
|
||||||
*/
|
|
||||||
function tva_paye($db, $y)
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
|
||||||
{
|
|
||||||
// Si on paye la tva sur les factures dues (non brouillon)
|
|
||||||
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra, sum(f.total_ht) as amount, sum(f.tva) as tva, s.tva_assuj as assuj, s.rowid as socid";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
|
|
||||||
$sql.= " WHERE ";
|
|
||||||
$sql.= " f.fk_statut in (1,2)";
|
|
||||||
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
|
|
||||||
$sql.= " AND s.rowid = f.fk_soc ";
|
|
||||||
$sql.= " GROUP BY s.rowid";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Si on paye la tva sur les payments
|
|
||||||
|
|
||||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
|
||||||
// n'est pas stocké dans la table des payments.
|
|
||||||
// Seul le module compta expert peut résoudre ce problème.
|
|
||||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
|
||||||
// detail part tva et part ht).
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
|
||||||
// n'est pas stocké dans la table des payments.
|
|
||||||
// Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
|
||||||
// detail part tva et part ht.
|
|
||||||
|
|
||||||
// Tva sur factures payés
|
|
||||||
$sql = "SELECT sum(f.total_tva) as amount";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
|
||||||
// $sql.= " WHERE ";
|
|
||||||
$sql .= " WHERE f.fk_statut in (1,2)";
|
|
||||||
// $sql.= " f.paye = 1";
|
|
||||||
$sql.= " AND date_format(f.datef,'%Y') = $y";
|
|
||||||
$sql.= " AND date_format(f.datef,'%m') = $m";
|
|
||||||
//print "xx $sql";
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$list = array();
|
|
||||||
while($assoc = $db->fetch_array($resql)){
|
|
||||||
$list[] = $assoc;
|
|
||||||
}
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print VAT tables
|
|
||||||
* @param resource Database handler
|
|
||||||
* @param string SQL query
|
|
||||||
* @param string Date
|
|
||||||
*/
|
|
||||||
function pt ($db, $sql, $date)
|
|
||||||
{
|
|
||||||
global $conf, $bc,$langs;
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
|
||||||
$i = 0;
|
|
||||||
$total = 0;
|
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
|
||||||
print "<tr class=\"liste_titre\">";
|
|
||||||
print "<td nowrap width=\"60%\">$date</td>";
|
|
||||||
print "<td align=\"right\">".$langs->trans("Amount")."</td>";
|
|
||||||
print "<td> </td>\n";
|
|
||||||
print "</tr>\n";
|
|
||||||
$var=True;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($result);
|
|
||||||
$var=!$var;
|
|
||||||
print "<tr $bc[$var]>";
|
|
||||||
print "<td nowrap>$obj->dm</td>\n";
|
|
||||||
$total = $total + $obj->amount;
|
|
||||||
|
|
||||||
print "<td nowrap align=\"right\">".price($obj->amount)."</td><td nowrap align=\"right\">".$total."</td>\n";
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
print "<tr class=\"liste_total\"><td align=\"right\">".$langs->trans("Total")." :</td><td nowrap align=\"right\"><b>".price($total)."</b></td><td> </td></tr>";
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
$db->free($result);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dolibar_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -225,61 +62,85 @@ function pt ($db, $sql, $date)
|
|||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$textprevyear="<a href=\"clients.php?year=" . ($year_current-1) . "\">".img_previous()."</a>";
|
$company_static=new Societe($db);
|
||||||
$textnextyear=" <a href=\"clients.php?year=" . ($year_current+1) . "\">".img_next()."</a>";
|
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear");
|
print_fiche_titre($langs->trans("VAT"),"");
|
||||||
|
|
||||||
echo '<form method="get" action="clients.php?year='.$year.'">';
|
$fsearch='<form method="get" action="clients.php?year='.$year.'">';
|
||||||
echo ' <input type="hidden" name="year" value="'.$year.'">';
|
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
|
||||||
echo ' <label for="min">'.$langs->trans("Minimum").': </label>';
|
$fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': ';
|
||||||
echo ' <input type="text" name="min" value="'.$min.'">';
|
$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||||
echo ' <input type="submit" name="submit" value="'.$langs->trans("Chercher").'">';
|
$fsearch.=' <input type="submit" class="button" name="submit" value="'.$langs->trans("Chercher").'">';
|
||||||
echo '</form>';
|
$fsearch.='</form>';
|
||||||
|
|
||||||
echo '<table width="100%">';
|
// Affiche en-tête du rapport
|
||||||
echo '<tr><td>';
|
if ($modecompta=="CREANCES-DETTES")
|
||||||
print_fiche_titre($langs->trans("VATSummary"));
|
{
|
||||||
//echo '</td><td>';
|
$nom=$langs->trans("ReportByCustomers");
|
||||||
//print_fiche_titre($langs->trans("VATPayed"));
|
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
|
||||||
echo '</td></tr>';
|
$period=$year_start;
|
||||||
|
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
|
||||||
|
$description=$langs->trans("VATReportDesc");
|
||||||
|
$description.=$fsearch;
|
||||||
|
$builddate=time();
|
||||||
|
$exportlink=$langs->trans("NotYetAvailable");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nom=$langs->trans("ReportByCustomers");
|
||||||
|
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
|
||||||
|
$period=$year_start;
|
||||||
|
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
|
||||||
|
$description=$langs->trans("VATReportDesc");
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.img_warning().' '.$langs->trans('OptionModeTrueInfoModuleComptabilite');
|
||||||
|
$description.=$fsearch;
|
||||||
|
$builddate=time();
|
||||||
|
$exportlink=$langs->trans("NotYetAvailable");
|
||||||
|
}
|
||||||
|
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
|
||||||
|
|
||||||
//echo '<tr><td width="50%" valign="top">';
|
|
||||||
echo '<tr>';
|
// VAT Received
|
||||||
|
|
||||||
|
print "<br>";
|
||||||
|
print_fiche_titre($langs->trans("VATReceived"));
|
||||||
|
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
print "<td align=\"right\"></td>";
|
print '<td align="left">'.$langs->trans("Num")."</td>";
|
||||||
print "<td>".$langs->trans("Name")."</td>";
|
print '<td align="left">'.$langs->trans("Company")."</td>";
|
||||||
print "<td>".$langs->trans("VATIntra")."</td>";
|
print "<td>".$langs->trans("VATIntra")."</td>";
|
||||||
print "<td align=\"right\">".$langs->trans("CA")."</td>";
|
print "<td align=\"right\">".$langs->trans("SalesTurnover")." ".$langs->trans("HT")."</td>";
|
||||||
print "<td align=\"right\">".$langs->trans("VATToPay")."</td>";
|
print "<td align=\"right\">".$langs->trans("VATReceived")."</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
$coll_list = tva_coll($db,$year_current);
|
||||||
|
if (is_array($coll_list))
|
||||||
{
|
{
|
||||||
$y = $year_current ;
|
$var=true;
|
||||||
|
|
||||||
|
|
||||||
$var=True;
|
|
||||||
$total = 0; $subtotal = 0;
|
$total = 0; $subtotal = 0;
|
||||||
$var=!$var;
|
|
||||||
$coll_list = tva_coll($db,$y);
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach($coll_list as $coll){
|
foreach($coll_list as $coll)
|
||||||
if($min == 0 or ($min>0 and $coll[2]>$min)){
|
{
|
||||||
|
if($min == 0 or ($min>0 and $coll[2]>$min))
|
||||||
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$intra = str_replace($find,$replace,$coll[1]);
|
$intra = str_replace($find,$replace,$coll[1]);
|
||||||
if(empty($intra)){
|
if(empty($intra))
|
||||||
if($coll[4] == '1'){
|
{
|
||||||
|
if($coll[4] == '1')
|
||||||
|
{
|
||||||
$intra = $langs->trans('Unknown');
|
$intra = $langs->trans('Unknown');
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$intra = $langs->trans('NotRegistered');
|
$intra = $langs->trans('NotRegistered');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print "<td nowrap>".$i."</td>";
|
print "<td nowrap>".$i."</td>";
|
||||||
print '<td nowrap><a href="../../soc.php?socid='.$coll[5].'">'.$coll[0].'</td>';
|
$company_static->id=$coll[5];
|
||||||
|
$company_static->nom=$coll[0];
|
||||||
|
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
|
||||||
$find = array(' ','.');
|
$find = array(' ','.');
|
||||||
$replace = array('','');
|
$replace = array('','');
|
||||||
print "<td nowrap>".$intra."</td>";
|
print "<td nowrap>".$intra."</td>";
|
||||||
@ -291,9 +152,75 @@ if ($conf->compta->mode == "CREANCES-DETTES")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("TotalToPay").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("TotalVATReceived").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||||
|
print '<tr><td colspan="5">'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
// VAT Payed
|
||||||
|
|
||||||
|
print "<br>";
|
||||||
|
print_fiche_titre($langs->trans("VATPayed"));
|
||||||
|
|
||||||
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
|
print "<tr class=\"liste_titre\">";
|
||||||
|
print '<td align="left">'.$langs->trans("Num")."</td>";
|
||||||
|
print '<td align="left">'.$langs->trans("Company")."</td>";
|
||||||
|
print "<td>".$langs->trans("VATIntra")."</td>";
|
||||||
|
print "<td align=\"right\">".$langs->trans("Outcome")." ".$langs->trans("HT")."</td>";
|
||||||
|
print "<td align=\"right\">".$langs->trans("VATPayed")."</td>";
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$company_static=new Societe($db);
|
||||||
|
|
||||||
|
$coll_list = tva_paye($db,$year_current);
|
||||||
|
if (is_array($coll_list))
|
||||||
|
{
|
||||||
|
$var=true;
|
||||||
|
$total = 0; $subtotal = 0;
|
||||||
|
$i = 1;
|
||||||
|
foreach($coll_list as $coll)
|
||||||
|
{
|
||||||
|
if($min == 0 or ($min>0 and $coll[2]>$min))
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
$intra = str_replace($find,$replace,$coll[1]);
|
||||||
|
if(empty($intra))
|
||||||
|
{
|
||||||
|
if($coll[4] == '1')
|
||||||
|
{
|
||||||
|
$intra = $langs->trans('Unknown');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$intra = $langs->trans('NotRegistered');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
print "<td nowrap>".$i."</td>";
|
||||||
|
$company_static->id=$coll[5];
|
||||||
|
$company_static->nom=$coll[0];
|
||||||
|
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
|
||||||
|
$find = array(' ','.');
|
||||||
|
$replace = array('','');
|
||||||
|
print "<td nowrap>".$intra."</td>";
|
||||||
|
print "<td nowrap align=\"right\">".price($coll[2])."</td>";
|
||||||
|
print "<td nowrap align=\"right\">".price($coll[3])."</td>";
|
||||||
|
$total = $total + $coll[3];
|
||||||
|
print "</tr>\n";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("TotalVATReceived").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||||
|
print '</tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -303,29 +230,165 @@ else
|
|||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
//echo '</td><td valign="top" width="50%">';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Réglée
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
$sql = "SELECT amount, date_format(f.datev,'%Y-%m') as dm";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f WHERE f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' ";
|
|
||||||
$sql .= " GROUP BY dm DESC";
|
|
||||||
|
|
||||||
pt($db, $sql,$langs->trans("Year")." $y");
|
|
||||||
|
|
||||||
|
|
||||||
print "</td></tr></table>";
|
|
||||||
*/
|
|
||||||
echo '</td></tr>';
|
|
||||||
echo '</table>';
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Look for collectable VAT clients in the chosen year
|
||||||
|
* \param db Database handle
|
||||||
|
* \param y Year
|
||||||
|
* \return array Liste of third parties
|
||||||
|
*/
|
||||||
|
function tva_coll($db,$y)
|
||||||
|
{
|
||||||
|
global $conf, $modecompta;
|
||||||
|
|
||||||
|
// Define sql request
|
||||||
|
$sql='';
|
||||||
|
if ($modecompta == "CREANCES-DETTES")
|
||||||
|
{
|
||||||
|
// If vat payed on due invoices (non draft)
|
||||||
|
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,";
|
||||||
|
$sql.= " sum(f.total) as amount, sum(f.tva) as tva,";
|
||||||
|
$sql.= " s.tva_assuj as assuj, s.rowid as socid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql.= " WHERE ";
|
||||||
|
$sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely)
|
||||||
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
|
$sql.= " AND s.rowid = f.fk_soc";
|
||||||
|
$sql.= " GROUP BY s.rowid";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If vat payed on payments
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT)
|
||||||
|
{
|
||||||
|
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||||
|
// n'est pas stocké dans la table des payments.
|
||||||
|
// Seul le module compta expert peut résoudre ce problème.
|
||||||
|
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||||
|
// detail part tva et part ht).
|
||||||
|
}
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||||
|
{
|
||||||
|
// Tva sur factures payés (should be on payment)
|
||||||
|
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,";
|
||||||
|
$sql.= " sum(f.total) as amount, sum(f.tva) as tva,";
|
||||||
|
$sql.= " s.tva_assuj as assuj, s.rowid as socid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql.= " WHERE ";
|
||||||
|
$sql.= " f.fk_statut in (2)"; // Payed (partially or completely)
|
||||||
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
|
$sql.= " AND s.rowid = f.fk_soc";
|
||||||
|
$sql.= " GROUP BY s.rowid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sql)
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Client::tva_coll sql=".$sql);
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
while($assoc = $db->fetch_array($resql))
|
||||||
|
{
|
||||||
|
$list[] = $assoc;
|
||||||
|
}
|
||||||
|
$db->free();
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get payable VAT
|
||||||
|
* @param resource Database handle
|
||||||
|
* @param int Year
|
||||||
|
*/
|
||||||
|
function tva_paye($db, $y)
|
||||||
|
{
|
||||||
|
global $conf, $modecompta;
|
||||||
|
|
||||||
|
// Define sql request
|
||||||
|
$sql='';
|
||||||
|
if ($modecompta == "CREANCES-DETTES")
|
||||||
|
{
|
||||||
|
// Si on paye la tva sur les factures dues (non brouillon)
|
||||||
|
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,";
|
||||||
|
$sql.= " sum(f.total_ht) as amount, sum(f.total_tva) as tva,";
|
||||||
|
$sql.= " s.tva_assuj as assuj, s.rowid as socid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql.= " WHERE ";
|
||||||
|
$sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely)
|
||||||
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
|
$sql.= " AND s.rowid = f.fk_soc ";
|
||||||
|
$sql.= " GROUP BY s.rowid";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Si on paye la tva sur les payments
|
||||||
|
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT)
|
||||||
|
{
|
||||||
|
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||||
|
// n'est pas stocké dans la table des payments.
|
||||||
|
// Seul le module compta expert peut résoudre ce problème.
|
||||||
|
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||||
|
// detail part tva et part ht).
|
||||||
|
}
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||||
|
{
|
||||||
|
// Tva sur factures payés
|
||||||
|
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,";
|
||||||
|
$sql.= " sum(f.total_ht) as amount, sum(f.total_tva) as tva,";
|
||||||
|
$sql.= " s.tva_assuj as assuj, s.rowid as socid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql.= " WHERE ";
|
||||||
|
//$sql.= " f.fk_statut in (2)"; // Payed (partially or completely)
|
||||||
|
$sql.= " f.paye in (1)"; // Payed (completely)
|
||||||
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
|
$sql.= " AND s.rowid = f.fk_soc ";
|
||||||
|
$sql.= " GROUP BY s.rowid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sql)
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Client::tva_paye sql=".$sql);
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
while($assoc = $db->fetch_array($resql))
|
||||||
|
{
|
||||||
|
$list[] = $assoc;
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -15,14 +15,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/tva/fiche.php
|
\file htdocs/compta/tva/fiche.php
|
||||||
|
\ingroup tax
|
||||||
\brief Page des règlements de TVA
|
\brief Page des règlements de TVA
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/tva/index.php
|
\file htdocs/compta/tva/index.php
|
||||||
\ingroup compta
|
\ingroup tax
|
||||||
\brief Page des societes
|
\brief Page des societes
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -15,11 +15,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../../main.inc.php");
|
require("../../main.inc.php");
|
||||||
|
|
||||||
function llxHeader($head = "") {
|
function llxHeader($head = "") {
|
||||||
|
|||||||
@ -17,18 +17,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/tva/quadri.php
|
\file htdocs/compta/tva/quadri.php
|
||||||
\ingroup compta
|
\ingroup tax
|
||||||
\brief Trimestrial page
|
\brief Trimestrial page
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
@todo deal with recurrent invoices as well
|
\todo Deal with recurrent invoices as well
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -17,23 +17,23 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/tva/quadri_detail.php
|
\file htdocs/compta/tva/quadri_detail.php
|
||||||
\ingroup compta
|
\ingroup tax
|
||||||
\brief Trimestrial page - detailed version
|
\brief Trimestrial page - detailed version
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
@todo deal with recurrent invoices as well
|
\todo Deal with recurrent invoices as well
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require("../../tva.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/report.inc.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/tva.class.php");
|
||||||
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
$langs->load("compta");
|
||||||
|
$langs->load("companies");
|
||||||
|
|
||||||
$year=$_GET["year"];
|
$year=$_GET["year"];
|
||||||
if ($year == 0 )
|
if ($year == 0 )
|
||||||
@ -45,6 +45,218 @@ if ($year == 0 )
|
|||||||
$year_start = $year;
|
$year_start = $year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||||
|
$modecompta = $conf->compta->mode;
|
||||||
|
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affichage page
|
||||||
|
*/
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
$company_static=new Societe($db);
|
||||||
|
|
||||||
|
print_fiche_titre($langs->trans("VAT"),"");
|
||||||
|
|
||||||
|
// Affiche en-tête du rapport
|
||||||
|
if ($modecompta=="CREANCES-DETTES")
|
||||||
|
{
|
||||||
|
$nom=$langs->trans("ReportByQuarter");
|
||||||
|
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
|
||||||
|
$period=$year_start;
|
||||||
|
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
|
||||||
|
$description=$langs->trans("VATReportDesc");
|
||||||
|
$description.=$fsearch;
|
||||||
|
$builddate=time();
|
||||||
|
$exportlink=$langs->trans("NotYetAvailable");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nom=$langs->trans("ReportByQuarter");
|
||||||
|
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
|
||||||
|
$period=$year_start;
|
||||||
|
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
|
||||||
|
$description=$langs->trans("VATReportDesc");
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.img_warning().' '.$langs->trans('OptionModeTrueInfoModuleComptabilite');
|
||||||
|
$description.=$fsearch;
|
||||||
|
$builddate=time();
|
||||||
|
$exportlink=$langs->trans("NotYetAvailable");
|
||||||
|
}
|
||||||
|
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
|
||||||
|
|
||||||
|
|
||||||
|
// VAT Received and payed
|
||||||
|
|
||||||
|
echo '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
|
$y = $year_current;
|
||||||
|
for ($q = 1 ; $q <= 4 ; $q++ )
|
||||||
|
{
|
||||||
|
$total = 0; $subtotal = 0;
|
||||||
|
$i=0;
|
||||||
|
$subtot_coll_total = 0;
|
||||||
|
$subtot_coll_vat = 0;
|
||||||
|
$subtot_paye_total = 0;
|
||||||
|
$subtot_paye_vat = 0;
|
||||||
|
$var=true;
|
||||||
|
$x_coll = tva_coll($db, $y, $q);
|
||||||
|
$x_paye = tva_paye($db, $y, $q);
|
||||||
|
|
||||||
|
if (! is_array($x_coll))
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||||
|
print '<tr><td colspan="5">'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'</td></tr>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$x_both = array();
|
||||||
|
//now, from these two arrays, get another array with one rate per line
|
||||||
|
foreach(array_keys($x_coll) as $my_coll_rate){
|
||||||
|
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
|
||||||
|
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
|
||||||
|
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
|
||||||
|
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
||||||
|
$x_both[$my_coll_rate]['coll']['links'] = '';
|
||||||
|
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
||||||
|
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy){
|
||||||
|
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
||||||
|
'id'=>$x_coll[$my_coll_rate]['facid'][$id],
|
||||||
|
'descr'=>$x_coll[$my_coll_rate]['descr'][$id],
|
||||||
|
'link'=>'<a href="../facture.php?facid='.$x_coll[$my_coll_rate]['facid'][$id].'" title="'.$langs->trans("Invoice").' '.$x_coll[$my_coll_rate]['facnum'][$id].'">'.$x_coll[$my_coll_rate]['facnum'][$id].'</a> ',
|
||||||
|
'totalht'=>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||||
|
'vat'=>$x_coll[$my_coll_rate]['vat_list'][$id]);
|
||||||
|
//$x_both[$my_coll_rate]['coll']['links'] .= '<a href="../facture.php?facid='.$x_coll[$my_coll_rate]['facid'][$id].'" title="'.$x_coll[$my_coll_rate]['facnum'][$id].'">..'.substr($x_coll[$my_coll_rate]['facnum'][$id],-2).'</a> ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// tva payed
|
||||||
|
foreach(array_keys($x_paye) as $my_paye_rate){
|
||||||
|
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
||||||
|
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
||||||
|
if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){
|
||||||
|
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
||||||
|
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
||||||
|
}
|
||||||
|
$x_both[$my_paye_rate]['paye']['links'] = '';
|
||||||
|
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
||||||
|
foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy){
|
||||||
|
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
||||||
|
'id'=>$x_paye[$my_paye_rate]['facid'][$id],
|
||||||
|
'descr'=>$x_paye[$my_paye_rate]['descr'][$id],
|
||||||
|
'link'=>'<a href="../../fourn/facture/fiche.php?facid='.$x_paye[$my_paye_rate]['facid'][$id].'" title="'.$langs->trans("Invoice").' '.$x_paye[$my_paye_rate]['facnum'][$id].'">'.$x_paye[$my_paye_rate]['facnum'][$id].'</a> ',
|
||||||
|
'totalht'=>$x_paye[$my_paye_rate]['totalht_list'][$id],
|
||||||
|
'vat'=>$x_paye[$my_paye_rate]['vat_list'][$id]);
|
||||||
|
//$x_both[$my_paye_rate]['paye']['links'] .= '<a href="../../fourn/facture/fiche.php?facid='.$x_paye[$my_paye_rate]['facid'][$id].'" title="'.$x_paye[$my_paye_rate]['facnum'][$id].'">..'.substr($x_paye[$my_paye_rate]['facnum'][$id],-2).'</a> ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//now we have an array (x_both) indexed by rates for coll and paye
|
||||||
|
|
||||||
|
//print table headers for this quadri - incomes first
|
||||||
|
//imprime les en-tete de tables pour ce quadri - d'abord les revenus
|
||||||
|
|
||||||
|
$x_coll_sum = 0;
|
||||||
|
$x_coll_ht = 0;
|
||||||
|
$x_paye_sum = 0;
|
||||||
|
$x_paye_ht = 0;
|
||||||
|
|
||||||
|
print '<tr><td colspan="4">'.$langs->trans("Quadri")." $q (".strftime("%b %Y",dolibarr_mktime(0,0,0,(($q-1)*3)+1,1,$y)).' - '.strftime("%b %Y",mktime(0,0,0,($q*3),1,$y)).')</td></tr>';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td align="left">'.$langs->trans("CustomersInvoices").'</td>';
|
||||||
|
print '<td align="left"> '.$langs->trans("Description").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Income").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("VATToPay").'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
//foreach($x_both as $rate => $both){
|
||||||
|
foreach(array_keys($x_coll) as $rate){
|
||||||
|
$var=!$var;
|
||||||
|
if(is_array($x_both[$rate]['coll']['detail'])){
|
||||||
|
print "<tr>";
|
||||||
|
print '<td class="tax_rate">'.$langs->trans("Rate").': '.$rate.'%</td><td colspan="3"></td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
foreach($x_both[$rate]['coll']['detail'] as $index=>$fields){
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td nowrap align="left">'.$fields['link'].'</td>';
|
||||||
|
print '<td align="left">'.$fields['descr'].'</td>';
|
||||||
|
print '<td nowrap align="right">'.price($fields['totalht']).'</td>';
|
||||||
|
print '<td nowrap align="right">'.price($fields['vat']).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$x_coll_sum += $x_both[$rate]['coll']['vat'];
|
||||||
|
$subtot_coll_total += $x_both[$rate]['coll']['totalht'];
|
||||||
|
$subtot_coll_vat += $x_both[$rate]['coll']['vat'];
|
||||||
|
}
|
||||||
|
print '<tr class="liste_total">' .
|
||||||
|
'<td></td>' .
|
||||||
|
'<td align="right">'.$langs->trans("Total").':</td>' .
|
||||||
|
'<td nowrap align="right">'.price($subtot_coll_total).'</td>' .
|
||||||
|
'<td nowrap align="right">'.price($subtot_coll_vat).'</td>' .
|
||||||
|
'</tr>' ;
|
||||||
|
|
||||||
|
//print table headers for this quadri - expenses now
|
||||||
|
//imprime les en-tete de tables pour ce quadri - maintenant les dépenses
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td align="left">'.$langs->trans("SuppliersInvoices").'</td>';
|
||||||
|
print '<td align="left">'.$langs->trans("Description").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Outcome").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("VATToCollect").'</td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
foreach(array_keys($x_paye) as $rate){
|
||||||
|
$var=!$var;
|
||||||
|
if(is_array($x_both[$rate]['paye']['detail']))
|
||||||
|
{
|
||||||
|
print "<tr>";
|
||||||
|
print '<td class="tax_rate">'.$langs->trans("Rate").': '.$rate.'%</td><td colspan="3"></td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields){
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td nowrap align="left">'.$fields['link'].'</td>';
|
||||||
|
print '<td align="left">'.$fields['descr'].'</td>';
|
||||||
|
print '<td nowrap align="right">'.price($fields['totalht']).'</td>';
|
||||||
|
print '<td nowrap align="right">'.price($fields['vat']).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$x_paye_sum += $x_both[$rate]['paye']['vat'];
|
||||||
|
$subtot_paye_total += $x_both[$rate]['paye']['totalht'];
|
||||||
|
$subtot_paye_vat += $x_both[$rate]['paye']['vat'];
|
||||||
|
}
|
||||||
|
print '<tr class="liste_total">' .
|
||||||
|
'<td></td>' .
|
||||||
|
'<td align="right">'.$langs->trans("Total").':</td>' .
|
||||||
|
'<td nowrap align="right">'.price($subtot_paye_total).'</td>' .
|
||||||
|
'<td nowrap align="right">'.price($subtot_paye_vat).'</td>' .
|
||||||
|
'</tr>';
|
||||||
|
|
||||||
|
print '<tr>';
|
||||||
|
print '<td colspan="3"></td><td align="right">'.$langs->trans("TotalToPay").' - '.$langs->trans("Quadri").$q.'</td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
$diff = $x_coll_sum - $x_paye_sum;
|
||||||
|
//$total = $total + $diff;
|
||||||
|
//$subtotal = $subtotal + $diff;
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td colspan="3"></td>';
|
||||||
|
//print '<td nowrap align="right"><b>'.price($total).'</b></td>' .
|
||||||
|
print '<td nowrap align="right"><b>'.price($diff)."</b></td>\n";
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
print '</tr><tr><td colspan="4"> </td></tr>'."\n";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,54 +271,85 @@ if ($year == 0 )
|
|||||||
*/
|
*/
|
||||||
function tva_coll($db,$y,$q)
|
function tva_coll($db,$y,$q)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $modecompta;
|
||||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
|
||||||
|
// Define sql request
|
||||||
|
$sql='';
|
||||||
|
if ($modecompta == "CREANCES-DETTES")
|
||||||
{
|
{
|
||||||
// if vat payed on due invoices
|
// If vat payed on due invoices (non draft)
|
||||||
$sql = "SELECT d.fk_facture as facid, f.facnumber as facnum, d.tva_taux as rate, d.total_ht as totalht, d.total_tva as amount, d.description as descr";
|
$sql = "SELECT d.rowid, d.fk_facture as facid, f.facnumber as facnum, d.tva_taux as rate, d.total_ht as totalht, d.total_tva as amount, d.description as descr";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||||
$sql.= MAIN_DB_PREFIX."facturedet as d " ;
|
$sql.= " ".MAIN_DB_PREFIX."facturedet as d" ;
|
||||||
$sql.= " WHERE ";
|
$sql.= " WHERE ";
|
||||||
$sql.= " f.fk_statut in (1,2) ";
|
$sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely)
|
||||||
$sql.= " AND f.rowid = d.fk_facture ";
|
$sql.= " AND f.rowid = d.fk_facture";
|
||||||
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||||
$sql.= " ORDER BY rate, facid";
|
$sql.= " ORDER BY rate, facid, d.rowid";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if vat payed on paiments
|
// If vat payed on payments
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT)
|
||||||
|
{
|
||||||
|
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||||
|
// n'est pas stocké dans la table des payments.
|
||||||
|
// Seul le module compta expert peut résoudre ce problème.
|
||||||
|
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||||
|
// detail part tva et part ht).
|
||||||
|
}
|
||||||
|
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||||
|
{
|
||||||
|
// Tva sur factures payés (should be on payment)
|
||||||
|
$sql = "SELECT d.rowid, d.fk_facture as facid, f.facnumber as facnum, d.tva_taux as rate, d.total_ht as totalht, d.total_tva as amount, d.description as descr";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX."facturedet as d" ;
|
||||||
|
$sql.= " WHERE ";
|
||||||
|
$sql.= " f.fk_statut in (2)"; // Payed (partially or completely)
|
||||||
|
$sql.= " AND f.rowid = d.fk_facture";
|
||||||
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
|
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||||
|
$sql.= " ORDER BY d.rowid, rate, facid";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
if ($sql)
|
||||||
|
{
|
||||||
if ($resql)
|
dolibarr_syslog("Client::tva_coll sql=".$sql);
|
||||||
{
|
$resql = $db->query($sql);
|
||||||
$list = array();
|
if ($resql)
|
||||||
$rate = -1;
|
{
|
||||||
while($assoc = $db->fetch_array($resql))
|
$list = array();
|
||||||
{
|
$rate = -1;
|
||||||
if($assoc['rate'] != $rate){ //new rate
|
while($assoc = $db->fetch_array($resql))
|
||||||
$list[$assoc['rate']]['totalht'] = $assoc['totalht'];
|
{
|
||||||
$list[$assoc['rate']]['vat'] = $assoc['amount'];
|
if($assoc['rate'] != $rate){ //new rate
|
||||||
}else{
|
$list[$assoc['rate']]['totalht'] = $assoc['totalht'];
|
||||||
$list[$assoc['rate']]['totalht'] += $assoc['totalht'];
|
$list[$assoc['rate']]['vat'] = $assoc['amount'];
|
||||||
$list[$assoc['rate']]['vat'] += $assoc['amount'];
|
}else{
|
||||||
}
|
$list[$assoc['rate']]['totalht'] += $assoc['totalht'];
|
||||||
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
|
$list[$assoc['rate']]['vat'] += $assoc['amount'];
|
||||||
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
|
}
|
||||||
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
|
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
|
||||||
$list[$assoc['rate']]['totalht_list'][] = $assoc['totalht'];
|
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
|
||||||
$list[$assoc['rate']]['vat_list'][] = $assoc['amount'];
|
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
|
||||||
$rate = $assoc['rate'];
|
$list[$assoc['rate']]['totalht_list'][] = $assoc['totalht'];
|
||||||
}
|
$list[$assoc['rate']]['vat_list'][] = $assoc['amount'];
|
||||||
return $list;
|
$rate = $assoc['rate'];
|
||||||
}
|
}
|
||||||
else
|
return $list;
|
||||||
{
|
}
|
||||||
dolibarr_print_error($db);
|
else
|
||||||
}
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -121,235 +364,88 @@ function tva_coll($db,$y,$q)
|
|||||||
*/
|
*/
|
||||||
function tva_paye($db, $y,$q)
|
function tva_paye($db, $y,$q)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $modecompta;
|
||||||
|
|
||||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
// Define sql request
|
||||||
|
$sql='';
|
||||||
|
if ($modecompta == "CREANCES-DETTES")
|
||||||
{
|
{
|
||||||
// Si on paye la tva sur les factures dues (non brouillon)
|
// Si on paye la tva sur les factures dues (non brouillon)
|
||||||
$sql = "SELECT d.fk_facture_fourn as facid, f.facnumber as facnum, d.tva_taux as rate, d.total_ht as totalht, d.tva as amount, d.description as descr ";
|
$sql = "SELECT d.rowid, d.fk_facture_fourn as facid, f.facnumber as facnum, d.tva_taux as rate, d.total_ht as totalht, d.tva as amount, d.description as descr ";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ";
|
||||||
$sql.= MAIN_DB_PREFIX."facture_fourn_det as d " ;
|
$sql.= " ".MAIN_DB_PREFIX."facture_fourn_det as d " ;
|
||||||
$sql.= " WHERE ";
|
$sql.= " WHERE ";
|
||||||
$sql.= " f.fk_statut in (1,2) ";
|
$sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely)
|
||||||
$sql.= " AND f.rowid = d.fk_facture_fourn ";
|
$sql.= " AND f.rowid = d.fk_facture_fourn ";
|
||||||
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||||
$sql.= " ORDER BY rate, facid ";
|
$sql.= " ORDER BY d.rowid, rate, facid ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si on paye la tva sur les payments
|
// Si on paye la tva sur les payments
|
||||||
}
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT)
|
||||||
if ($resql)
|
{
|
||||||
{
|
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||||
$list = array();
|
// n'est pas stocké dans la table des payments.
|
||||||
$rate = -1;
|
// Seul le module compta expert peut résoudre ce problème.
|
||||||
while($assoc = $db->fetch_array($resql))
|
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||||
{
|
// detail part tva et part ht).
|
||||||
if($assoc['rate'] != $rate){ //new rate
|
|
||||||
$list[$assoc['rate']]['totalht'] = $assoc['totalht'];
|
|
||||||
$list[$assoc['rate']]['vat'] = $assoc['amount'];
|
|
||||||
}else{
|
|
||||||
$list[$assoc['rate']]['totalht'] += $assoc['totalht'];
|
|
||||||
$list[$assoc['rate']]['vat'] += $assoc['amount'];
|
|
||||||
}
|
|
||||||
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
|
|
||||||
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
|
|
||||||
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
|
|
||||||
$list[$assoc['rate']]['totalht_list'][] = $assoc['totalht'];
|
|
||||||
$list[$assoc['rate']]['vat_list'][] = $assoc['amount'];
|
|
||||||
$rate = $assoc['rate'];
|
|
||||||
}
|
|
||||||
return $list;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main script
|
|
||||||
*/
|
|
||||||
|
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
$textprevyear="<a href=\"quadri_detail.php?year=" . ($year_current-1) . "\">".img_previous()."</a>";
|
|
||||||
$textnextyear=" <a href=\"quadri_detail.php?year=" . ($year_current+1) . "\">".img_next()."</a>";
|
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear");
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
echo '<table class="noborder" width="100%">';
|
|
||||||
|
|
||||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
|
||||||
{
|
|
||||||
$y = $year_current ;
|
|
||||||
|
|
||||||
|
|
||||||
for ($q = 1 ; $q <= 4 ; $q++ )
|
|
||||||
{
|
|
||||||
$total = 0; $subtotal = 0;
|
|
||||||
$i=0;
|
|
||||||
$subtot_coll_total = 0;
|
|
||||||
$subtot_coll_vat = 0;
|
|
||||||
$subtot_paye_total = 0;
|
|
||||||
$subtot_paye_vat = 0;
|
|
||||||
$var=true;
|
|
||||||
$x_coll = tva_coll($db, $y, $q);
|
|
||||||
$x_paye = tva_paye($db, $y, $q);
|
|
||||||
$x_both = array();
|
|
||||||
//now, from these two arrays, get another array with one rate per line
|
|
||||||
foreach(array_keys($x_coll) as $my_coll_rate){
|
|
||||||
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
|
|
||||||
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
|
|
||||||
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
|
|
||||||
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
|
||||||
$x_both[$my_coll_rate]['coll']['links'] = '';
|
|
||||||
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
|
||||||
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy){
|
|
||||||
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
|
||||||
'id'=>$x_coll[$my_coll_rate]['facid'][$id],
|
|
||||||
'descr'=>$x_coll[$my_coll_rate]['descr'][$id],
|
|
||||||
'link'=>'<a href="../facture.php?facid='.$x_coll[$my_coll_rate]['facid'][$id].'" title="'.$langs->trans("Invoice").' '.$x_coll[$my_coll_rate]['facnum'][$id].'">'.$x_coll[$my_coll_rate]['facnum'][$id].'</a> ',
|
|
||||||
'totalht'=>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
|
||||||
'vat'=>$x_coll[$my_coll_rate]['vat_list'][$id]);
|
|
||||||
//$x_both[$my_coll_rate]['coll']['links'] .= '<a href="../facture.php?facid='.$x_coll[$my_coll_rate]['facid'][$id].'" title="'.$x_coll[$my_coll_rate]['facnum'][$id].'">..'.substr($x_coll[$my_coll_rate]['facnum'][$id],-2).'</a> ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// tva payed
|
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||||
foreach(array_keys($x_paye) as $my_paye_rate){
|
{
|
||||||
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
// Tva sur factures payés
|
||||||
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
$sql = "SELECT d.rowid, d.fk_facture_fourn as facid, f.facnumber as facnum, d.tva_taux as rate, d.total_ht as totalht, d.tva as amount, d.description as descr ";
|
||||||
if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ";
|
||||||
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
$sql.= " ".MAIN_DB_PREFIX."facture_fourn_det as d " ;
|
||||||
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
$sql.= " WHERE ";
|
||||||
}
|
//$sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely)
|
||||||
$x_both[$my_paye_rate]['paye']['links'] = '';
|
$sql.= " f.paye in (1)"; // Payed (completely)
|
||||||
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
$sql.= " AND f.rowid = d.fk_facture_fourn ";
|
||||||
foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy){
|
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||||
'id'=>$x_paye[$my_paye_rate]['facid'][$id],
|
$sql.= " ORDER BY d.rowid, rate, facid ";
|
||||||
'descr'=>$x_paye[$my_paye_rate]['descr'][$id],
|
|
||||||
'link'=>'<a href="../../fourn/facture/fiche.php?facid='.$x_paye[$my_paye_rate]['facid'][$id].'" title="'.$langs->trans("Invoice").' '.$x_paye[$my_paye_rate]['facnum'][$id].'">'.$x_paye[$my_paye_rate]['facnum'][$id].'</a> ',
|
|
||||||
'totalht'=>$x_paye[$my_paye_rate]['totalht_list'][$id],
|
|
||||||
'vat'=>$x_paye[$my_paye_rate]['vat_list'][$id]);
|
|
||||||
//$x_both[$my_paye_rate]['paye']['links'] .= '<a href="../../fourn/facture/fiche.php?facid='.$x_paye[$my_paye_rate]['facid'][$id].'" title="'.$x_paye[$my_paye_rate]['facnum'][$id].'">..'.substr($x_paye[$my_paye_rate]['facnum'][$id],-2).'</a> ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//now we have an array (x_both) indexed by rates for coll and paye
|
|
||||||
|
|
||||||
//print table headers for this quadri - incomes first
|
|
||||||
//imprime les en-tete de tables pour ce quadri - d'abord les revenus
|
|
||||||
|
|
||||||
$x_coll_sum = 0;
|
|
||||||
$x_coll_ht = 0;
|
|
||||||
$x_paye_sum = 0;
|
|
||||||
$x_paye_ht = 0;
|
|
||||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Quadri")." $q (".strftime("%b %Y",dolibarr_mktime(0,0,0,(($q-1)*3)+1,1,$y)).' - '.strftime("%b %Y",mktime(0,0,0,($q*3),1,$y)).')</td></tr>';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td align="left">'.$langs->trans("CustomersInvoices").'</td>';
|
|
||||||
print '<td align="left"> '.$langs->trans("Description").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Income").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("VATToPay").'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
//foreach($x_both as $rate => $both){
|
|
||||||
foreach(array_keys($x_coll) as $rate){
|
|
||||||
$var=!$var;
|
|
||||||
if(is_array($x_both[$rate]['coll']['detail'])){
|
|
||||||
print "<tr>";
|
|
||||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.$rate.'%</td><td colspan="3"></td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
foreach($x_both[$rate]['coll']['detail'] as $index=>$fields){
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td nowrap align="left">'.$fields['link'].'</td>';
|
|
||||||
print '<td align="left">'.$fields['descr'].'</td>';
|
|
||||||
print '<td nowrap align="right">'.price($fields['totalht']).'</td>';
|
|
||||||
print '<td nowrap align="right">'.price($fields['vat']).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$x_coll_sum += $x_both[$rate]['coll']['vat'];
|
|
||||||
$subtot_coll_total += $x_both[$rate]['coll']['totalht'];
|
|
||||||
$subtot_coll_vat += $x_both[$rate]['coll']['vat'];
|
|
||||||
}
|
|
||||||
print '<tr class="liste_total">' .
|
|
||||||
'<td></td>' .
|
|
||||||
'<td align="right">'.$langs->trans("Total").':</td>' .
|
|
||||||
'<td nowrap align="right">'.price($subtot_coll_total).'</td>' .
|
|
||||||
'<td nowrap align="right">'.price($subtot_coll_vat).'</td>' .
|
|
||||||
'</tr>' ;
|
|
||||||
|
|
||||||
//print table headers for this quadri - expenses now
|
|
||||||
//imprime les en-tete de tables pour ce quadri - maintenant les dépenses
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td align="left">'.$langs->trans("SuppliersInvoices").'</td>';
|
|
||||||
print '<td align="left">'.$langs->trans("Description").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Outcome").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("VATToCollect").'</td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
foreach(array_keys($x_paye) as $rate){
|
|
||||||
$var=!$var;
|
|
||||||
if(is_array($x_both[$rate]['paye']['detail']))
|
|
||||||
{
|
|
||||||
print "<tr>";
|
|
||||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.$rate.'%</td><td colspan="3"></td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields){
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td nowrap align="left">'.$fields['link'].'</td>';
|
|
||||||
print '<td align="left">'.$fields['descr'].'</td>';
|
|
||||||
print '<td nowrap align="right">'.price($fields['totalht']).'</td>';
|
|
||||||
print '<td nowrap align="right">'.price($fields['vat']).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$x_paye_sum += $x_both[$rate]['paye']['vat'];
|
|
||||||
$subtot_paye_total += $x_both[$rate]['paye']['totalht'];
|
|
||||||
$subtot_paye_vat += $x_both[$rate]['paye']['vat'];
|
|
||||||
}
|
|
||||||
print '<tr class="liste_total">' .
|
|
||||||
'<td></td>' .
|
|
||||||
'<td align="right">'.$langs->trans("Total").':</td>' .
|
|
||||||
'<td nowrap align="right">'.price($subtot_paye_total).'</td>' .
|
|
||||||
'<td nowrap align="right">'.price($subtot_paye_vat).'</td>' .
|
|
||||||
'</tr>';
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td colspan="3"></td><td align="right">'.$langs->trans("TotalToPay").' - '.$langs->trans("Quadri").$q.'</td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
|
|
||||||
$diff = $x_coll_sum - $x_paye_sum;
|
|
||||||
//$total = $total + $diff;
|
|
||||||
//$subtotal = $subtotal + $diff;
|
|
||||||
|
|
||||||
print "<tr>";
|
|
||||||
print '<td colspan="3"></td>';
|
|
||||||
//print '<td nowrap align="right"><b>'.price($total).'</b></td>' .
|
|
||||||
print '<td nowrap align="right"><b>'.price($diff)."</b></td>\n";
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '</tr><tr><td colspan="4"> </td></tr>'."\n";
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if ($sql)
|
||||||
else
|
{
|
||||||
{
|
dolibarr_syslog("Client::tva_paye sql=".$sql);
|
||||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
$resql = $db->query($sql);
|
||||||
print '<tr><td colspan="5">'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'</td></tr>';
|
if ($resql)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
$rate = -1;
|
||||||
|
while($assoc = $db->fetch_array($resql))
|
||||||
|
{
|
||||||
|
if($assoc['rate'] != $rate){ //new rate
|
||||||
|
$list[$assoc['rate']]['totalht'] = $assoc['totalht'];
|
||||||
|
$list[$assoc['rate']]['vat'] = $assoc['amount'];
|
||||||
|
}else{
|
||||||
|
$list[$assoc['rate']]['totalht'] += $assoc['totalht'];
|
||||||
|
$list[$assoc['rate']]['vat'] += $assoc['amount'];
|
||||||
|
}
|
||||||
|
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
|
||||||
|
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
|
||||||
|
$list[$assoc['rate']]['descr'][] = $assoc['descr'];
|
||||||
|
$list[$assoc['rate']]['totalht_list'][] = $assoc['totalht'];
|
||||||
|
$list[$assoc['rate']]['vat_list'][] = $assoc['amount'];
|
||||||
|
$rate = $assoc['rate'];
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/compta/tva/reglement.php
|
\file htdocs/compta/tva/reglement.php
|
||||||
|
\ingroup tax
|
||||||
\brief Liste des règlements de TVA effectués
|
\brief Liste des règlements de TVA effectués
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -380,15 +380,16 @@ class Conf
|
|||||||
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR';
|
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR';
|
||||||
$this->monnaie=$this->global->MAIN_MONNAIE;
|
$this->monnaie=$this->global->MAIN_MONNAIE;
|
||||||
|
|
||||||
// $this->compta->mode = Option du module Compta: Defini le mode de calcul des etats comptables (CA,...)
|
// $this->compta->mode = Option du module Comptabilite (simple ou expert):
|
||||||
$this->compta->mode = 'RECETTES-DEPENSES'; // Par defaut
|
// Defini le mode de calcul des etats comptables (CA,...)
|
||||||
if (defined('COMPTA_MODE') && COMPTA_MODE) {
|
$this->compta->mode = 'RECETTES-DEPENSES'; // By default
|
||||||
|
if (isset($this->global->COMPTA_MODE)) {
|
||||||
// Peut etre 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
|
// Peut etre 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
|
||||||
$this->compta->mode = COMPTA_MODE;
|
$this->compta->mode = $this->global->COMPTA_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->defaulttx
|
// $this->defaulttx
|
||||||
if (defined('FACTURE_TVAOPTION') && FACTURE_TVAOPTION == 'franchise')
|
if (isset($this->global->FACTURE_TVAOPTION) && $this->global->FACTURE_TVAOPTION == 'franchise')
|
||||||
{
|
{
|
||||||
$this->defaulttx='0'; // Taux par defaut des factures clients
|
$this->defaulttx='0'; // Taux par defaut des factures clients
|
||||||
}
|
}
|
||||||
@ -454,7 +455,7 @@ class Conf
|
|||||||
|
|
||||||
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de desactiver la fonction TVA
|
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de desactiver la fonction TVA
|
||||||
* (pour particuliers ou liberaux en franchise)
|
* (pour particuliers ou liberaux en franchise)
|
||||||
* En attendant, valeur forcee a 1
|
* En attendant, valeur forcee a 1 car toujours interessant a avoir meme ceux qui veulent pas.
|
||||||
*/
|
*/
|
||||||
$this->compta->tva=1;
|
$this->compta->tva=1;
|
||||||
|
|
||||||
|
|||||||
@ -21,15 +21,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/facture.class.php
|
\file htdocs/facture.class.php
|
||||||
\ingroup facture
|
\ingroup facture
|
||||||
\brief Fichier de la classe des factures clients
|
\brief Fichier de la classe des factures clients
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
||||||
|
|||||||
@ -18,16 +18,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/fourn/fournisseur.facture.class.php
|
\file htdocs/fourn/fournisseur.facture.class.php
|
||||||
\ingroup fournisseur,facture
|
\ingroup fournisseur,facture
|
||||||
\brief Fichier de la classe des factures fournisseurs
|
\brief Fichier de la classe des factures fournisseurs
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
include_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||||
@ -43,8 +40,15 @@ class FactureFournisseur extends Facture
|
|||||||
var $id;
|
var $id;
|
||||||
var $db;
|
var $db;
|
||||||
var $socid;
|
var $socid;
|
||||||
|
|
||||||
|
//! 0=brouillon,
|
||||||
|
//! 1=validée,
|
||||||
|
//! TODO Ce statut doit etre 2 et non 1 classée payée partiellement (close_code='discount_vat','badcustomer') ou complètement (close_code=null),
|
||||||
|
//! TODO Ce statut doit etre 2 et non 1 classée abandonnée et aucun paiement n'a eu lieu (close_code='badcustomer','abandon' ou 'replaced')
|
||||||
var $statut;
|
var $statut;
|
||||||
|
//! 1 si facture payée COMPLETEMENT, 0 sinon (ce champ ne devrait plus servir car insuffisant)
|
||||||
var $paye;
|
var $paye;
|
||||||
|
|
||||||
var $author;
|
var $author;
|
||||||
var $libelle;
|
var $libelle;
|
||||||
var $date;
|
var $date;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
*
|
*
|
||||||
@ -17,12 +17,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \defgroup comptabilite Module comptabilite
|
/** \defgroup comptabilite Module comptabilite
|
||||||
\brief Module pour inclure des fonctions de comptabilit<EFBFBD> (gestion de comptes comptables et rapports)
|
\brief Module pour inclure des fonctions de comptabilit<EFBFBD> (gestion de comptes comptables et rapports)
|
||||||
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -17,12 +17,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \defgroup comptabilite_expert Module comptabilite expert
|
/** \defgroup comptabilite_expert Module comptabilite expert
|
||||||
\brief Module pour inclure des fonctions de comptabilit<EFBFBD> (gestion de comptes comptables et rapports)
|
\brief Module pour inclure des fonctions de comptabilit<EFBFBD> (gestion de comptes comptables et rapports)
|
||||||
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -6,8 +6,10 @@ MenuFinancial=Financial
|
|||||||
OptionMode=Option for accountancy
|
OptionMode=Option for accountancy
|
||||||
OptionModeTrue=Option Input-Ouput
|
OptionModeTrue=Option Input-Ouput
|
||||||
OptionModeVirtual=Option Credits-Debits
|
OptionModeVirtual=Option Credits-Debits
|
||||||
OptionModeTrueDesc=In this context, the turnover is calculated over paid invoices. \nThe validity of the figures is assured only if the book-keeping is scrutinized through the input/output on the accounts via invoices. \nRemarks: in this version, Dolibarr use the passed date of invoices with state 'Validated' and not passed date with state 'Paid'.
|
OptionModeTrueDesc=In this context, the turnover is calculated over paid invoices. \nThe validity of the figures is assured only if the book-keeping is scrutinized through the input/output on the accounts via invoices.
|
||||||
|
OptionModeTrueInfoModuleComptabilite=Remarks: In this accountancy module, Dolibarr use the passed date of invoices with state 'Validated' and not passed date of real individual payments.
|
||||||
OptionModeVirtualDesc=In this context, the turnover is calculated over validated invoices. When these invoices are due, whether they have been paid or not, they are listed in the turnover output.
|
OptionModeVirtualDesc=In this context, the turnover is calculated over validated invoices. When these invoices are due, whether they have been paid or not, they are listed in the turnover output.
|
||||||
|
VATReportDesc=This report sows VAT received and payed.
|
||||||
FeatureIsSupportedInInOutModeOnly=Feature only available in CREDITS-DEBTS accountancy mode (See Accountancy module configuration)
|
FeatureIsSupportedInInOutModeOnly=Feature only available in CREDITS-DEBTS accountancy mode (See Accountancy module configuration)
|
||||||
Param=Setup
|
Param=Setup
|
||||||
AccountsGeneral=Accounts
|
AccountsGeneral=Accounts
|
||||||
@ -24,6 +26,7 @@ Withdrawal=Withdrawal
|
|||||||
Withdrawals=Withdrawals
|
Withdrawals=Withdrawals
|
||||||
VAT=VAT
|
VAT=VAT
|
||||||
VATToPay=VAT to pay
|
VATToPay=VAT to pay
|
||||||
|
VATReceived=VAT received
|
||||||
VATToCollect=VAT to collect
|
VATToCollect=VAT to collect
|
||||||
VATSummary=VAT Summary
|
VATSummary=VAT Summary
|
||||||
VATPayed=VAT payed
|
VATPayed=VAT payed
|
||||||
@ -49,6 +52,7 @@ NewVATPayment=New VAT payment
|
|||||||
VATPayment=VAT Payment
|
VATPayment=VAT Payment
|
||||||
VATPayments=VAT Payments
|
VATPayments=VAT Payments
|
||||||
TotalToPay=Total to pay
|
TotalToPay=Total to pay
|
||||||
|
TotalVATReceived=Total VAT received
|
||||||
CustomerAccountancyCode=Customer accountancy code
|
CustomerAccountancyCode=Customer accountancy code
|
||||||
SupplierAccountancyCode=Supplier accountacy code
|
SupplierAccountancyCode=Supplier accountacy code
|
||||||
AlreadyPayed=Already payed
|
AlreadyPayed=Already payed
|
||||||
|
|||||||
@ -6,7 +6,8 @@ MenuFinancial=Financier
|
|||||||
OptionMode=Option de tenue de comptabilité
|
OptionMode=Option de tenue de comptabilité
|
||||||
OptionModeTrue=Option Recettes-Dépenses
|
OptionModeTrue=Option Recettes-Dépenses
|
||||||
OptionModeVirtual=Option Créances-Dettes
|
OptionModeVirtual=Option Créances-Dettes
|
||||||
OptionModeTrueDesc=Dans ce mode, le CA est calculé sur la base des factures payées.\nLa validité des chiffres n'est donc assurée que si la tenue de la comptabilité passe rigoureusement par des entrées/sorties sur les comptes via des factures.\nRemarque : dans cette version, Dolibarr utilise la date de passage de la facture à l'état 'Validée' et non la date de passage à l'état 'Payée'.
|
OptionModeTrueDesc=Dans ce mode, le CA est calculé sur la base des factures payées.\nLa validité des chiffres n'est donc assurée que si la tenue de la comptabilité passe rigoureusement par des entrées/sorties sur les comptes via des factures.
|
||||||
|
OptionModeTrueInfoModuleComptabilite=Remarque : Dans ce module comptabilite, Dolibarr utilise la date de passage de la facture à l'état 'Validée' et non la date de passage à l'état 'Payée'.
|
||||||
OptionModeVirtualDesc=Dans ce mode, le CA est calculé sur la base des factures validées. Qu'elles soient ou non payés, dès lors qu'elles sont dues, elles apparaissent dans le résultat.
|
OptionModeVirtualDesc=Dans ce mode, le CA est calculé sur la base des factures validées. Qu'elles soient ou non payés, dès lors qu'elles sont dues, elles apparaissent dans le résultat.
|
||||||
FeatureIsSupportedInInOutModeOnly=Fonctionnalité disponible uniquement en mode de comptabilité CREDITS-DEBITS (voir configuration du module Comptabilité)
|
FeatureIsSupportedInInOutModeOnly=Fonctionnalité disponible uniquement en mode de comptabilité CREDITS-DEBITS (voir configuration du module Comptabilité)
|
||||||
Param=Configuration
|
Param=Configuration
|
||||||
|
|||||||
@ -6,8 +6,10 @@ MenuFinancial=Compta/Tr
|
|||||||
OptionMode=Option de tenue de comptabilité
|
OptionMode=Option de tenue de comptabilité
|
||||||
OptionModeTrue=Option Recettes-Dépenses
|
OptionModeTrue=Option Recettes-Dépenses
|
||||||
OptionModeVirtual=Option Créances-Dettes
|
OptionModeVirtual=Option Créances-Dettes
|
||||||
OptionModeTrueDesc=Dans ce mode, le CA est calculé sur la base des factures payées.\nLa validité des chiffres n'est donc assurée que si la tenue de la comptabilité passe rigoureusement par des entrées/sorties sur les comptes via des factures.\nRemarque : dans cette version, Dolibarr utilise la date de passage de la facture à l'état 'Validée' et non la date de passage à l'état 'Payée'.
|
OptionModeTrueDesc=Dans ce mode, le CA est calculé sur la base des factures payées.\nLa validité des chiffres n'est donc assurée que si la tenue de la comptabilité passe rigoureusement par des entrées/sorties sur les comptes via des factures.
|
||||||
|
OptionModeTrueInfoModuleComptabilite=Remarque : Dans le module comptabilite actif, Dolibarr utilise la date de passage de la facture à l'état 'Validée' et non la date des paiements individuels.
|
||||||
OptionModeVirtualDesc=Dans ce mode, le CA est calculé sur la base des factures validées. Payées ou non, elles apparaissent dans le résultat dès qu'elles sont dues.
|
OptionModeVirtualDesc=Dans ce mode, le CA est calculé sur la base des factures validées. Payées ou non, elles apparaissent dans le résultat dès qu'elles sont dues.
|
||||||
|
VATReportDesc=Cet écran présente le rapport des TVA perçus et payés.
|
||||||
FeatureIsSupportedInInOutModeOnly=Fonction disponible uniquement en mode compta CREANCES-DETTES (Voir configuration du module compta)
|
FeatureIsSupportedInInOutModeOnly=Fonction disponible uniquement en mode compta CREANCES-DETTES (Voir configuration du module compta)
|
||||||
Param=Paramétrage
|
Param=Paramétrage
|
||||||
AccountsGeneral=Comptes généraux
|
AccountsGeneral=Comptes généraux
|
||||||
@ -24,6 +26,7 @@ Withdrawl=Pr
|
|||||||
Withdrawls=Prélèvements
|
Withdrawls=Prélèvements
|
||||||
VAT=TVA
|
VAT=TVA
|
||||||
VATToPay=TVA à payer
|
VATToPay=TVA à payer
|
||||||
|
VATReceived=TVA perçue
|
||||||
VATToCollect=TVA à récupérer
|
VATToCollect=TVA à récupérer
|
||||||
VATSummary=Résumé TVA
|
VATSummary=Résumé TVA
|
||||||
VATPayed=TVA payée
|
VATPayed=TVA payée
|
||||||
@ -49,6 +52,7 @@ NewVATPayment=Nouveau r
|
|||||||
VATPayment=Réglement TVA
|
VATPayment=Réglement TVA
|
||||||
VATPayments=Réglements TVA
|
VATPayments=Réglements TVA
|
||||||
TotalToPay=Total à payer
|
TotalToPay=Total à payer
|
||||||
|
TotalVATReceived=Total TVA perçue
|
||||||
CustomerAccountancyCode=Code compta client
|
CustomerAccountancyCode=Code compta client
|
||||||
SupplierAccountancyCode=Code compta fournisseur
|
SupplierAccountancyCode=Code compta fournisseur
|
||||||
AlreadyPayed=Déjà réglé
|
AlreadyPayed=Déjà réglé
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user