Update stockatdate.php (#26481)
As commented in #23782 this update is to clean and clarify the code for future evolution of stocktodate. In fact the calculated value in the SQL request is the current stock value and not the estimated stock value at date value. Therefore I changed in SQL request the estimatedvalue to currentvalue and reused as a variable for a better understanding and for future use (other PR) as it will be interesting to get a comparison between stockatdate value to currentstock value. Also some others changes are required to improve the page speed.
This commit is contained in:
parent
4fc415a287
commit
8acc47220d
1 changed files with 6 additions and 5 deletions
|
|
@ -276,10 +276,10 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price, p.pmp,';
|
|||
$sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
|
||||
$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock, ';
|
||||
if (!empty($search_fk_warehouse)) {
|
||||
$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue";
|
||||
$sql .= " SUM(p.pmp * ps.reel) as currentvalue, SUM(p.price * ps.reel) as sellvalue";
|
||||
$sql .= ', SUM(ps.reel) as stock_reel';
|
||||
} else {
|
||||
$sql .= " SUM(p.pmp * p.stock) as estimatedvalue, SUM(p.price * p.stock) as sellvalue";
|
||||
$sql .= " SUM(p.pmp * p.stock) as currentvalue, SUM(p.price * p.stock) as sellvalue";
|
||||
}
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
|
|
@ -611,12 +611,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
|||
|
||||
// PMP value
|
||||
print '<td class="right">';
|
||||
if (price2num($stock * $objp->pmp, 'MT')) {
|
||||
print '<span class="amount">'.price(price2num($stock * $objp->pmp, 'MT'), 1).'</span>';
|
||||
$estimatedvalue = $stock * $objp->pmp;
|
||||
if (price2num($estimatedvalue, 'MT')) {
|
||||
print '<span class="amount">'.price(price2num($estimatedvalue, 'MT'), 1).'</span>';
|
||||
} else {
|
||||
print '';
|
||||
}
|
||||
$totalbuyingprice += $stock * $objp->pmp;
|
||||
$totalbuyingprice += $estimatedvalue;
|
||||
print '</td>';
|
||||
|
||||
// Selling value
|
||||
|
|
|
|||
Loading…
Reference in a new issue