diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index 823866f8ce6..66c1ae1ce56 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -180,21 +180,21 @@ else
// Always show vat rates with vat 0
$s=2/7;$qty=1;$vat=0;
- $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0,0);
+ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0,0,$mysoc);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n";
$s=10/3;$qty=1;$vat=0;
- $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0,0);
+ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0,0,$mysoc);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n";
$s=10/3;$qty=2;$vat=0;
- $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0);
+ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
@@ -230,7 +230,7 @@ else
for ($qty=1; $qty<=2; $qty++)
{
$s=10/3;
- $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0);
+ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
@@ -245,14 +245,14 @@ else
// were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
$s=10/3;$qty=1;$vat=10;
- $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0);
+ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n";
$s=10/3;$qty=2;$vat=10;
- $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0);
+ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
@@ -272,8 +272,8 @@ else
$s2=2/7;
// Round by line
- $tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0, 0);
- $tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0, 0);
+ $tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
+ $tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
$total_ht = $tmparray1[0] + $tmparray2[0];
$total_tva = $tmparray1[1] + $tmparray2[1];
$total_ttc = $tmparray1[2] + $tmparray2[2];
@@ -296,7 +296,7 @@ else
// Global round
$subtotal_ht = (($qty*price2num($s1,'MU')) + ($qty*price2num($s2,'MU')));
- $tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0, 0);
+ $tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0, 0,$mysoc);
$total_ht = $tmparray3[0];
$total_tva = $tmparray3[1];
$total_ttc = $tmparray3[2];
diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php
index 296ced0f172..fd67bf9e2ae 100644
--- a/htdocs/cashdesk/class/Facturation.class.php
+++ b/htdocs/cashdesk/class/Facturation.class.php
@@ -89,7 +89,7 @@ class Facturation
*/
public function ajoutArticle()
{
- global $conf,$db;
+ global $conf,$db,$mysoc;
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
@@ -118,7 +118,7 @@ class Facturation
}
// Define part of HT, VAT, TTC
- $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remisePercent(),$vat_rate,0,0,0,'HT',0,$product->type,0);
+ $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remisePercent(),$vat_rate,0,0,0,'HT',0,$product->type,$mysoc);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 8176d1f3c63..de32e30c5e6 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1222,7 +1222,7 @@ class Commande extends CommonOrder
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type,'', $localtaxes_type);
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 204092b257a..35238d71a2f 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -405,6 +405,8 @@ class FactureRec extends Facture
*/
function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null)
{
+ global $mysoc;
+
$facid=$this->id;
dol_syslog("FactureRec::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,fk_unit=$fk_unit", LOG_DEBUG);
@@ -437,7 +439,7 @@ class FactureRec extends Facture
// 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, $type);
+ $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits, $type, $mysoc);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index b58d2052b99..60f931ba90c 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2401,18 +2401,20 @@ class Facture extends CommonInvoice
/**
* Update invoice line with percentage
*
- * @param FactureLigne $line Invoice line
- * @param int $percent Percentage
+ * @param FactureLigne $line Invoice line
+ * @param int $percent Percentage
* @return void
*/
function update_percent($line, $percent)
{
+ global $mysoc;
+
include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php');
// Cap percentages to 100
if ($percent > 100) $percent = 100;
$line->situation_percent = $percent;
- $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->product_type, 'HT', 0, 0, '', '', $percent);
+ $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->product_type, 'HT', 0, 0, $mysoc, '', $percent);
$line->total_ht = $tabprice[0];
$line->total_tva = $tabprice[1];
$line->total_ttc = $tabprice[2];
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 08b53bf9e25..2513de4caaa 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -1181,7 +1181,7 @@ class Expedition extends CommonObject
*/
function fetch_lines()
{
- global $conf;
+ global $conf, $mysoc;
// TODO: recuperer les champs du document associe a part
$sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked";
@@ -1257,7 +1257,7 @@ class Expedition extends CommonObject
$line->volume_units = $obj->volume_units;
// For invoicing
- $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type); // We force type to 0
+ $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc); // We force type to 0
$line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements)
$line->qty = $line->qty_shipped;
$line->total_ht = $tabprice[0];
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index aa36b690619..30642ad09c5 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -886,7 +886,8 @@ if ($action == "addline")
$object_ligne->fk_expensereport = $_POST['fk_expensereport'];
$type = 0; // TODO What if service ?
- $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type);
+ $seller = ''; // seller is unknown
+ $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
$object_ligne->vatrate = price2num($vatrate);
$object_ligne->total_ttc = $tmp[2];
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index a5d43a0d95e..8729dedc0a5 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -1292,7 +1292,10 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
function migrate_price_facture($db,$langs,$conf)
{
$err=0;
-
+
+ $tmpmysoc=new Societe($db);
+ $tmpmysoc->setMysoc($conf);
+
$db->begin();
print '