[ task #1063 ] Allow edit localtaxes rate for thirds. Works with reports
and payments
This commit is contained in:
parent
72243d4f38
commit
747b6a9f94
@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -353,6 +354,108 @@ if ($conf->tax->enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
//localtax
|
||||
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
$j=1;
|
||||
$numlt=3;
|
||||
}
|
||||
elseif($mysoc->localtax1_assuj=="1")
|
||||
{
|
||||
$j=1;
|
||||
$numlt=2;
|
||||
}
|
||||
elseif($mysoc->localtax2_assuj=="1")
|
||||
{
|
||||
$j=2;
|
||||
$numlt=3;
|
||||
}
|
||||
else
|
||||
{
|
||||
$j=0;
|
||||
$numlt=0;
|
||||
}
|
||||
|
||||
while($j<$numlt)
|
||||
{
|
||||
if (empty($_GET["mode"]) || $_GET["mode"] != 'sconly')
|
||||
{
|
||||
print "<br>";
|
||||
|
||||
$tva = new Tva($db);
|
||||
|
||||
print_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"),$mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
|
||||
|
||||
|
||||
$sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv";
|
||||
$sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ;
|
||||
if ($year > 0)
|
||||
{
|
||||
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
|
||||
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
|
||||
$sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
|
||||
}
|
||||
if (preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
$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_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pv.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
$var=1;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total = $total + $obj->amount;
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
|
||||
|
||||
print "<td>".$obj->label."</td>\n";
|
||||
|
||||
print '<td align="right">'.price($obj->amount)."</td>";
|
||||
|
||||
// Ref payment
|
||||
$tva_static->id=$obj->rowid;
|
||||
$tva_static->ref=$obj->rowid;
|
||||
print '<td align="left">'.$tva_static->getNomUrl(1)."</td>\n";
|
||||
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->dp),'day')."</td>\n";
|
||||
print '<td align="right">'.price($obj->amount)."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("Total").'</td>';
|
||||
print '<td align="right">'.price($total)."</td>";
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="right">'.price($total)."</td>";
|
||||
print "</tr>";
|
||||
|
||||
print "</table>";
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Alexandre spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
||||
@ -150,9 +150,9 @@ if ($result)
|
||||
$compta_localtax1 = (! empty($obj->account_localtax1)?$obj->account_localtax1:$langs->trans("CodeNotDef"));
|
||||
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));
|
||||
|
||||
$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
|
||||
$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc, $obj->thirdparty);
|
||||
$compta_localtax1= (! empty($account_localtax1[2])?$account_localtax1[2]:$langs->trans("CodeNotDef"));
|
||||
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
|
||||
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc, $obj->thirdparty);
|
||||
$compta_localtax2= (! empty($account_localtax2[2])?$account_localtax2[2]:$langs->trans("CodeNotDef"));
|
||||
|
||||
$tabfac[$obj->rowid]["date"] = $obj->datef;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
||||
@ -153,9 +153,9 @@ if ($result)
|
||||
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"));
|
||||
$compta_tva = (! empty($obj->account_tva)?$obj->account_tva:$cpttva);
|
||||
|
||||
$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
|
||||
$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $obj->thirdparty, $mysoc);
|
||||
$compta_localtax1= (! empty($account_localtax1[3])?$account_localtax1[3]:$langs->trans("CodeNotDef"));
|
||||
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
|
||||
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $obj->thirdparty, $mysoc);
|
||||
$compta_localtax2= (! empty($account_localtax2[3])?$account_localtax2[3]:$langs->trans("CodeNotDef"));
|
||||
|
||||
//la ligne facture
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -31,6 +31,7 @@ class Localtax extends CommonObject
|
||||
{
|
||||
var $id;
|
||||
var $ref;
|
||||
var $ltt;
|
||||
var $tms;
|
||||
var $datep;
|
||||
var $datev;
|
||||
@ -74,6 +75,7 @@ class Localtax extends CommonObject
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax(";
|
||||
$sql.= "localtaxtype,";
|
||||
$sql.= "tms,";
|
||||
$sql.= "datep,";
|
||||
$sql.= "datev,";
|
||||
@ -84,6 +86,7 @@ class Localtax extends CommonObject
|
||||
$sql.= "fk_user_creat,";
|
||||
$sql.= "fk_user_modif";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= " ".$this->ltt.",";
|
||||
$sql.= " '".$this->db->idate($this->tms)."',";
|
||||
$sql.= " '".$this->db->idate($this->datep)."',";
|
||||
$sql.= " '".$this->db->idate($this->datev)."',";
|
||||
@ -141,6 +144,7 @@ class Localtax extends CommonObject
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET";
|
||||
$sql.= " localtaxtype=".$this->ltt.",";
|
||||
$sql.= " tms=".$this->db->idate($this->tms).",";
|
||||
$sql.= " datep=".$this->db->idate($this->datep).",";
|
||||
$sql.= " datev=".$this->db->idate($this->datev).",";
|
||||
@ -186,6 +190,7 @@ class Localtax extends CommonObject
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.localtaxtype,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " t.datep,";
|
||||
$sql.= " t.datev,";
|
||||
@ -212,6 +217,7 @@ class Localtax extends CommonObject
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->ltt = $obj->localtaxtype;
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
$this->datep = $this->db->jdate($obj->datep);
|
||||
$this->datev = $this->db->jdate($obj->datev);
|
||||
@ -285,6 +291,7 @@ class Localtax extends CommonObject
|
||||
$this->id=0;
|
||||
|
||||
$this->tms='';
|
||||
$this->ltt=0;
|
||||
$this->datep='';
|
||||
$this->datev='';
|
||||
$this->amount='';
|
||||
@ -476,12 +483,12 @@ class Localtax extends CommonObject
|
||||
}
|
||||
|
||||
// Insertion dans table des paiement localtax
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax (datep, datev, amount";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax (localtaxtype, datep, datev, amount";
|
||||
if ($this->note) $sql.=", note";
|
||||
if ($this->label) $sql.=", label";
|
||||
$sql.= ", fk_user_creat, fk_bank";
|
||||
$sql.= ") ";
|
||||
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
||||
$sql.= " VALUES (".$this->ltt.", '".$this->db->idate($this->datep)."',";
|
||||
$sql.= "'".$this->db->idate($this->datev)."'," . $this->amount;
|
||||
if ($this->note) $sql.=", '".$this->db->escape($this->note)."'";
|
||||
if ($this->label) $sql.=", '".$this->db->escape($this->label)."'";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -33,6 +33,8 @@ $langs->load("compta");
|
||||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
|
||||
$local=GETPOST('localTaxType', 'int');
|
||||
|
||||
// Date range
|
||||
$year=GETPOST("year");
|
||||
if (empty($year))
|
||||
@ -102,12 +104,14 @@ $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
||||
$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
||||
$fsearch.=' <input type="text" name="min" id="min" value="'.$min.'" size="6">';
|
||||
|
||||
$calc=MAIN_INFO_LOCALTAX_CALC.$local;
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->transcountry("LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
|
||||
$nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
|
||||
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$description=$langs->trans("RulesVATDue");
|
||||
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
$description.=$fsearch;
|
||||
$description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
@ -120,11 +124,12 @@ if ($modetax==1) // Calculate on invoice for goods and services
|
||||
$productsup=$langs->trans("Description");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
}
|
||||
if ($modetax==0) // Invoice for goods, payment for services
|
||||
if ($conf->global->$calc==2) // Invoice for goods, payment for services
|
||||
{
|
||||
$nom=$langs->transcountry("LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
|
||||
$nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
|
||||
$calcmode=$langs->trans("CalcModeLT2Debt");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$description=$langs->trans("RulesVATIn");
|
||||
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
$description.=$fsearch;
|
||||
$description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
@ -137,173 +142,179 @@ if ($modetax==0) // Invoice for goods, payment for services
|
||||
$productsup=$langs->trans("Description");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
}
|
||||
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
|
||||
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
||||
|
||||
$vatcust=$langs->transcountry("LT2",$mysoc->country_code);
|
||||
$vatsup=$langs->transcountry("LT2",$mysoc->country_code);
|
||||
|
||||
$vatcust=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code);
|
||||
$vatsup=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code);
|
||||
|
||||
// IRPF that the customer has retained me
|
||||
if($conf->global->$calc ==0 || $conf->global->$calc == 2){
|
||||
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("Customer")."</td>";
|
||||
print "<td>".$langs->transcountry("ProfId1",$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("TotalHT")."</td>";
|
||||
print "<td align=\"right\">".$vatcust."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
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("Customer")."</td>";
|
||||
print "<td>".$langs->transcountry("ProfId1",$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("TotalHT")."</td>";
|
||||
print "<td align=\"right\">".$vatcust."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell');
|
||||
|
||||
$action = "tvaclient";
|
||||
$object = &$coll_list;
|
||||
$parameters["mode"] = $modetax;
|
||||
$parameters["start"] = $date_start;
|
||||
$parameters["end"] = $date_end;
|
||||
$parameters["direction"] = 'sell';
|
||||
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (is_array($coll_list))
|
||||
{
|
||||
$var=true;
|
||||
$total = 0; $totalamount = 0;
|
||||
$i = 1;
|
||||
foreach($coll_list as $coll)
|
||||
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell');
|
||||
|
||||
$action = "tvaclient";
|
||||
$object = &$coll_list;
|
||||
$parameters["mode"] = $modetax;
|
||||
$parameters["start"] = $date_start;
|
||||
$parameters["end"] = $date_end;
|
||||
$parameters["direction"] = 'sell';
|
||||
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (is_array($coll_list))
|
||||
{
|
||||
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2!=0)
|
||||
$var=true;
|
||||
$total = 0; $totalamount = 0;
|
||||
$i = 1;
|
||||
foreach($coll_list as $coll)
|
||||
{
|
||||
$var=!$var;
|
||||
$intra = str_replace($find,$replace,$coll->tva_intra);
|
||||
if(empty($intra))
|
||||
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) !=0)
|
||||
{
|
||||
if($coll->assuj == '1')
|
||||
$var=!$var;
|
||||
$intra = str_replace($find,$replace,$coll->tva_intra);
|
||||
if(empty($intra))
|
||||
{
|
||||
$intra = $langs->trans('Unknown');
|
||||
}
|
||||
else
|
||||
{
|
||||
$intra = '';
|
||||
if($coll->assuj == '1')
|
||||
{
|
||||
$intra = $langs->trans('Unknown');
|
||||
}
|
||||
else
|
||||
{
|
||||
$intra = '';
|
||||
}
|
||||
}
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td class="nowrap">'.$i."</td>";
|
||||
$company_static->id=$coll->socid;
|
||||
$company_static->nom=$coll->nom;
|
||||
print '<td class="nowrap">'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print '<td class="nowrap">'.$intra."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($coll->amount)."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($local==1?$coll->localtax1:$coll->localtax2)."</td>";
|
||||
$totalamount = $totalamount + $coll->amount;
|
||||
$total = $total + ($local==1?$coll->localtax1:$coll->localtax2);
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td class="nowrap">'.$i."</td>";
|
||||
$company_static->id=$coll->socid;
|
||||
$company_static->nom=$coll->nom;
|
||||
print '<td class="nowrap">'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print '<td class="nowrap">'.$intra."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($coll->amount)."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($coll->localtax2)."</td>";
|
||||
$totalamount = $totalamount + $coll->amount;
|
||||
$total = $total + $coll->localtax2;
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$x_coll_sum = $total;
|
||||
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("Total").':</td>';
|
||||
print '<td class="nowrap" align="right">'.price($totalamount).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($total).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$x_coll_sum = $total;
|
||||
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("Total").':</td>';
|
||||
print '<td class="nowrap" align="right">'.price($totalamount).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($total).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// IRPF I retained my supplier
|
||||
if($conf->global->$calc ==0 || $conf->global->$calc == 1){
|
||||
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("Supplier")."</td>";
|
||||
print "<td>".$langs->transcountry("ProfId1",$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("TotalHT")."</td>";
|
||||
print "<td align=\"right\">".$vatsup."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td align="left">'.$langs->trans("Num")."</td>";
|
||||
print '<td align="left">'.$langs->trans("Supplier")."</td>";
|
||||
print "<td>".$langs->transcountry("ProfId1",$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("TotalHT")."</td>";
|
||||
print "<td align=\"right\">".$vatsup."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$company_static=new Societe($db);
|
||||
|
||||
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
|
||||
$parameters["direction"] = 'buy';
|
||||
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (is_array($coll_list))
|
||||
{
|
||||
$var=true;
|
||||
$total = 0; $totalamount = 0;
|
||||
$i = 1;
|
||||
foreach($coll_list as $coll)
|
||||
$company_static=new Societe($db);
|
||||
|
||||
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
|
||||
$parameters["direction"] = 'buy';
|
||||
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (is_array($coll_list))
|
||||
{
|
||||
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2!=0)
|
||||
$var=true;
|
||||
$total = 0; $totalamount = 0;
|
||||
$i = 1;
|
||||
foreach($coll_list as $coll)
|
||||
{
|
||||
$var=!$var;
|
||||
$intra = str_replace($find,$replace,$coll->tva_intra);
|
||||
if(empty($intra))
|
||||
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) != 0)
|
||||
{
|
||||
if($coll->assuj == '1')
|
||||
$var=!$var;
|
||||
$intra = str_replace($find,$replace,$coll->tva_intra);
|
||||
if(empty($intra))
|
||||
{
|
||||
$intra = $langs->trans('Unknown');
|
||||
}
|
||||
else
|
||||
{
|
||||
$intra = '';
|
||||
if($coll->assuj == '1')
|
||||
{
|
||||
$intra = $langs->trans('Unknown');
|
||||
}
|
||||
else
|
||||
{
|
||||
$intra = '';
|
||||
}
|
||||
}
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td class="nowrap">'.$i."</td>";
|
||||
$company_static->id=$coll->socid;
|
||||
$company_static->nom=$coll->nom;
|
||||
print '<td class="nowrap">'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print '<td class="nowrap">'.$intra."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($coll->amount)."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($local==1?$coll->localtax1:$coll->localtax2)."</td>";
|
||||
$totalamount = $totalamount + $coll->amount;
|
||||
$total = $total + ($local==1?$coll->localtax1:$coll->localtax2);
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td class="nowrap">'.$i."</td>";
|
||||
$company_static->id=$coll->socid;
|
||||
$company_static->nom=$coll->nom;
|
||||
print '<td class="nowrap">'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print '<td class="nowrap">'.$intra."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($coll->amount)."</td>";
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($coll->localtax2)."</td>";
|
||||
$totalamount = $totalamount + $coll->amount;
|
||||
$total = $total + $coll->localtax2;
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$x_paye_sum = $total;
|
||||
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("Total").':</td>';
|
||||
print '<td class="nowrap" align="right">'.price($totalamount).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($total).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
}
|
||||
$x_paye_sum = $total;
|
||||
|
||||
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("Total").':</td>';
|
||||
print '<td class="nowrap" align="right">'.price($totalamount).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($total).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
// Total to pay
|
||||
print '<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
$diff = $x_paye_sum;
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="4">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
|
||||
print '<td class="liste_total nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if($conf->global->$calc ==0){
|
||||
// Total to pay
|
||||
print '<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
$diff = $x_coll_sum - $x_paye_sum ;
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="4">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
|
||||
print '<td class="liste_total nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -30,7 +30,7 @@ $langs->load("banks");
|
||||
$langs->load("bills");
|
||||
|
||||
$id=$_REQUEST["id"];
|
||||
|
||||
$lttype=GETPOST('localTaxType', 'int');
|
||||
$mesg = '';
|
||||
|
||||
// Security check
|
||||
@ -44,6 +44,11 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
*/
|
||||
|
||||
//add payment of localtax
|
||||
if($_POST["cancel"] == $langs->trans("Cancel")){
|
||||
header("Location: reglement.php?localTaxType=".$lttype);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$localtax = new Localtax($db);
|
||||
@ -59,12 +64,13 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
$localtax->datep=$datep;
|
||||
$localtax->amount=$_POST["amount"];
|
||||
$localtax->label=$_POST["label"];
|
||||
$localtax->ltt=$lttype;
|
||||
|
||||
$ret=$localtax->addPayment($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$db->commit();
|
||||
header("Location: reglement.php");
|
||||
header("Location: reglement.php?localTaxType=".$lttype);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@ -145,10 +151,11 @@ if ($_GET["action"] == 'create')
|
||||
{
|
||||
print "<form name='add' action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="localTaxType" value="'.$lttype.'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print_fiche_titre($langs->transcountry("newLT2Payment",$mysoc->country_code));
|
||||
|
||||
print_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment",$mysoc->country_code));
|
||||
|
||||
if ($mesg) print $mesg;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -163,7 +170,7 @@ if ($_GET["action"] == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="40" value="'.($_POST["label"]?$_POST["label"]:$langs->transcountry("LT2Payment",$mysoc->country_code)).'"></td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="40" value="'.($_POST["label"]?$_POST["label"]:$langs->transcountry(($lttype==2?"LT2Payment":"LT1Payment"),$mysoc->country_code)).'"></td></tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.$_POST["amount"].'"></td></tr>';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
$langs->load("other");
|
||||
$localTaxType=GETPOST('localTaxType', 'int');
|
||||
|
||||
$year=$_GET["year"];
|
||||
if ($year == 0 )
|
||||
@ -95,13 +96,30 @@ function pt ($db, $sql, $date)
|
||||
|
||||
llxHeader();
|
||||
|
||||
$tva = new Tva($db);
|
||||
if($localTaxType==1)
|
||||
{
|
||||
$LT='LT1';
|
||||
$LTSummary='LT1Summary';
|
||||
$LTPaid='LT1Paid';
|
||||
$LTCustomer='LT1Customer';
|
||||
$LTSupplier='LT1Supplier';
|
||||
$CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$LT='LT2';
|
||||
$LTSummary='LT2Summary';
|
||||
$LTPaid='LT2Paid';
|
||||
$LTCustomer='LT2Customer';
|
||||
$LTSupplier='LT2Supplier';
|
||||
$CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2;
|
||||
}
|
||||
|
||||
|
||||
$textprevyear="<a href=\"index.php?year=" . ($year_current-1) . "\">".img_previous()."</a>";
|
||||
$textnextyear=" <a href=\"index.php?year=" . ($year_current+1) . "\">".img_next()."</a>";
|
||||
$textprevyear="<a href=\"index.php?localTaxType=".$localTaxType."&year=" . ($year_current-1) . "\">".img_previous()."</a>";
|
||||
$textnextyear=" <a href=\"index.php?localTaxType=".$localTaxType."&year=" . ($year_current+1) . "\">".img_next()."</a>";
|
||||
|
||||
print_fiche_titre($langs->transcountry("LT2",$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear");
|
||||
print_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear");
|
||||
|
||||
print $langs->trans("VATReportBuildWithOptionDefinedInModule").'<br>';
|
||||
print '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')<br>';
|
||||
@ -109,10 +127,10 @@ print '<br>';
|
||||
|
||||
print '<table width="100%" class="nobordernopadding">';
|
||||
print '<tr><td>';
|
||||
print_titre($langs->transcountry("LT2Summary",$mysoc->country_code));
|
||||
print_titre($langs->transcountry($LTSummary,$mysoc->country_code));
|
||||
|
||||
print '</td><td width="5"> </td><td>';
|
||||
print_titre($langs->transcountry("LT2Paid",$mysoc->country_code));
|
||||
print_titre($langs->transcountry($LTPaid,$mysoc->country_code));
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
@ -120,8 +138,20 @@ print '<tr><td width="50%" valign="top">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td width=\"30%\">".$langs->trans("Year")." $y</td>";
|
||||
print "<td align=\"right\">".$langs->transcountry("LT2Customer",$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->transcountry("LT2Supplier",$mysoc->country_code)."</td>";
|
||||
if($CalcLT==0)
|
||||
{
|
||||
print "<td align=\"right\">".$langs->transcountry($LTCustomer,$mysoc->country_code)."</td>";
|
||||
print "<td align=\"right\">".$langs->transcountry($LTSupplier,$mysoc->country_code)."</td>";
|
||||
}
|
||||
if($CalcLT==1)
|
||||
{
|
||||
print "<td align=\"right\">".$langs->transcountry($LTSupplier,$mysoc->country_code)."</td><td></td>";
|
||||
}
|
||||
if($CalcLT==2)
|
||||
{
|
||||
print "<td align=\"right\">".$langs->transcountry($LTCustomer,$mysoc->country_code)."</td><td></td>";
|
||||
}
|
||||
|
||||
print "<td align=\"right\">".$langs->trans("TotalToPay")."</td>";
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
@ -160,24 +190,59 @@ for ($m = 1 ; $m < 13 ; $m++ )
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td class="nowrap">'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'</td>';
|
||||
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val)
|
||||
if($CalcLT==0)
|
||||
{
|
||||
$x_coll+=$val['localtax2'];
|
||||
}
|
||||
$subtotalcoll = $subtotalcoll + $x_coll;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_coll)."</td>";
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val)
|
||||
{
|
||||
$x_coll+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalcoll = $subtotalcoll + $x_coll;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_coll)."</td>";
|
||||
|
||||
$x_paye = 0;
|
||||
foreach($coll_listbuy as $vatrate=>$val)
|
||||
$x_paye = 0;
|
||||
foreach($coll_listbuy as $vatrate=>$val)
|
||||
{
|
||||
$x_paye+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalpaye = $subtotalpaye + $x_paye;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_paye)."</td>";
|
||||
}
|
||||
elseif($CalcLT==1)
|
||||
{
|
||||
$x_paye+=$val['localtax2'];
|
||||
$x_paye = 0;
|
||||
foreach($coll_listbuy as $vatrate=>$val)
|
||||
{
|
||||
$x_paye+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalpaye = $subtotalpaye + $x_paye;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_paye)."</td><td></td>";
|
||||
}
|
||||
$subtotalpaye = $subtotalpaye + $x_paye;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_paye)."</td>";
|
||||
|
||||
$diff = $x_coll - $x_paye;
|
||||
elseif($CalcLT==2)
|
||||
{
|
||||
$x_coll = 0;
|
||||
foreach($coll_listsell as $vatrate=>$val)
|
||||
{
|
||||
$x_coll+=$val[$localTaxType==1?'localtax1':'localtax2'];
|
||||
}
|
||||
$subtotalcoll = $subtotalcoll + $x_coll;
|
||||
print "<td class=\"nowrap\" align=\"right\">".price($x_coll)."</td><td></td>";
|
||||
|
||||
}
|
||||
|
||||
if($CalcLT==0)
|
||||
{
|
||||
$diff= $x_coll - $x_paye;
|
||||
}
|
||||
elseif($CalcLT==1)
|
||||
{
|
||||
$diff= $x_paye;
|
||||
}
|
||||
elseif($CalcLT==2)
|
||||
{
|
||||
$diff= $x_coll;
|
||||
}
|
||||
|
||||
$total = $total + $diff;
|
||||
$subtotal = $subtotal + $diff;
|
||||
|
||||
@ -186,12 +251,26 @@ for ($m = 1 ; $m < 13 ; $m++ )
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
if ($i > 2) {
|
||||
if ($i > 2)
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="right">'.$langs->trans("SubTotal").':</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
if($CalcLT==0)
|
||||
{
|
||||
print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
}
|
||||
elseif($CalcLT==1)
|
||||
{
|
||||
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td><td></td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
}
|
||||
elseif($CalcLT==2)
|
||||
{
|
||||
print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td><td></td>';
|
||||
print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
|
||||
}
|
||||
print '<td> </td></tr>';
|
||||
$i = 0;
|
||||
$subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
|
||||
@ -214,6 +293,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f";
|
||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||
$sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND localtaxtype=".$localTaxType;
|
||||
$sql.= " GROUP BY dm ASC";
|
||||
|
||||
pt($db, $sql,$langs->trans("Year")." $y");
|
||||
|
||||
669
htdocs/compta/localtax/quadri_detail.php
Normal file
669
htdocs/compta/localtax/quadri_detail.php
Normal file
@ -0,0 +1,669 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
* Copyright (C) 2014 Rosana Romero <rromero@2byte.es>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/tva/quadri_detail.php
|
||||
* \ingroup tax
|
||||
* \brief Trimestrial page - detailed version
|
||||
* TODO Deal with recurrent invoices as well
|
||||
*/
|
||||
global $mysoc;
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("compta");
|
||||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
|
||||
$local=GETPOST('localTaxType', 'int');
|
||||
// Date range
|
||||
$year=GETPOST("year");
|
||||
if (empty($year))
|
||||
{
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
|
||||
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$q=GETPOST("q");
|
||||
if (empty($q))
|
||||
{
|
||||
if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); }
|
||||
else
|
||||
{
|
||||
$month_current = strftime("%m",dol_now());
|
||||
if ($month_current >= 10) $q=4;
|
||||
elseif ($month_current >= 7) $q=3;
|
||||
elseif ($month_current >= 4) $q=2;
|
||||
else $q=1;
|
||||
}
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
|
||||
if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
|
||||
if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); }
|
||||
if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
|
||||
}
|
||||
|
||||
$min = GETPOST("min");
|
||||
if (empty($min)) $min = 0;
|
||||
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
|
||||
if (empty($modetax)) $modetax=0;
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid','int');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$morequerystring='';
|
||||
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
||||
foreach($listofparams as $param)
|
||||
{
|
||||
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
||||
}
|
||||
|
||||
llxHeader('','','','',0,0,'','',$morequerystring);
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
$company_static=new Societe($db);
|
||||
$invoice_customer=new Facture($db);
|
||||
$invoice_supplier=new FactureFournisseur($db);
|
||||
$product_static=new Product($db);
|
||||
$payment_static=new Paiement($db);
|
||||
$paymentfourn_static=new PaiementFourn($db);
|
||||
|
||||
//print_fiche_titre($langs->trans("VAT"),"");
|
||||
|
||||
//$fsearch.='<br>';
|
||||
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
|
||||
$fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
||||
//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
||||
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||
|
||||
$calc=MAIN_INFO_LOCALTAX_CALC.$local;
|
||||
// Affiche en-tete du rapport
|
||||
if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode");
|
||||
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) $prevquarter--;
|
||||
else { $prevquarter=4; $prevyear--; }
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) $nextquarter++;
|
||||
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>":"");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
else $description.='<br>'.$langs->trans("DepositsAreIncluded");
|
||||
$description.=$fsearch;
|
||||
$builddate=time();
|
||||
//$exportlink=$langs->trans("NotYetAvailable");
|
||||
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
if ($conf->global->$calc==2) // Invoice for goods, payment for services
|
||||
{
|
||||
$nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode");
|
||||
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) $prevquarter--;
|
||||
else { $prevquarter=4; $prevyear--; }
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) $nextquarter++;
|
||||
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>":"");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded");
|
||||
else $description.=' '.$langs->trans("DepositsAreIncluded");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
$description.=$fsearch;
|
||||
$builddate=time();
|
||||
//$exportlink=$langs->trans("NotYetAvailable");
|
||||
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
||||
|
||||
|
||||
if($local==1){
|
||||
$vatcust=$langs->transcountry("LocalTax1", $mysoc->country_code);
|
||||
$vatsup=$langs->transcountry("LocalTax1", $mysoc->country_code);
|
||||
}else{
|
||||
$vatcust=$langs->transcountry("LocalTax2", $mysoc->country_code);
|
||||
$vatsup=$langs->transcountry("LocalTax2", $mysoc->country_code);
|
||||
}
|
||||
|
||||
// VAT Received and paid
|
||||
|
||||
|
||||
|
||||
$y = $year_current;
|
||||
$total = 0;
|
||||
$i=0;
|
||||
|
||||
// Load arrays of datas
|
||||
$x_coll= local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell', $local);
|
||||
//$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
||||
$x_paye = local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy', $local);
|
||||
|
||||
|
||||
echo '<table class="noborder" width="100%">';
|
||||
|
||||
if (! is_array($x_coll) || ! is_array($x_paye))
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($x_coll == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($x_coll == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$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)
|
||||
{
|
||||
//foreach($x_coll[$my_coll_rate][localtax1_list]){
|
||||
$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)
|
||||
{
|
||||
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
|
||||
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
|
||||
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
|
||||
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
||||
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
||||
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
||||
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
||||
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
||||
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
||||
'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
||||
'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||
'localtax1'=> $x_coll[$my_coll_rate]['localtax1_list'][$id],
|
||||
'localtax2'=> $x_coll[$my_coll_rate]['localtax2_list'][$id],
|
||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_customer->getNomUrl(1,'',12));
|
||||
}
|
||||
}
|
||||
// tva paid
|
||||
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)
|
||||
{
|
||||
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
|
||||
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
|
||||
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
|
||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'localtax1'=> $x_paye[$my_paye_rate]['localtax1_list'][$id],
|
||||
'localtax2'=> $x_paye[$my_paye_rate]['localtax2_list'][$id],
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_supplier->getNomUrl(1,'',12));
|
||||
}
|
||||
}
|
||||
//now we have an array (x_both) indexed by rates for coll and paye
|
||||
|
||||
|
||||
//print table headers for this quadri - incomes first
|
||||
|
||||
$x_coll_sum = 0;
|
||||
$x_coll_ht = 0;
|
||||
$x_paye_sum = 0;
|
||||
$x_paye_ht = 0;
|
||||
|
||||
$span=3;
|
||||
if ($modetax == 0) $span+=2;
|
||||
|
||||
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
|
||||
|
||||
if($conf->global->$calc ==0 || $conf->global->$calc == 2){
|
||||
// Customers invoices
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$elementcust.'</td>';
|
||||
print '<td align="left">'.$productcust.'</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td align="right">'.$amountcust.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||
}
|
||||
print '<td align="right">'.$langs->trans("BI").'</td>';
|
||||
print '<td align="right">'.$vatcust.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$LT=0;
|
||||
$sameLT=false;
|
||||
foreach(array_keys($x_coll) as $rate)
|
||||
{
|
||||
$subtot_coll_total_ht = 0;
|
||||
$subtot_coll_vat = 0;
|
||||
|
||||
if (is_array($x_both[$rate]['coll']['detail']))
|
||||
{
|
||||
// VAT Rate
|
||||
$var=true;
|
||||
|
||||
if($rate!=0){
|
||||
print "<tr>";
|
||||
//print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
/**/
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
print '</tr>'."\n";
|
||||
}
|
||||
foreach($x_both[$rate]['coll']['detail'] as $index => $fields)
|
||||
{
|
||||
if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)){
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($fields['ddate_start'])) $type=1;
|
||||
if (! empty($fields['ddate_end'])) $type=1;
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid'])
|
||||
{
|
||||
$product_static->id=$fields['pid'];
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg))
|
||||
{
|
||||
if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||
elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||
else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc']))
|
||||
{
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0)
|
||||
{
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
print '<td class="nowrap" align="right">';
|
||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$payment_static->id=$fields['payment_id'];
|
||||
print $payment_static->getNomUrl(2);
|
||||
}
|
||||
if ($type == 0)
|
||||
{
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
}
|
||||
else {
|
||||
print $fields['payment_amount'];
|
||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Total collected
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'));
|
||||
print '</td>';
|
||||
|
||||
// Localtax
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat= $local==1?$fields['localtax1']:$fields['localtax2'];
|
||||
print price(price2num($temp_vat,'MT'));
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_coll_total_ht += $temp_ht;
|
||||
$subtot_coll_vat += $temp_vat;
|
||||
$x_coll_sum += $temp_vat;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($rate!=0){
|
||||
// Total customers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_coll_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_coll_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($x_coll) == 0) // Show a total ine if nothing shown
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Blank line
|
||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
||||
print '</table>';
|
||||
$diff=$x_coll_sum;
|
||||
}
|
||||
|
||||
if($conf->global->$calc ==0 || $conf->global->$calc == 1){
|
||||
echo '<table class="noborder" width="100%">';
|
||||
//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">'.$elementsup.'</td>';
|
||||
print '<td align="left">'.$productsup.'</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td align="right">'.$amountsup.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||
}
|
||||
print '<td align="right">'.$langs->trans("BI").'</td>';
|
||||
print '<td align="right">'.$vatsup.'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
foreach(array_keys($x_paye) as $rate)
|
||||
{
|
||||
$subtot_paye_total_ht = 0;
|
||||
$subtot_paye_vat = 0;
|
||||
|
||||
if(is_array($x_both[$rate]['paye']['detail']))
|
||||
{
|
||||
$var=true;
|
||||
if($rate!=0){
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
print '</tr>'."\n";
|
||||
}
|
||||
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields)
|
||||
{
|
||||
if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)){
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($fields['ddate_start'])) $type=1;
|
||||
if (! empty($fields['ddate_end'])) $type=1;
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid'])
|
||||
{
|
||||
$product_static->id=$fields['pid'];
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc']))
|
||||
{
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0)
|
||||
{
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
print '<td class="nowrap" align="right">';
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$paymentfourn_static->id=$fields['payment_id'];
|
||||
print $paymentfourn_static->getNomUrl(2);
|
||||
}
|
||||
if ($type == 0)
|
||||
{
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $fields['payment_amount'];
|
||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// VAT paid
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'));
|
||||
print '</td>';
|
||||
|
||||
// Localtax
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat= $local==1?$fields['localtax1']:$fields['localtax2'];
|
||||
print price(price2num($temp_vat,'MT'));
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_paye_total_ht += $temp_ht;
|
||||
$subtot_paye_vat += $temp_vat;
|
||||
$x_paye_sum += $temp_vat;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($rate!=0){
|
||||
// Total suppliers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_paye_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_paye_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($x_paye) == 0) // Show a total ine if nothing shown
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
$diff=$x_paye_sum;
|
||||
}
|
||||
|
||||
if($conf->global->$calc ==0){$diff=$x_coll_sum - $x_paye_sum;}
|
||||
echo '<table class="noborder" width="100%">';
|
||||
// Total to pay
|
||||
print '<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
//$diff = $local==1?$x_coll_sum:$x_paye_sum;
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
|
||||
print '<td class="liste_total nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
echo '</table>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
?>
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -31,6 +31,7 @@ $langs->load("compta");
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
$ltt=$_REQUEST["localTaxType"];
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -40,11 +41,11 @@ llxHeader();
|
||||
|
||||
$localtax_static = new Localtax($db);
|
||||
|
||||
print_fiche_titre($langs->transcountry("LT2Payments",$mysoc->country_code));
|
||||
print_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code));
|
||||
|
||||
$sql = "SELECT rowid, amount, label, f.datev as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f ";
|
||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||
$sql.= " WHERE f.entity = ".$conf->entity." AND localtaxtype=".$ltt;
|
||||
$sql.= " ORDER BY dm DESC";
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -834,15 +834,24 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
global $mysoc;
|
||||
|
||||
//Local Taxes
|
||||
if($mysoc->country_code=='ES' && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj=="1"))
|
||||
//Local Taxes 1
|
||||
if($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj=="1"))
|
||||
{
|
||||
if (empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&mainmenu=accountancy",$langs->transcountry("LT2",$mysoc->country_code),1,$user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/localtax/fiche.php?leftmenu=tax_vat&action=create",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
|
||||
if (empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
|
||||
//if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
|
||||
$newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&mainmenu=accountancy&localTaxType=1",$langs->transcountry("LT1",$mysoc->country_code),1,$user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/fiche.php?leftmenu=tax_vat&action=create&localTaxType=1",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat&localTaxType=1",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat&localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat&localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
|
||||
}
|
||||
//Local Taxes 2
|
||||
if($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj=="1"))
|
||||
{
|
||||
$newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&mainmenu=accountancy&localTaxType=2",$langs->transcountry("LT2",$mysoc->country_code),1,$user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/fiche.php?leftmenu=tax_vat&action=create&localTaxType=2",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat&localTaxType=2",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat&localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
|
||||
if (empty($leftmenu) || preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat&localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user