New: Add more information on stock values.

This commit is contained in:
Laurent Destailleur 2011-05-22 02:14:01 +00:00
parent c6df144818
commit 678a64c591
6 changed files with 171 additions and 97 deletions

View File

@ -70,8 +70,11 @@ LieuWareHouse=Localisation warehouse
WarehousesAndProducts=Warehouses and products
AverageUnitPricePMPShort=Weighted average input price
AverageUnitPricePMP=Weighted average input price
EstimatedStockValueShort=Estimated value of stock
EstimatedStockValue=Estimated value of stock
SellPriceMin=Selling Unit Price
EstimatedStockValueSellShort=Value to sell
EstimatedStockValueSell=Value to Sell
EstimatedStockValueShort=Input stock value
EstimatedStockValue=Input stock value
DeleteAWarehouse=Delete a warehouse
ConfirmDeleteWarehouse=Are you sure you want to delete the warehouse <b>%s</b> ?
PersonalStock=Personal stock %s

View File

@ -70,8 +70,11 @@ LieuWareHouse=Lieu entrepôt
WarehousesAndProducts=Entrepôts et produits
AverageUnitPricePMPShort=Prix moyen pondéré (PMP)
AverageUnitPricePMP=Prix moyen pondéré (PMP) d'acquisition
EstimatedStockValueShort=Valorisation (PMP)
EstimatedStockValue=Valorisation acquisition stock (PMP)
SellPriceMin=Prix vente unitaire
EstimatedStockValueSellShort=Valorisation vente
EstimatedStockValueSell=Valorisation à la vente
EstimatedStockValueShort=Valorisation achat (PMP)
EstimatedStockValue=Valorisation à l'achat (PMP)
DeleteAWarehouse=Supprimer un entrepôt
ConfirmDeleteWarehouse=Êtes-vous sûr de vouloir supprimer l'entrepôt <b>%s</b> ?
PersonalStock=Stock personnel %s

View File

