FIX bad calculation for stock value
This commit is contained in:
parent
384c89dcef
commit
9b797c1831
@ -418,7 +418,7 @@ class Entrepot extends CommonObject
|
||||
{
|
||||
$ret=array();
|
||||
|
||||
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value";
|
||||
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= " WHERE ps.fk_entrepot = ".$this->id;
|
||||
|
||||
@ -364,7 +364,7 @@ else
|
||||
print_liste_field_titre($langs->trans("Product"),"", "p.ref","&id=".$_GET['id'],"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$_GET['id'],"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "p.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
|
||||
@ -426,10 +426,10 @@ else
|
||||
$totalunit+=$objp->value;
|
||||
|
||||
// Price buy PMP
|
||||
print '<td align="right">'.price(price2num($objp->pmp,'MU')).'</td>';
|
||||
print '<td align="right">'.price(price2num($objp->ppmp,'MU')).'</td>';
|
||||
// Total PMP
|
||||
print '<td align="right">'.price(price2num($objp->pmp*$objp->value,'MT')).'</td>';
|
||||
$totalvalue+=price2num($objp->pmp*$objp->value,'MT');
|
||||
print '<td align="right">'.price(price2num($objp->ppmp*$objp->value,'MT')).'</td>';
|
||||
$totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
|
||||
|
||||
// Price sell min
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
|
||||
@ -53,7 +53,7 @@ $year = strftime("%Y",time());
|
||||
|
||||
// Affichage valorisation par entrepot
|
||||
$sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu,";
|
||||
$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue";
|
||||
$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user