mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Add Weighted average price as default price for buying price for margin
calculation. Add option MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price.
This commit is contained in:
parent
033e77c04a
commit
f92bc7986b
|
|
@ -8,7 +8,8 @@ For users:
|
|||
- New: Use new combobox.
|
||||
- New: Add hidden option MAXTABS_IN_CARD.
|
||||
- Fix / Improve : [ bug #1747 ] Remove creation of batch 'Undefined'
|
||||
|
||||
- Add Weighted average price as default price for buying price for margin calculation. Add option
|
||||
MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price.
|
||||
|
||||
For translators:
|
||||
- Update language files.
|
||||
|
|
|
|||
|
|
@ -483,7 +483,8 @@ jQuery(document).ready(function() {
|
|||
}
|
||||
if (this.id == 'pmpprice')
|
||||
{
|
||||
if (this.price > 0 && 1 == 1) { defaultkey = this.id; defaultprice = this.price; }
|
||||
var defaultbuyprice = <?php echo (isset($conf->global->MARGIN_PMP_AS_DEFAULT_BUY_PRICE)?int($conf->global->MARGIN_PMP_AS_DEFAULT_BUY_PRICE):1); ?>;
|
||||
if (this.price > 0 && 1 == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; }
|
||||
options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
|||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||
|
||||
$idprod=GETPOST('idprod','int');
|
||||
|
||||
|
|
@ -43,8 +44,11 @@ top_httphead();
|
|||
|
||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
|
||||
if (! empty($idprod))
|
||||
if ($idprod > 0)
|
||||
{
|
||||
$producttmp=new ProductFournisseur($db);
|
||||
$producttmp->fetch($idprod);
|
||||
|
||||
$sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,";
|
||||
$sql.= " pfp.ref_fourn,";
|
||||
$sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice, pfp.charges, pfp.unitcharges,";
|
||||
|
|
@ -111,6 +115,7 @@ if (! empty($idprod))
|
|||
if ($objp->duration) $label .= " - ".$objp->duration;
|
||||
|
||||
$label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit");
|
||||
if ($objp->ref_fourn) $label.=' ('.$objp->ref_fourn.')';
|
||||
|
||||
$prices[] = array("id" => $objp->idprodfournprice, "price" => price($price,0,'',0), "label" => $label, "title" => $title);
|
||||
$i++;
|
||||
|
|
@ -121,9 +126,8 @@ if (! empty($idprod))
|
|||
}
|
||||
|
||||
// Add price for pmp
|
||||
$price=123;
|
||||
$price=$producttmp->pmp;
|
||||
$prices[] = array("id" => 'pmpprice', "price" => $price, "label" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency));
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($prices);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user