FIX #5763 Bug: Cannot Create Supplier Price Request
This commit is contained in:
parent
538274998b
commit
43da410b95
@ -195,6 +195,8 @@ class Product extends CommonObject
|
|||||||
var $buyprice;
|
var $buyprice;
|
||||||
public $fourn_pu;
|
public $fourn_pu;
|
||||||
|
|
||||||
|
public $fourn_price_base_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @see ref_supplier
|
* @see ref_supplier
|
||||||
@ -1314,7 +1316,7 @@ class Product extends CommonObject
|
|||||||
* This also set some properties on product like ->buyprice, ->fourn_pu, ...
|
* This also set some properties on product like ->buyprice, ->fourn_pu, ...
|
||||||
*
|
*
|
||||||
* @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price
|
* @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price
|
||||||
* @param double $qty Quantity asked
|
* @param double $qty Quantity asked or -1 to get first entry found
|
||||||
* @param int $product_id Filter on a particular product id
|
* @param int $product_id Filter on a particular product id
|
||||||
* @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search.
|
* @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search.
|
||||||
* @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
|
* @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
|
||||||
@ -1337,7 +1339,7 @@ class Product extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
if ($obj && $obj->quantity > 0) // If found
|
if ($obj && $obj->quantity > 0) // If we found a supplier prices from the id of supplier price
|
||||||
{
|
{
|
||||||
if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression))
|
if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression))
|
||||||
{
|
{
|
||||||
@ -1355,7 +1357,8 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->buyprice = $obj->price; // deprecated
|
$this->buyprice = $obj->price; // deprecated
|
||||||
$this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id
|
$this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier
|
||||||
|
$this->fourn_price_base_type = 'HT'; // Price base type
|
||||||
$this->ref_fourn = $obj->ref_fourn; // deprecated
|
$this->ref_fourn = $obj->ref_fourn; // deprecated
|
||||||
$this->ref_supplier = $obj->ref_fourn; // Ref supplier
|
$this->ref_supplier = $obj->ref_fourn; // Ref supplier
|
||||||
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
|
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
|
||||||
@ -1397,8 +1400,9 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->buyprice = $obj->price; // deprecated
|
$this->buyprice = $obj->price; // deprecated
|
||||||
$this->fourn_qty = $obj->quantity; // min quantity for price
|
$this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier
|
||||||
$this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id
|
$this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier
|
||||||
|
$this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier
|
||||||
$this->ref_fourn = $obj->ref_supplier; // deprecated
|
$this->ref_fourn = $obj->ref_supplier; // deprecated
|
||||||
$this->ref_supplier = $obj->ref_supplier; // Ref supplier
|
$this->ref_supplier = $obj->ref_supplier; // Ref supplier
|
||||||
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
|
$this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier
|
||||||
|
|||||||
@ -596,7 +596,8 @@ if (empty($reshook))
|
|||||||
if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
|
if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
|
||||||
{
|
{
|
||||||
$idprod=$reg[1];
|
$idprod=$reg[1];
|
||||||
// Call to init properties of $productsupplier
|
$res=$productsupplier->fetch($idprod);
|
||||||
|
// Call to init properties of $productsupplier
|
||||||
// So if a supplier price already exists for another thirdparty (first one found), we use it as reference price
|
// So if a supplier price already exists for another thirdparty (first one found), we use it as reference price
|
||||||
$productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist
|
$productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist
|
||||||
}
|
}
|
||||||
@ -604,37 +605,35 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
//$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
|
//$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
|
||||||
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist
|
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist
|
||||||
|
$res=$productsupplier->fetch($idprod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($idprod > 0)
|
if ($idprod > 0)
|
||||||
{
|
{
|
||||||
$res=$productsupplier->fetch($idprod);
|
$pu_ht = $productsupplier->fourn_pu;
|
||||||
|
$price_base_type = $productsupplier->fourn_price_base_type;
|
||||||
|
$type = $productsupplier->type;
|
||||||
$label = $productsupplier->label;
|
$label = $productsupplier->label;
|
||||||
|
|
||||||
$desc = $productsupplier->description;
|
$desc = $productsupplier->description;
|
||||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
|
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
|
||||||
|
|
||||||
$type = $productsupplier->type;
|
|
||||||
|
|
||||||
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
|
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
|
||||||
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
|
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
|
||||||
if (empty($tva_tx)) $tva_npr=0;
|
if (empty($tva_tx)) $tva_npr=0;
|
||||||
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
||||||
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
||||||
|
|
||||||
$result=$object->addline(
|
$result=$object->addline(
|
||||||
$desc,
|
$desc,
|
||||||
$productsupplier->fourn_pu,
|
$pu_ht,
|
||||||
$qty,
|
$qty,
|
||||||
$tva_tx,
|
$tva_tx,
|
||||||
$localtax1_tx,
|
$localtax1_tx,
|
||||||
$localtax2_tx,
|
$localtax2_tx,
|
||||||
$productsupplier->id,
|
$productsupplier->id,
|
||||||
$remise_percent,
|
$remise_percent,
|
||||||
$type,
|
$price_base_type,
|
||||||
$productsupplier->price_ttc,
|
$pu_ttc,
|
||||||
$tva_npr,
|
$tva_npr,
|
||||||
$type,
|
$type,
|
||||||
-1,
|
-1,
|
||||||
@ -646,6 +645,7 @@ if (empty($reshook))
|
|||||||
$array_options,
|
$array_options,
|
||||||
$ref_fourn
|
$ref_fourn
|
||||||
);
|
);
|
||||||
|
//var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit;
|
||||||
}
|
}
|
||||||
if ($idprod == -99 || $idprod == 0)
|
if ($idprod == -99 || $idprod == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user