From 2c00825d7d5d3c90810b05b23d5a5d4128b604a2 Mon Sep 17 00:00:00 2001 From: trifonnt Date: Tue, 18 Nov 2008 18:12:47 +0000 Subject: [PATCH] Fixed sql for Query class. We can't use aliase for Table names. Developer must use Table name. --- base/src/org/compiere/model/MCash.java | 36 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) 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;