Fixed: We must use PMP of product. Not warehouse.
This commit is contained in:
parent
6a70af2b67
commit
9be99b2987
@ -33,7 +33,7 @@ create table llx_entrepot
|
|||||||
fk_departement integer,
|
fk_departement integer,
|
||||||
fk_pays integer DEFAULT 0,
|
fk_pays integer DEFAULT 0,
|
||||||
statut tinyint DEFAULT 1, -- 1 open, 0 close
|
statut tinyint DEFAULT 1, -- 1 open, 0 close
|
||||||
valo_pmp float(12,4), -- valoristaion du stock en PMP
|
valo_pmp float(12,4), -- PMP value for this warehouse (deprecated. No sens for a warehouse)
|
||||||
fk_user_author integer,
|
fk_user_author integer,
|
||||||
import_key varchar(14)
|
import_key varchar(14)
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ create table llx_product_stock
|
|||||||
fk_product integer NOT NULL,
|
fk_product integer NOT NULL,
|
||||||
fk_entrepot integer NOT NULL,
|
fk_entrepot integer NOT NULL,
|
||||||
reel real, -- physical stock
|
reel real, -- physical stock
|
||||||
pmp double(24,8) default 0 NOT NULL, -- PMP value for product in this warehouse
|
pmp double(24,8) default 0 NOT NULL, -- PMP value for product in this warehouse (deprecated. no sens for warehouse)
|
||||||
import_key varchar(14) -- Import key
|
import_key varchar(14) -- Import key
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
|||||||
@ -73,13 +73,13 @@ if ($action == 'add' && $user->rights->stock->creer)
|
|||||||
$object->town = GETPOST("town");
|
$object->town = GETPOST("town");
|
||||||
$object->country_id = GETPOST("country_id");
|
$object->country_id = GETPOST("country_id");
|
||||||
|
|
||||||
if (! empty($object->libelle))
|
if (! empty($object->libelle))
|
||||||
{
|
{
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans("RecordSaved"));
|
setEventMessage($langs->trans("RecordSaved"));
|
||||||
|
|
||||||
if (! empty($backtopage))
|
if (! empty($backtopage))
|
||||||
{
|
{
|
||||||
header("Location: ".$backtopage);
|
header("Location: ".$backtopage);
|
||||||
@ -180,9 +180,9 @@ if ($action == 'create')
|
|||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||||
|
|
||||||
dol_fiche_head();
|
dol_fiche_head();
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@ -225,7 +225,7 @@ if ($action == 'create')
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
print '<center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>';
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
@ -445,10 +445,10 @@ else
|
|||||||
$totalunit+=$objp->value;
|
$totalunit+=$objp->value;
|
||||||
|
|
||||||
// Price buy PMP
|
// 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
|
// Total PMP
|
||||||
print '<td align="right">'.price(price2num($objp->pmp*$objp->value,'MT')).'</td>';
|
print '<td align="right">'.price(price2num($objp->ppmp*$objp->value,'MT')).'</td>';
|
||||||
$totalvalue+=price2num($objp->pmp*$objp->value,'MT');
|
$totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
|
||||||
|
|
||||||
// Price sell min
|
// Price sell min
|
||||||
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
||||||
|
|||||||
@ -52,7 +52,7 @@ $year = strftime("%Y",time());
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,";
|
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,";
|
||||||
$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.= " 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_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.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
|
||||||
|
|||||||
@ -125,7 +125,7 @@ if ($action == "correct_stock" && ! $cancel)
|
|||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($id);
|
$result=$product->fetch($id);
|
||||||
}
|
}
|
||||||
if ($product->hasbatch())
|
if ($product->hasbatch())
|
||||||
{
|
{
|
||||||
$d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']);
|
$d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']);
|
||||||
$d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
|
$d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
|
||||||
@ -140,7 +140,7 @@ if ($action == "correct_stock" && ! $cancel)
|
|||||||
$d_sellby,
|
$d_sellby,
|
||||||
GETPOST('batch_number')
|
GETPOST('batch_number')
|
||||||
); // We do not change value of stock for a correction
|
); // We do not change value of stock for a correction
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result=$product->correct_stock(
|
$result=$product->correct_stock(
|
||||||
@ -633,9 +633,9 @@ if ($resql)
|
|||||||
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
|
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
|
||||||
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>';
|
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>';
|
||||||
// PMP
|
// PMP
|
||||||
print '<td align="right">'.(price2num($obj->pmp)?price2num($obj->pmp,'MU'):'').'</td>'; // Ditto : Show PMP from movement or from product
|
print '<td align="right">'.(price2num($product->pmp)?price2num($product->pmp,'MU'):'').'</td>'; // Ditto : Show PMP from movement or from product
|
||||||
// Value purchase
|
// Value purchase
|
||||||
print '<td align="right">'.(price2num($obj->pmp)?price(price2num($obj->pmp*$obj->reel,'MT')):'').'</td>'; // Ditto : Show PMP from movement or from product
|
print '<td align="right">'.(price2num($product->pmp)?price(price2num($product->pmp*$obj->reel,'MT')):'').'</td>'; // Ditto : Show PMP from movement or from product
|
||||||
// Sell price
|
// Sell price
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price,'MU'),1);
|
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price,'MU'),1);
|
||||||
@ -647,15 +647,15 @@ if ($resql)
|
|||||||
else print $langs->trans("Variable");
|
else print $langs->trans("Variable");
|
||||||
print '</tr>'; ;
|
print '</tr>'; ;
|
||||||
$total += $obj->reel;
|
$total += $obj->reel;
|
||||||
if (price2num($obj->pmp)) $totalwithpmp += $obj->reel;
|
if (price2num($product->pmp)) $totalwithpmp += $obj->reel;
|
||||||
$totalvalue = $totalvalue + ($obj->pmp*$obj->reel); // Ditto : Show PMP from movement or from product
|
$totalvalue = $totalvalue + ($product->pmp*$obj->reel); // Ditto : Show PMP from movement or from product
|
||||||
$totalvaluesell = $totalvaluesell + ($product->price*$obj->reel); // Ditto : Show PMP from movement or from product
|
$totalvaluesell = $totalvaluesell + ($product->price*$obj->reel); // Ditto : Show PMP from movement or from product
|
||||||
//Batch Detail
|
//Batch Detail
|
||||||
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch())
|
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch())
|
||||||
{
|
{
|
||||||
$details=Productbatch::findAll($db,$obj->product_stock_id);
|
$details=Productbatch::findAll($db,$obj->product_stock_id);
|
||||||
if ($details<0) dol_print_error($db);
|
if ($details<0) dol_print_error($db);
|
||||||
foreach ($details as $pdluo)
|
foreach ($details as $pdluo)
|
||||||
{
|
{
|
||||||
print "\n".'<tr><td></td>';
|
print "\n".'<tr><td></td>';
|
||||||
print '<td align="right">'.$pdluo->batch.'</td>';
|
print '<td align="right">'.$pdluo->batch.'</td>';
|
||||||
@ -670,14 +670,15 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else dol_print_error($db);
|
else dol_print_error($db);
|
||||||
|
|
||||||
print '<tr class="liste_total"><td align="right" class="liste_total" colspan="4">'.$langs->trans("Total").':</td>';
|
print '<tr class="liste_total"><td align="right" class="liste_total" colspan="4">'.$langs->trans("Total").':</td>';
|
||||||
print '<td class="liste_total" align="right">'.$total.'</td>';
|
print '<td class="liste_total" align="right">'.$total.'</td>';
|
||||||
print '<td class="liste_total" align="right">';
|
print '<td class="liste_total" align="right">';
|
||||||
print ($totalwithpmp?price(price2num(price2num($totalvalue,'MT')/$totalwithpmp,'MT')):' '); // This value may have rounding errors
|
print ($totalwithpmp?price(price2num($totalvalue/$totalwithpmp,'MU')):' '); // This value may have rounding errors
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Value purchase
|
// Value purchase
|
||||||
print '<td class="liste_total" align="right">';
|
print '<td class="liste_total" align="right">';
|
||||||
print price(price2num($totalvalue,'MT'),1);
|
print $totalvalue?price(price2num($totalvalue,'MT'),1):' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="liste_total" align="right">';
|
print '<td class="liste_total" align="right">';
|
||||||
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print ($total?price($totalvaluesell/$total,1):' ');
|
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print ($total?price($totalvaluesell/$total,1):' ');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user