Fix bug ID: 2165542 - Cannot pay/receive an installment via cash journal

This commit is contained in:
Carlos Ruiz 2008-10-14 07:34:38 +00:00
parent 784d20d001
commit acc65b8ccc
1 changed files with 22 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
@ -16,11 +16,16 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.math.*; import java.math.BigDecimal;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.sql.SQLException;
import org.compiere.util.*; import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* Cash Book Journal Callouts * Cash Book Journal Callouts
@ -52,6 +57,11 @@ public class CalloutCashJournal extends CalloutEngine
mTab.setValue("C_Currency_ID", null); mTab.setValue("C_Currency_ID", null);
return ""; return "";
} }
int C_InvoicePaySchedule_ID = 0;
if (Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_Invoice_ID") == C_Invoice_ID.intValue ()
&& Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID") != 0)
C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");
// Date // Date
Timestamp ts = Env.getContextAsDate(ctx, WindowNo, "DateAcct"); // from C_Cash Timestamp ts = Env.getContextAsDate(ctx, WindowNo, "DateAcct"); // from C_Cash
@ -59,16 +69,18 @@ public class CalloutCashJournal extends CalloutEngine
ts = new Timestamp(System.currentTimeMillis()); ts = new Timestamp(System.currentTimeMillis());
// //
String sql = "SELECT C_BPartner_ID, C_Currency_ID," // 1..2 String sql = "SELECT C_BPartner_ID, C_Currency_ID," // 1..2
+ "invoiceOpen(C_Invoice_ID, 0), IsSOTrx, " // 3..4 + "invoiceOpen(C_Invoice_ID, ?), IsSOTrx, " // 3..4
+ "paymentTermDiscount(invoiceOpen(C_Invoice_ID, 0),C_Currency_ID,C_PaymentTerm_ID,DateInvoiced,?) " + "invoiceDiscount(C_Invoice_ID,?,?) " // 5
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; + "FROM C_Invoice WHERE C_Invoice_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setTimestamp(1, ts); pstmt.setInt (1, C_InvoicePaySchedule_ID);
pstmt.setInt(2, C_Invoice_ID.intValue()); pstmt.setTimestamp (2, ts);
pstmt.setInt (3, C_InvoicePaySchedule_ID);
pstmt.setInt(4, C_Invoice_ID.intValue());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {