Merge pull request #20428 from Easya-Solutions/13.0_fix-reception-pmp-with-discount-price
FIX include discount price for PMP after a reception (Issue #20029)
This commit is contained in:
commit
c4e58ab4c0
@ -554,7 +554,7 @@ class Reception extends CommonObject
|
||||
|
||||
// Loop on each product line to add a stock movement
|
||||
// TODO in future, reception lines may not be linked to order line
|
||||
$sql = "SELECT cd.fk_product, cd.subprice,";
|
||||
$sql = "SELECT cd.fk_product, cd.subprice, cd.remise_percent,";
|
||||
$sql .= " ed.rowid, ed.qty, ed.fk_entrepot,";
|
||||
$sql .= " ed.eatby, ed.sellby, ed.batch";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,";
|
||||
@ -580,12 +580,18 @@ class Reception extends CommonObject
|
||||
$mouvS = new MouvementStock($this->db);
|
||||
$mouvS->origin = &$this;
|
||||
|
||||
// get unit price with discount
|
||||
$up_ht_disc = $obj->subprice;
|
||||
if (!empty($obj->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) {
|
||||
$up_ht_disc = price2num($up_ht_disc * (100 - $obj->remise_percent) / 100, 'MU');
|
||||
}
|
||||
|
||||
if (empty($obj->batch))
|
||||
{
|
||||
// line without batch detail
|
||||
|
||||
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record.
|
||||
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref));
|
||||
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref));
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->errors[] = $mouvS->error;
|
||||
@ -597,7 +603,7 @@ class Reception extends CommonObject
|
||||
|
||||
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record.
|
||||
// Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version)
|
||||
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch);
|
||||
$result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->errors[] = $mouvS->error;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user