uniformize update buyprice + some fixes
This commit is contained in:
parent
d0c179e1e9
commit
e3dfe60567
@ -428,7 +428,7 @@ class ProductFournisseur extends Product
|
|||||||
$sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
|
$sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
|
||||||
$sql .= " " . $newnpr . ",";
|
$sql .= " " . $newnpr . ",";
|
||||||
$sql .= $conf->entity . ",";
|
$sql .= $conf->entity . ",";
|
||||||
$sql .= $delivery_time_days . ",";
|
$sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null') . ",";
|
||||||
$sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'") . ",";
|
$sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'") . ",";
|
||||||
$sql .= (empty($barcode) ? 'NULL' : "'" . $this->db->escape($barcode) . "'") . ",";
|
$sql .= (empty($barcode) ? 'NULL' : "'" . $this->db->escape($barcode) . "'") . ",";
|
||||||
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'" . $this->db->escape($fk_barcode_type) . "'");
|
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'" . $this->db->escape($fk_barcode_type) . "'");
|
||||||
@ -447,7 +447,7 @@ class ProductFournisseur extends Product
|
|||||||
if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
|
if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
|
||||||
// Add record into log table
|
// Add record into log table
|
||||||
// $this->product_fourn_price_id must be set
|
// $this->product_fourn_price_id must be set
|
||||||
$result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrenc, $multicurrency_code);
|
$result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1792,25 +1792,25 @@ class SupplierProposal extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function updateOrCreatePriceFournisseur($user)
|
public function updateOrCreatePriceFournisseur($user)
|
||||||
{
|
{
|
||||||
$productsupplier = new ProductFournisseur($this->db);
|
global $conf;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG);
|
dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG);
|
||||||
foreach ($this->lines as $product)
|
foreach ($this->lines as $product)
|
||||||
{
|
{
|
||||||
if ($product->subprice <= 0) continue;
|
if ($product->subprice <= 0) continue;
|
||||||
|
$productsupplier = new ProductFournisseur($this->db);
|
||||||
|
|
||||||
$idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty);
|
$multicurrency_tx = 1;
|
||||||
$res = $productsupplier->fetch($idProductFourn);
|
$fk_multicurrency = 0;
|
||||||
|
|
||||||
if ($productsupplier->id) {
|
if(empty($this->thirdparty)) $this->fetch_thirdparty();
|
||||||
if ($productsupplier->fourn_qty == $product->qty) {
|
|
||||||
$this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user);
|
$ref_fourn = $product->ref_fourn;
|
||||||
} else {
|
if(empty($ref_fourn)) $ref_fourn = $product->ref_supplier;
|
||||||
$this->createPriceFournisseur($product, $user);
|
if(!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $product->multicurrency_code);
|
||||||
}
|
$productsupplier->id = $product->fk_product;
|
||||||
} else {
|
|
||||||
$this->createPriceFournisseur($product, $user);
|
$productsupplier->update_buyprice($product->qty, $product->subprice, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_subprice, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', '' );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user