Merge pull request #39 from simnandez/develop

New: [task 219] LocalTaxes: Add taxes and dividends
This commit is contained in:
Regis Houssin 2011-10-28 03:29:31 -07:00
commit a4c128e11a
16 changed files with 1602 additions and 2 deletions

View File

@ -0,0 +1,592 @@
<?php
/* Copyright (C) 2011 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/localtax/class/localtax.class.php
* \ingroup tax
* \author Laurent Destailleur
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
/**
\class Localtax
\brief Put here description of your class
*/
class localtax extends CommonObject
{
var $id;
var $ref;
var $tms;
var $datep;
var $datev;
var $amount;
var $label;
var $note;
var $fk_bank;
var $fk_user_creat;
var $fk_user_modif;
/**
* Constructor
*
* @param DoliDB $DB Database handler
*/
function localtax($DB)
{
$this->db = $DB;
return 1;
}
/**
* Create in database
*
* @param User $user User that create
* @return int <0 if KO, >0 if OK
*/
function create($user)
{
global $conf, $langs;
// Clean parameters
$this->amount=trim($this->amount);
$this->label=trim($this->label);
$this->note=trim($this->note);
$this->fk_bank=trim($this->fk_bank);
$this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif);
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax(";
$sql.= "tms,";
$sql.= "datep,";
$sql.= "datev,";
$sql.= "amount,";
$sql.= "label,";
$sql.= "note,";
$sql.= "fk_bank,";
$sql.= "fk_user_creat,";
$sql.= "fk_user_modif";
$sql.= ") VALUES (";
$sql.= " ".$this->db->idate($this->tms).",";
$sql.= " ".$this->db->idate($this->datep).",";
$sql.= " ".$this->db->idate($this->datev).",";
$sql.= " '".$this->amount."',";
$sql.= " '".$this->label."',";
$sql.= " '".$this->note."',";
$sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->fk_bank."'").",";
$sql.= " '".$this->fk_user_creat."',";
$sql.= " '".$this->fk_user_modif."'";
$sql.= ")";
dol_syslog("localtax::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax");
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return $this->id;
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("localtax::create ".$this->error, LOG_ERR);
return -1;
}
}
/**
* Update database
* @param user User that modify
* @param notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
// Clean parameters
$this->amount=trim($this->amount);
$this->label=trim($this->label);
$this->note=trim($this->note);
$this->fk_bank=trim($this->fk_bank);
$this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif);
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET";
$sql.= " tms=".$this->db->idate($this->tms).",";
$sql.= " datep=".$this->db->idate($this->datep).",";
$sql.= " datev=".$this->db->idate($this->datev).",";
$sql.= " amount='".$this->amount."',";
$sql.= " label='".$this->db->escape($this->label)."',";
$sql.= " note='".$this->db->escape($this->note)."',";
$sql.= " fk_bank='".$this->fk_bank."',";
$sql.= " fk_user_creat='".$this->fk_user_creat."',";
$sql.= " fk_user_modif='".$this->fk_user_modif."'";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("localtax::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("localtax::update ".$this->error, LOG_ERR);
return -1;
}
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
return 1;
}
/**
* Load object in memory from database
* @param id id object
* @param user User that load
* @return int <0 if KO, >0 if OK
*/
function fetch($id, $user=0)
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.tms,";
$sql.= " t.datep,";
$sql.= " t.datev,";
$sql.= " t.amount,";
$sql.= " t.label,";
$sql.= " t.note,";
$sql.= " t.fk_bank,";
$sql.= " t.fk_user_creat,";
$sql.= " t.fk_user_modif,";
$sql.= " b.fk_account,";
$sql.= " b.fk_type,";
$sql.= " b.rappro";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
$sql.= " WHERE t.rowid = ".$id;
dol_syslog("localtax::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms);
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->label = $obj->label;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
$this->fk_account = $obj->fk_account;
$this->fk_type = $obj->fk_type;
$this->rappro = $obj->rappro;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("localtax::fetch ".$this->error, LOG_ERR);
return -1;
}
}
/**
* Delete object in database
* @param user User that delete
* @return int <0 if KO, >0 if OK
*/
function delete($user)
{
global $conf, $langs;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("localtax::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("localtax::delete ".$this->error, LOG_ERR);
return -1;
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return 1;
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
function initAsSpecimen()
{
$this->id=0;
$this->tms='';
$this->datep='';
$this->datev='';
$this->amount='';
$this->label='';
$this->note='';
$this->fk_bank='';
$this->fk_user_creat='';
$this->fk_user_modif='';
}
/**
* Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax, non ?
*
*/
function solde($year = 0)
{
$reglee = $this->localtax_sum_reglee($year);
$payee = $this->localtax_sum_payee($year);
$collectee = $this->localtax_sum_collectee($year);
$solde = $reglee - ($collectee - $payee);
return $solde;
}
/**
* Total de la localtax des factures emises par la societe.
*
*/
function localtax_sum_collectee($year = 0)
{
$sql = "SELECT sum(f.localtax) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
if ($year)
{
$sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
}
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
return $obj->amount;
}
else
{
return 0;
}
$this->db->free($result);
}
else
{
print $this->db->error();
return -1;
}
}
/**
* localtax payed
*
*/
function localtax_sum_payee($year = 0)
{
$sql = "SELECT sum(f.total_localtax) as total_localtax";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
if ($year)
{
$sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
}
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
return $obj->total_localtax;
}
else
{
return 0;
}
$this->db->free();
}
else
{
print $this->db->error();
return -1;
}
}
/**
* localtax payed
* Total de la localtax payed
*
*/
function localtax_sum_reglee($year = 0)
{
$sql = "SELECT sum(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
if ($year)
{
$sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
}
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
return $obj->amount;
}
else
{
return 0;
}
$this->db->free();
}
else
{
print $this->db->error();
return -1;
}
}
/**
* Add a payment of localtax
* @param user Object user that insert
* @return int <0 if KO, rowid in localtax table if OK
*/
function addPayment($user)
{
global $conf,$langs;
$this->db->begin();
// Check parameters
$this->amount=price2num($this->amount);
if (! $this->label)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
return -3;
}
if ($this->amount <= 0)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
return -4;
}
if ($conf->banque->enabled && (empty($this->accountid) || $this->accountid <= 0))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
return -5;
}
if ($conf->banque->enabled && (empty($this->paymenttype) || $this->paymenttype <= 0))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
return -5;
}
// Insertion dans table des paiement localtax
$sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax (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.= "'".$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)."'";
$sql.=", '".$user->id."', NULL";
$sql.= ")";
dol_syslog("localtax::addPayment sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); // TODO devrait s'appeler paiementlocaltax
if ($this->id > 0)
{
$ok=1;
if ($conf->banque->enabled)
{
// Insertion dans llx_bank
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
$acc = new Account($this->db);
$result=$acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($db);
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
// Mise a jour fk_bank dans llx_localtax. On connait ainsi la ligne de localtax qui a g<>n<EFBFBD>r<EFBFBD> l'<27>criture bancaire
if ($bank_line_id > 0)
{
$this->update_fk_bank($bank_line_id);
}
else
{
$this->error=$acc->error;
$ok=0;
}
// Mise a jour liens
$result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/localtax/fiche.php?id=', "(VATPayment)", "payment_vat");
if ($result < 0)
{
$this->error=$acc->error;
$ok=0;
}
}
if ($ok)
{
$this->db->commit();
return $this->id;
}
else
{
$this->db->rollback();
return -3;
}
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -2;
}
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -1;
}
}
/**
* Update the link betwen localtax payment and the line into llx_bank
* @param id_bank Id compte bancaire
* @return int <0 if KO, >0 if OK
*/
function update_fk_bank($id_bank)
{
$sql = 'UPDATE llx_localtax set fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
if ($result)
{
return 1;
}
else
{
dol_print_error($this->db);
return -1;
}
}
/**
* brief Returns clickable name
* @param withpicto 0=Link, 1=Picto into link, 2=Picto
* @param option Sur quoi pointe le lien
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/localtax/fiche.php?id='.$this->id.'">';
$lienfin='</a>';
$picto='payment';
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
return $result;
}
}
?>

View File

@ -0,0 +1,299 @@
<?php
/* Copyright (C) 2011 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/localtax/clients.php
* \ingroup tax
* \brief Third parties localtax report
*/
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");
$langs->load("bills");
$langs->load("compta");
$langs->load("companies");
$langs->load("products");
// 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"];
// Security check
$socid = GETPOST("socid");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
/*
* View
*/
$html=new Form($db);
$company_static=new Societe($db);
$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);
$fsearch.='<br>';
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
$fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': ';
$fsearch.=' <input type="text" name="min" id="min" value="'.$min.'" size="6">';
// Affiche en-tete du rapport
if ($modetax==1) // Calculate on invoice for goods and services
{
$nom=$langs->transcountry("LT2ReportByCustomersInInputOutputMode",$mysoc->pays_code);
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$description=$langs->trans("RulesVATDue");
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
$description.=$fsearch;
$description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
$builddate=time();
$elementcust=$langs->trans("CustomersInvoices");
$productcust=$langs->trans("Description");
$amountcust=$langs->trans("AmountHT");
$elementsup=$langs->trans("SuppliersInvoices");
$productsup=$langs->trans("Description");
$amountsup=$langs->trans("AmountHT");
}
if ($modetax==0) // Invoice for goods, payment for services
{
$nom=$langs->transcountry("LT2ReportByCustomersInInputOutputMode",$mysoc->pays_code);
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$description=$langs->trans("RulesVATIn");
if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
$description.=$fsearch;
$description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
$builddate=time();
$elementcust=$langs->trans("CustomersInvoices");
$productcust=$langs->trans("Description");
$amountcust=$langs->trans("AmountHT");
$elementsup=$langs->trans("SuppliersInvoices");
$productsup=$langs->trans("Description");
$amountsup=$langs->trans("AmountHT");
}
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
$vatcust=$langs->transcountry("LT2",$mysoc->pays_code);
$vatsup=$langs->transcountry("LT2",$mysoc->pays_code);
// IRPF that the customer has retained me
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->pays_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');
if (is_array($coll_list))
{
$var=true;
$total = 0; $totalamount = 0;
$i = 1;
foreach($coll_list as $coll)
{
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2>0)
{
$var=!$var;
$intra = str_replace($find,$replace,$coll->tva_intra);
if(empty($intra))
{
if($coll->assuj == '1')
{
$intra = $langs->trans('Unknown');
}
else
{
$intra = '';
}
}
print "<tr ".$bc[$var].">";
print "<td nowrap>".$i."</td>";
$company_static->id=$coll->socid;
$company_static->nom=$coll->nom;
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
$find = array(' ','.');
$replace = array('','');
print "<td nowrap>".$intra."</td>";
print "<td nowrap align=\"right\">".price($coll->amount)."</td>";
print "<td 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 nowrap align="right">'.price($totalamount).'</td>';
print '<td 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>';
}
// IRPF I retained my supplier
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->pays_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');
if (is_array($coll_list))
{
$var=true;
$total = 0; $totalamount = 0;
$i = 1;
foreach($coll_list as $coll)
{
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2>0)
{
$var=!$var;
$intra = str_replace($find,$replace,$coll->tva_intra);
if(empty($intra))
{
if($coll->assuj == '1')
{
$intra = $langs->trans('Unknown');
}
else
{
$intra = '';
}
}
print "<tr $bc[$var]>";
print "<td nowrap>".$i."</td>";
$company_static->id=$coll->socid;
$company_static->nom=$coll->nom;
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
$find = array(' ','.');
$replace = array('','');
print "<td nowrap>".$intra."</td>";
print "<td nowrap align=\"right\">".price($coll->amount)."</td>";
print "<td 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 nowrap align="right">'.price($totalamount).'</td>';
print '<td 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="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>';
}
print '</table>';
$db->close();
llxFooter();
?>

View File

@ -0,0 +1,266 @@
<?php
/* Copyright (C) 2011 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/localtax/fiche.php
* \ingroup tax
* \brief Page of IRPF payments
*/
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/compta/localtax/class/localtax.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
$langs->load("compta");
$langs->load("banks");
$langs->load("bills");
$id=$_REQUEST["id"];
$mesg = '';
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
/*
* Actions
*/
//add payment of localtax
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$localtax = new localtax($db);
$db->begin();
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
$localtax->accountid=$_POST["accountid"];
$localtax->paymenttype=$_POST["paiementtype"];
$localtax->datev=$datev;
$localtax->datep=$datep;
$localtax->amount=$_POST["amount"];
$localtax->label=$_POST["label"];
$ret=$localtax->addPayment($user);
if ($ret > 0)
{
$db->commit();
Header("Location: reglement.php");
exit;
}
else
{
$db->rollback();
$mesg='<div class="error">'.$localtax->error.'</div>';
$_GET["action"]="create";
}
}
//delete payment of localtax
if ($_GET["action"] == 'delete')
{
$localtax = new localtax($db);
$result=$localtax->fetch($_GET['id']);
if ($localtax->rappro == 0)
{
$db->begin();
$ret=$localtax->delete($user);
if ($ret > 0)
{
if ($localtax->fk_bank)
{
$accountline=new AccountLine($db);
$result=$accountline->fetch($localtax->fk_bank);
$result=$accountline->delete($user);
}
if ($result > 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/localtax/reglement.php');
exit;
}
else
{
$localtax->error=$accountline->error;
$db->rollback();
$mesg='<div class="error">'.$localtax->error.'</div>';
}
}
else
{
$db->rollback();
$mesg='<div class="error">'.$localtax->error.'</div>';
}
}
else
{
$mesg='<div class="error">Error try do delete a line linked to a conciliated bank transaction</div>';
}
}
/*
* View
*/
llxHeader();
$html = new Form($db);
if ($id)
{
$vatpayment = new localtax($db);
$result = $vatpayment->fetch($id);
if ($result <= 0)
{
dol_print_error($db);
exit;
}
}
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="action" value="add">';
print_fiche_titre($langs->transcountry("newLT2Payment",$mysoc->pays_code));
if ($mesg) print $mesg;
print '<table class="border" width="100%">';
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $html->select_date($datep,"datep",'','','','add');
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateValue").'</td><td>';
print $html->select_date($datev,"datev",'','','','add');
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->pays_code)).'"></td></tr>';
// Amount
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.$_POST["amount"].'"></td></tr>';
if ($conf->banque->enabled)
{
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
$html->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$html->select_types_paiements($_POST["paiementtype"], "paiementtype");
print "</td>\n";
print "</tr>";
}
print '</table>';
print "<br>";
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
if ($id)
{
if ($mesg) print $mesg;
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/localtax/fiche.php?id='.$vatpayment->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $vatpayment->ref;
print '</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
print dol_print_date($vatpayment->datep,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("DateValue").'</td><td colspan="3">';
print dol_print_date($vatpayment->datev,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($vatpayment->amount).'</td></tr>';
if ($conf->banque->enabled)
{
if ($vatpayment->fk_account > 0)
{
$bankline=new AccountLine($db);
$bankline->fetch($vatpayment->fk_bank);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1,0,'showall');
print '</td>';
print '</tr>';
}
}
print '</table>';
print '</div>';
/*
* Boutons d'actions
*/
print "<div class=\"tabsAction\">\n";
if ($vatpayment->rappro == 0)
print '<a class="butActionDelete" href="fiche.php?id='.$vatpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
else
print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
print "</div>";
}
$db->close();
llxFooter();
?>

View File

@ -0,0 +1,219 @@
<?php
/* Copyright (C) 2011 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/localtax/index.php
* \ingroup tax
* \brief Index page of IRPF reports
*/
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/tax.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/tva/class/tva.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
$langs->load("other");
$year=$_GET["year"];
if ($year == 0 )
{
$year_current = strftime("%Y",time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
// Security check
$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"];
function pt ($db, $sql, $date)
{
global $conf, $bc,$langs;
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td nowrap="nowrap" width="60%">'.$date.'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '<td>&nbsp;</td>'."\n";
print "</tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td nowrap="nowrap">'.$obj->dm."</td>\n";
$total = $total + $obj->mm;
print '<td nowrap="nowrap" align="right">'.price($obj->mm)."</td><td >&nbsp;</td>\n";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td align="right">'.$langs->trans("Total")." :</td><td nowrap=\"nowrap\" align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>";
print "</table>";
$db->free($result);
}
else {
dolibar_print_error($db);
}
}
/*
* View
*/
llxHeader();
$tva = new Tva($db);
$textprevyear="<a href=\"index.php?year=" . ($year_current-1) . "\">".img_previous()."</a>";
$textnextyear=" <a href=\"index.php?year=" . ($year_current+1) . "\">".img_next()."</a>";
print_fiche_titre($langs->transcountry("LT2",$mysoc->pays_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear");
print $langs->trans("VATReportBuildWithOptionDefinedInModule").'<br>';
print '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')<br>';
print '<br>';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td>';
print_titre($langs->transcountry("LT2Summary",$mysoc->pays_code));
print '</td><td width="5">&nbsp;</td><td>';
print_titre($langs->transcountry("LT2Paid",$mysoc->pays_code));
print '</td></tr>';
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->pays_code)."</td>";
print "<td align=\"right\">".$langs->transcountry("LT2Supplier",$mysoc->pays_code)."</td>";
print "<td align=\"right\">".$langs->trans("TotalToPay")."</td>";
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$y = $year_current ;
$var=True;
$total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
$i=0;
for ($m = 1 ; $m < 13 ; $m++ )
{
$coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m);
$coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m);
if (! is_array($coll_listbuy) && $coll_listbuy == -1)
{
$langs->load("errors");
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
break;
}
if (! is_array($coll_listbuy) && $coll_listbuy == -2)
{
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
break;
}
$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['localtax2'];
}
$subtotalcoll = $subtotalcoll + $x_coll;
print "<td nowrap align=\"right\">".price($x_coll)."</td>";
$x_paye = 0;
foreach($coll_listbuy as $vatrate=>$val)
{
$x_paye+=$val['localtax2'];
}
$subtotalpaye = $subtotalpaye + $x_paye;
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>&nbsp;</td>\n";
print "</tr>\n";
$i++;
if ($i > 2) {
print '<tr class="liste_total">';
print '<td align="right">'.$langs->trans("SubTotal").':</td>';
print '<td nowrap="nowrap" align="right">'.price($subtotalcoll).'</td>';
print '<td nowrap="nowrap" align="right">'.price($subtotalpaye).'</td>';
print '<td nowrap="nowrap" align="right">'.price($subtotalpaye).'</td>';
print '<td>&nbsp;</td></tr>';
$i = 0;
$subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
}
}
print '<tr class="liste_total"><td align="right" colspan="3">'.$langs->trans("TotalToPay").':</td><td nowrap align="right">'.price($total).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
print '</table>';
print '</td><td>&nbsp;</td><td valign="top" width="50%">';
/*
* Payed
*/
$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm";
$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.= " GROUP BY dm ASC";
pt($db, $sql,$langs->trans("Year")." $y");
print "</td></tr></table>";
print '</td></tr>';
print '</table>';
$db->close();
llxFooter();
?>

