Integrate revision 6025

Enhancements from Paul (phib) FR [ 2042637 ] Bank statement create lines currency handling improvements
This commit is contained in:
Carlos Ruiz 2008-08-22 20:28:48 +00:00
parent cdb5a5f46f
commit 3bab3420d3
1 changed files with 15 additions and 12 deletions

View File

@ -39,6 +39,8 @@ import org.compiere.util.*;
*/ */
public class VCreateFromStatement extends VCreateFrom implements VetoableChangeListener public class VCreateFromStatement extends VCreateFrom implements VetoableChangeListener
{ {
private MBankAccount bankAccount;
/** /**
* Protected Constructor * Protected Constructor
* @param mTab MTab * @param mTab MTab
@ -72,7 +74,7 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
bankAccountField = new VLookup ("C_BankAccount_ID", true, false, true, lookup); bankAccountField = new VLookup ("C_BankAccount_ID", true, true, true, lookup);
bankAccountField.addVetoableChangeListener(this); bankAccountField.addVetoableChangeListener(this);
// Set Default // Set Default
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID"); int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
@ -84,6 +86,8 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
authorizationField.addActionListener(this); authorizationField.addActionListener(this);
loadBankAccount(C_BankAccount_ID, R_AuthCode); loadBankAccount(C_BankAccount_ID, R_AuthCode);
bankAccount = new MBankAccount(Env.getCtx(), C_BankAccount_ID, null);
return true; return true;
} // dynInit } // dynInit
@ -137,10 +141,11 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
*/ */
Vector<Vector<Object>> data = new Vector<Vector<Object>>(); Vector<Vector<Object>> data = new Vector<Vector<Object>>();
String sql = "SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt," String sql = "SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,"
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1 + "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,pay.DateAcct,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID),"
+ " bp.Name " + " bp.Name "
+ "FROM C_BankAccount ba" + "FROM C_BankAccount ba"
+ " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)" + " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)"
+ " INNER JOIN C_Payment pay ON (p.C_Payment_ID=pay.C_Payment_ID)"
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)" + " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)"
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) " + " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'" + "WHERE p.Processed='Y' AND p.IsReconciled='N'"
@ -154,19 +159,13 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
// Voided Bank Statements have 0 StmtAmt // Voided Bank Statements have 0 StmtAmt
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)"; + "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
// Get StatementDate
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
if (ts == null)
ts = new Timestamp(System.currentTimeMillis());
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setTimestamp(1, ts); pstmt.setInt(1, C_BankAccount_ID);
pstmt.setInt(2, C_BankAccount_ID);
//RF [1811114] //RF [1811114]
if (R_AuthCode!= "" && R_AuthCode!= null){ if (R_AuthCode!= "" && R_AuthCode!= null){
pstmt.setString(3, R_AuthCode);} pstmt.setString(2, R_AuthCode);}
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
@ -266,8 +265,7 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
int C_Payment_ID = pp.getKey(); int C_Payment_ID = pp.getKey();
pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Currency pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Currency
int C_Currency_ID = pp.getKey(); int C_Currency_ID = pp.getKey();
BigDecimal TrxAmt = (BigDecimal)model.getValueAt(i, 4); // 4-PayAmt BigDecimal TrxAmt = (BigDecimal)model.getValueAt(i, 5); // 5- Conv Amt
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
// //
log.fine("Line Date=" + trxDate log.fine("Line Date=" + trxDate
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt); + ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
@ -275,6 +273,11 @@ public class VCreateFromStatement extends VCreateFrom implements VetoableChangeL
MBankStatementLine bsl = new MBankStatementLine (bs); MBankStatementLine bsl = new MBankStatementLine (bs);
bsl.setStatementLineDate(trxDate); bsl.setStatementLineDate(trxDate);
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null)); bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
bsl.setTrxAmt(TrxAmt);
bsl.setStmtAmt(TrxAmt);
bsl.setC_Currency_ID(bankAccount.getC_Currency_ID());
if (!bsl.save()) if (!bsl.save())
log.log(Level.SEVERE, "Line not created #" + i); log.log(Level.SEVERE, "Line not created #" + i);
} // if selected } // if selected