Fix: Multiprices were not update by mass vat update tool
This commit is contained in:
parent
12c3fe2558
commit
bd8f1f2d2f
@ -98,12 +98,46 @@ if ($action == 'convert')
|
|||||||
$newnpr=$objectstatic->recuperableonly;
|
$newnpr=$objectstatic->recuperableonly;
|
||||||
$newlevel=0;
|
$newlevel=0;
|
||||||
|
|
||||||
|
$ret=0; $retm=0;
|
||||||
|
|
||||||
|
// Update single price
|
||||||
|
if (! empty($price_base_type))
|
||||||
|
{
|
||||||
|
print "$newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
|
||||||
$ret=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr);
|
$ret=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr);
|
||||||
if ($ret < 0) $error++;
|
}
|
||||||
|
// Update multiprice
|
||||||
|
foreach ($objectstatic->multiprices as $level => $multiprices)
|
||||||
|
{
|
||||||
|
$price_base_type = $objectstatic->multiprices_base_type[$level]; // Get price_base_type of product/service to keep the same for update
|
||||||
|
if (empty($price_base_type)) continue; // Discard not defined price levels
|
||||||
|
|
||||||
|
if ($price_base_type == 'TTC')
|
||||||
|
{
|
||||||
|
$newprice=price2num($objectstatic->multiprices_ttc[$level],'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
|
||||||
|
$newminprice=$objectstatic->multiprices_min_ttc[$level];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$newprice=price2num($objectstatic->multiprices[$level],'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
|
||||||
|
$newminprice=$objectstatic->multiprices_min[$level];
|
||||||
|
}
|
||||||
|
if ($newminprice > $newprice) $newminprice=$newprice;
|
||||||
|
$newvat=str_replace('*','',$newvatrate);
|
||||||
|
$newnpr=$objectstatic->multiprices_recuperableonly[$level];
|
||||||
|
$newlevel=$level;
|
||||||
|
|
||||||
|
print "$newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
|
||||||
|
$retm=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr);
|
||||||
|
if ($retm < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ret < 0 || $retm < 0) $error++;
|
||||||
else $nbrecordsmodified++;
|
else $nbrecordsmodified++;
|
||||||
|
|
||||||
// FIXME Now update all price levels. Call $objectstatic->updatePrice( as many times than exisitng price_level
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@ -63,6 +63,7 @@ class Product extends CommonObject
|
|||||||
var $multiprices_ttc=array();
|
var $multiprices_ttc=array();
|
||||||
var $multiprices_base_type=array();
|
var $multiprices_base_type=array();
|
||||||
var $multiprices_tva_tx=array();
|
var $multiprices_tva_tx=array();
|
||||||
|
var $multiprices_recuperableonly=array();
|
||||||
//! Price by quantity arrays
|
//! Price by quantity arrays
|
||||||
var $price_by_qty;
|
var $price_by_qty;
|
||||||
var $prices_by_qty=array();
|
var $prices_by_qty=array();
|
||||||
@ -1197,7 +1198,7 @@ class Product extends CommonObject
|
|||||||
for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
|
for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
|
||||||
{
|
{
|
||||||
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
|
||||||
$sql.= " price_base_type, tva_tx, tosell, price_by_qty, rowid";
|
$sql.= " price_base_type, tva_tx, tosell, price_by_qty, rowid, recuperableonly";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
|
||||||
$sql.= " WHERE price_level=".$i;
|
$sql.= " WHERE price_level=".$i;
|
||||||
$sql.= " AND fk_product = '".$this->id."'";
|
$sql.= " AND fk_product = '".$this->id."'";
|
||||||
@ -1214,6 +1215,7 @@ class Product extends CommonObject
|
|||||||
$this->multiprices_min_ttc[$i]=$result["price_min_ttc"];
|
$this->multiprices_min_ttc[$i]=$result["price_min_ttc"];
|
||||||
$this->multiprices_base_type[$i]=$result["price_base_type"];
|
$this->multiprices_base_type[$i]=$result["price_base_type"];
|
||||||
$this->multiprices_tva_tx[$i]=$result["tva_tx"];
|
$this->multiprices_tva_tx[$i]=$result["tva_tx"];
|
||||||
|
$this->multiprices_recuperableonly[$i]=$result["recuperableonly"];
|
||||||
|
|
||||||
// Price by quantity
|
// Price by quantity
|
||||||
$this->prices_by_qty[$i]=$result["price_by_qty"];
|
$this->prices_by_qty[$i]=$result["price_by_qty"];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user