forked from Wavyzz/dolibarr
Merge remote-tracking branch 'origin/3.9' into develop
This commit is contained in:
@@ -109,12 +109,14 @@ class Facturation
|
|||||||
$localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1);
|
$localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1);
|
||||||
|
|
||||||
// Define part of HT, VAT, TTC
|
// Define part of HT, VAT, TTC
|
||||||
$resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, 0, 0, 0, 'HT', $use_npr, $product->type, $mysoc, $locataxarray);
|
$resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray);
|
||||||
|
|
||||||
// Calcul du total ht sans remise
|
// Calcul du total ht sans remise
|
||||||
$total_ht = $resultarray[0];
|
$total_ht = $resultarray[0];
|
||||||
$total_vat = $resultarray[1];
|
$total_vat = $resultarray[1];
|
||||||
$total_ttc = $resultarray[2];
|
$total_ttc = $resultarray[2];
|
||||||
|
$total_localtax1 = $resultarray[9];
|
||||||
|
$total_localtax2 = $resultarray[10];
|
||||||
|
|
||||||
// Calcul du montant de la remise
|
// Calcul du montant de la remise
|
||||||
if ($this->remisePercent())
|
if ($this->remisePercent())
|
||||||
@@ -151,6 +153,9 @@ class Facturation
|
|||||||
$newcartarray[$i]['remise']=price2num($montant_remise_ht);
|
$newcartarray[$i]['remise']=price2num($montant_remise_ht);
|
||||||
$newcartarray[$i]['total_ht']=price2num($total_ht,'MT');
|
$newcartarray[$i]['total_ht']=price2num($total_ht,'MT');
|
||||||
$newcartarray[$i]['total_ttc']=price2num($total_ttc,'MT');
|
$newcartarray[$i]['total_ttc']=price2num($total_ttc,'MT');
|
||||||
|
$newcartarray[$i]['total_vat']=price2num($total_vat, 'MT');
|
||||||
|
$newcartarray[$i]['total_localtax1']=price2num($total_localtax1, 'MT');
|
||||||
|
$newcartarray[$i]['total_localtax2']=price2num($total_localtax2, 'MT');
|
||||||
$_SESSION['poscart']=$newcartarray;
|
$_SESSION['poscart']=$newcartarray;
|
||||||
|
|
||||||
$this->raz();
|
$this->raz();
|
||||||
@@ -204,11 +209,17 @@ class Facturation
|
|||||||
// Total HT
|
// Total HT
|
||||||
$remise = $tab[$i]['remise'];
|
$remise = $tab[$i]['remise'];
|
||||||
$total_ht += ($tab[$i]['total_ht']);
|
$total_ht += ($tab[$i]['total_ht']);
|
||||||
|
$total_vat += ($tab[$i]['total_vat']);
|
||||||
$total_ttc += ($tab[$i]['total_ttc']);
|
$total_ttc += ($tab[$i]['total_ttc']);
|
||||||
|
$total_localtax1 += ($tab[$i]['total_localtax1']);
|
||||||
|
$total_localtax2 += ($tab[$i]['total_localtax2']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->prix_total_ttc = $total_ttc;
|
$this->prix_total_ttc = $total_ttc;
|
||||||
$this->prix_total_ht = $total_ht;
|
$this->prix_total_ht = $total_ht;
|
||||||
|
$this->prix_total_vat = $total_vat;
|
||||||
|
$this->prix_total_localtax1 = $total_localtax1;
|
||||||
|
$this->prix_total_localtax2 = $total_localtax2;
|
||||||
|
|
||||||
$this->montant_tva = $total_ttc - $total_ht;
|
$this->montant_tva = $total_ttc - $total_ht;
|
||||||
//print $this->prix_total_ttc.'eeee'; exit;
|
//print $this->prix_total_ttc.'eeee'; exit;
|
||||||
|
|||||||
@@ -158,45 +158,30 @@ switch ($action)
|
|||||||
// Get content of cart
|
// Get content of cart
|
||||||
$tab_liste = $_SESSION['poscart'];
|
$tab_liste = $_SESSION['poscart'];
|
||||||
|
|
||||||
// Loop on each product
|
// Loop on each line into cart
|
||||||
$tab_liste_size=count($tab_liste);
|
$tab_liste_size=count($tab_liste);
|
||||||
for ($i=0;$i < $tab_liste_size;$i++)
|
for ($i=0; $i < $tab_liste_size; $i++)
|
||||||
{
|
{
|
||||||
// Recuperation de l'article
|
$tmp = getTaxesFromId($tab_liste[$i]['fk_tva']);
|
||||||
$product = new Product($db);
|
$vat_rate = $tmp['rate'];
|
||||||
$product->fetch($tab_liste[$i]['fk_article']);
|
$vat_npr = $tmp['npr'];
|
||||||
$ret=array('label'=>$product->label,'tva_tx'=>$product->tva_tx,'price'=>$product->price);
|
|
||||||
|
|
||||||
if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
|
||||||
{
|
|
||||||
if (isset($product->multiprices[$societe->price_level]))
|
|
||||||
{
|
|
||||||
$ret['price'] = $product->multiprices[$societe->price_level];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$tab_article = $ret;
|
|
||||||
|
|
||||||
$res = $db->query('SELECT taux FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$tab_liste[$i]['fk_tva']);
|
|
||||||
$ret=array();
|
|
||||||
$tab = $db->fetch_array($res);
|
|
||||||
foreach ( $tab as $cle => $valeur )
|
|
||||||
{
|
|
||||||
$ret[$cle] = $valeur;
|
|
||||||
}
|
|
||||||
$tab_tva = $ret;
|
|
||||||
|
|
||||||
$invoiceline=new FactureLigne($db);
|
$invoiceline=new FactureLigne($db);
|
||||||
$invoiceline->fk_product=$tab_liste[$i]['fk_article'];
|
$invoiceline->fk_product=$tab_liste[$i]['fk_article'];
|
||||||
$invoiceline->desc=$tab_article['label'];
|
$invoiceline->desc=$tab_liste[$i]['label'];
|
||||||
$invoiceline->tva_tx=empty($tab_tva['taux'])?0:$tab_tva['taux']; // works even if vat_rate is ''
|
|
||||||
//$invoiceline->tva_tx=$tab_tva['taux'];
|
|
||||||
$invoiceline->qty=$tab_liste[$i]['qte'];
|
$invoiceline->qty=$tab_liste[$i]['qte'];
|
||||||
$invoiceline->remise_percent=$tab_liste[$i]['remise_percent'];
|
$invoiceline->remise_percent=$tab_liste[$i]['remise_percent'];
|
||||||
$invoiceline->price=$tab_article['price'];
|
$invoiceline->price=$tab_liste[$i]['price'];
|
||||||
$invoiceline->subprice=$tab_article['price'];
|
$invoiceline->subprice=$tab_liste[$i]['price'];
|
||||||
|
|
||||||
|
$invoiceline->tva_tx=empty($vat_rate)?0:$vat_rate; // works even if vat_rate is ''
|
||||||
|
$invoiceline->info_bits=empty($vat_npr)?0:$vat_npr;
|
||||||
|
|
||||||
$invoiceline->total_ht=$tab_liste[$i]['total_ht'];
|
$invoiceline->total_ht=$tab_liste[$i]['total_ht'];
|
||||||
$invoiceline->total_ttc=$tab_liste[$i]['total_ttc'];
|
$invoiceline->total_ttc=$tab_liste[$i]['total_ttc'];
|
||||||
$invoiceline->total_tva=($tab_liste[$i]['total_ttc']-$tab_liste[$i]['total_ht']);
|
$invoiceline->total_tva=$tab_liste[$i]['total_vat'];
|
||||||
|
$invoiceline->total_localtax1=$tab_liste[$i]['total_localtax1'];
|
||||||
|
$invoiceline->total_localtax2=$tab_liste[$i]['total_localtax2'];
|
||||||
$invoice->lines[]=$invoiceline;
|
$invoice->lines[]=$invoiceline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3646,8 +3646,7 @@ function get_localtax_by_third($local)
|
|||||||
* Get vat rate and npr from id.
|
* Get vat rate and npr from id.
|
||||||
* You can call getLocalTaxesFromRate after to get other fields
|
* You can call getLocalTaxesFromRate after to get other fields
|
||||||
*
|
*
|
||||||
* @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
|
* @param int $vatrowid Line ID into vat rate table.
|
||||||
* @param int $usenpr Use npr
|
|
||||||
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
|
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
|
||||||
*/
|
*/
|
||||||
function getTaxesFromId($vatrowid)
|
function getTaxesFromId($vatrowid)
|
||||||
|
|||||||
@@ -40,8 +40,8 @@
|
|||||||
* @param float $pu Unit price (HT or TTC selon price_base_type)
|
* @param float $pu Unit price (HT or TTC selon price_base_type)
|
||||||
* @param float $remise_percent_ligne Discount for line
|
* @param float $remise_percent_ligne Discount for line
|
||||||
* @param float $txtva 0=do not apply standard tax, Vat rate=apply
|
* @param float $txtva 0=do not apply standard tax, Vat rate=apply
|
||||||
* @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty)
|
* @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
|
||||||
* @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty)
|
* @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
|
||||||
* @param float $remise_percent_global 0
|
* @param float $remise_percent_global 0
|
||||||
* @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
|
* @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
|
||||||
* @param int $info_bits Miscellaneous informations on line
|
* @param int $info_bits Miscellaneous informations on line
|
||||||
|
|||||||
Reference in New Issue
Block a user