Clean deprecated (field unit_charge in supplier price)
This commit is contained in:
parent
1f60d9ba81
commit
2cd5ed65a6
@ -85,8 +85,6 @@ class FormMargin
|
||||
$product = new ProductFournisseur($db);
|
||||
if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
|
||||
$line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100);
|
||||
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
|
||||
$line->pa_ht += $product->fourn_unitcharges;
|
||||
}
|
||||
// si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente
|
||||
if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) {
|
||||
@ -96,7 +94,7 @@ class FormMargin
|
||||
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
|
||||
$pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
|
||||
$pa = $line->qty * $pa_ht;
|
||||
|
||||
|
||||
// calcul des marges
|
||||
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
|
||||
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit
|
||||
|
||||
@ -64,10 +64,6 @@ class ProductFournisseur extends Product
|
||||
var $fourn_unitprice;
|
||||
var $fourn_tva_tx;
|
||||
var $fourn_tva_npr;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
var $fourn_unitcharges; // old version used a buggy system to calculate margin of a charge field on supplier price. Now margin is on pmp, best supplier price or cost price.
|
||||
|
||||
var $fk_supplier_price_expression;
|
||||
var $supplier_reputation; // reputation of supplier
|
||||
@ -215,7 +211,6 @@ class ProductFournisseur extends Product
|
||||
$error=0;
|
||||
|
||||
$unitBuyPrice = price2num($buyprice/$qty,'MU');
|
||||
$unitCharges = price2num($charges/$qty,'MU');
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
@ -250,7 +245,6 @@ class ProductFournisseur extends Product
|
||||
$sql.= " remise_percent = ".$remise_percent.",";
|
||||
$sql.= " remise = ".$remise.",";
|
||||
$sql.= " unitprice = ".$unitBuyPrice.",";
|
||||
$sql.= " unitcharges = ".$unitCharges.","; // deprecated
|
||||
$sql.= " fk_availability = ".$availability.",";
|
||||
$sql.= " entity = ".$conf->entity.",";
|
||||
$sql.= " tva_tx = ".price2num($tva_tx).",";
|
||||
@ -306,7 +300,7 @@ class ProductFournisseur extends Product
|
||||
if ($resql) {
|
||||
// Add price for this quantity to supplier
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
|
||||
$sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)";
|
||||
$sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)";
|
||||
$sql .= " values('" . $this->db->idate($now) . "',";
|
||||
$sql .= " " . $this->id . ",";
|
||||
$sql .= " " . $fourn->id . ",";
|
||||
@ -319,7 +313,6 @@ class ProductFournisseur extends Product
|
||||
$sql .= " " . $unitBuyPrice . ",";
|
||||
$sql .= " " . $tva_tx . ",";
|
||||
$sql .= " " . $charges . ",";
|
||||
$sql .= " " . $unitCharges . ",";
|
||||
$sql .= " " . $availability . ",";
|
||||
$sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").",";
|
||||
$sql .= " " . $newnpr . ",";
|
||||
@ -393,7 +386,7 @@ class ProductFournisseur extends Product
|
||||
{
|
||||
global $conf;
|
||||
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,";
|
||||
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
|
||||
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
|
||||
$sql.= " pfp.supplier_reputation";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE pfp.rowid = ".$rowid;
|
||||
@ -418,7 +411,6 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_remise_percent = $obj->remise_percent;
|
||||
$this->fourn_remise = $obj->remise;
|
||||
$this->fourn_unitprice = $obj->unitprice;
|
||||
$this->fourn_unitcharges = $obj->unitcharges; // deprecated
|
||||
$this->fourn_tva_tx = $obj->tva_tx;
|
||||
// TODO
|
||||
// $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ?
|
||||
@ -478,7 +470,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE pfp.entity IN (".getEntity('productprice').")";
|
||||
@ -510,7 +502,6 @@ class ProductFournisseur extends Product
|
||||
$prodfourn->fourn_remise = $record["remise"];
|
||||
$prodfourn->fourn_unitprice = $record["unitprice"];
|
||||
$prodfourn->fourn_charges = $record["charges"]; // deprecated
|
||||
$prodfourn->fourn_unitcharges = $record["unitcharges"]; // deprecated
|
||||
$prodfourn->fourn_tva_tx = $record["tva_tx"];
|
||||
$prodfourn->fourn_id = $record["fourn_id"];
|
||||
$prodfourn->fourn_name = $record["supplier_name"];
|
||||
@ -588,7 +579,7 @@ class ProductFournisseur extends Product
|
||||
|
||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||
$sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, ";
|
||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
|
||||
$sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
@ -623,7 +614,7 @@ class ProductFournisseur extends Product
|
||||
{
|
||||
$fourn_price = $record["price"];
|
||||
// discount calculated buy price
|
||||
$fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) + $record["unitcharges"] - $record["remise"];
|
||||
$fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"];
|
||||
if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) {
|
||||
$prod_supplier = new ProductFournisseur($this->db);
|
||||
$prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"];
|
||||
@ -657,7 +648,6 @@ class ProductFournisseur extends Product
|
||||
$this->fourn_remise = $record["remise"];
|
||||
$this->fourn_unitprice = $record["unitprice"];
|
||||
$this->fourn_charges = $record["charges"]; // deprecated
|
||||
$this->fourn_unitcharges = $record["unitcharges"]; // deprecated
|
||||
$this->fourn_tva_tx = $record["tva_tx"];
|
||||
$this->fourn_id = $record["fourn_id"];
|
||||
$this->fourn_name = $record["supplier_name"];
|
||||
@ -755,14 +745,14 @@ class ProductFournisseur extends Product
|
||||
$out .= '<td class="liste_titre">'.$langs->trans("Supplier").'</td>';
|
||||
$out .= '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td></tr>';
|
||||
foreach ($productFournList as $productFourn) {
|
||||
$out.= '<tr><td align="right">'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').'</td>';
|
||||
$out.= '<tr><td align="right">'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').'</td>';
|
||||
$out.= '<td align="right">'.($showunitprice?$productFourn->fourn_qty:'').'</td>';
|
||||
$out.= '<td>'.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).'</td>';
|
||||
$out.= '<td>'.$productFourn->fourn_ref.'<td></tr>';
|
||||
}
|
||||
$out .= '</table>';
|
||||
} else {
|
||||
$out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").' (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
|
||||
$out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").' (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
|
||||
-- For 8.0
|
||||
|
||||
ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges;
|
||||
|
||||
ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0;
|
||||
ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0;
|
||||
|
||||
|
||||
@ -29,13 +29,12 @@ create table llx_product_fournisseur_price
|
||||
fk_soc integer,
|
||||
ref_fourn varchar(30),
|
||||
fk_availability integer,
|
||||
price double(24,8) DEFAULT 0,
|
||||
price double(24,8) DEFAULT 0, -- price without tax for quantity
|
||||
quantity double,
|
||||
remise_percent double NOT NULL DEFAULT 0,
|
||||
remise double NOT NULL DEFAULT 0,
|
||||
unitprice double(24,8) DEFAULT 0,
|
||||
unitprice double(24,8) DEFAULT 0, -- unit price without tax
|
||||
charges double(24,8) DEFAULT 0, -- to store transport cost. Constant PRODUCT_CHARGES must be set to see it.
|
||||
unitcharges double(24,8) DEFAULT 0, -- deprecated
|
||||
default_vat_code varchar(10),
|
||||
tva_tx double(6,3) NOT NULL,
|
||||
localtax1_tx double(6,3) DEFAULT 0,
|
||||
|
||||
@ -370,7 +370,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT');
|
||||
$totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise), 'MT');
|
||||
$total+=$totalline;
|
||||
|
||||
print '<td align="right">';
|
||||
|
||||
@ -638,11 +638,6 @@ if ($id > 0 || $ref)
|
||||
print_liste_field_titre("DiscountQtyMin",$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("NbDaysToDelivery",$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("ReputationForThisProduct",$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder);
|
||||
// Charges ????
|
||||
if ($conf->global->PRODUCT_CHARGES)
|
||||
{
|
||||
if (! empty($conf->margin->enabled)) print_liste_field_titre("UnitCharges");
|
||||
}
|
||||
print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -708,18 +703,6 @@ if ($id > 0 || $ref)
|
||||
}
|
||||
print'</td>';
|
||||
|
||||
// Charges ????
|
||||
/*
|
||||
if ($conf->global->PRODUCT_CHARGES)
|
||||
{
|
||||
if (! empty($conf->margin->enabled))
|
||||
{
|
||||
print '<td align="right">';
|
||||
print $productfourn->fourn_unitcharges?price($productfourn->fourn_unitcharges) : ($productfourn->fourn_qty?price($productfourn->fourn_charges/$productfourn->fourn_qty):" ");
|
||||
print '</td>';
|
||||
}
|
||||
}*/
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id);
|
||||
|
||||
@ -793,7 +793,7 @@ else
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
|
||||
{
|
||||
$htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1);
|
||||
print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext);
|
||||
print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext);
|
||||
}
|
||||
else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user