From c03e01aa2e70aee3adab2583378a564d0a21d128 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Tue, 3 Dec 2013 12:29:25 +0800 Subject: [PATCH 1/4] 1003544 Purchase Order window is showing as default the Sales Price List --- .../org/compiere/model/CalloutInvoice.java | 13 +++++++++- .../src/org/compiere/model/CalloutOrder.java | 26 +++++++++++++++++-- .../src/org/compiere/model/MInvoice.java | 13 +++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java index 0f6c48b1a8..0adede9787 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java @@ -159,7 +159,18 @@ public class CalloutInvoice extends CalloutEngine { // get default PriceList int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); if (i != 0) - mTab.setValue("M_PriceList_ID", new Integer(i)); + { + MPriceList pl = new MPriceList(ctx, i, null); + if (IsSOTrx == pl.isSOPriceList()) + mTab.setValue("M_PriceList_ID", new Integer(i)); + else + { + String sql2 = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql2, Env.getAD_Client_ID(ctx), IsSOTrx); + if (ii != 0) + mTab.setValue("M_PriceList_ID", new Integer(ii)); + } + } } // PaymentRule diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 241b8c4858..8a5c2359e6 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -289,7 +289,18 @@ public class CalloutOrder extends CalloutEngine { // get default PriceList int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); if (i != 0) - mTab.setValue("M_PriceList_ID", new Integer(i)); + { + MPriceList pl = new MPriceList(ctx, i, null); + if (IsSOTrx == pl.isSOPriceList()) + mTab.setValue("M_PriceList_ID", new Integer(i)); + else + { + String sql2 = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql2, Env.getAD_Client_ID(ctx), IsSOTrx); + if (ii != 0) + mTab.setValue("M_PriceList_ID", new Integer(ii)); + } + } } // Bill-To @@ -494,7 +505,18 @@ public class CalloutOrder extends CalloutEngine { // get default PriceList int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); if (i != 0) - mTab.setValue("M_PriceList_ID", new Integer(i)); + { + MPriceList pl = new MPriceList(ctx, i, null); + if (IsSOTrx == pl.isSOPriceList()) + mTab.setValue("M_PriceList_ID", new Integer(i)); + else + { + String sql2 = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql2, Env.getAD_Client_ID(ctx), IsSOTrx); + if (ii != 0) + mTab.setValue("M_PriceList_ID", new Integer(ii)); + } + } } int bill_Location_ID = rs.getInt("Bill_Location_ID"); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 53c83e5daa..e9c0f166c6 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -925,11 +925,16 @@ public class MInvoice extends X_C_Invoice implements DocAction { int ii = Env.getContextAsInt(getCtx(), "#M_PriceList_ID"); if (ii != 0) - setM_PriceList_ID(ii); - else { - String sql = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsDefault='Y'"; - ii = DB.getSQLValue (null, sql, getAD_Client_ID()); + MPriceList pl = new MPriceList(getCtx(), ii, null); + if (isSOTrx() == pl.isSOPriceList()) + setM_PriceList_ID(ii); + } + + if (getM_PriceList_ID() == 0) + { + String sql = "SELECT M_PriceList_ID FROM M_PriceList WHERE AD_Client_ID=? AND IsSOPriceList=? AND IsActive='Y' ORDER BY IsDefault DESC"; + ii = DB.getSQLValue (null, sql, getAD_Client_ID(), isSOTrx()); if (ii != 0) setM_PriceList_ID (ii); } From 548d0d1791dc912e3151ce776e372a6db7184cb2 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Tue, 3 Dec 2013 13:07:49 +0800 Subject: [PATCH 2/4] IDEMPIERE-1590 Sales region field is showing summary regions --- migration/i2.0/oracle/201312031304_IDEMPIERE-1590.sql | 10 ++++++++++ .../i2.0/postgresql/201312031304_IDEMPIERE-1590.sql | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 migration/i2.0/oracle/201312031304_IDEMPIERE-1590.sql create mode 100644 migration/i2.0/postgresql/201312031304_IDEMPIERE-1590.sql diff --git a/migration/i2.0/oracle/201312031304_IDEMPIERE-1590.sql b/migration/i2.0/oracle/201312031304_IDEMPIERE-1590.sql new file mode 100644 index 0000000000..9774524ed2 --- /dev/null +++ b/migration/i2.0/oracle/201312031304_IDEMPIERE-1590.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Dec 3, 2013 1:02:10 PM SGT +-- IDEMPIERE-1590 Sales region field is showing summary regions +UPDATE AD_Column SET AD_Reference_Value_ID=144, AD_Reference_ID=18,Updated=TO_DATE('2013-12-03 13:02:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2968 +; + +SELECT register_migration_script('201312031304_IDEMPIERE-1590.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i2.0/postgresql/201312031304_IDEMPIERE-1590.sql b/migration/i2.0/postgresql/201312031304_IDEMPIERE-1590.sql new file mode 100644 index 0000000000..f293875995 --- /dev/null +++ b/migration/i2.0/postgresql/201312031304_IDEMPIERE-1590.sql @@ -0,0 +1,7 @@ +-- Dec 3, 2013 1:02:10 PM SGT +-- IDEMPIERE-1590 Sales region field is showing summary regions +UPDATE AD_Column SET AD_Reference_Value_ID=144, AD_Reference_ID=18,Updated=TO_TIMESTAMP('2013-12-03 13:02:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2968 +; + +SELECT register_migration_script('201312031304_IDEMPIERE-1590.sql') FROM dual +; \ No newline at end of file From c436141c39b659af7a5833a7a69bbd44ab5848b4 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 3 Dec 2013 17:57:54 +0800 Subject: [PATCH 3/4] 1003528 GL Bug? Reversed payment showing up on Payment Allocation. Fixed reverse accrual of payment. --- .../src/org/compiere/model/MPayment.java | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 72bc869627..9ddbe060b3 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -2429,8 +2429,7 @@ public final class MPayment extends X_C_Payment } // setC_Invoice_ID(0); - if (!accrual) - setIsAllocated(false); + setIsAllocated(false); } // deallocate /** @@ -2626,40 +2625,37 @@ public final class MPayment extends X_C_Payment setReversal_ID(reversal.getC_Payment_ID()); StringBuilder info = new StringBuilder(reversal.getDocumentNo()); - if (!accrual) - { - // Create automatic Allocation - MAllocationHdr alloc = new MAllocationHdr (getCtx(), false, - getDateTrx(), getC_Currency_ID(), - Msg.translate(getCtx(), "C_Payment_ID") + ": " + reversal.getDocumentNo(), get_TrxName()); - alloc.setAD_Org_ID(getAD_Org_ID()); - if (!alloc.save()) - log.warning("Automatic allocation - hdr not saved"); - else - { - // Original Allocation - MAllocationLine aLine = new MAllocationLine (alloc, getPayAmt(true), - Env.ZERO, Env.ZERO, Env.ZERO); - aLine.setDocInfo(getC_BPartner_ID(), 0, 0); - aLine.setPaymentInfo(getC_Payment_ID(), 0); - if (!aLine.save(get_TrxName())) - log.warning("Automatic allocation - line not saved"); - // Reversal Allocation - aLine = new MAllocationLine (alloc, reversal.getPayAmt(true), - Env.ZERO, Env.ZERO, Env.ZERO); - aLine.setDocInfo(reversal.getC_BPartner_ID(), 0, 0); - aLine.setPaymentInfo(reversal.getC_Payment_ID(), 0); - if (!aLine.save(get_TrxName())) - log.warning("Automatic allocation - reversal line not saved"); - } - // added AdempiereException by zuhri - if (!alloc.processIt(DocAction.ACTION_Complete)) - throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg()); - // end added - alloc.saveEx(get_TrxName()); - // - info.append(" - @C_AllocationHdr_ID@: ").append(alloc.getDocumentNo()); - } + + // Create automatic Allocation + MAllocationHdr alloc = new MAllocationHdr (getCtx(), false, + ( accrual ? dateAcct : getDateTrx() ), + getC_Currency_ID(), + Msg.translate(getCtx(), "C_Payment_ID") + ": " + reversal.getDocumentNo(), get_TrxName()); + alloc.setAD_Org_ID(getAD_Org_ID()); + alloc.saveEx(get_TrxName()); + + // Original Allocation + MAllocationLine aLine = new MAllocationLine (alloc, getPayAmt(true), + Env.ZERO, Env.ZERO, Env.ZERO); + aLine.setDocInfo(getC_BPartner_ID(), 0, 0); + aLine.setPaymentInfo(getC_Payment_ID(), 0); + if (!aLine.save(get_TrxName())) + log.warning("Automatic allocation - line not saved"); + // Reversal Allocation + aLine = new MAllocationLine (alloc, reversal.getPayAmt(true), + Env.ZERO, Env.ZERO, Env.ZERO); + aLine.setDocInfo(reversal.getC_BPartner_ID(), 0, 0); + aLine.setPaymentInfo(reversal.getC_Payment_ID(), 0); + if (!aLine.save(get_TrxName())) + log.warning("Automatic allocation - reversal line not saved"); + + // added AdempiereException by zuhri + if (!alloc.processIt(DocAction.ACTION_Complete)) + throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg()); + // end added + alloc.saveEx(get_TrxName()); + // + info.append(" - @C_AllocationHdr_ID@: ").append(alloc.getDocumentNo()); // Update BPartner if (getC_BPartner_ID() != 0) From 86a7ba3ad4cc8bc6e7ed99175fa44faafe53cd87 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Tue, 3 Dec 2013 19:40:09 +0800 Subject: [PATCH 4/4] IDEMPIERE-1592 Import Accounts window / Problem with order the accounts imported --- .../src/org/compiere/process/ImportAccount.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportAccount.java b/org.adempiere.base.process/src/org/compiere/process/ImportAccount.java index 46d8023ea7..0dc49c09b9 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportAccount.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportAccount.java @@ -358,12 +358,11 @@ public class ImportAccount extends SvrProcess no = DB.executeUpdate(sql.toString(), get_TrxName()); if (log.isLoggable(Level.CONFIG)) log.config("Not Found Parent ElementValue=" + no); // - sql = new StringBuilder ("SELECT i.ParentElementValue_ID, i.I_ElementValue_ID,") + sql = new StringBuilder ("SELECT COALESCE(i.ParentElementValue_ID, 0), i.I_ElementValue_ID,") .append(" e.AD_Tree_ID, i.C_ElementValue_ID, i.Value||'-'||i.Name AS Info ") .append("FROM I_ElementValue i") .append(" INNER JOIN C_Element e ON (i.C_Element_ID=e.C_Element_ID) ") .append("WHERE i.C_ElementValue_ID IS NOT NULL AND e.AD_Tree_ID IS NOT NULL") - .append(" AND i.ParentElementValue_ID IS NOT NULL") .append(" AND i.I_IsImported='Y' AND Processed='N' AND i.AD_Client_ID=").append(m_AD_Client_ID); int noParentUpdate = 0; try