View File

@ -0,0 +1,97 @@
<?php
/* Copyright (C) 2011 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/localtax/reglement.php
* \ingroup tax
* \brief List of IRPF payments
*/
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/compta/localtax/class/localtax.class.php");
$langs->load("compta");
$langs->load("compta");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
/*
* View
*/
llxHeader();
$localtax_static = new localtax($db);
print_fiche_titre($langs->transcountry("LT2Payments",$mysoc->pays_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.= " ORDER BY dm DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td nowrap align="left">'.$langs->trans("Ref").'</td>';
print "<td>".$langs->trans("Label")."</td>";
print '<td nowrap align="left">'.$langs->trans("DatePayment").'</td>';
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
print "</tr>\n";
$var=1;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
$localtax_static->id=$obj->rowid;
$localtax_static->ref=$obj->rowid;
print "<td>".$localtax_static->getNomUrl(1)."</td>\n";
print "<td>".dol_trunc($obj->label,40)."</td>\n";
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
$total = $total + $obj->amount;
print "<td align=\"right\">".price($obj->amount)."</td>";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total").'</td>';
print "<td align=\"right\"><b>".price($total)."</b></td></tr>";
print "</table>";
$db->free($result);
}
else
{
dol_print_error($db);
}
$db->close();
llxFooter();
?>

View File

@ -49,6 +49,8 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
$invoicedettable='facturedet';
$fk_facture='fk_facture';
$total_tva='total_tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
}
if ($direction == 'buy')
{
@ -56,6 +58,8 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
$invoicedettable='facture_fourn_det';
$fk_facture='fk_facture_fourn';
$total_tva='tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
}
// Define sql request
@ -74,8 +78,10 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
}
if ($conf->global->MAIN_MODULE_COMPTABILITE)
{
$sql = "SELECT s.rowid as socid, s.nom as nom, s.tva_intra as tva_intra, s.tva_assuj as assuj,";
$sql.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva";
$sql = "SELECT s.rowid as socid, s.nom as nom, s.siren as tva_intra, s.tva_assuj as assuj,";
$sql.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva,";
$sql.= " sum(fd.".$total_localtax1.") as localtax1,";
$sql.= " sum(fd.".$total_localtax2.") as localtax2";
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as fd,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
@ -195,6 +201,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$fk_facture2='fk_facture';
$fk_payment='fk_paiement';
$total_tva='total_tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
$paymenttable='paiement';
$paymentfacturetable='paiement_facture';
}
@ -206,6 +214,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$fk_facture2='fk_facturefourn';
$fk_payment='fk_paiementfourn';
$total_tva='tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
$paymenttable='paiementfourn';
$paymentfacturetable='paiementfourn_facturefourn';
}
@ -229,6 +239,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
{
// 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_tx 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.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$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,";
@ -275,6 +286,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
{
// 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_tx 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.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$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,";
@ -331,12 +343,16 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
{
if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0;
if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0;
if (! isset($list[$assoc['rate']]['locatax1'])) $list[$assoc['rate']]['localtax1']=0;
if (! isset($list[$assoc['rate']]['locatax2'])) $list[$assoc['rate']]['localtax2']=0;
if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid
{
$oldrowid=$assoc['rowid'];
$list[$assoc['rate']]['totalht'] += $assoc['total_ht'];
$list[$assoc['rate']]['vat'] += $assoc['total_vat'];
$list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2'];
}
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
@ -351,6 +367,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht'];
$list[$assoc['rate']]['vat_list'][] = $assoc['total_vat'];
$list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$assoc['rate']]['pid'][] = $assoc['pid'];
$list[$assoc['rate']]['pref'][] = $assoc['pref'];
@ -390,6 +408,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
{
// Count on invoice date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx 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.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$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,";
@ -437,6 +456,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
{
// Count on payments date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx 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.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$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,";
@ -491,12 +511,16 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
{
if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0;
if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0;
if (! isset($list[$assoc['rate']]['locatax1'])) $list[$assoc['rate']]['localtax1']=0;
if (! isset($list[$assoc['rate']]['locatax2'])) $list[$assoc['rate']]['localtax2']=0;
if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid
{
$oldrowid=$assoc['rowid'];
$list[$assoc['rate']]['totalht'] += $assoc['total_ht'];
$list[$assoc['rate']]['vat'] += $assoc['total_vat'];
$list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2'];
}
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
@ -511,6 +535,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht'];
$list[$assoc['rate']]['vat_list'][] = $assoc['total_vat'];
$list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1'];
$list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2'];
$list[$assoc['rate']]['pid'][] = $assoc['pid'];
$list[$assoc['rate']]['pref'][] = $assoc['pref'];

View File

@ -941,7 +941,20 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/reglement.php?leftmenu=tax_vat",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
global $mysoc;
//Local Taxes
if($mysoc->pays_code=='ES' && $mysoc->localtax2_assuj=="1")
{
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&amp;mainmenu=accountancy",$langs->transcountry("LT2",$mysoc->pays_code),1,$user->rights->tax->charges->lire);
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/fiche.php?leftmenu=tax_vat&action=create",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer);
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat",$langs->trans("Payments"),2,$user->rights->tax->charges->lire);
if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
//if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
}
}
}
// Compta simple

View File

@ -69,3 +69,17 @@ DROP TABLE IF EXISTS llx_pos_tmp;
ALTER TABLE llx_deplacement ADD COLUMN fk_user_modif integer AFTER fk_user_author;
CREATE TABLE IF NOT EXISTS `llx_localtax` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`datep` date DEFAULT NULL,
`datev` date DEFAULT NULL,
`amount` double NOT NULL DEFAULT '0',
`label` varchar(255) DEFAULT NULL,
`entity` int(11) NOT NULL DEFAULT '1',
`note` text,
`fk_bank` int(11) DEFAULT NULL,
`fk_user_creat` int(11) DEFAULT NULL,
`fk_user_modif` int(11) DEFAULT NULL,
PRIMARY KEY (`rowid`)
) ENGINE=InnoDB;

View File

@ -0,0 +1,42 @@
-- ===================================================================
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2011 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
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ===================================================================
create table llx_localtax
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
datep date, -- date of payment
datev date, -- date of value
amount real NOT NULL DEFAULT 0,
label varchar(255),
entity integer DEFAULT 1 NOT NULL,
note text,
fk_bank integer,
fk_user_creat integer,
fk_user_modif integer
)ENGINE=innodb;
--
-- List of codes for the field entity
--
-- 1 : first company vat
-- 2 : second company vat
-- 3 : etc...
--

View File

@ -296,6 +296,8 @@ IncludedVAT=IVA inclòs
HT=Sense IVA
TTC=IVA inclòs
VAT=IVA
LT1ES=RE
LT2ES=IRPF
VATRate=Taxa IVA
Average=Mitja
Sum=Suma

View File

@ -37,7 +37,11 @@ VATToPay=VAT sells
VATReceived=VAT received
VATToCollect=VAT purchases
VATSummary=VAT Balance
LT2SummaryES=IRPF Balance
VATPaid=VAT paid
LT2PaidES=IRPF Paid
LT2CustomerES=IRPF sales
LT2SupplierES=IRPF purchases
VATCollected=VAT collected
ToPay=To pay
ToGet=To get back
@ -63,6 +67,9 @@ ListOfCustomerPayments=List of customer payments
ListOfSupplierPayments=List of supplier payments
DatePayment=Payment date
NewVATPayment=New VAT payment
newLT2PaymentES=New IRPF payment
LT2PaymentES=IRPF Payment
LT2PaymentsES=IRPF Payments
VATPayment=VAT Payment
VATPayments=VAT Payments
SocialContributionsPayments=Social contributions payments
@ -104,6 +111,7 @@ RulesResultDue=- Amounts shown are with all taxes included<br>- It includes outs
RulesResultInOut=- Amounts shown are with all taxes included<br>- It includes the real payments made on invoices, expenses and VAT. <br>- It is based on the payment dates of the invoices, expenses anf VAT.<br>
RulesCADue=- It includes the client's due invoices (except deposit invoices) whether they are paid or not. <br>- It is based on the validation date of these invoices. <br>
RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br>
LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF
VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid (VAT receipt)
VATReportByCustomersInDueDebtMode=Report by the customer VAT collected and paid (VAT rate)
VATReportByQuartersInInputOutputMode=Report by rate of the VAT collected and paid (VAT receipt)

View File

@ -298,6 +298,8 @@ IncludedVAT=Included tax
HT=Net of tax
TTC=Inc. tax
VAT=Sales tax
LT1ES=RE
LT2ES=IRPF
VATRate=Tax Rate
Average=Average
Sum=Sum

View File

@ -37,7 +37,11 @@ VATToPay=IVA ventas
VATReceived=IVA repercutido
VATToCollect=IVA compras
VATSummary=Balance de IVA
LT2SummaryES=Balance de IRPF
VATPaid=IVA Pagado
LT2PaidES=IRPF Pagado
LT2CustomerES=IRPF ventas
LT2SupplierES=IRPF compras
VATCollected=IVA recuperado
ToPay=A pagar
ToGetBack=A recuperar
@ -63,6 +67,9 @@ ListOfCustomerPayments=Listado de pagos de clientes
ListOfSupplierPayments=Listado de pagos a proveedores
DatePayment=Fecha de pago
NewVATPayment=Nuevo pago de IVA
newLT2PaymentES=Nuevo pago de IRPF
LT2PaymentES=Pago IRPF
LT2PaymentsES=Pagos IRPF
VATPayment=Pago IVA
VATPayments=Pagos IVA
SocialContributionsPayments=Pagos cargas sociales
@ -104,6 +111,7 @@ RulesResultDue=- Los importes mostrados son importes totales<br>- Incluye las fa
RulesResultInOut=- Los importes mostrados son importes totales<br>- Incluye los pagos realizados para las facturas, cargas e IVA.<br>- Se basa en la fecha de pago de las mismas.<br>
RulesCADue=- Incluye las facturas a clientes (que no sean de anticipo), estén pagadas o no.<br>- Se base en la fecha de validación de las mismas.<br>
RulesCAIn=- Incluye los pagos efectuados de las facturas a clientes.<br>- Se basa en la fecha de pago de las mismas<br>
LT2ReportByCustomersInInputOutputModeES=Informe por tercero del IRPF
VATReportByCustomersInInputOutputMode=Informe por cliente del IVA repercutido y pagado (IVA pagado)
VATReportByCustomersInDueDebtMode=Informe por cliente del IVA repercutido y pagado (IVA debido)
VATReportByQuartersInInputOutputMode=Informe por tasa del IVA repercutido y pagado (IVA pagado)

View File

@ -296,6 +296,8 @@ IncludedVAT=IVA incluido
HT=Sin IVA
TTC=IVA incluido
VAT=IVA
LT1ES=RE
LT2ES=IRPF
VATRate=Tasa IVA
Average=Media
Sum=Suma

View File

@ -37,8 +37,12 @@ VATToPay=TVA ventes
VATReceived=TVA collectée
VATToCollect=TVA achats
VATSummary=Balance de TVA
LT2SummaryES=Balance de IRPF
VATPaid=TVA payée
LT2PaidES=IRPF Payée
VATCollected=TVA récupérée
LT2CustomerES=IRPF ventes
LT2SupplierES=IRPF achats
ToPay=A payer
ToGetBack=A récupérer
TaxAndDividendsArea=Espace taxes, charges sociales et dividendes
@ -65,6 +69,9 @@ DatePayment=Date de règlement
NewVATPayment=Nouveau règlement de TVA
VATPayment=Règlement TVA
VATPayments=Règlements TVA
LT2PaymentES=Règlement IRPF
LT2PaymentsES=Règlements IRPF
newLT2PaymentES=Nouveau règlement de IRPF
SocialContributionsPayments=Règlements charges sociales
ShowVatPayment=Affiche paiement TVA
TotalToPay=Total à payer
@ -104,6 +111,7 @@ RulesResultDue=- Les montants affichés sont les montants taxe incluse<br>- Il i
RulesResultInOut=- Les montants affichés sont les montants taxe incluse<br>- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TVA.<br>- Il se base sur la date de règlement de ces factures, charges et TVA.<br>
RulesCADue=- Il inclut les factures clients dues (hors facture accompte), qu'elles soient payées ou non.<br>- Il se base sur la date de validation de ces factures.<br>
RulesCAIn=- Il inclut les règlements effectivement reçus des factures clients.<br>- Il se base sur la date de règlement de ces factures<br>
LT2ReportByCustomersInInputOutputModeES=Rapport par client des IRPF
VATReportByCustomersInInputOutputMode=Rapport par client des TVA collectées et payées (TVA sur encaissement)
VATReportByCustomersInDueDebtMode=Rapport par client des TVA collectées et payées (TVA sur débit)
VATReportByQuartersInInputOutputMode=Rapport par taux des TVA collectées et payées (TVA sur encaissement)

View File

@ -298,6 +298,8 @@ IncludedVAT=Dont TVA
HT=HT
TTC=TTC
VAT=TVA
LT1ES=RE
LT2ES=IRPF
VATRate=Taux TVA
Average=Moyenne
Sum=Somme