diff --git a/base/src/org/compiere/model/GridTab.java b/base/src/org/compiere/model/GridTab.java index 387799ea67..bfbf8e9edc 100644 --- a/base/src/org/compiere/model/GridTab.java +++ b/base/src/org/compiere/model/GridTab.java @@ -537,8 +537,10 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable { m_parentNeedSave = false; String lc = getLinkColumnName(); - if (lc.equals("")) - log.severe ("No link column"); + if (lc.equals("")) { + log.warning ("No link column"); + where.append (" 2=3"); + } else { String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc); diff --git a/base/src/org/compiere/model/GridWindow.java b/base/src/org/compiere/model/GridWindow.java index ae0f523e88..c98767ce20 100644 --- a/base/src/org/compiere/model/GridWindow.java +++ b/base/src/org/compiere/model/GridWindow.java @@ -68,8 +68,6 @@ public class GridWindow implements Serializable private GridWindowVO m_vo; /** Tabs */ private ArrayList m_tabs = new ArrayList(); - /** Position */ - private Rectangle m_position = null; /** Model last updated */ private Timestamp m_modelUpdated = null; diff --git a/base/src/org/compiere/model/MBPBankAccount.java b/base/src/org/compiere/model/MBPBankAccount.java index 52f61634e9..b04304f060 100644 --- a/base/src/org/compiere/model/MBPBankAccount.java +++ b/base/src/org/compiere/model/MBPBankAccount.java @@ -167,11 +167,11 @@ public class MBPBankAccount extends X_C_BP_BankAccount */ public MBank getBank() { - int C_BP_BankAccount_ID = getC_BP_BankAccount_ID(); - if (C_BP_BankAccount_ID == 0) + int C_Bank_ID = getC_Bank_ID(); + if (C_Bank_ID == 0) return null; if (m_bank == null) - m_bank = new MBank (getCtx(), C_BP_BankAccount_ID, get_TrxName()); + m_bank = new MBank (getCtx(), C_Bank_ID, get_TrxName()); return m_bank; } // getBank diff --git a/base/src/org/compiere/model/MBPartner.java b/base/src/org/compiere/model/MBPartner.java index 9ae5b58b98..e640a7e51f 100644 --- a/base/src/org/compiere/model/MBPartner.java +++ b/base/src/org/compiere/model/MBPartner.java @@ -84,7 +84,7 @@ public class MBPartner extends X_C_BPartner { MBPartner retValue = null; String sql = "SELECT * FROM C_BPartner " - + "WHERE C_BPartner_ID=(SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)"; + + "WHERE C_BPartner_ID IN (SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)"; PreparedStatement pstmt = null; try { @@ -376,7 +376,7 @@ public class MBPartner extends X_C_BPartner boolean success = true; String sql = "SELECT * FROM C_BPartner " - + "WHERE C_BPartner_ID=(SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)"; + + "WHERE C_BPartner_ID IN (SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)"; PreparedStatement pstmt = null; try { @@ -568,7 +568,7 @@ public class MBPartner extends X_C_BPartner return m_accounts; // ArrayList list = new ArrayList(); - String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=?"; + String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=? AND IsActive='Y'"; PreparedStatement pstmt = null; try { diff --git a/base/src/org/compiere/model/MCostDetail.java b/base/src/org/compiere/model/MCostDetail.java index 14991934ca..18fb4ec7c9 100644 --- a/base/src/org/compiere/model/MCostDetail.java +++ b/base/src/org/compiere/model/MCostDetail.java @@ -403,12 +403,12 @@ public class MCostDetail extends X_M_CostDetail * @param ctx context * @param whereClause where clause * @param ID 1st parameter - * @param ID2 2nd parameter + * @param M_AttributeSetInstance_ID ASI * @param trxName trx * @return cost detail */ private static MCostDetail get (Properties ctx, String whereClause, - int ID, int ID2, String trxName) + int ID, int M_AttributeSetInstance_ID, String trxName) { String sql = "SELECT * FROM M_CostDetail WHERE " + whereClause; MCostDetail retValue = null; @@ -417,7 +417,7 @@ public class MCostDetail extends X_M_CostDetail { pstmt = DB.prepareStatement (sql, null); pstmt.setInt (1, ID); - pstmt.setInt (2, ID2); + pstmt.setInt (2, M_AttributeSetInstance_ID); ResultSet rs = pstmt.executeQuery (); if (rs.next ()) retValue = new MCostDetail (ctx, rs, trxName); @@ -693,7 +693,7 @@ public class MCostDetail extends X_M_CostDetail { if (isProcessed()) { - log.info("already processed"); + log.info("Already processed"); return true; } boolean ok = false; diff --git a/base/src/org/compiere/model/MDunningLevel.java b/base/src/org/compiere/model/MDunningLevel.java index 77df1fb4a0..40c4ceadb5 100644 --- a/base/src/org/compiere/model/MDunningLevel.java +++ b/base/src/org/compiere/model/MDunningLevel.java @@ -32,7 +32,7 @@ import org.compiere.util.DB; public class MDunningLevel extends X_C_DunningLevel { /** Logger */ - private static CLogger s_log = CLogger.getCLogger (MPayment.class); + private static CLogger s_log = CLogger.getCLogger (MDunningLevel.class); /** * Standard Constructor diff --git a/base/src/org/compiere/model/MDunningRunLine.java b/base/src/org/compiere/model/MDunningRunLine.java index c205020169..77ae37d6d7 100644 --- a/base/src/org/compiere/model/MDunningRunLine.java +++ b/base/src/org/compiere/model/MDunningRunLine.java @@ -282,7 +282,7 @@ public class MDunningRunLine extends X_C_DunningRunLine // Total setTotalAmt(getConvertedAmt().add(getFeeAmt()).add(getInterestAmt())); // Reset Collection Status only if null - if (getInvoice().getInvoiceCollectionType ()==null) + if (getInvoice()!=null && getInvoice().getInvoiceCollectionType ()==null) { if (m_invoice!=null) { diff --git a/base/src/org/compiere/model/MEntityType.java b/base/src/org/compiere/model/MEntityType.java index f4f6d27c3d..048e0505d2 100644 --- a/base/src/org/compiere/model/MEntityType.java +++ b/base/src/org/compiere/model/MEntityType.java @@ -184,6 +184,20 @@ public class MEntityType extends X_AD_EntityType /** 10=D, 20=C, 100=U, 110=CUST, 200=A, 210=EXT, 220=XX */ private static final int s_maxAD_EntityType_ID = 221; + /** + * Set AD_EntityType_ID + */ + private void setAD_EntityType_ID() + { + int AD_EntityType_ID = getAD_EntityType_ID(); + if (AD_EntityType_ID == 0) + { + String sql = "SELECT NVL(MAX(AD_EntityType_ID), 999999) FROM AD_EntityType WHERE AD_EntityType_ID > 1000"; + AD_EntityType_ID= DB.getSQLValue (get_TrxName(), sql); + setAD_EntityType_ID(AD_EntityType_ID+1); + } + } // setAD_EntityType_ID + /** * Is System Maintained * @return true if D/C/U/CUST/A/EXT/XX @@ -246,6 +260,7 @@ public class MEntityType extends X_AD_EntityType + " - Must be ASCII Letter or Digit"); return false; } + setAD_EntityType_ID(); } // new s_entityTypes = null; // reset return true; diff --git a/base/src/org/compiere/model/MGoal.java b/base/src/org/compiere/model/MGoal.java index da401a0dc2..1af2df7628 100644 --- a/base/src/org/compiere/model/MGoal.java +++ b/base/src/org/compiere/model/MGoal.java @@ -475,6 +475,17 @@ public class MGoal extends X_PA_Goal return m_color; } // getColor + /** + * Get the color schema for this goal. + * + * @return the color schema, or null if the measure targer is 0 + */ + public MColorSchema getColorSchema() + { + return (getMeasureTarget().signum() == 0) ? + null : MColorSchema.get(getCtx(), getPA_ColorSchema_ID()); + } + /** * Get Measure Display * @return Measure Display diff --git a/base/src/org/compiere/model/MImage.java b/base/src/org/compiere/model/MImage.java index a3507ca4d1..c44eab4e4f 100644 --- a/base/src/org/compiere/model/MImage.java +++ b/base/src/org/compiere/model/MImage.java @@ -87,8 +87,6 @@ public class MImage extends X_AD_Image private Image m_image = null; /** The Icon */ private Icon m_icon = null; - /** The Image File */ - private File m_file = null; /** * Get Image diff --git a/base/src/org/compiere/model/MInOut.java b/base/src/org/compiere/model/MInOut.java index a77be7d323..2fa350b2b8 100644 --- a/base/src/org/compiere/model/MInOut.java +++ b/base/src/org/compiere/model/MInOut.java @@ -1015,7 +1015,7 @@ public class MInOut extends X_M_InOut implements DocAction // Credit Check if (isSOTrx() && !isReversal()) { - MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); + MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus())) { m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@=" @@ -1546,11 +1546,11 @@ public class MInOut extends X_M_InOut implements DocAction // Org Must be linked to BPartner MOrg org = MOrg.get(getCtx(), getAD_Org_ID()); - int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(); + int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName()); if (counterC_BPartner_ID == 0) return null; // Business Partner needs to be linked to Org - MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); + MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); if (counterAD_Org_ID == 0) return null; @@ -1771,6 +1771,7 @@ public class MInOut extends X_M_InOut implements DocAction return false; } reversal.closeIt(); + reversal.setProcessing (false); reversal.setDocStatus(DOCSTATUS_Reversed); reversal.setDocAction(DOCACTION_None); reversal.save(get_TrxName()); diff --git a/base/src/org/compiere/model/MInvoice.java b/base/src/org/compiere/model/MInvoice.java index 7b7333643d..053c2ed35f 100644 --- a/base/src/org/compiere/model/MInvoice.java +++ b/base/src/org/compiere/model/MInvoice.java @@ -1046,7 +1046,7 @@ public class MInvoice extends X_C_Invoice implements DocAction { BigDecimal retValue = null; String sql = "SELECT SUM(currencyConvert(al.Amount+al.DiscountAmt+al.WriteOffAmt," - + "ah.C_Currency_ID, i.C_Currency_ID,ah.DateTrx,i.C_ConversionType_ID, al.AD_Client_ID,al.AD_Org_ID)) " + + "ah.C_Currency_ID, i.C_Currency_ID,ah.DateTrx,COALESCE(i.C_ConversionType_ID,0), al.AD_Client_ID,al.AD_Org_ID)) " + "FROM C_AllocationLine al" + " INNER JOIN C_AllocationHdr ah ON (al.C_AllocationHdr_ID=ah.C_AllocationHdr_ID)" + " INNER JOIN C_Invoice i ON (al.C_Invoice_ID=i.C_Invoice_ID) " @@ -1820,7 +1820,7 @@ public class MInvoice extends X_C_Invoice implements DocAction // Org Must be linked to BPartner MOrg org = MOrg.get(getCtx(), getAD_Org_ID()); - int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(); + int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName()); if (counterC_BPartner_ID == 0) return null; // Business Partner needs to be linked to Org @@ -2046,6 +2046,7 @@ public class MInvoice extends X_C_Invoice implements DocAction reversal.setC_Payment_ID(0); reversal.setIsPaid(true); reversal.closeIt(); + reversal.setProcessing (false); reversal.setDocStatus(DOCSTATUS_Reversed); reversal.setDocAction(DOCACTION_None); reversal.save(get_TrxName()); diff --git a/base/src/org/compiere/model/MJournal.java b/base/src/org/compiere/model/MJournal.java index 91af1db21c..f01ccc2768 100644 --- a/base/src/org/compiere/model/MJournal.java +++ b/base/src/org/compiere/model/MJournal.java @@ -250,7 +250,7 @@ public class MJournal extends X_GL_Journal implements DocAction count++; } if (fromLines.length != count) - log.log(Level.SEVERE, "copyLinesFrom - Line difference - JournalLines=" + fromLines.length + " <> Saved=" + count); + log.log(Level.SEVERE, "Line difference - JournalLines=" + fromLines.length + " <> Saved=" + count); return count; } // copyLinesFrom diff --git a/base/src/org/compiere/model/MJournalBatch.java b/base/src/org/compiere/model/MJournalBatch.java index 92d65682ef..03b835259b 100644 --- a/base/src/org/compiere/model/MJournalBatch.java +++ b/base/src/org/compiere/model/MJournalBatch.java @@ -50,11 +50,13 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction MJournalBatch to = new MJournalBatch (ctx, 0, trxName); PO.copyValues(from, to, from.getAD_Client_ID(), from.getAD_Org_ID()); to.set_ValueNoCheck ("DocumentNo", null); + to.set_ValueNoCheck ("C_Period_ID", null); to.setDateAcct(dateDoc); to.setDateDoc(dateDoc); to.setDocStatus(DOCSTATUS_Drafted); to.setDocAction(DOCACTION_Complete); to.setIsApproved(false); + to.setProcessed (false); // if (!to.save()) throw new IllegalStateException("Could not create Journal Batch"); @@ -220,7 +222,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction PO.copyValues(fromJournals[i], toJournal, getAD_Client_ID(), getAD_Org_ID()); toJournal.setGL_JournalBatch_ID(getGL_JournalBatch_ID()); toJournal.set_ValueNoCheck ("DocumentNo", null); // create new - toJournal.setC_Period_ID(0); + toJournal.set_ValueNoCheck ("C_Period_ID", null); toJournal.setDateDoc(getDateDoc()); // dates from this Batch toJournal.setDateAcct(getDateAcct()); toJournal.setDocStatus(MJournal.DOCSTATUS_Drafted); @@ -238,7 +240,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction } } if (fromJournals.length != count) - log.log(Level.SEVERE, "copyDetailsFrom - Line difference - Journals=" + fromJournals.length + " <> Saved=" + count); + log.log(Level.SEVERE, "Line difference - Journals=" + fromJournals.length + " <> Saved=" + count); return count + lineCount; } // copyLinesFrom diff --git a/base/src/org/compiere/model/MMovementLine.java b/base/src/org/compiere/model/MMovementLine.java index 93338519a9..8792181498 100644 --- a/base/src/org/compiere/model/MMovementLine.java +++ b/base/src/org/compiere/model/MMovementLine.java @@ -174,7 +174,29 @@ public class MMovementLine extends X_M_MovementLine // Qty Precision if (newRecord || is_ValueChanged("QtyEntered")) - setMovementQty(getMovementQty()); + setMovementQty(getMovementQty()); + + // Mandatory Instance + if (getM_AttributeSetInstanceTo_ID() == 0) + { + if (getM_AttributeSetInstance_ID() != 0) // set to from + setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID()); + else + { + MProduct product = getProduct(); + if (product != null + && product.getM_AttributeSet_ID() != 0) + { + MAttributeSet mas = MAttributeSet.get(getCtx(), product.getM_AttributeSet_ID()); + if (mas.isInstanceAttribute() + && (mas.isMandatory() || mas.isMandatoryAlways())) + { + log.saveError("FillMandatory", Msg.getElement(getCtx(), "M_AttributeSetInstanceTo_ID")); + return false; + } + } + } + } // ASI return true; } // beforeSave diff --git a/base/src/org/compiere/model/MOrder.java b/base/src/org/compiere/model/MOrder.java index d9c6f2a15f..ec5b1be96a 100644 --- a/base/src/org/compiere/model/MOrder.java +++ b/base/src/org/compiere/model/MOrder.java @@ -1314,7 +1314,7 @@ public class MOrder extends X_C_Order implements DocAction // Credit Check if (isSOTrx()) { - MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); + MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus())) { m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@=" @@ -1888,11 +1888,11 @@ public class MOrder extends X_C_Order implements DocAction // Org Must be linked to BPartner MOrg org = MOrg.get(getCtx(), getAD_Org_ID()); - int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(); + int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName()); if (counterC_BPartner_ID == 0) return null; // Business Partner needs to be linked to Org - MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); + MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); if (counterAD_Org_ID == 0) return null; @@ -2142,6 +2142,26 @@ public class MOrder extends X_C_Order implements DocAction MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); String DocSubTypeSO = dt.getDocSubTypeSO(); + + // Replace Prepay with POS to revert all doc + if (MDocType.DOCSUBTYPESO_PrepayOrder.equals (DocSubTypeSO)) + { + MDocType newDT = null; + MDocType[] dts = MDocType.getOfClient (getCtx()); + for (int i = 0; i < dts.length; i++) + { + MDocType type = dts[i]; + if (MDocType.DOCSUBTYPESO_PrepayOrder.equals(type.getDocSubTypeSO())) + { + if (type.isDefault() || newDT == null) + newDT = type; + } + } + if (newDT == null) + return false; + else + setC_DocType_ID (newDT.getC_DocType_ID()); + } // PO - just re-open if (!isSOTrx()) diff --git a/base/src/org/compiere/model/MPayment.java b/base/src/org/compiere/model/MPayment.java index ffa43a4456..cfad320de5 100644 --- a/base/src/org/compiere/model/MPayment.java +++ b/base/src/org/compiere/model/MPayment.java @@ -1655,16 +1655,16 @@ public final class MPayment extends X_C_Payment // Org Must be linked to BPartner MOrg org = MOrg.get(getCtx(), getAD_Org_ID()); - int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(); + int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName()); if (counterC_BPartner_ID == 0) return null; // Business Partner needs to be linked to Org - MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); + MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int(); if (counterAD_Org_ID == 0) return null; - MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null); + MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, get_TrxName()); // MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID); log.info("Counter BP=" + counterBP.getName()); diff --git a/base/src/org/compiere/model/MProductCategoryAcct.java b/base/src/org/compiere/model/MProductCategoryAcct.java index e9f1c0bab6..163bb85552 100644 --- a/base/src/org/compiere/model/MProductCategoryAcct.java +++ b/base/src/org/compiere/model/MProductCategoryAcct.java @@ -122,4 +122,20 @@ public class MProductCategoryAcct extends X_M_Product_Category_Acct return success; } // afterSave + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuffer sb = new StringBuffer ("MProductCategoryAcct["); + sb.append (get_ID()) + .append (",M_Product_Category_ID=").append (getM_Product_Category_ID()) + .append (",C_AcctSchema_ID=").append(getC_AcctSchema_ID()) + .append (",CostingLevel=").append(getCostingLevel()) + .append (",CostingMethod=").append(getCostingMethod()) + .append ("]"); + return sb.toString (); + } // toString + } // MProductCategoryAcct diff --git a/base/src/org/compiere/model/MRecurring.java b/base/src/org/compiere/model/MRecurring.java index f4ccec0db4..482f1c9936 100644 --- a/base/src/org/compiere/model/MRecurring.java +++ b/base/src/org/compiere/model/MRecurring.java @@ -56,7 +56,7 @@ public class MRecurring extends X_C_Recurring public String toString() { StringBuffer sb = new StringBuffer ("MRecurring[") - .append(get_ID()).append(",").append(getName()); + .append(get_ID()).append("-").append(getName()); if (getRecurringType().equals(MRecurring.RECURRINGTYPE_Order)) sb.append(",C_Order_ID=").append(getC_Order_ID()); else if (getRecurringType().equals(MRecurring.RECURRINGTYPE_Invoice)) @@ -65,7 +65,7 @@ public class MRecurring extends X_C_Recurring sb.append(",C_Project_ID=").append(getC_Project_ID()); else if (getRecurringType().equals(MRecurring.RECURRINGTYPE_GLJournal)) sb.append(",GL_JournalBatch_ID=").append(getGL_JournalBatch_ID()); - sb.append(",Fequency=").append(getFrequencyType()).append("*").append(getFrequency()); + sb.append(",Frequency=").append(getFrequencyType()).append("*").append(getFrequency()); sb.append("]"); return sb.toString(); } // toString diff --git a/base/src/org/compiere/model/NaturalAccountMap.java b/base/src/org/compiere/model/NaturalAccountMap.java index 0c37fec60a..0f117a41c4 100644 --- a/base/src/org/compiere/model/NaturalAccountMap.java +++ b/base/src/org/compiere/model/NaturalAccountMap.java @@ -59,10 +59,6 @@ public final class NaturalAccountMap extends CCache m_trxName = trxName; } // NaturalAccountMap - /** Delimiter */ - private String m_delim = ","; - /** KeyNo */ - private static int s_keyNo = 0; /** Context */ private Properties m_ctx = null; /** Transaction */ diff --git a/base/src/org/compiere/model/ProductCost.java b/base/src/org/compiere/model/ProductCost.java index c637701158..f539a4f7ac 100644 --- a/base/src/org/compiere/model/ProductCost.java +++ b/base/src/org/compiere/model/ProductCost.java @@ -501,4 +501,18 @@ public class ProductCost return cost; } // getPOCost + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuffer sb = new StringBuffer ("ProductCost["); + sb.append ("M_Product_ID=").append(m_M_Product_ID) + .append(",M_AttributeSetInstance_ID").append(m_M_AttributeSetInstance_ID) + .append (",Qty=").append(m_qty) + .append ("]"); + return sb.toString (); + } // toString + } // ProductCost diff --git a/base/src/org/compiere/process/BPartnerOrgLink.java b/base/src/org/compiere/process/BPartnerOrgLink.java index 600a6cbad5..9d71acf95a 100644 --- a/base/src/org/compiere/process/BPartnerOrgLink.java +++ b/base/src/org/compiere/process/BPartnerOrgLink.java @@ -100,7 +100,7 @@ public class BPartnerOrgLink extends SvrProcess } else // check if linked to already { - int C_BPartner_ID = org.getLinkedC_BPartner_ID(); + int C_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName()); if (C_BPartner_ID > 0) throw new IllegalArgumentException ("Organization '" + org.getName() + "' already linked (to C_BPartner_ID=" + C_BPartner_ID + ")"); diff --git a/base/src/org/compiere/process/ChangeLogProcess.java b/base/src/org/compiere/process/ChangeLogProcess.java index abdf4e5fdc..a3aec58bd4 100644 --- a/base/src/org/compiere/process/ChangeLogProcess.java +++ b/base/src/org/compiere/process/ChangeLogProcess.java @@ -239,16 +239,28 @@ public class ChangeLogProcess extends SvrProcess { m_sqlUpdate.append(getSQLValue(cLog.getOldValue())); if (p_CheckNewValue.booleanValue()) - m_sqlUpdateWhere.append(" AND ").append(m_column.getColumnName()) - .append("=").append(getSQLValue(cLog.getNewValue())); + { + m_sqlUpdateWhere.append(" AND ").append(m_column.getColumnName()); + String newValue = getSQLValue(cLog.getNewValue()); + if (newValue == null || "NULL".equals(newValue)) + m_sqlUpdateWhere.append(" IS NULL"); + else + m_sqlUpdateWhere.append("=").append(newValue); + } } // ReDo (a) -> b else if (p_CheckOldValue != null) { m_sqlUpdate.append(getSQLValue(cLog.getNewValue())); - if (p_CheckOldValue.booleanValue()) - m_sqlUpdateWhere.append(" AND ").append(m_column.getColumnName()) - .append("=").append(getSQLValue(cLog.getOldValue())); + if (p_CheckOldValue.booleanValue()) + { + String newValue = getSQLValue(cLog.getOldValue()); + m_sqlUpdateWhere.append(" AND ").append(m_column.getColumnName()); + if (newValue == null || "NULL".equals(newValue)) + m_sqlUpdateWhere.append(" IS NULL"); + else + m_sqlUpdateWhere.append("=").append(newValue); + } } } // createStatement diff --git a/base/src/org/compiere/process/DistributionRun.java b/base/src/org/compiere/process/DistributionRun.java index 4c039c4a03..7fc9b7ea31 100644 --- a/base/src/org/compiere/process/DistributionRun.java +++ b/base/src/org/compiere/process/DistributionRun.java @@ -357,7 +357,7 @@ public class DistributionRun extends SvrProcess if (runAD_Org_ID == 0) runAD_Org_ID = Env.getAD_Org_ID(getCtx()); MOrg runOrg = MOrg.get(getCtx(), runAD_Org_ID); - int runC_BPartner_ID = runOrg.getLinkedC_BPartner_ID(); + int runC_BPartner_ID = runOrg.getLinkedC_BPartner_ID(get_TrxName()); boolean counter = !m_run.isCreateSingleOrder() // no single Order && runC_BPartner_ID > 0 // Org linked to BP && !m_docType.isSOTrx(); // PO diff --git a/base/src/org/compiere/process/DocumentTypeVerify.java b/base/src/org/compiere/process/DocumentTypeVerify.java index 113d6cd788..018992d27c 100644 --- a/base/src/org/compiere/process/DocumentTypeVerify.java +++ b/base/src/org/compiere/process/DocumentTypeVerify.java @@ -39,7 +39,6 @@ public class DocumentTypeVerify extends SvrProcess /** * No Parameters (Nop) - * @see org.compiere.process.SvrProcess#prepare() */ protected void prepare() { @@ -47,7 +46,6 @@ public class DocumentTypeVerify extends SvrProcess /** * Execute process - * @see org.compiere.process.SvrProcess#doIt() * @return info * @throws Exception */ diff --git a/base/src/org/compiere/process/ImportAccount.java b/base/src/org/compiere/process/ImportAccount.java index a7568cae44..33de47170f 100644 --- a/base/src/org/compiere/process/ImportAccount.java +++ b/base/src/org/compiere/process/ImportAccount.java @@ -42,9 +42,6 @@ public class ImportAccount extends SvrProcess /** Delete old Imported */ private boolean m_deleteOldImported = false; - /** Organization to be imported to */ - private int m_AD_Org_ID = 0; - /** Effective */ private Timestamp m_DateValue = null; diff --git a/base/src/org/compiere/process/ImportBPartner.java b/base/src/org/compiere/process/ImportBPartner.java index 5862a8bfd9..fbe91e37b3 100644 --- a/base/src/org/compiere/process/ImportBPartner.java +++ b/base/src/org/compiere/process/ImportBPartner.java @@ -36,8 +36,6 @@ public class ImportBPartner extends SvrProcess /** Delete old Imported */ private boolean m_deleteOldImported = false; - /** Organization to be imported to */ - private int m_AD_Org_ID = 0; /** Effective */ private Timestamp m_DateValue = null; @@ -100,11 +98,11 @@ public class ImportBPartner extends SvrProcess log.fine("Reset=" + no); // Set BP_Group - sql = new StringBuffer ("UPDATE I_BPartner i " - + "SET GroupValue=(SELECT Value FROM C_BP_Group g WHERE g.IsDefault='Y'" - + " AND g.AD_Client_ID=i.AD_Client_ID AND ROWNUM=1) " - + "WHERE GroupValue IS NULL AND C_BP_Group_ID IS NULL" - + " AND I_IsImported<>'Y'").append(clientCheck); + sql = new StringBuffer ("UPDATE I_BPartner i " + + "SET GroupValue=(SELECT MAX(Value) FROM C_BP_Group g WHERE g.IsDefault='Y'" + + " AND g.AD_Client_ID=i.AD_Client_ID"); + sql.append("WHERE GroupValue IS NULL AND C_BP_Group_ID IS NULL" + + " AND I_IsImported<>'Y'").append(clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Group Default=" + no); // @@ -149,14 +147,14 @@ public class ImportBPartner extends SvrProcess no = DB.executeUpdate(sql.toString(), get_TrxName()); log.config("Invalid Country=" + no); - // Set Region - sql = new StringBuffer ("UPDATE I_BPartner i " - + "Set RegionName=(SELECT Name FROM C_Region r" - + " WHERE r.IsDefault='Y' AND r.C_Country_ID=i.C_Country_ID" - + " AND r.AD_Client_ID IN (0, i.AD_Client_ID) AND ROWNUM=1) " - + "WHERE RegionName IS NULL AND C_Region_ID IS NULL" - + " AND I_IsImported<>'Y'").append(clientCheck); - no = DB.executeUpdate(sql.toString(), get_TrxName()); + // Set Region + sql = new StringBuffer ("UPDATE I_BPartner i " + + "Set RegionName=(SELECT MAX(Name FROM C_Region r" + + " WHERE r.IsDefault='Y' AND r.C_Country_ID=i.C_Country_ID" + + " AND r.AD_Client_ID IN (0, i.AD_Client_ID)) " ); + sql.append("WHERE RegionName IS NULL AND C_Region_ID IS NULL" + + " AND I_IsImported<>'Y'").append(clientCheck); + no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Set Region Default=" + no); // sql = new StringBuffer ("UPDATE I_BPartner i " @@ -433,7 +431,7 @@ public class ImportBPartner extends SvrProcess if (impBP.getPhone() != null) user.setPhone(impBP.getPhone()); if (impBP.getPhone2() != null) - user.setPhone(impBP.getPhone2()); + user.setPhone2(impBP.getPhone2()); if (impBP.getFax() != null) user.setFax(impBP.getFax()); if (impBP.getEMail() != null) diff --git a/db/ddlutils/oracle/procedures/C_ProcessCreate.sql b/db/ddlutils/oracle/procedures/C_ProcessCreate.sql deleted file mode 100644 index 4ac739d956..0000000000 --- a/db/ddlutils/oracle/procedures/C_ProcessCreate.sql +++ /dev/null @@ -1,56 +0,0 @@ -IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'C_ProcessCreate') - BEGIN - PRINT '<<< DROPPING PROCEDURE C_ProcessCreate >>>' - DROP Procedure C_ProcessCreate - END -go ------------------------------------------------------------------------------- -CREATE Procedure C_ProcessCreate -( - @AD_Table_ID Identifier, - @Record_ID Identifier, - @AD_IProcess_ID Identifier OUTPUT -) ---WITH ENCRYPTION -AS -/****************************************************************************** - * Author: Jorg Janke (c) ClassApps 1999 - * Version: $Header: /cvs/adempiere/db/database/Procedures/C_ProcessCreate.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $ - * - * Description: - * Create process for background execution - * - * Return values: - * Int_Process_ID - * - * Called by: - * - ******************************************************************************/ -BEGIN - Set NoCount ON - BEGIN TRANSACTION - - SELECT @AD_IProcess_ID = ISNULL(MAX(AD_IProcess_ID), 0)+1 - FROM AD_IProcess - --------------------------------- - INSERT INTO AD_IProcess - (AD_IProcess_ID, AD_Table_ID, Record_ID, IsProcessing, Updated) - VALUES - (@AD_IProcess_ID, @AD_Table_ID, @Record_ID, 'N', null) - - IF (@@ERROR <> 0) - BEGIN - RAISERROR 60001 'Int_Process insert error' - ROLLBACK TRAN - RETURN(1) - END - - COMMIT TRANSACTION -END -- C_ProcessCreate -go ------------------------------------------------------------------------------- -IF OBJECT_ID('C_ProcessCreate') IS NOT NULL - PRINT '<<< CREATED PROCEDURE C_ProcessCreate >>>' -ELSE - PRINT '<<< FAILED CREATING PROCEDURE C_ProcessCreate >>>' -go \ No newline at end of file diff --git a/dbPort/src/org/compiere/model/MOrg.java b/dbPort/src/org/compiere/model/MOrg.java index a4fd6ca246..3c989eff17 100644 --- a/dbPort/src/org/compiere/model/MOrg.java +++ b/dbPort/src/org/compiere/model/MOrg.java @@ -202,11 +202,11 @@ public class MOrg extends X_AD_Org * Get Linked BPartner * @return C_BPartner_ID */ - public int getLinkedC_BPartner_ID() + public int getLinkedC_BPartner_ID(String trxName) { if (m_linkedBPartner == null) { - int C_BPartner_ID = DB.getSQLValue(null, + int C_BPartner_ID = DB.getSQLValue(trxName, "SELECT C_BPartner_ID FROM C_BPartner WHERE AD_OrgBP_ID=?", getAD_Org_ID()); if (C_BPartner_ID < 0) // not found = -1