From f7af4d1e2011e0b6280fa9a162c7316b63a22510 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Wed, 17 Apr 2013 18:23:21 +0800 Subject: [PATCH] IDEMPIERE-862 Create lines from MPS Lines function is not working --- .../oracle/views/M_PACKAGELINES_AVAIL_V.sql | 30 +++++++++++++++++ .../views/M_PACKAGELINES_AVAIL_V.sql | 30 +++++++++++++++++ .../oracle/201304171803_IDEMPIERE-861.sql | 33 +++++++++++++++++++ .../postgresql/201304171803_IDEMPIERE-861.sql | 33 +++++++++++++++++++ .../src/org/compiere/model/MPackage.java | 9 +++++ .../grid/VCreateFromPackageShipmentUI.java | 2 +- .../form/WCreateFromPackageShipmentUI.java | 2 +- .../grid/CreateFromPackageShipment.java | 2 +- 8 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 db/ddlutils/oracle/views/M_PACKAGELINES_AVAIL_V.sql create mode 100644 db/ddlutils/postgresql/views/M_PACKAGELINES_AVAIL_V.sql create mode 100644 migration/i1.0a-release/oracle/201304171803_IDEMPIERE-861.sql create mode 100644 migration/i1.0a-release/postgresql/201304171803_IDEMPIERE-861.sql diff --git a/db/ddlutils/oracle/views/M_PACKAGELINES_AVAIL_V.sql b/db/ddlutils/oracle/views/M_PACKAGELINES_AVAIL_V.sql new file mode 100644 index 0000000000..0e985a84ed --- /dev/null +++ b/db/ddlutils/oracle/views/M_PACKAGELINES_AVAIL_V.sql @@ -0,0 +1,30 @@ +CREATE OR REPLACE VIEW m_packagelines_avail_v AS + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line, iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 ) AS qty, iol.m_product_id, p.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + JOIN ad_clientinfo ci ON ci.ad_client_id = iol.ad_client_id + WHERE p.ispicklistprintdetails = 'N' AND iol.m_product_id <> COALESCE(ci.m_productfreight_id, 0 ) AND (iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 )) <> 0 +UNION + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line + pbom.line / 100 AS line, iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 ) AS qty, pbom.m_productbom_id AS m_product_id, p2.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN m_product_bom pbom ON p.m_product_id = pbom.m_product_id + JOIN m_product p2 ON pbom.m_productbom_id = p2.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + WHERE p.isbom = 'Y' AND p.isverified = 'Y' AND p.ispicklistprintdetails = 'Y' AND (iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 )) <> 0 + ORDER BY 1, 2, 3, 5; \ No newline at end of file diff --git a/db/ddlutils/postgresql/views/M_PACKAGELINES_AVAIL_V.sql b/db/ddlutils/postgresql/views/M_PACKAGELINES_AVAIL_V.sql new file mode 100644 index 0000000000..0e985a84ed --- /dev/null +++ b/db/ddlutils/postgresql/views/M_PACKAGELINES_AVAIL_V.sql @@ -0,0 +1,30 @@ +CREATE OR REPLACE VIEW m_packagelines_avail_v AS + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line, iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 ) AS qty, iol.m_product_id, p.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + JOIN ad_clientinfo ci ON ci.ad_client_id = iol.ad_client_id + WHERE p.ispicklistprintdetails = 'N' AND iol.m_product_id <> COALESCE(ci.m_productfreight_id, 0 ) AND (iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 )) <> 0 +UNION + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line + pbom.line / 100 AS line, iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 ) AS qty, pbom.m_productbom_id AS m_product_id, p2.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN m_product_bom pbom ON p.m_product_id = pbom.m_product_id + JOIN m_product p2 ON pbom.m_productbom_id = p2.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + WHERE p.isbom = 'Y' AND p.isverified = 'Y' AND p.ispicklistprintdetails = 'Y' AND (iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 )) <> 0 + ORDER BY 1, 2, 3, 5; \ No newline at end of file diff --git a/migration/i1.0a-release/oracle/201304171803_IDEMPIERE-861.sql b/migration/i1.0a-release/oracle/201304171803_IDEMPIERE-861.sql new file mode 100644 index 0000000000..c3478c3c0c --- /dev/null +++ b/migration/i1.0a-release/oracle/201304171803_IDEMPIERE-861.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE VIEW m_packagelines_avail_v AS + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line, iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 ) AS qty, iol.m_product_id, p.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + JOIN ad_clientinfo ci ON ci.ad_client_id = iol.ad_client_id + WHERE p.ispicklistprintdetails = 'N' AND iol.m_product_id <> COALESCE(ci.m_productfreight_id, 0 ) AND (iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 )) <> 0 +UNION + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line + pbom.line / 100 AS line, iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 ) AS qty, pbom.m_productbom_id AS m_product_id, p2.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN m_product_bom pbom ON p.m_product_id = pbom.m_product_id + JOIN m_product p2 ON pbom.m_productbom_id = p2.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + WHERE p.isbom = 'Y' AND p.isverified = 'Y' AND p.ispicklistprintdetails = 'Y' AND (iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 )) <> 0 + ORDER BY 1, 2, 3, 5; + +SELECT register_migration_script('201304171803_IDEMPIERE-861.sql') FROM dual +; diff --git a/migration/i1.0a-release/postgresql/201304171803_IDEMPIERE-861.sql b/migration/i1.0a-release/postgresql/201304171803_IDEMPIERE-861.sql new file mode 100644 index 0000000000..c3478c3c0c --- /dev/null +++ b/migration/i1.0a-release/postgresql/201304171803_IDEMPIERE-861.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE VIEW m_packagelines_avail_v AS + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line, iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 ) AS qty, iol.m_product_id, p.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + JOIN ad_clientinfo ci ON ci.ad_client_id = iol.ad_client_id + WHERE p.ispicklistprintdetails = 'N' AND iol.m_product_id <> COALESCE(ci.m_productfreight_id, 0 ) AND (iol.qtyentered - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_inoutline_id = iol.m_inoutline_id), 0 )) <> 0 +UNION + SELECT DISTINCT iol.ad_client_id, iol.ad_org_id, iol.m_inout_id, iol.m_inoutline_id, iol.line + pbom.line / 100 AS line, iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 ) AS qty, pbom.m_productbom_id AS m_product_id, p2.name AS productname, uom.name AS uom + FROM m_inoutline iol + LEFT JOIN m_packageline mpl ON iol.m_inoutline_id = mpl.m_inoutline_id + JOIN m_product p ON iol.m_product_id = p.m_product_id + JOIN m_product_bom pbom ON p.m_product_id = pbom.m_product_id + JOIN m_product p2 ON pbom.m_productbom_id = p2.m_product_id + JOIN c_uom uom ON iol.c_uom_id = uom.c_uom_id + WHERE p.isbom = 'Y' AND p.isverified = 'Y' AND p.ispicklistprintdetails = 'Y' AND (iol.qtyentered * pbom.bomqty - COALESCE(( SELECT sum(m_packageline.qty) AS sum + FROM m_packageline + WHERE m_packageline.m_product_id = p2.m_product_id AND (m_packageline.m_package_id IN ( SELECT m_package.m_package_id + FROM m_package + WHERE m_package.m_inout_id = iol.m_inout_id))), 0 )) <> 0 + ORDER BY 1, 2, 3, 5; + +SELECT register_migration_script('201304171803_IDEMPIERE-861.sql') FROM dual +; diff --git a/org.adempiere.base/src/org/compiere/model/MPackage.java b/org.adempiere.base/src/org/compiere/model/MPackage.java index 093e16b945..c8783ba573 100644 --- a/org.adempiere.base/src/org/compiere/model/MPackage.java +++ b/org.adempiere.base/src/org/compiere/model/MPackage.java @@ -579,6 +579,15 @@ public class MPackage extends X_M_Package for (int i = 0; i < ids.length; i++) { MPackageMPS packageMPS = new MPackageMPS(getCtx(), ids[i], get_TrxName()); + if (packageMPS.getWeight() == null || packageMPS.getWeight().compareTo(BigDecimal.ZERO) == 0) + { + String sql = "SELECT SUM(LineWeight) FROM X_PackageLineWeight plw WHERE plw.M_PackageMPS_ID=?"; + BigDecimal weight = DB.getSQLValueBD(get_TrxName(), sql, packageMPS.getM_PackageMPS_ID()); + if (weight == null) + weight = BigDecimal.ZERO; + packageMPS.setWeight(weight); + packageMPS.saveEx(); + } MShippingTransactionLine stl = new MShippingTransactionLine(st.getCtx(), 0, st.get_TrxName()); stl.setAD_Client_ID(packageMPS.getAD_Client_ID()); diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java index e36356b4cc..44ede962c2 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java @@ -72,7 +72,7 @@ public class VCreateFromPackageShipmentUI extends CreateFromPackageShipment dialog.setTitle(getTitle()); - int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_Package_ID); + int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID); MPackageMPS packageMPS = new MPackageMPS(Env.getCtx(), M_PackageMPS_ID, null); MPackage mPackage = new MPackage(Env.getCtx(), packageMPS.getM_Package_ID(), null); loadTableOIS(getShipmentData(mPackage.getM_InOut_ID())); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromPackageShipmentUI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromPackageShipmentUI.java index 154f252930..3fd6b5b7a6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromPackageShipmentUI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromPackageShipmentUI.java @@ -66,7 +66,7 @@ public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment window.setTitle(getTitle()); - int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_Package_ID); + int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID); MPackageMPS packageMPS = new MPackageMPS(Env.getCtx(), M_PackageMPS_ID, null); MPackage mPackage = new MPackage(Env.getCtx(), packageMPS.getM_Package_ID(), null); loadTableOIS(getShipmentData(mPackage.getM_InOut_ID())); diff --git a/org.adempiere.ui/src/org/compiere/grid/CreateFromPackageShipment.java b/org.adempiere.ui/src/org/compiere/grid/CreateFromPackageShipment.java index 9bf821fb3b..ffa7ccf4f8 100644 --- a/org.adempiere.ui/src/org/compiere/grid/CreateFromPackageShipment.java +++ b/org.adempiere.ui/src/org/compiere/grid/CreateFromPackageShipment.java @@ -119,7 +119,7 @@ public abstract class CreateFromPackageShipment extends CreateFrom public boolean save(IMiniTable miniTable, String trxName) { - int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_Package_ID); + int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID); MPackageMPS packageMPS = new MPackageMPS(Env.getCtx(), M_PackageMPS_ID, null); MPackage mPackage = new MPackage(Env.getCtx(), packageMPS.getM_Package_ID(), null);