diff --git a/htdocs/compta/tva/pre.inc.php3 b/htdocs/compta/tva/pre.inc.php3
index 50e2582b6a5..676364e4b96 100644
--- a/htdocs/compta/tva/pre.inc.php3
+++ b/htdocs/compta/tva/pre.inc.php3
@@ -45,6 +45,8 @@ function llxHeader($head = "") {
$menu->add_submenu("index.php3?year=2002","2002");
$menu->add_submenu("index.php3?year=2001","2001");
+ $menu->add("reglement.php","Reglement");
+
$menu->add("/compta/bank/index.php3","Bank");
left_menu($menu->liste);
diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php
new file mode 100644
index 00000000000..0d7f9604184
--- /dev/null
+++ b/htdocs/compta/tva/reglement.php
@@ -0,0 +1,193 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ *
+ */
+require("./pre.inc.php3");
+require("../../tva.class.php3");
+
+/*
+ *
+ *
+ */
+function tva_coll($db, $y,$m) {
+ $sql = "SELECT sum(f.tva) as amount";
+ $sql .= " FROM llx_facture as f WHERE f.paye = 1";
+ $sql .= " AND date_format(f.datef,'%Y') = $y";
+ $sql .= " AND date_format(f.datef,'%m') = $m";
+
+ $result = $db->query($sql);
+ if ($result) {
+ $obj = $db->fetch_object ( 0 );
+ return $obj->amount;
+ }
+}
+/*
+ *
+ *
+ */
+function tva_paye($db, $y,$m) {
+ $sql = "SELECT sum(f.tva) as amount";
+ $sql .= " FROM llx_facture_fourn as f WHERE f.paye = 1";
+ $sql .= " AND date_format(f.datef,'%Y') = $y";
+ $sql .= " AND date_format(f.datef,'%m') = $m";
+
+ $result = $db->query($sql);
+ if ($result) {
+ $obj = $db->fetch_object ( 0 );
+ return $obj->amount;
+ }
+}
+
+function pt ($db, $sql, $date) {
+ global $bc;
+
+ $result = $db->query($sql);
+ if ($result) {
+ $num = $db->num_rows();
+ $i = 0;
+ $total = 0 ;
+ print "
";
+ print "";
+ print "| $date | ";
+ print "Montant | ";
+ print " | \n";
+ print "
\n";
+ $var=True;
+ while ($i < $num) {
+ $obj = $db->fetch_object( $i);
+ $var=!$var;
+ print "";
+ print "| $obj->dm | \n";
+ $total = $total + $obj->amount;
+
+ print "".price($obj->amount)." | ".$total." | \n";
+ print "
\n";
+
+ $i++;
+ }
+ print "| Total : | ".price($total)." | euros HT |
";
+
+ print "
";
+ $db->free();
+ } else {
+ print $db->error();
+ }
+}
+
+/*
+ *
+ */
+
+llxHeader();
+
+$db = new Db();
+
+$tva = new Tva($db);
+
+print "Solde :" . price($tva->solde($year));
+
+if ($year == 0 ) {
+ $year_current = strftime("%Y",time());
+ //$year_start = $conf->years;
+ $year_start = $year_current;
+} else {
+ $year_current = $year;
+ $year_start = $year;
+}
+echo '';
+echo '| TVA collectée | ';
+echo 'Tva Réglée |
';
+
+for ($y = $year_current ; $y >= $year_start ; $y=$y-1 ) {
+
+ echo '';
+
+ print "";
+ print "";
+ print "| Année $y | ";
+ print "Collectée | ";
+ print "Payée | ";
+ print " | \n";
+ print " | \n";
+ print " \n";
+ $var=True;
+ $total = 0; $subtotal = 0;
+ $i=0;
+ for ($m = 1 ; $m < 13 ; $m++ ) {
+ $var=!$var;
+ print "";
+ print '| '.strftime("%b %Y",mktime(0,0,0,$m,1,$y)).' | ';
+
+ $x_coll = tva_coll($db, $y, $m);
+ print "".price($x_coll)." | ";
+
+ $x_paye = tva_paye($db, $y, $m);
+ print "".price($x_paye)." | ";
+
+ $diff = $x_coll - $x_paye;
+ $total = $total + $diff;
+ $subtotal = $subtotal + $diff;
+
+ print "".price($diff)." | \n";
+ print " | \n";
+ print " \n";
+
+ $i++;
+ if ($i > 2) {
+ print '| Sous total : | '.price($subtotal).' | '.price($subtotal * 0.8).' | ';
+ $i = 0;
+ $subtotal = 0;
+ }
+ }
+ print ' | Total : | '.price($total).' | ';
+ print " | \n";
+ print " ";
+
+ echo ' | ';
+ /*
+ * Payée
+ */
+
+ print "";
+ print "| ";
+
+ $sql = "SELECT amount, date_format(f.datev,'%Y-%m') as dm";
+ $sql .= " FROM llx_tva as f WHERE f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' ";
+ $sql .= " GROUP BY dm DESC";
+
+ pt($db, $sql,"Année $y");
+
+ print " | ";
+
+ echo ' |
';
+}
+
+
+
+
+
+echo '
';
+
+
+
+$db->close();
+
+llxFooter("Dernière modification $Date$ révision $Revision$");
+?>