diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5a3482fac18..c2b58027c6c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3088,7 +3088,6 @@ class Form // Now we get list $num = $this->load_cache_vatrates($code_pays); - if ($num > 0) { // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index fc02ba27d4a..9613e6a282e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -157,15 +157,16 @@ class ProductFournisseur extends Product if (empty($buyprice)) $buyprice=0; if (empty($charges)) $charges=0; if (empty($availability)) $availability=0; - if ($price_base_type == 'TTC') + if (empty($remise_percent)) $remise_percent=0; + if ($price_base_type == 'TTC') { - $ttx = get_default_tva($fourn,$mysoc,$this->id); + //$ttx = get_default_tva($fourn,$mysoc,$this->id); // We must use the VAT rate defined by user and not calculate it + $ttx = $tva_tx; $buyprice = $buyprice/(1+($ttx/100)); } $buyprice=price2num($buyprice,'MU'); $charges=price2num($charges,'MU'); $qty=price2num($qty); - $error=0; $unitBuyPrice = price2num($buyprice/$qty,'MU'); @@ -190,6 +191,7 @@ class ProductFournisseur extends Product $sql.= " entity = ".$conf->entity.","; $sql.= " charges = ".($charges != ''?price2num($charges):"null"); $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + // TODO Add price_base_type and price_ttc dol_syslog(get_class($this).'::update_buyprice sql='.$sql); $resql = $this->db->query($sql); @@ -333,9 +335,11 @@ class ProductFournisseur extends Product * List all supplier prices of a product * * @param int $prodid Id of product + * @param string $sortfield Sort field + * @param string $sortorder Sort order * @return array Array of Products with new properties to define supplier price */ - function list_product_fournisseur_price($prodid) + function list_product_fournisseur_price($prodid, $sortfield='', $sortorder='') { global $conf; @@ -347,8 +351,8 @@ class ProductFournisseur extends Product $sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")"; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND pfp.fk_product = ".$prodid; - $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price"; - + if (empty($sortfield)) $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price"; + else $sql.= $this->db->order($sortfield,$sortorder); dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -469,14 +473,16 @@ class ProductFournisseur extends Product * Display supplier of product * * @param int $withpicto Add picto + * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') * @return string String with supplier price + * TODO Remove this method. Use getNomUrl directly. */ - function getSocNomUrl($withpicto=0) + function getSocNomUrl($withpicto=0,$option='supplier') { $cust = new Fournisseur($this->db); $cust->fetch($this->fourn_id); - return $cust->getNomUrl($withpicto); + return $cust->getNomUrl($withpicto,$option); } /** diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index f59a9e0bba6..5c107a7e50b 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -145,8 +145,9 @@ Restock=Restock ProductSpecial=Special QtyMin=Quantity minimum PriceQty=Price for this quantity -PriceQtyMin=Price quantity min. -DiscountQtyMin=Discount quantity min. +PriceQtyMin=Price quantity min. (without discount) +VATRateForSupplierProduct=VAT Rate (for this supplier/product) +DiscountQtyMin=Discount quantity min. (by default) NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product NoSupplierPriceDefinedForThisProduct=No supplier price/qty defined for this product RecordedProducts=Products recorded diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 3c301e60168..37c70e544d9 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -145,8 +145,9 @@ Restock=Réassort ProductSpecial=Special QtyMin=Quantité minimum PriceQty=Prix pour la quantité -PriceQtyMin=Prix quantité min. -DiscountQtyMin=Remise quantité min. +PriceQtyMin=Prix quantité min. (sans remise) +DiscountQtyMin=Remise par défaut quantité min. +VATRateForSupplierProduct=Taux TVA (pour ce produit/fournisseur) NoPriceDefinedForThisSupplier=Aucun prix/qté défini pour ce fournisseur/produit NoSupplierPriceDefinedForThisProduct=Aucun prix/qté fournisseur défini pour ce produit RecordedProducts=Produits en vente diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 08b7ab05410..15913ef83ee 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -153,7 +153,6 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) { $supplier=new Fournisseur($db); $result=$supplier->fetch($id_fourn); - if (isset($_POST['ref_fourn_price_id'])) $product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); @@ -273,7 +272,7 @@ if ($id || $ref) print '
| '.$langs->trans("Supplier").' | '; + print ' | ||||
| '.$langs->trans("Supplier").' | '; if ($rowid) { $supplier=new Fournisseur($db); @@ -298,7 +297,7 @@ if ($id || $ref) print ' | ||||
| '.$langs->trans("SupplierRef").' | '; + print ' | ||||
| '.$langs->trans("SupplierRef").' | '; if ($rowid) { print $product->fourn_ref; @@ -310,18 +309,11 @@ if ($id || $ref) print ' | '; print '||||
| '.$langs->trans("VATRate").' | '; - print ''; - //print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country - print 'tva_tx).'">'; - print ' | ||||
| '.$langs->trans("Availability").' | '; + print ' | ||||
| '.$langs->trans("Availability").' | '; $form->select_availability($product->fk_availability,"oselDispo",1); print ' | ||||
| '.$langs->trans("VATRateForSupplierProduct").' | '; + print ''; + //print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country + if (! empty($socid)) // When update + { + $supplierselected=new Societe($db); + $supplierselected->fetch($socid); + $default_vat=get_default_tva($supplier, $mysoc, $product->id); + } + if ($action == 'add_price' && $socid) $default_vat=$product->tva_tx; // If editing product-fourn + print ''; + print ' | '.$langs->trans("PriceQtyMin").' | '; + print '|||
| '.$langs->trans("PriceQtyMin").' | '; print ''; print ' '; print $form->select_PriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type"); - print ' | '; - + print ''.$langs->trans("DiscountQtyMin").' | '; - print '%'; + print ' | ||
| '.$langs->trans("DiscountQtyMin").' | '; + print '%'; print ' | '; print '||||
| '.$langs->trans("Charges").' | '; - print ''; + print ' | '; print ' | '; print '|||
| '.$productfourn->getSocNomUrl(1).' | '; + print ''.$productfourn->getSocNomUrl(1,'supplier').' | '; // Supplier print ''.$productfourn->fourn_ref.' | '; @@ -473,10 +488,10 @@ if ($id || $ref) print price($productfourn->fourn_unitprice); //print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" "); print ''; - + // Discount print ''; - print vatrate($productfourn->fourn_remise_percent, $langs); + print price2num($productfourn->fourn_remise_percent).'%'; print ' | '; // Unit Charges ???||