Qual: Code to calucalte VAT is now more clear.
This commit is contained in:
parent
0f16946a03
commit
6b7d3ad0c1
@ -45,7 +45,7 @@ if ($_POST['action'] == 'setcomptamode')
|
||||
$compta_mode = $_POST['compta_mode'];
|
||||
if (! dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity)) { print $db->error(); }
|
||||
// Note: This setup differs from TAX_MODE.
|
||||
// TAX_MODE is used with 0=normal, 1=option vat for services is on debit
|
||||
// TAX_MODE is used for VAT exigibility only.
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -45,6 +45,17 @@ llxHeader();
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$tax_mode = defined('TAX_MODE')?TAX_MODE:0;
|
||||
|
||||
// TAX_MODE=0 (most cases):
|
||||
// Buy Sell
|
||||
// Product On delivery On delivery
|
||||
// Service On payment On payment
|
||||
|
||||
// TAX_MODE=1 (option):
|
||||
// Buy Sell
|
||||
// Product On delivery On delivery
|
||||
// Service On payment On invoice
|
||||
|
||||
|
||||
if ($_POST['action'] == 'settaxmode')
|
||||
{
|
||||
$tax_mode = $_POST['tax_mode'];
|
||||
@ -79,25 +90,67 @@ print_fiche_titre($langs->trans('TaxSetup'),$linkback,'setup');
|
||||
|
||||
|
||||
print '<br>';
|
||||
if (empty($mysoc->tva_assuj))
|
||||
{
|
||||
print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
// Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="settaxmode">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
|
||||
print "</tr>\n";
|
||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
|
||||
print "</td></tr>\n";
|
||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
|
||||
print '</form>';
|
||||
|
||||
// Cas du parametre TAX_MODE
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="settaxmode">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
|
||||
print "</tr>\n";
|
||||
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
|
||||
print "</td></tr>\n";
|
||||
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
|
||||
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
|
||||
print '</form>';
|
||||
print "</table>\n";
|
||||
|
||||
print "</table>\n";
|
||||
print '<br><br>';
|
||||
print_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'','');
|
||||
//print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td> </td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
|
||||
// Products
|
||||
print '<tr><td>'.$langs->trans("Product").'</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("OnDelivery");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("OnDelivery");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
print '</td></tr>';
|
||||
// Services
|
||||
print '<tr><td>'.$langs->trans("Services").'</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("OnPayment");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($tax_mode == 0)
|
||||
{
|
||||
print $langs->trans("OnPayment");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
}
|
||||
if ($tax_mode == 1)
|
||||
{
|
||||
print $langs->trans("OnInvoice");
|
||||
print ' ('.$langs->trans("InvoiceValidateDateUsed").')';
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -155,18 +155,18 @@ if ($resql)
|
||||
print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
// Type
|
||||
print '<td align="left">';
|
||||
print '<td class="liste_titre" align="left">';
|
||||
$html->select_type_socialcontrib($typeid,'typeid',1,16,0);
|
||||
print '</td>';
|
||||
// Period end date
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org>
|
||||
*
|
||||
@ -56,7 +56,7 @@ if($min == 0 or $min!=floatval(strval($min))){
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if ($_GET["modetax"]) $modetax=$_GET["modetax"];
|
||||
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"];
|
||||
|
||||
// Security check
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
@ -82,7 +82,7 @@ $fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||
$fsearch.=' <input type="submit" class="button" name="submit" value="'.$langs->trans("Chercher").'">';
|
||||
$fsearch.='</form>';
|
||||
|
||||
// Affiche en-tête du rapport
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->trans("VATReportByCustomersInDueDebtMode");
|
||||
@ -90,7 +90,7 @@ if ($modetax==1) // Calculate on invoice for goods and services
|
||||
$period=$year_start;
|
||||
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATDue");
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@ -99,12 +99,12 @@ if ($modetax==1) // Calculate on invoice for goods and services
|
||||
$productcust=$langs->trans("Description");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("Description");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPayed");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
if ($modetax==0) // Invoice for goods, payment for services
|
||||
{
|
||||
@ -113,7 +113,7 @@ if ($modetax==0) // Invoice for goods, payment for services
|
||||
$period=$year_start;
|
||||
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATIn");
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@ -122,12 +122,12 @@ if ($modetax==0) // Invoice for goods, payment for services
|
||||
$productcust=$langs->trans("Description");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("Description");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPayed");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
|
||||
|
||||
@ -185,7 +185,7 @@ if (is_array($coll_list))
|
||||
}
|
||||
}
|
||||
|
||||
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 class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
@ -257,7 +257,7 @@ if (is_array($coll_list))
|
||||
}
|
||||
}
|
||||
|
||||
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 class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
@ -26,6 +26,7 @@
|
||||
\version $Id$
|
||||
*/
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
|
||||
|
||||
$langs->load("other");
|
||||
@ -45,128 +46,12 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"];
|
||||
|
||||
|
||||
/**
|
||||
* \brief On cherche la tva a collecter
|
||||
* \param db Handle acces base
|
||||
* \param y Year
|
||||
* \param m Month
|
||||
*/
|
||||
function tva_coll($db,$y,$m)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
||||
{
|
||||
// Si on paye la tva sur les factures dues (non brouillon)
|
||||
$sql = "SELECT sum(f.tva) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " AND f.fk_statut IN (1,2)";
|
||||
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
|
||||
$sql.= " AND date_format(f.datef,'%m') = ".$m;
|
||||
}
|
||||
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)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
return $obj->amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief On recupere la tva à payer
|
||||
* \param db Handle accès base
|
||||
* \param y Année
|
||||
* \param m Mois
|
||||
*/
|
||||
function tva_paye($db, $y,$m)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
||||
{
|
||||
// Si on paye la tva sur les factures dues (non brouillon)
|
||||
$sql = "SELECT sum(f.total_tva) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)";
|
||||
$sql.= " AND date_format(f.datef,'%Y') = $y";
|
||||
$sql.= " AND date_format(f.datef,'%m') = $m";
|
||||
}
|
||||
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 stocke dans la table des payments.
|
||||
// Seul le module compta expert peut resoudre ce probleme.
|
||||
// (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 stocke 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 payes
|
||||
$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)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
return $obj->amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pt ($db, $sql, $date)
|
||||
{
|
||||
@ -227,6 +112,9 @@ print_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")."
|
||||
echo '<table width="100%" class="nobordernopadding">';
|
||||
echo '<tr><td>';
|
||||
print_titre($langs->trans("VATSummary"));
|
||||
// The report mode is the one defined by defaut in tax module setup
|
||||
//print $modetax;
|
||||
//print '('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')';
|
||||
echo '</td><td width="5"> </td><td>';
|
||||
print_titre($langs->trans("VATPayed"));
|
||||
echo '</td></tr>';
|
||||
@ -242,51 +130,67 @@ print "<td align=\"right\">".$langs->trans("TotalToPay")."</td>";
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
if ($conf->compta->mode == "CREANCES-DETTES")
|
||||
|
||||
$y = $year_current ;
|
||||
|
||||
|
||||
$var=True;
|
||||
$total = 0; $subtotal = 0;
|
||||
$i=0;
|
||||
for ($m = 1 ; $m < 13 ; $m++ )
|
||||
{
|
||||
$y = $year_current ;
|
||||
$coll_listsell = vat_by_quarter($db, $y, 0, $modetax, 'sell', $m);
|
||||
$coll_listbuy = vat_by_quarter($db, $y, 0, $modetax, 'buy', $m);
|
||||
|
||||
|
||||
$var=True;
|
||||
$total = 0; $subtotal = 0;
|
||||
$i=0;
|
||||
for ($m = 1 ; $m < 13 ; $m++ )
|
||||
if ($coll_listbuy == -2)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td nowrap>'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'</td>';
|
||||
|
||||
$x_coll = tva_coll($db, $y, $m);
|
||||
print "<td nowrap align=\"right\">".price($x_coll)."</td>";
|
||||
|
||||
$x_paye = tva_paye($db, $y, $m);
|
||||
print "<td nowrap align=\"right\">".price($x_paye)."</td>";
|
||||
|
||||
$diff = $x_coll - $x_paye;
|
||||
$total = $total + $diff;
|
||||
$subtotal = $subtotal + $diff;
|
||||
|
||||
print "<td nowrap align=\"right\">".price($diff)."</td>\n";
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
if ($i > 2) {
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("SubTotal").':</td><td nowrap align="right">'.price($subtotal).'</td><td> </td></tr>';
|
||||
$i = 0;
|
||||
$subtotal = 0;
|
||||
}
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
break;
|
||||
}
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("TotalToPay").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print "<td> </td>\n";
|
||||
print '</tr>';
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td nowrap>'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'</td>';
|
||||
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val)
|
||||
{
|
||||
$x_coll+=$val['vat'];
|
||||
}
|
||||
print "<td nowrap align=\"right\">".price($x_coll)."</td>";
|
||||
|
||||
$x_paye = 0;
|
||||
foreach($coll_listbuy as $vatrate=>$val)
|
||||
{
|
||||
$x_paye+=$val['vat'];
|
||||
}
|
||||
print "<td nowrap align=\"right\">".price($x_paye)."</td>";
|
||||
|
||||
$diff = $x_coll - $x_paye;
|
||||
$total = $total + $diff;
|
||||
$subtotal = $subtotal + $diff;
|
||||
|
||||
print "<td nowrap align=\"right\">".price($diff)."</td>\n";
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
if ($i > 2) {
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("SubTotal").':</td><td nowrap align="right">'.price($subtotal).'</td><td> </td></tr>';
|
||||
$i = 0;
|
||||
$subtotal = 0;
|
||||
}
|
||||
}
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("TotalToPay").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print "<td> </td>\n";
|
||||
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>';
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
*
|
||||
@ -56,7 +56,7 @@ $q=(! empty($_GET["q"]))?$_GET["q"]:1;
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if ($_GET["modetax"]) $modetax=$_GET["modetax"];
|
||||
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"];
|
||||
|
||||
// Security check
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
@ -80,8 +80,8 @@ $paymentfourn_static=new PaiementFourn($db);
|
||||
|
||||
//print_fiche_titre($langs->trans("VAT"),"");
|
||||
|
||||
// Affiche en-tête du rapport
|
||||
if ($modetax==1) // Caluclate on invoice for goods and services
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->trans("VATReportByQuartersInDueDebtMode");
|
||||
$nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&q='.$q.'&modetax=0">','</a>').')';
|
||||
@ -94,7 +94,7 @@ if ($modetax==1) // Caluclate on invoice for goods and services
|
||||
else { $nextquarter=1; $nextyear++; }
|
||||
$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATDue");
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@ -103,12 +103,12 @@ if ($modetax==1) // Caluclate on invoice for goods and services
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPayed");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
if ($modetax==0) // Invoice for goods, payment for services
|
||||
{
|
||||
@ -123,7 +123,7 @@ if ($modetax==0) // Invoice for goods, payment for services
|
||||
else { $nextquarter=1; $nextyear++; }
|
||||
$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATIn");
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@ -132,12 +132,12 @@ if ($modetax==0) // Invoice for goods, payment for services
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPayed");
|
||||
if ($conf->global->FACTURE_TVAOPTION != 'franchise') $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
|
||||
|
||||
@ -386,7 +386,7 @@ else
|
||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
||||
|
||||
//print table headers for this quadri - expenses now
|
||||
//imprime les en-tete de tables pour ce quadri - maintenant les dépenses
|
||||
//imprime les en-tete de tables pour ce quadri - maintenant les d<EFBFBD>penses
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$elementsup.'</td>';
|
||||
print '<td align="left">'.$productsup.'</td>';
|
||||
|
||||
@ -1040,9 +1040,6 @@ else
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
//if($mysoc->tva_assuj == "0")
|
||||
//print '<input type="hidden" name="tva_tx" value="0">0';
|
||||
//else
|
||||
print $html->select_tva('tauxtva',$conf->defaulttx,$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
|
||||
@ -69,8 +69,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
|
||||
$this->option_logo = 1; // Affiche logo
|
||||
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
|
||||
$this->option_modereg = 1; // Affiche mode r<EFBFBD>glement
|
||||
$this->option_condreg = 1; // Affiche conditions r<EFBFBD>glement
|
||||
$this->option_modereg = 1; // Affiche mode reglement
|
||||
$this->option_condreg = 1; // Affiche conditions reglement
|
||||
$this->option_codeproduitservice = 1; // Affiche code produit-service
|
||||
$this->option_multilang = 1; // Dispo en plusieurs langues
|
||||
$this->option_escompte = 1; // Affiche si il y a eu escompte
|
||||
@ -78,8 +78,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 1; //Support add of a watermark on drafts
|
||||
|
||||
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
|
||||
$this->franchise=1;
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Recupere emmetteur
|
||||
$this->emetteur=$mysoc;
|
||||
|
||||
@ -79,8 +79,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
|
||||
|
||||
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
|
||||
$this->franchise=1;
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Recupere emmetteur
|
||||
$this->emetteur=$mysoc;
|
||||
|
||||
@ -79,8 +79,7 @@ class pdf_oursin extends ModelePDFFactures
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
|
||||
|
||||
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
|
||||
$this->franchise=1;
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Recupere emmetteur
|
||||
$this->emetteur=$mysoc;
|
||||
|
||||
@ -72,8 +72,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
|
||||
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
|
||||
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
|
||||
$this->option_codeproduitservice = 1; // Affiche code produit-service
|
||||
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
|
||||
$this->franchise=1;
|
||||
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Recupere emmetteur
|
||||
$this->emetteur=$mysoc;
|
||||
|
||||
@ -67,7 +67,7 @@ class modAccounting extends DolibarrModules
|
||||
$this->config_page_url = array("accounting.php");
|
||||
|
||||
// Dependancies
|
||||
$this->depends = array("modFacture","modBanque");
|
||||
$this->depends = array("modFacture","modBanque","modTax");
|
||||
$this->requiredby = array();
|
||||
$this->conflictwith = array("modComptabilite");
|
||||
$this->langfiles = array("compta");
|
||||
|
||||
@ -79,8 +79,7 @@ class pdf_propale_azur extends ModelePDFPropales
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 1; //Support add of a watermark on drafts
|
||||
|
||||
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
|
||||
$this->franchise=1;
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Recupere emmetteur
|
||||
$this->emetteur=$mysoc;
|
||||
|
||||
@ -71,8 +71,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$this->option_codeproduitservice = 1; // Affiche code produit-service
|
||||
$this->option_multilang = 1; // Dispo en plusieurs langues
|
||||
|
||||
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
|
||||
$this->franchise=1;
|
||||
$this->franchise=!$mysoc->tva_assuj;
|
||||
|
||||
// Recupere emmetteur
|
||||
$this->emetteur=$mysoc;
|
||||
@ -397,9 +396,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$tab2_height = $tab2_hl * 4;
|
||||
$pdf->SetFont('Arial','', 9);
|
||||
|
||||
// Affiche la mention TVA non applicable selon option
|
||||
$pdf->SetXY ($this->marge_gauche, $tab2_top + 0);
|
||||
if ($this->franchise==1)
|
||||
|
||||
// If France, show VAT mention if not applicable
|
||||
if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
|
||||
{
|
||||
$pdf->MultiCell(100, $tab2_hl, "* TVA non applicable art-293B du CGI", 0, 'L', 0);
|
||||
}
|
||||
|
||||
@ -1041,11 +1041,20 @@ DeleteLine=Delete line
|
||||
ConfirmDeleteLine=Are you sure you want to delete this line ?
|
||||
##### Tax #####
|
||||
TaxSetup=Taxes, social contributions and dividends module setup
|
||||
OptionVatMode=Option d'exigibilité de TVA
|
||||
OptionVatMode=VAT due
|
||||
OptionVATDefault=Standard
|
||||
OptionVATDebitOption=Option services sur debit
|
||||
OptionVatDefaultDesc=L'exigibilité de la TVA est:<br>- sur livraison pour les biens<br>- sur paiement pour les services
|
||||
OptionVatDebitOptionDesc=L'exigibilité de la TVA est:<br>- sur livraison pour les biens<br>- sur facturation (d�bit) pour les services
|
||||
OptionVATDebitOption=Option services on Debit
|
||||
OptionVatDefaultDesc=VAT is due:<br>- on delivery/payments for goods<br>- on payments for services
|
||||
OptionVatDebitOptionDesc=VAT is due:<br>- on delivery/payments for goods<br>- on invoice (debit) for services
|
||||
SummaryOfVatExigibilityUsedByDefault=Time of VAT exigibility by default according to choosed option:
|
||||
OnDelivery=On delivery
|
||||
OnPayment=On payement
|
||||
OnInvoice=On invoice
|
||||
SupposedToBePaymentDate=Payment date used if delivery date not known
|
||||
Buy=Buy
|
||||
Sell=Sell
|
||||
InvoiceValidateDateUsed=Invoice dtate used
|
||||
YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Setup - Company/Foundation), so there is no VAT options to setup.
|
||||
##### Agenda #####
|
||||
AgendaSetup=Actions and agenda module setup
|
||||
PasswordTogetVCalExport=Key to authorize export link
|
||||
|
||||
@ -1041,11 +1041,20 @@ DeleteLine = Suppression de ligne
|
||||
ConfirmDeleteLine = Êtes-vous sûr de vouloir effacer cette ligne ?
|
||||
##### Tax ##### = undefined
|
||||
TaxSetup = Configuration du module Taxes, charges sociales et dividendes
|
||||
OptionVatMode = Option d'exigibilité de TVA
|
||||
OptionVatMode = Option d'exigibilité de TVA par défaut
|
||||
OptionVATDefault = Standard
|
||||
OptionVATDebitOption = Option services sur debit
|
||||
OptionVATDebitOption = Option services sur Débit
|
||||
OptionVatDefaultDesc = L'exigibilité de la TVA est:<br>- sur livraison pour les biens<br>- sur paiement pour les services
|
||||
OptionVatDebitOptionDesc = L'exigibilité de la TVA est:<br>- sur livraison pour les biens<br>- sur facturation (débit) pour les services
|
||||
SummaryOfVatExigibilityUsedByDefault=Moment d'exigibilité par défaut de la TVA pour l'option choisie:
|
||||
OnDelivery=Sur livraison
|
||||
OnPayment=Sur paiement
|
||||
OnInvoice=Sur facture
|
||||
SupposedToBePaymentDate=Date de paiement utilisé
|
||||
Buy=Achat
|
||||
Sell=Vente
|
||||
InvoiceValidateDateUsed=Date de validation utilisée
|
||||
YourCompanyDoesNotUseVAT=Votre institution est configurée comme non assujetie à la TVA (Accueil - Configuration - Société/Institution), aussi il n'y a aucun option sur la gestion TVA à paramétrer.
|
||||
##### Agenda ##### = undefined
|
||||
AgendaSetup = Configuration du module actions et agenda
|
||||
PasswordTogetVCalExport = Clé pour autoriser lien export
|
||||
|
||||
@ -64,7 +64,7 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
||||
if ($conf->global->MAIN_MODULE_ACCOUNTING)
|
||||
{
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stock<EFBFBD> dans la table des payments.
|
||||
// n'est pas stocke dans la table des payments.
|
||||
// Seul le module compta expert peut r<>soudre ce probl<62>me.
|
||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||
// detail part tva et part ht).
|
||||
@ -116,7 +116,7 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
||||
if ($sql && $sql=='TODO') return -2;
|
||||
if ($sql && $sql!='TODO')
|
||||
{
|
||||
dol_syslog("Client::vat_by_customer sql=".$sql);
|
||||
dol_syslog("Tax.lib:thirdparty sql=".$sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -137,7 +137,7 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Gets VAT to collect for the given month of the given year
|
||||
* \brief Gets VAT to collect for the given year (and given quarter or month)
|
||||
* The function gets the VAT in split results, as the VAT declaration asks
|
||||
* to report the amounts for different VAT rates as different lines.
|
||||
* This function also accounts recurrent invoices
|
||||
@ -145,10 +145,11 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
||||
* \param y Year
|
||||
* \param q Period. If 1-4, it's year quarter.
|
||||
* \param modetax 0 or 1 (option vat on debit)
|
||||
* \param direction 'sell' or 'buy'
|
||||
* \param direction 'sell' (customer invoice) or 'buy' (supplier invoices)
|
||||
* \param m Month
|
||||
* \return array List of quarters with vat
|
||||
*/
|
||||
function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -181,20 +182,20 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
|
||||
// Define sql request
|
||||
$sql='';
|
||||
if ($modetax == 1) // Option vat on debit
|
||||
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
|
||||
{
|
||||
// If vat payed on due invoices (non draft)
|
||||
if ($conf->global->MAIN_MODULE_ACCOUNTING)
|
||||
{
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stock<EFBFBD> dans la table des payments.
|
||||
// Seul le module compta expert peut r<EFBFBD>soudre ce probl<62>me.
|
||||
// n'est pas stocke dans la table des payments.
|
||||
// Seul le module compta expert peut resoudre ce probleme.
|
||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||
// detail part tva et part ht).
|
||||
$sql='TODO';
|
||||
}
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||
{
|
||||
// Count on delivery date (use invoice date as delivery is unknown)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
@ -207,27 +208,27 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or 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).")";
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")";
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
}
|
||||
else // Option vat on payments
|
||||
else // Option vat on delivery for goods (payments) and payments for services
|
||||
{
|
||||
// If vat payed on payments
|
||||
if ($conf->global->MAIN_MODULE_ACCOUNTING)
|
||||
{
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stock<EFBFBD> dans la table des payments.
|
||||
// Seul le module compta expert peut r<EFBFBD>soudre ce probl<62>me.
|
||||
// n'est pas stocke dans la table des payments.
|
||||
// Seul le module compta expert peut resoudre ce probleme.
|
||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||
// detail part tva et part ht).
|
||||
$sql='TODO';
|
||||
}
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||
{
|
||||
// Tva sur factures pay<61>s (should be on shipment, done on payment instead !)
|
||||
// Count on delivery date (use invoice date as delivery is unknown)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
@ -247,13 +248,15 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
// $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'";
|
||||
// $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
$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).")";
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")";
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
}
|
||||
|
||||
//print $sql.'<br>';
|
||||
if (! $sql) return -1;
|
||||
if ($sql && $sql=='TODO') return -2;
|
||||
if ($sql && $sql!='TODO')
|
||||
@ -267,8 +270,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$oldrowid='';
|
||||
while($assoc = $db->fetch_array($resql))
|
||||
{
|
||||
if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['total_ht']=0;
|
||||
if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['total_vat']=0;
|
||||
if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0;
|
||||
if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0;
|
||||
|
||||
if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid
|
||||
{
|
||||
@ -312,21 +315,22 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
|
||||
// Define sql request
|
||||
$sql='';
|
||||
if ($modetax == 1) // Option vat on debit
|
||||
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
|
||||
{
|
||||
// If vat payed on due invoices (non draft)
|
||||
if ($conf->global->MAIN_MODULE_ACCOUNTING)
|
||||
{
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stock<63> dans la table des payments.
|
||||
// Seul le module compta expert peut r<>soudre ce probl<62>me.
|
||||
// Count on invoice date
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stocke dans la table des payments.
|
||||
// Seul le module compta expert peut resoudre ce probleme.
|
||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||
// detail part tva et part ht).
|
||||
$sql='TODO';
|
||||
}
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||
{
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
// Count on invoice date
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
@ -338,28 +342,29 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or 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).")";
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")";
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
}
|
||||
else // Option vat on payments
|
||||
else // Option vat on delivery for goods (payments) and payments for services
|
||||
{
|
||||
// If vat payed on payments
|
||||
if ($conf->global->MAIN_MODULE_ACCOUNTING)
|
||||
{
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stock<63> dans la table des payments.
|
||||
// Seul le module compta expert peut r<>soudre ce probl<62>me.
|
||||
// Count on payments date
|
||||
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment
|
||||
// n'est pas stocke dans la table des payments.
|
||||
// Seul le module compta expert peut resoudre ce probleme.
|
||||
// (Il faut quand un paiement a lieu, stocker en plus du montant du paiement le
|
||||
// detail part tva et part ht).
|
||||
$sql='TODO';
|
||||
}
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||
{
|
||||
// Tva sur factures pay<61>s (should be on payment)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
// Count on payments date
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
@ -375,7 +380,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$sql.= " AND pf.".$fk_facture2." = f.rowid";
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
$sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'";
|
||||
$sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($m) $sql.= " AND (date_format(pa.datep,'%m') > ".($m-1)." AND date_format(pa.datep,'%m') <= ".($m).")";
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
||||
@ -394,8 +400,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$oldrowid='';
|
||||
while($assoc = $db->fetch_array($resql))
|
||||
{
|
||||
if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['total_ht']=0;
|
||||
if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['total_vat']=0;
|
||||
if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0;
|
||||
if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0;
|
||||
|
||||
if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid
|
||||
{
|
||||
|
||||
@ -296,7 +296,6 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
|
||||
$mysoc->profid2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET;
|
||||
$mysoc->profid3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE;
|
||||
$mysoc->profid4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS;
|
||||
$mysoc->tva_assuj=$conf->global->FACTURE_TVAOPTION;
|
||||
$mysoc->tva_intra=$conf->global->MAIN_INFO_TVAINTRA;
|
||||
$mysoc->capital=$conf->global->MAIN_INFO_CAPITAL;
|
||||
$mysoc->forme_juridique_code=$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE;
|
||||
@ -305,6 +304,9 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
|
||||
$mysoc->logo=$conf->global->MAIN_INFO_SOCIETE_LOGO;
|
||||
$mysoc->logo_small=$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL;
|
||||
$mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
|
||||
|
||||
// Define if company use vat or not (Do not use conf->global->FACTURE_TVAOPTION anymore)
|
||||
$mysoc->tva_assuj=($conf->global->FACTURE_TVAOPTION=='franchise'?0:1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -498,6 +498,7 @@ div.tabBar {
|
||||
border-bottom: 1px solid #555555;
|
||||
border-left: 1px solid #D0D0D0;
|
||||
border-top: 1px solid #D8D8D8;
|
||||
/* background: #F0F0F0 url(<?php echo $dolibarr_main_url_root.'/theme/login_background.png' ?>) repeat-x; */
|
||||
}
|
||||
|
||||
div.tabsAction {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user