diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index b62b49d1c84..c557aa4c7b4 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -885,6 +885,8 @@ class Commande extends CommonObject
$line->desc=$desc;
$line->qty=$qty;
$line->tva_tx=$txtva;
+ $line->localtax1_tx=$txlocaltax1;
+ $line->localtax2_tx=$txlocaltax2;
$line->fk_product=$fk_product;
$line->fk_remise_except=$fk_remise_except;
$line->remise_percent=$remise_percent;
@@ -957,6 +959,8 @@ class Commande extends CommonObject
$prod->fetch($idproduct);
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
+ $localtax1_tx=get_localtax($tva_tx,1,$this->client);
+ $localtax2_tx=get_localtax($tva_tx,2,$this->client);
// multiprix
if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level)
$price = $prod->multiprices[$this->client->price_level];
@@ -971,6 +975,8 @@ class Commande extends CommonObject
$line->subprice=$price;
$line->remise_percent=$remise_percent;
$line->tva_tx=$tva_tx;
+ $line->localtax1_tx=$localtax1_tx;
+ $line->localtax2_tx=$localtax2_tx;
$line->ref=$prod->ref;
$line->libelle=$prod->libelle;
$line->product_desc=$prod->description;
@@ -1208,8 +1214,8 @@ class Commande extends CommonObject
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
- $sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,';
- $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.date_start, l.date_end,';
+ $sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,';
+ $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
@@ -1238,9 +1244,13 @@ class Commande extends CommonObject
$line->product_type = $objp->product_type;
$line->qty = $objp->qty;
$line->tva_tx = $objp->tva_tx;
+ $line->localtax1_tx = $objp->localtax1_tx;
+ $line->localtax2_tx = $objp->localtax2_tx;
$line->total_ht = $objp->total_ht;
$line->total_ttc = $objp->total_ttc;
$line->total_tva = $objp->total_tva;
+ $line->total_localtax1 = $objp->total_localtax1;
+ $line->total_localtax2 = $objp->total_localtax2;
$line->subprice = $objp->subprice;
$line->fk_remise_except = $objp->fk_remise_except;
$line->remise_percent = $objp->remise_percent;
@@ -2402,6 +2412,8 @@ class OrderLine
var $qty; // Quantity (example 2)
var $tva_tx; // VAT Rate for product/service (example 19.6)
+ var $localtax1_tx; // Local tax 1
+ var $localtax2_tx; // Local tax 2
var $subprice; // U.P. HT (example 100)
var $remise_percent; // % for line discount (example 20%)
var $rang = 0;
@@ -2411,6 +2423,8 @@ class OrderLine
// Bit 1: 0 ligne normale - 1 si ligne de remise fixe
var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne
var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne
+ var $total_localtax1; // Total local tax 1 for the line
+ var $total_localtax2; // Total local tax 2 for the line
var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne
// Ne plus utiliser
diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php
index 7ac54ca9eaf..4b62f84d49d 100644
--- a/htdocs/compta/commande/fiche.php
+++ b/htdocs/compta/commande/fiche.php
@@ -365,13 +365,13 @@ if ($id > 0 || ! empty($ref))
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '
| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | ';
- print ''.price($propal->total_localtax1).' | ';
+ print ''.price($commande->total_localtax1).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
}
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{
print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | ';
- print ''.price($propal->total_localtax2).' | ';
+ print ''.price($commande->total_localtax2).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
}
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 18ab40b29c7..ac23d82f3c5 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -601,7 +601,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$product->fetch($_POST['idprod'.$i]);
$startday=dol_mktime(12, 0 , 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']);
$endday=dol_mktime(12, 0 , 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']);
- $result=$facture->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
+ $result=$facture->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}
}
@@ -717,6 +717,8 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
+ $lines[$i]->localtax1_tx,
+ $lines[$i]->localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$date_start,
@@ -760,7 +762,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$product->fetch($_POST['idprod'.$i]);
$startday=dol_mktime(12, 0 , 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']);
$endday=dol_mktime(12, 0 , 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']);
- $result=$facture->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
+ $result=$facture->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}
}
@@ -879,6 +881,9 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
$desc=$_POST['dp_desc'];
$type=$_POST["type"];
}
+
+ $localtax1_tx=get_localtax($tva_tx,1,$fac->client);
+ $localtax2_tx=get_localtax($tva_tx,2,$fac->client);
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
@@ -899,6 +904,8 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
$pu_ht,
$_POST['qty'],
$tva_tx,
+ $localtax1_tx,
+ $localtax2_tx,
$_POST['idprod'],
$_POST['remise_percent'],
$date_start,
@@ -965,6 +972,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
// Define vat_rate
$vat_rate=$_POST['tva_tx'];
$vat_rate=str_replace('*','',$vat_rate);
+ $localtax1_rate=get_localtax($vat_rate,1,$fac->client);
+ $localtax2_rate=get_localtax($vat_rate,2,$fac->client);
// Check parameters
if (empty($_POST['productid']) && $_POST["type"] < 0)
@@ -1007,6 +1016,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
$date_start,
$date_end,
$vat_rate,
+ $localtax1_rate,
+ $localtax2_rate,
'HT',
$info_bits,
$type
@@ -1669,6 +1680,18 @@ if ($_GET['action'] == 'create')
print '| '.$langs->trans($classname).' | '.$object->getNomUrl(1).' |
';
print '| '.$langs->trans('TotalHT').' | '.price($object->total_ht).' |
';
print '| '.$langs->trans('TotalVAT').' | '.price($object->total_tva)." |
";
+ if ($mysoc->pays_code=='ES' && $conf->global->MAIN_FEATURES_LEVEL >= 1)
+ {
+ if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
+ {
+ print '| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | '.price($object->total_localtax1)." |
";
+ }
+
+ if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
+ {
+ print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | '.price($object->total_localtax2)." |
";
+ }
+ }
print '| '.$langs->trans('TotalTTC').' | '.price($object->total_ttc)." |
";
}
else
@@ -2621,13 +2644,13 @@ else
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | ';
- print ''.price($propal->total_localtax1).' | ';
+ print ''.price($fac->total_localtax1).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
}
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{
print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | ';
- print ''.price($propal->total_localtax2).' | ';
+ print ''.price($fac->total_localtax2).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
}
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 28cf1f4a3aa..3e5088be203 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -298,13 +298,17 @@ class Facture extends CommonObject
$res=$prod->fetch($_facrec->lignes[$i]->fk_product);
}
$tva_tx = get_default_tva($mysoc,$soc,($prod->tva_tx?$prod->tva_tx:0));
-
+ $localtax1_tx=get_localtax($tva_tx,1,$soc);
+ $localtax2_tx=get_localtax($tva_tx,2,$soc);
+
$result_insert = $this->addline(
$this->id,
$_facrec->lignes[$i]->desc,
$_facrec->lignes[$i]->subprice,
$_facrec->lignes[$i]->qty,
$tva_tx,
+ $localtax1_tx,
+ $localtax2_tx,
$_facrec->lignes[$i]->fk_product,
$_facrec->lignes[$i]->remise_percent,
'','',0,0,'','HT',0,
@@ -405,6 +409,8 @@ class Facture extends CommonObject
$facture->lignes[$i]->price = -$facture->lignes[$i]->price;
$facture->lignes[$i]->total_ht = -$facture->lignes[$i]->total_ht;
$facture->lignes[$i]->total_tva = -$facture->lignes[$i]->total_tva;
+ $facture->lignes[$i]->total_localtax1 = -$facture->lignes[$i]->total_localtax1;
+ $facture->lignes[$i]->total_localtax2 = -$facture->lignes[$i]->total_localtax2;
$facture->lignes[$i]->total_ttc = -$facture->lignes[$i]->total_ttc;
}
}
@@ -540,7 +546,7 @@ class Facture extends CommonObject
{
global $conf;
- $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
+ $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
$sql.= ', f.datef as df';
$sql.= ', f.date_lim_reglement as dlr';
$sql.= ', f.datec as datec';
@@ -582,6 +588,8 @@ class Facture extends CommonObject
$this->remise = $obj->remise;
$this->total_ht = $obj->total;
$this->total_tva = $obj->tva;
+ $this->total_localtax1 = $obj->localtax1;
+ $this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc;
$this->paye = $obj->paye;
$this->close_code = $obj->close_code;
@@ -661,9 +669,9 @@ class Facture extends CommonObject
function fetch_lines()
{
$sql = 'SELECT l.rowid, l.fk_product, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
- $sql.= ' l.remise, l.remise_percent, l.fk_remise_except, l.subprice,';
+ $sql.= ' l.localtax1_tx, l.localtax2_tx, l.remise, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
- $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,';
+ $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,';
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
@@ -691,6 +699,8 @@ class Facture extends CommonObject
$faclig->qty = $objp->qty;
$faclig->subprice = $objp->subprice;
$faclig->tva_tx = $objp->tva_tx;
+ $faclig->localtax1_tx = $objp->localtax1_tx;
+ $faclig->localtax2_tx = $objp->localtax2_tx;
$faclig->remise_percent = $objp->remise_percent;
$faclig->fk_remise_except = $objp->fk_remise_except;
$faclig->fk_product = $objp->fk_product;
@@ -701,6 +711,8 @@ class Facture extends CommonObject
$faclig->info_bits = $objp->info_bits;
$faclig->total_ht = $objp->total_ht;
$faclig->total_tva = $objp->total_tva;
+ $faclig->total_localtax1 = $objp->total_localtax1;
+ $faclig->total_localtax2 = $objp->total_localtax2;
$faclig->total_ttc = $objp->total_ttc;
$faclig->export_compta = $objp->fk_export_compta;
$faclig->code_ventilation = $objp->fk_code_ventilation;
@@ -750,6 +762,8 @@ class Facture extends CommonObject
if (isset($this->close_code)) $this->close_code=trim($this->close_code);
if (isset($this->close_note)) $this->close_note=trim($this->close_note);
if (isset($this->total_tva)) $this->tva=trim($this->total_tva);
+ if (isset($this->total_localtax1)) $this->tva=trim($this->total_localtax1);
+ if (isset($this->total_localtax2)) $this->tva=trim($this->total_localtax2);
if (isset($this->total_ht)) $this->total_ht=trim($this->total_ht);
if (isset($this->total_ttc)) $this->total_ttc=trim($this->total_ttc);
if (isset($this->statut)) $this->statut=trim($this->statut);
@@ -786,6 +800,8 @@ class Facture extends CommonObject
$sql.= " close_code=".(isset($this->close_code)?"'".addslashes($this->close_code)."'":"null").",";
$sql.= " close_note=".(isset($this->close_note)?"'".addslashes($this->close_note)."'":"null").",";
$sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").",";
+ $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").",";
+ $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").",";
$sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").",";
$sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").",";
$sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").",";
@@ -801,7 +817,6 @@ class Facture extends CommonObject
$sql.= " model_pdf=".(isset($this->modelpdf)?"'".addslashes($this->modelpdf)."'":"null").",";
$sql.= " import_key=".(isset($this->import_key)?"'".addslashes($this->import_key)."'":"null")."";
-
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
@@ -1571,9 +1586,9 @@ class Facture extends CommonObject
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
- function addline($facid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0)
+ function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0)
{
- dol_syslog("Facture::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
+ dol_syslog("Facture::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
// Check parameters
@@ -1592,7 +1607,9 @@ class Facture extends CommonObject
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva);
-
+ $txlocaltax1=price2num($txlocaltax1);
+ $txlocaltax2=price2num($txlocaltax2);
+
if ($price_base_type=='HT')
{
$pu=$pu_ht;
@@ -1606,10 +1623,12 @@ class Facture extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
// \TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
@@ -1635,6 +1654,8 @@ class Facture extends CommonObject
$ligne->desc=$desc;
$ligne->qty=$qty;
$ligne->tva_tx=$txtva;
+ $ligne->localtax1_tx=$txlocaltax1;
+ $ligne->localtax2_tx=$txlocaltax2;
$ligne->fk_product=$fk_product;
$ligne->product_type=$product_type;
$ligne->remise_percent=$remise_percent;
@@ -1647,6 +1668,8 @@ class Facture extends CommonObject
$ligne->fk_remise_except=$fk_remise_except;
$ligne->total_ht=$total_ht;
$ligne->total_tva=$total_tva;
+ $ligne->total_localtax1=$total_localtax1;
+ $ligne->total_localtax2=$total_localtax2;
$ligne->total_ttc=$total_ttc;
// \TODO Ne plus utiliser
@@ -1696,7 +1719,7 @@ class Facture extends CommonObject
* \param type Type of line (0=product, 1=service)
* \return int < 0 si erreur, > 0 si ok
*/
- function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva, $price_base_type='HT', $info_bits=0, $type=0)
+ function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2,$price_base_type='HT', $info_bits=0, $type=0)
{
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
@@ -1712,7 +1735,8 @@ class Facture extends CommonObject
if (! $qty) $qty=0;
$pu = price2num($pu);
$txtva=price2num($txtva);
-
+ $txlocaltax1=price2num($txlocaltax1);
+ $txlocaltax2=price2num($txlocaltax2);
// Check parameters
if ($type < 0) return -1;
@@ -1720,10 +1744,12 @@ class Facture extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits);
+ $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $localtax1, $localtax2, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
+ $total_localtax1=$tabprice[9];
+ $total_localtax1=$tabprice[10];
$pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
@@ -1746,12 +1772,16 @@ class Facture extends CommonObject
$ligne->desc=$desc;
$ligne->qty=$qty;
$ligne->tva_tx=$txtva;
+ $ligne->localtax1_tx=$txlocaltax1;
+ $ligne->localtax2_tx=$txlocaltax2;
$ligne->remise_percent=$remise_percent;
$ligne->subprice=$pu;
$ligne->date_start=$date_start;
$ligne->date_end=$date_end;
$ligne->total_ht=$total_ht;
$ligne->total_tva=$total_tva;
+ $ligne->total_localtax1=$total_localtax1;
+ $ligne->total_localtax2=$total_localtax2;
$ligne->total_ttc=$total_ttc;
$ligne->info_bits=$info_bits;
$ligne->product_type=$type;
@@ -2861,6 +2891,8 @@ class FactureLigne
var $qty; // Quantity (example 2)
var $tva_tx; // Taux tva produit/service (example 19.6)
+ var $localtax1_tx; // Local tax 1
+ var $localtax2_tx; // Local tax 2
var $subprice; // P.U. HT (example 100)
var $remise_percent; // % de la remise ligne (example 20%)
var $fk_remise_except; // Link to line into llx_remise_except
@@ -2874,6 +2906,8 @@ class FactureLigne
var $total_ht;
//! Total TVA de la ligne toute quantite et incluant la remise ligne
var $total_tva;
+ var $total_localtax1; //Total Local tax 1 de la ligne
+ var $total_localtax2; //Total Local tax 2 de la ligne
//! Total TTC de la ligne toute quantite et incluant la remise ligne
var $total_ttc;
@@ -2909,7 +2943,7 @@ class FactureLigne
function fetch($rowid)
{
$sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_product, fd.product_type, fd.description, fd.price, fd.qty, fd.tva_tx,';
- $sql.= ' fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,';
+ $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,';
$sql.= ' fd.date_start as date_start, fd.date_end as date_end,';
$sql.= ' fd.info_bits, fd.total_ht, fd.total_tva, fd.total_ttc, fd.rang,';
$sql.= ' fd.fk_code_ventilation, fd.fk_export_compta,';
@@ -2927,6 +2961,8 @@ class FactureLigne
$this->qty = $objp->qty;
$this->subprice = $objp->subprice;
$this->tva_tx = $objp->tva_tx;
+ $this->localtax1_tx = $objp->localtax1_tx;
+ $this->localtax2_tx = $objp->localtax2_tx;
$this->remise_percent = $objp->remise_percent;
$this->fk_remise_except = $objp->fk_remise_except;
$this->fk_product = $objp->fk_product;
@@ -2936,6 +2972,8 @@ class FactureLigne
$this->info_bits = $objp->info_bits;
$this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva;
+ $this->total_localtax1= $objp->total_localtax1;
+ $this->total_localtax2= $objp->total_localtax2;
$this->total_ttc = $objp->total_ttc;
$this->fk_code_ventilation = $objp->fk_code_ventilation;
$this->fk_export_compta = $objp->fk_export_compta;
@@ -3001,15 +3039,17 @@ class FactureLigne
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
- $sql.= ' (fk_facture, description, qty, tva_tx,';
+ $sql.= ' (fk_facture, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
$sql.= ' date_start, date_end, fk_code_ventilation, fk_export_compta, ';
$sql.= ' rang,';
- $sql.= ' info_bits, total_ht, total_tva, total_ttc)';
+ $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc)';
$sql.= " VALUES (".$this->fk_facture.",";
$sql.= " '".addslashes($this->desc)."',";
$sql.= " ".price2num($this->qty).",";
$sql.= " ".price2num($this->tva_tx).",";
+ $sql.= " ".price2num($this->localtax1_tx).",";
+ $sql.= " ".price2num($this->localtax2_tx).",";
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
else { $sql.='null,'; }
$sql.= " ".$this->product_type.",";
@@ -3029,6 +3069,8 @@ class FactureLigne
$sql.= " '".$this->info_bits."',";
$sql.= " ".price2num($this->total_ht).",";
$sql.= " ".price2num($this->total_tva).",";
+ $sql.= " ".price2num($this->total_localtax1).",";
+ $sql.= " ".price2num($this->total_localtax2).",";
$sql.= " ".price2num($this->total_ttc);
$sql.= ')';
@@ -3137,6 +3179,8 @@ class FactureLigne
if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
else $sql.= ",fk_remise_except=null";
$sql.= ",tva_tx=".price2num($this->tva_tx)."";
+ $sql.= ",localtax1_tx=".price2num($this->localtax1_tx)."";
+ $sql.= ",localtax2_tx=".price2num($this->localtax2_tx)."";
$sql.= ",qty=".price2num($this->qty)."";
if ($this->date_start) { $sql.= ",date_start='".$this->db->idate($this->date_start)."'"; }
else { $sql.=',date_start=null'; }
@@ -3147,6 +3191,8 @@ class FactureLigne
$sql.= ",info_bits='".$this->info_bits."'";
$sql.= ",total_ht=".price2num($this->total_ht)."";
$sql.= ",total_tva=".price2num($this->total_tva)."";
+ $sql.= ",total_localtax1=".price2num($this->total_localtax1)."";
+ $sql.= ",total_localtax2=".price2num($this->total_localtax2)."";
$sql.= ",total_ttc=".price2num($this->total_ttc)."";
$sql.= " WHERE rowid = ".$this->rowid;
@@ -3189,11 +3235,11 @@ class FactureLigne
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
$sql.= " total_ht=".price2num($this->total_ht)."";
$sql.= ",total_tva=".price2num($this->total_tva)."";
+ $sql.= ",total_localtax1=".price2num($this->total_localtax1)."";
+ $sql.= ",total_localtax2=".price2num($this->total_localtax2)."";
$sql.= ",total_ttc=".price2num($this->total_ttc)."";
$sql.= " WHERE rowid = ".$this->rowid;
-
-
$resql=$this->db->query($sql);
if ($resql)
{
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 759ca4b06be..d8b7bae429f 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -380,6 +380,8 @@ class Contrat extends CommonObject
$ligne->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx;
+ $ligne->localtax1_tx = 0;
+ $ligne->localtax2_tx = 0;
$ligne->subprice = $objp->subprice;
$ligne->statut = $objp->statut;
$ligne->remise_percent = $objp->remise_percent;
@@ -387,6 +389,8 @@ class Contrat extends CommonObject
$ligne->price = $objp->price; // For backward compatibility
$ligne->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva;
+ $ligne->total_localtax1= 0;
+ $ligne->total_localtax2= 0;
$ligne->total_ttc = $objp->total_ttc;
$ligne->fk_product = $objp->fk_product;
$ligne->info_bits = $objp->info_bits;
@@ -464,12 +468,16 @@ class Contrat extends CommonObject
$ligne->statut = $objp->statut;
$ligne->ref = $objp->ref;
$ligne->tva_tx = $objp->tva_tx;
+ $ligne->localtax1_tx =0;
+ $ligne->localtax2_tx =0;
$ligne->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent;
$ligne->price_ht = $objp->price_ht;
$ligne->price = $objp->price; // For backward compatibility
$ligne->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva;
+ $ligne->total_localtax1= 0;
+ $ligne->total_localtax2= 0;
$ligne->total_ttc = $objp->total_ttc;
$ligne->fk_product = 0;
$ligne->info_bits = $objp->info_bits;
@@ -1427,6 +1435,8 @@ class ContratLigne
var $date_fin_validite; // date end planned
var $date_cloture; // date end real
var $tva_tx;
+ var $localtax1_tx;
+ var $localtax2_tx;
var $qty;
var $remise_percent;
var $remise;
@@ -1437,6 +1447,8 @@ class ContratLigne
var $total_ht;
var $total_tva;
+ var $total_localtax1;
+ var $total_localtax2;
var $total_ttc;
var $info_bits;
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 4b5c053bba1..645e9880731 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -2487,14 +2487,16 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
function get_localtax($tva, $local, $societe_acheteuse="")
{
global $db, $conf, $mysoc;
+
+ $code_pays=$mysoc->pays_code;
+
if (is_object($societe_acheteuse))
{
+ if ($code_pays!=$societe_acheteuse->pays_code) return 0;
if ($local==1 && !$societe_acheteuse->localtax1_assuj) return 0;
elseif ($local==2 && !$societe_acheteuse->localtax2_assuj) return 0;
}
- $code_pays=$mysoc->pays_code;
-
// Search local taxes
$sql = "SELECT t.localtax1, t.localtax2";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
diff --git a/htdocs/lib/order.lib.php b/htdocs/lib/order.lib.php
index 95a89feae21..107d22f272f 100644
--- a/htdocs/lib/order.lib.php
+++ b/htdocs/lib/order.lib.php
@@ -58,7 +58,7 @@ function commande_prepare_head($commande)
if ($conf->facture->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
- $head[$h][1] = $langs->trans("Compta");
+ $head[$h][1] = $langs->trans("AccountancyCard");
$head[$h][2] = 'accountancy';
$h++;
}
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 2dc027f1d63..cc16c246d57 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -558,6 +558,8 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
$desc = $prod->description;
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
+ $localtax1_tx= get_localtax($tva_tx, 1, $soc);
+ $localtax2_tx= get_localtax($tva_tx, 2, $soc);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
@@ -592,6 +594,8 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
$pu_ht,
$_POST["qty"],
$tva_tx,
+ $localtax1_tx,
+ $localtax2_tx,
$prod->id,
$_POST["remise_percent"],
'',