2
0
forked from Wavyzz/dolibarr

Try to improve stock display for all stock increase/decrease options

This commit is contained in:
frederic34
2014-11-01 21:38:50 +01:00
parent 9c51effe5c
commit f23f16da86
4 changed files with 100 additions and 77 deletions

View File

@@ -61,6 +61,8 @@ ShipmentCreationIsDoneFromOrder=For the moment, creation of a new shipment is do
RelatedShippings=Related shippings
ShipmentLine=Shipment line
CarrierList=List of transporters
SendingRunning=Product from customer order already sent
SuppliersReceiptRunning=Product from supplier order alrady received
# Sending methods
SendingMethodCATCH=Catch by customer

View File

@@ -61,6 +61,8 @@ ShipmentCreationIsDoneFromOrder=Pour le moment, la création d'une nouvelle exp
RelatedShippings=Expédition(s) associée(s)
ShipmentLine=Ligne d'expédition
CarrierList=Liste des transporteurs
SendingRunning=Produits de commandes clients déjà expédiés
SuppliersReceiptRunning=Produit de commandes fournisseurs déjà réceptionnés
# Sending methods
SendingMethodCATCH=Enlèvement par le client

View File

@@ -3036,36 +3036,50 @@ class Product extends CommonObject
{
global $conf;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
{
$stock_commande_client=$stock_commande_fournisseur=0;
$stock_sending_client=$stock_reception_fournisseur=0;
$stock_commande_client=0;
$stock_commande_fournisseur=0;
$stock_sending_client=0;
$stock_reception_fournisseur=0;
if (! empty($conf->commande->enabled))
{
if (! empty($conf->commande->enabled)) {
$result=$this->load_stats_commande(0,'1,2');
if ($result < 0) dol_print_error($db,$this->error);
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled))
{
if (! empty($conf->expedition->enabled)) {
$result=$this->load_stats_sending(0,'1,2');
if ($result < 0) dol_print_error($db,$this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$this->load_stats_commande_fournisseur(0,'3');
if (! empty($conf->fournisseur->enabled)) {
$result=$this->load_stats_commande_fournisseur(0,'3,4');
if ($result < 0) dol_print_error($db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0,'3');
$result=$this->load_stats_reception(0,'4');
if ($result < 0) dol_print_error($db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
}
$this->stock_theorique=$this->stock_reel-($stock_commande_client-$stock_sending_client)+($stock_commande_fournisseur-$stock_reception_fournisseur);
//echo $this->stock_theorique.' = '.$this->stock_reel.' - ('.$stock_commande_client.' - '.$stock_sending_client.') + ('.$stock_commande_fournisseur.' - '.$stock_reception_fournisseur.')';
// Stock decrease mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) {
$this->stock_theorique=$this->stock_reel;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
$this->stock_theorique=$this->stock_reel-$stock_commande_client;
}
// Stock Increase mode
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
$this->stock_theorique-=$stock_reception_fournisseur;
}
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) {
$this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
}
}

View File

@@ -39,6 +39,7 @@ $langs->load("products");
$langs->load("orders");
$langs->load("bills");
$langs->load("stocks");
$langs->load("sendings");
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
@@ -332,57 +333,61 @@ if ($id > 0 || $ref)
print '</tr>';
// Calculating a theorical value
// If stock if stock increment is done on real sending
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
{
// Stock theorique
print '<tr><td>'.$langs->trans("VirtualStock").'</td>';
print "<td>".$product->stock_theorique;
if ($product->stock_theorique < $product->seuil_stock_alerte)
{
if ($product->stock_theorique < $product->seuil_stock_alerte) {
print ' '.img_warning($langs->trans("StockLowerThanLimit"));
}
print '</td>';
print '</tr>';
print '<tr><td>';
if ($product->stock_theorique != $product->stock_reel) print $langs->trans("StockDiffPhysicTeoric");
else print $langs->trans("RunningOrders");
$text_stock_options = (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'<br>':'');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':'');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'<br>':'');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':'');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':'');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':'');
print $form->textwithtooltip($langs->trans("StockDiffPhysicTeoric"),$text_stock_options,2,1,img_picto('', 'info'),'',0);;
print '</td>';
print '<td>';
$found=0;
// Nbre de commande clients en cours
// Number of customer orders running
if (! empty($conf->commande->enabled))
{
if ($found) print '<br>'; else $found=1;
print $langs->trans("CustomersOrdersRunning").': '.($product->stats_commande['qty']-$product->stats_sendings['qty']);
print $langs->trans("CustomersOrdersRunning").': '.$product->stats_commande['qty'];
$result=$product->load_stats_commande(0,'0');
if ($result < 0) dol_print_error($db,$product->error);
print ' ('.$langs->trans("Draft").': '.$product->stats_commande['qty'].')';
//print '<br>';
//print $langs->trans("CustomersSendingRunning").': '.$stock_sending_client;
}
// Nbre de commande fournisseurs en cours
if (! empty($conf->fournisseur->enabled))
{
// Number of product from customer order already sent (partial shipping)
if (! empty($conf->expedition->enabled)) {
if ($found) print '<br>'; else $found=1;
print $langs->trans("SuppliersOrdersRunning").': '.($product->stats_commande_fournisseur['qty']-$product->stats_reception['qty']);
$result=$product->load_stats_sending(0,'2');
print $langs->trans("SendingRunning").': '.$product->stats_expedition['qty'];
}
// Number of supplier order running
if (! empty($conf->fournisseur->enabled)) {
if ($found) print '<br>'; else $found=1;
$result=$product->load_stats_commande_fournisseur(0,'3,4');
print $langs->trans("SuppliersOrdersRunning").': '.$product->stats_commande_fournisseur['qty'];
$result=$product->load_stats_commande_fournisseur(0,'0,1,2');
if ($result < 0) dol_print_error($db,$product->error);
print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')';
}
print '</td></tr>';
// Number of product from supplier order already received (partial receipt)
if (! empty($conf->fournisseur->enabled)) {
if ($found) print '<br>'; else $found=1;
print $langs->trans("SuppliersReceiptRunning").': '.$product->stats_reception['qty'];
}
// If stock if stock increment is done on
// TODO Add information when stock increment is done on other option
// TODO Add also information on possible decrease stock accroding to stock decrease option
print '</td></tr>';
// Last movement
$sql = "SELECT max(m.datem) as datem";