diff --git a/base/src/org/compiere/model/MCash.java b/base/src/org/compiere/model/MCash.java index f1ec840c0b..0f906a3af0 100644 --- a/base/src/org/compiere/model/MCash.java +++ b/base/src/org/compiere/model/MCash.java @@ -44,6 +44,9 @@ import org.compiere.util.TimeUtil; */ public class MCash extends X_C_Cash implements DocAction { + + private static final long serialVersionUID = 1L; + /** * Get Cash Journal for currency, org and date * @param ctx context @@ -57,14 +60,16 @@ public class MCash extends X_C_Cash implements DocAction Timestamp dateAcct, int C_Currency_ID, String trxName) { // Existing Journal - String whereClause = "c.AD_Org_ID=?" // #1 - + " AND TRUNC(c.StatementDate)=?" // #2 - + " AND c.Processed='N'" + String whereClause = "C_Cash.AD_Org_ID=?" // #1 + + " AND TRUNC(C_Cash.StatementDate)=?" // #2 + + " AND C_Cash.Processed='N'" + " AND EXISTS (SELECT * FROM C_CashBook cb " - + "WHERE c.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=c.AD_Org_ID" + + "WHERE C_Cash.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=C_Cash.AD_Org_ID" + " AND cb.C_Currency_ID=?)"; // #3 - MCash retValue = new Query(ctx,MCash.Table_Name,whereClause,trxName) - .setParameters(new Object[]{AD_Org_ID,TimeUtil.getDay(dateAcct),C_Currency_ID}).first(); + MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName) + .setParameters(new Object[]{AD_Org_ID,TimeUtil.getDay(dateAcct),C_Currency_ID}) + .first() + ; if (retValue != null) return retValue; @@ -94,12 +99,14 @@ public class MCash extends X_C_Cash implements DocAction public static MCash get (Properties ctx, int C_CashBook_ID, Timestamp dateAcct, String trxName) { - String whereClause ="c.C_CashBook_ID=?" // #1 - + " AND TRUNC(c.StatementDate)=?" // #2 - + " AND c.Processed='N'"; + String whereClause ="C_CashBook_ID=?" // #1 + + " AND TRUNC(StatementDate)=?" // #2 + + " AND Processed='N'"; - MCash retValue = new Query(ctx,MCash.Table_Name,whereClause,trxName) - .setParameters(new Object[]{C_CashBook_ID,TimeUtil.getDay(dateAcct)}).first(); + MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName) + .setParameters(new Object[]{C_CashBook_ID, TimeUtil.getDay(dateAcct)}) + .first() + ; if (retValue != null) return retValue; @@ -202,8 +209,11 @@ public class MCash extends X_C_Cash implements DocAction } String whereClause ="C_Cash_ID=?"; - List list = new Query(getCtx(),MCashLine.Table_Name, whereClause, get_TrxName()) - .setParameters(new Object[]{getC_Cash_ID()}).setOrderBy("Line").list(); + List list = new Query(getCtx(), MCashLine.Table_Name, whereClause, get_TrxName()) + .setParameters(new Object[]{getC_Cash_ID()}) + .setOrderBy("Line") + .list() + ; m_lines = list.toArray(new MCashLine[list.size()]); return m_lines;