[ BF 2944056 ] - Fix quantities for Substitute & Related products in InfoProduct
https://sourceforge.net/tracker/index.php?func=detail&aid=2944056&group_id=176962&atid=879332 Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2944056
This commit is contained in:
parent
4d1300ed0f
commit
217188b3f0
|
@ -1,18 +1,78 @@
|
||||||
CREATE OR REPLACE VIEW M_Product_SubstituteRelated_V AS
|
CREATE OR REPLACE VIEW M_PRODUCT_SUBSTITUTERELATED_V AS
|
||||||
SELECT s.AD_Client_ID, s.AD_Org_ID, s.IsActive, s.Created, s.CreatedBy, s.Updated, s.UpdatedBy, s.m_product_id, s.substitute_id, s.description, 'S' AS ROWTYPE, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand, ms.qtyreserved, mpr.pricestd, mpr.m_pricelist_version_id, mw.m_warehouse_id, mp.NAME, org.NAME AS orgname
|
SELECT s.ad_client_id,
|
||||||
FROM M_SUBSTITUTE s
|
s.ad_org_id,
|
||||||
JOIN M_STORAGE ms ON ms.m_product_id = s.substitute_id
|
s.isactive,
|
||||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
s.created,
|
||||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
s.createdby,
|
||||||
JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
s.updated,
|
||||||
JOIN M_PRODUCTPRICE mpr ON ms.m_product_id = mpr.m_product_id
|
s.updatedby,
|
||||||
JOIN AD_ORG org ON org.ad_org_id = mw.ad_org_id
|
s.m_product_id,
|
||||||
UNION
|
s.substitute_id,
|
||||||
SELECT r.ad_client_id, r.ad_org_id, r.IsActive, r.Created, r.CreatedBy, r.Updated, r.UpdatedBy, r.m_product_id, r.relatedproduct_id, r.description, 'R' AS ROWTYPE, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand, ms.qtyreserved, mpr.pricestd, mpr.m_pricelist_version_id, mw.m_warehouse_id, mp.NAME, org.NAME AS orgname
|
'S' AS rowtype,
|
||||||
FROM M_RELATEDPRODUCT r
|
mp.name,
|
||||||
JOIN M_STORAGE ms ON ms.m_product_id = r.relatedproduct_id
|
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
|
||||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
sum(ms.qtyonhand) AS qtyonhand,
|
||||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
sum(ms.qtyreserved) AS qtyreserved,
|
||||||
JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
ROUND(MAX(mpr.pricestd),0) AS pricestd,
|
||||||
JOIN M_PRODUCTPRICE mpr ON ms.m_product_id = mpr.m_product_id
|
mpr.m_pricelist_version_id,
|
||||||
JOIN AD_ORG org ON org.ad_org_id = mw.ad_org_id;
|
mw.m_warehouse_id,
|
||||||
|
org.name AS orgname
|
||||||
|
FROM m_substitute s
|
||||||
|
JOIN m_storage ms ON ms.m_product_id = s.substitute_id
|
||||||
|
JOIN m_product mp ON ms.m_product_id = mp.m_product_id
|
||||||
|
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
|
||||||
|
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
||||||
|
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
|
||||||
|
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
|
||||||
|
GROUP BY s.ad_client_id,
|
||||||
|
s.ad_org_id,
|
||||||
|
s.isactive,
|
||||||
|
s.created,
|
||||||
|
s.createdby,
|
||||||
|
s.updated,
|
||||||
|
s.updatedby,
|
||||||
|
s.m_product_id,
|
||||||
|
s.substitute_id,
|
||||||
|
mw.m_warehouse_id,
|
||||||
|
mpr.m_pricelist_version_id,
|
||||||
|
org.name,
|
||||||
|
mp.name
|
||||||
|
UNION
|
||||||
|
SELECT r.ad_client_id,
|
||||||
|
r.ad_org_id,
|
||||||
|
r.isactive,
|
||||||
|
r.created,
|
||||||
|
r.createdby,
|
||||||
|
r.updated,
|
||||||
|
r.updatedby,
|
||||||
|
r.m_product_id,
|
||||||
|
r.relatedproduct_id AS substitute_id,
|
||||||
|
'R' AS rowtype,
|
||||||
|
mp.name,
|
||||||
|
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
|
||||||
|
sum(ms.qtyonhand) AS qtyonhand,
|
||||||
|
sum(ms.qtyreserved) AS qtyreserved,
|
||||||
|
ROUND(MAX(mpr.pricestd),0) AS pricestd,
|
||||||
|
mpr.m_pricelist_version_id,
|
||||||
|
mw.m_warehouse_id,
|
||||||
|
org.name AS orgname
|
||||||
|
FROM m_relatedproduct r
|
||||||
|
JOIN m_storage ms ON ms.m_product_id = r.relatedproduct_id
|
||||||
|
JOIN m_product mp ON ms.m_product_id = mp.m_product_id
|
||||||
|
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
|
||||||
|
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
||||||
|
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
|
||||||
|
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
|
||||||
|
GROUP BY r.ad_client_id,
|
||||||
|
r.ad_org_id,
|
||||||
|
r.isactive,
|
||||||
|
r.created,
|
||||||
|
r.createdby,
|
||||||
|
r.updated,
|
||||||
|
r.updatedby,
|
||||||
|
r.m_product_id,
|
||||||
|
r.relatedproduct_id,
|
||||||
|
mw.m_warehouse_id,
|
||||||
|
mpr.m_pricelist_version_id,
|
||||||
|
org.name,
|
||||||
|
mp.name;
|
|
@ -1,55 +1,78 @@
|
||||||
CREATE OR
|
CREATE OR REPLACE VIEW M_PRODUCT_SUBSTITUTERELATED_V AS
|
||||||
REPLACE VIEW m_product_substituterelated_v AS
|
SELECT s.ad_client_id,
|
||||||
SELECT s.ad_client_id,
|
s.ad_org_id,
|
||||||
s.ad_org_id,
|
s.isactive,
|
||||||
s.isactive,
|
s.created,
|
||||||
s.created,
|
s.createdby,
|
||||||
s.createdby,
|
s.updated,
|
||||||
s.updated,
|
s.updatedby,
|
||||||
s.updatedby,
|
s.m_product_id,
|
||||||
s.m_product_id,
|
s.substitute_id,
|
||||||
s.substitute_id,
|
'S' AS rowtype,
|
||||||
s.description,
|
mp.name,
|
||||||
'S' AS ROWTYPE,
|
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
|
||||||
(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
|
sum(ms.qtyonhand) AS qtyonhand,
|
||||||
mp.NAME,
|
sum(ms.qtyreserved) AS qtyreserved,
|
||||||
ms.qtyonhand,
|
ROUND(MAX(mpr.pricestd),0) AS pricestd,
|
||||||
ms.qtyreserved,
|
mpr.m_pricelist_version_id,
|
||||||
mpr.pricestd,
|
mw.m_warehouse_id,
|
||||||
mpr.m_pricelist_version_id,
|
org.name AS orgname
|
||||||
mw.m_warehouse_id,
|
FROM m_substitute s
|
||||||
org.NAME AS orgname
|
JOIN m_storage ms ON ms.m_product_id = s.substitute_id
|
||||||
FROM M_SUBSTITUTE s
|
JOIN m_product mp ON ms.m_product_id = mp.m_product_id
|
||||||
JOIN M_STORAGE ms ON ms.m_product_id = s.substitute_id
|
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
|
||||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
||||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
|
||||||
JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
|
||||||
JOIN M_PRODUCTPRICE mpr ON ms.m_product_id = mpr.m_product_id
|
GROUP BY s.ad_client_id,
|
||||||
JOIN AD_ORG org ON org.ad_org_id = mw.ad_org_id
|
s.ad_org_id,
|
||||||
UNION
|
s.isactive,
|
||||||
SELECT r.ad_client_id,
|
s.created,
|
||||||
r.ad_org_id,
|
s.createdby,
|
||||||
r.isactive,
|
s.updated,
|
||||||
r.created,
|
s.updatedby,
|
||||||
r.createdby,
|
s.m_product_id,
|
||||||
r.updated,
|
s.substitute_id,
|
||||||
r.updatedby,
|
mw.m_warehouse_id,
|
||||||
r.m_product_id,
|
mpr.m_pricelist_version_id,
|
||||||
r.relatedproduct_id AS substitute_id,
|
org.name,
|
||||||
r.description,
|
mp.name
|
||||||
'R' AS ROWTYPE,
|
UNION
|
||||||
(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
|
SELECT r.ad_client_id,
|
||||||
mp.NAME,
|
r.ad_org_id,
|
||||||
ms.qtyonhand,
|
r.isactive,
|
||||||
ms.qtyreserved,
|
r.created,
|
||||||
mpr.pricestd,
|
r.createdby,
|
||||||
mpr.m_pricelist_version_id,
|
r.updated,
|
||||||
mw.m_warehouse_id,
|
r.updatedby,
|
||||||
org.NAME AS orgname
|
r.m_product_id,
|
||||||
FROM M_RELATEDPRODUCT r
|
r.relatedproduct_id AS substitute_id,
|
||||||
JOIN M_STORAGE ms ON ms.m_product_id = r.relatedproduct_id
|
'R' AS rowtype,
|
||||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
mp.name,
|
||||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
sum(ms.qtyonhand - ms.qtyreserved) AS qtyavailable,
|
||||||
JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
sum(ms.qtyonhand) AS qtyonhand,
|
||||||
JOIN M_PRODUCTPRICE mpr ON ms.m_product_id = mpr.m_product_id
|
sum(ms.qtyreserved) AS qtyreserved,
|
||||||
JOIN AD_ORG org ON org.ad_org_id = mw.ad_org_id;
|
ROUND(MAX(mpr.pricestd),0) AS pricestd,
|
||||||
|
mpr.m_pricelist_version_id,
|
||||||
|
mw.m_warehouse_id,
|
||||||
|
org.name AS orgname
|
||||||
|
FROM m_relatedproduct r
|
||||||
|
JOIN m_storage ms ON ms.m_product_id = r.relatedproduct_id
|
||||||
|
JOIN m_product mp ON ms.m_product_id = mp.m_product_id
|
||||||
|
JOIN m_locator ml ON ms.m_locator_id = ml.m_locator_id
|
||||||
|
JOIN m_warehouse mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
||||||
|
JOIN m_productprice mpr ON ms.m_product_id = mpr.m_product_id
|
||||||
|
JOIN ad_org org ON org.ad_org_id = mw.ad_org_id
|
||||||
|
GROUP BY r.ad_client_id,
|
||||||
|
r.ad_org_id,
|
||||||
|
r.isactive,
|
||||||
|
r.created,
|
||||||
|
r.createdby,
|
||||||
|
r.updated,
|
||||||
|
r.updatedby,
|
||||||
|
r.m_product_id,
|
||||||
|
r.relatedproduct_id,
|
||||||
|
mw.m_warehouse_id,
|
||||||
|
mpr.m_pricelist_version_id,
|
||||||
|
org.name,
|
||||||
|
mp.name;
|
Loading…
Reference in New Issue