@ -1041,7 +1041,7 @@ class Product extends CommonObject
//! Spanish local taxes
$this->localtax1_tx = $object->localtax1_tx;
$this->localtax2_tx = $object->localtax2_tx;
$this->type = $object->fk_product_type;
$this->status = $object->tosell;
$this->status_buy = $object->tobuy;
@ -1062,20 +1062,20 @@ class Product extends CommonObject
$this->volume_units = $object->volume_units;
$this->barcode = $object->barcode;
$this->barcode_type = $object->fk_barcode_type;
$this->accountancy_code_buy = $object->accountancy_code_buy;
$this->accountancy_code_sell= $object->accountancy_code_sell;
$this->stock_reel = $object->stock;
$this->pmp = $object->pmp;
$this->import_key = $object->import_key;
$this->db->free($resql);
// multilangs
if ($conf->global->MAIN_MULTILANGS) $this->getMultiLangs();
// Barcode
if ($conf->global->MAIN_MODULE_BARCODE)
{
@ -1083,7 +1083,7 @@ class Product extends CommonObject
{
$this->barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
}
if ($this->barcode_type > 0)
{
$sql = "SELECT code, libelle, coder";
@ -1104,7 +1104,7 @@ class Product extends CommonObject
}
}
}
// Load multiprices array
if ($conf->global->PRODUIT_MULTIPRICES)
{
@ -1121,7 +1121,7 @@ class Product extends CommonObject
if ($resql)
{
$result = $this->db->fetch_array($resql);
$this->multiprices[$i]=$result["price"];
$this->multiprices_ttc[$i]=$result["price_ttc"];
$this->multiprices_min[$i]=$result["price_min"];
@ -1136,9 +1136,9 @@ class Product extends CommonObject
}
}
}
$res=$this->load_stock();
return $res;
}
else
@ -2215,6 +2215,11 @@ class Product extends CommonObject
$lien = '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$this->id.'">';
$lienfin='</a>';
}
else if ($option == 'stock')
{
$lien = '<a href="'.DOL_URL_ROOT.'/product/stock/product.php?id='.$this->id.'">';
$lienfin='</a>';
}
else
{
$lien = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
@ -338,17 +338,19 @@ else
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Product"),"", "p.ref","&amp;id=".$_GET['id'],"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"", "p.label","&amp;id=".$_GET['id'],"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&amp;id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder);
if ($user->rights->stock->mouvement->creer) print '<td>&nbsp;</td>';
if ($user->rights->stock->creer) print '<td>&nbsp;</td>';
print "</tr>";
$totalunit=0;
$totalvalue=0;
$totalvalue=$totalvaluesell=0;
$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp,";
$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc,";
$sql.= " ps.pmp, ps.reel as value";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product p";
$sql.= " WHERE ps.fk_product = p.rowid";
@ -400,19 +402,34 @@ else
$productstatic->id=$objp->rowid;
$productstatic->ref=$objp->ref;
$productstatic->type=$objp->type;
print $productstatic->getNomUrl(1,'',16);
print $productstatic->getNomUrl(1,'stock',16);
print '</td>';
print '<td>'.$objp->produit.'</td>';
print '<td align="right">'.$objp->value.'</td>';
$totalunit+=$objp->value;
// Price buy PMP
print '<td align="right">'.price(price2num($objp->pmp,'MU')).'</td>';
// Total PMP
print '<td align="right">'.price(price2num($objp->pmp*$objp->value,'MT')).'</td>';
$totalvalue+=price2num($objp->pmp*$objp->value,'MT');
if ($user->rights->stock->mouvement->creer)
// Price sell min
if (empty($conf->global->PRODUIT_MULTIPRICES))
{
$pricemin=$objp->price;
print '<td align="right">';
print price(price2num($pricemin,'MU'));
print '</td>';
// Total sell min
print '<td align="right">';
print price(price2num($pricemin*$objp->value,'MT'));
print '</td>';
}
$totalvaluesell+=price2num($pricemin*$objp->value,'MT');
if ($user->rights->stock->mouvement->creer)
{
print '<td align="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$entrepot->id.'&amp;id='.$objp->rowid.'&amp;action=transfert">';
print img_picto($langs->trans("StockMovement"),'uparrow.png').' '.$langs->trans("StockMovement");
@ -434,8 +451,13 @@ else
print '<tr class="liste_total"><td class="liste_total" colspan="2">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.$totalunit.'</td>';
print '<td class="liste_total">&nbsp;</td>';
print '<td class="liste_total" align="right">'.price(price2num($totalvalue,'MT')).'</td>';
print '<td class="liste_total">&nbsp;</td>';
print '<td class="liste_total" align="right">'.price(price2num($totalvalue,'MT')).'</td>';
if (empty($conf->global->PRODUIT_MULTIPRICES))
{
print '<td class="liste_total">&nbsp;</td>';
print '<td class="liste_total" align="right">'.price(price2num($totalvaluesell,'MT')).'</td>';
}
print '<td class="liste_total">&nbsp;</td>';
print '<td class="liste_total">&nbsp;</td>';
print '</tr>';

View File

@ -198,11 +198,18 @@ if ($_GET["id"] || $_GET["ref"])
// PMP
print '<tr><td>'.$langs->trans("AverageUnitPricePMP").'</td>';
print '<td>'.price($product->pmp);
print '</td>';
print '<td>'.price($product->pmp).' '.$langs->trans("HT").'</td>';
print '</tr>';
// Real stock
// Sell price
print '<tr><td>'.$langs->trans("SellPriceMin").'</td>';
print '<td>';
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price($product->price).' '.$langs->trans("HT");
else print $langs->trans("Variable");
print '</td>';
print '</tr>';
// Real stock
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
print '<td>'.$product->stock_reel;
if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockTooLow"));
@ -436,11 +443,13 @@ print '<tr class="liste_titre"><td width="40%">'.$langs->trans("Warehouse").'</t
print '<td align="right">'.$langs->trans("NumberOfUnit").'</td>';
print '<td align="right">'.$langs->trans("AverageUnitPricePMPShort").'</td>';
print '<td align="right">'.$langs->trans("EstimatedStockValueShort").'</td>';
print '<td align="right">'.$langs->trans("SellPriceMin").'</td>';
print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>';
print '</tr>';
$sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= ", ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql.= " ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " WHERE ps.reel != 0";
$sql.= " AND ps.fk_entrepot = e.rowid";
$sql.= " AND e.entity = ".$conf->entity;
@ -449,7 +458,7 @@ $sql.= " ORDER BY e.label";
$entrepotstatic=new Entrepot($db);
$total=0;
$totalvalue=0;
$totalvalue=$totalvaluesell=0;
$resql=$db->query($sql);
if ($resql)
@ -464,21 +473,42 @@ if ($resql)
print '<tr '.$bc[$var].'>';
print '<td>'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>';
// PMP
print '<td align="right">'.price2num(($obj->pmp > 0 ? $obj->pmp : $product->pmp),'MU').'</td>'; // Ditto : Show PMP from movement or from product
print '<td align="right">'.price(price2num(($obj->pmp > 0 ? $obj->pmp : $product->pmp)*$obj->reel,'MT')).'</td>'; // Ditto : Show PMP from movement or from product
// Sell price
print '<td align="right">';
if (empty($conf->global->PRODUIT_MUTLI_PRICES)) print price(price2num($product->price,'MU'));
else print $langs->trans("Variable");
print '</td>'; // Ditto : Show PMP from movement or from product
print '<td align="right">';
if (empty($conf->global->PRODUIT_MUTLI_PRICES)) print price(price2num($product->price*$obj->reel,'MT')).'</td>'; // Ditto : Show PMP from movement or from product
else print $langs->trans("Variable");
print '</tr>'; ;
$total = $total + $obj->reel;
$totalvalue = $totalvalue + price2num(($obj->pmp > 0 ? $obj->pmp : $product->pmp)*$obj->reel,'MT'); // Ditto : Show PMP from movement or from product
$totalvaluesell = $totalvaluesell + price2num($product->price*$obj->reel,'MT'); // Ditto : Show PMP from movement or from product
$i++;
$var=!$var;
}
}
else dol_print_error($db);
print '<tr class="liste_total"><td align="right" class="liste_total">'.$langs->trans("Total").':</td>';
print '<td class="liste_total" align="right">'.$total.'</td>';
print '<td class="liste_total" align="right">';
print ($total?price($totalvalue/$total):'&nbsp;');
print '</td>';
print '<td class="liste_total" align="right">'.price($totalvalue).'</td>';
print '<td class="liste_total" align="right">';
print price($totalvalue);
print '</td>';
print '<td class="liste_total" align="right">';
if (empty($conf->global->PRODUIT_MUTLI_PRICES)) print ($total?price($totalvaluesell/$total):'&nbsp;');
else print $langs->trans("Variable");
print '</td>';
print '<td class="liste_total" align="right">';
if (empty($conf->global->PRODUIT_MUTLI_PRICES)) print price($totalvaluesell);
else print $langs->trans("Variable");
print '</td>';
print "</tr>";
print "</table>";

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -21,7 +21,7 @@
/**
* \file htdocs/product/stock/valo.php
* \ingroup stock
* \brief Page de valorisation des stocks
* \brief Page with stock values
* \version $Id$
*/
@ -55,97 +55,108 @@ $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";
$sql.= " SUM(ps.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";
$sql.= " WHERE e.entity = ".$conf->entity;
if ($sref)
{
$sql.= " AND e.ref LIKE '%".$sref."%'";
$sql.= " AND e.ref LIKE '%".$sref."%'";
}
if ($sall)
{
$sql.= " AND (e.label LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.description LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.address LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.ville LIKE '%".$db->escape($sall)."%')";
$sql.= " AND (e.label LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.description LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.address LIKE '%".$db->escape($sall)."%'";
$sql.= " OR e.ville LIKE '%".$db->escape($sall)."%')";
}
$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu";
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset);
$result = $db->query($sql) ;
if ($result)
{
$num = $db->num_rows($result);
$num = $db->num_rows($result);
$i = 0;
$i = 0;
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
llxHeader("",$langs->trans("EnhancedValueOfWarehouses"),$help_url);
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
llxHeader("",$langs->trans("EnhancedValueOfWarehouses"),$help_url);
print_barre_liste($langs->trans("EnhancedValueOfWarehouses"), $page, "valo.php", "", $sortfield, $sortorder,'',$num);
print_barre_liste($langs->trans("EnhancedValueOfWarehouses"), $page, "valo.php", "", $sortfield, $sortorder,'',$num);
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"valo.php", "e.label","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LocationSummary"),"valo.php", "e.lieu","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EstimatedStockValue"),"valo.php", "e.valo_pmp",'','','align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"valo.php", "e.statut",'','','align="right"',$sortfield,$sortorder);
print "</tr>\n";
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"valo.php", "e.label","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LocationSummary"),"valo.php", "e.lieu","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EstimatedStockValue"),"valo.php", "e.valo_pmp",'','','align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EstimatedStockValueSell"),"", "",'','','align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"valo.php", "e.statut",'','','align="right"',$sortfield,$sortorder);
print "</tr>\n";
if ($num)
{
$entrepot=new Entrepot($db);
$total = 0;
$var=false;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($result);
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->ref.'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$objp->label.'</a></td>';
print '<td>'.$objp->lieu.'</td>';
print '<td align="right">';
print price(price2num($objp->estimatedvalue,'MT'));
print '</td>';
print '<td align="right">'.$entrepot->LibStatut($objp->statut,5).'</td>';
print "</tr>\n";
$total += price2num($objp->estimatedvalue,'MU');
$var=!$var;
$i++;
}
if ($num)
{
$entrepot=new Entrepot($db);
$total = $totalsell = 0;
$var=false;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($result);
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->ref.'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$objp->label.'</a></td>';
print '<td>'.$objp->lieu.'</td>';
// PMP value
print '<td align="right">';
print price(price2num($objp->estimatedvalue,'MT'));
print '</td>';
// Selling value
print '<td align="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue,'MT'));
else print $langs->trans("Variable");
print '</td>';
// Status
print '<td align="right">'.$entrepot->LibStatut($objp->statut,5).'</td>';
print "</tr>\n";
$total += price2num($objp->estimatedvalue,'MU');
$totalsell += price2num($objp->sellvalue,'MU');
$var=!$var;
$i++;
}
print '<tr class="liste_total">';
print '<td colspan="2" align="right">'.$langs->trans("Total").'</td>';
print '<td align="right">'.price($total).' '.$langs->trans('Currency'.$conf->monnaie).'</td>';
print '<td align="right">&nbsp;</td>';
print "</tr>\n";
print '<tr class="liste_total">';
print '<td colspan="2" align="right">'.$langs->trans("Total").'</td>';
print '<td align="right">'.price(price2num($total,'MT')).' '.$langs->trans('Currency'.$conf->monnaie).'</td>';
print '<td align="right">'.price(price2num($totalsell,'MT')).' '.$langs->trans('Currency'.$conf->monnaie).'</td>';
print '<td align="right">&nbsp;</td>';
print "</tr>\n";
}
$db->free($result);
print "</table>";
}
$db->free($result);
print "</table>";
print '<br>';
print '<br>';
$file='entrepot-'.$year.'.png';
if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
print '<img src="'.$url.'">';
}
$file='entrepot-'.$year.'.png';
if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
print '<img src="'.$url.'">';
}
$file='entrepot-'.($year-1).'.png';
if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
print '<br><img src="'.$url.'">';
}
$file='entrepot-'.($year-1).'.png';
if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
{
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
print '<br><img src="'.$url.'">';
}
}
else
{
dol_print_error($db);
dol_print_error($db);
}
$db->close();