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 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.process/src/org/compiere/process/ImportAccount.java b/org.adempiere.base.process/src/org/compiere/process/ImportAccount.java index 235334c58c..66060a4a68 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 diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 2bcbc1236e..3165845c59 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -928,11 +928,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); } 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)