From acc65b8ccc84a5ecf926a4bc815c3513f2c4870e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 14 Oct 2008 07:34:38 +0000 Subject: [PATCH] Fix bug ID: 2165542 - Cannot pay/receive an installment via cash journal --- .../compiere/model/CalloutCashJournal.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/base/src/org/compiere/model/CalloutCashJournal.java b/base/src/org/compiere/model/CalloutCashJournal.java index 9732e034a6..309e754421 100644 --- a/base/src/org/compiere/model/CalloutCashJournal.java +++ b/base/src/org/compiere/model/CalloutCashJournal.java @@ -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. * * 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 * @@ -16,11 +16,16 @@ *****************************************************************************/ package org.compiere.model; -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.logging.*; -import org.compiere.util.*; +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +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 @@ -52,6 +57,11 @@ public class CalloutCashJournal extends CalloutEngine mTab.setValue("C_Currency_ID", null); 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 Timestamp ts = Env.getContextAsDate(ctx, WindowNo, "DateAcct"); // from C_Cash @@ -59,16 +69,18 @@ public class CalloutCashJournal extends CalloutEngine ts = new Timestamp(System.currentTimeMillis()); // String sql = "SELECT C_BPartner_ID, C_Currency_ID," // 1..2 - + "invoiceOpen(C_Invoice_ID, 0), IsSOTrx, " // 3..4 - + "paymentTermDiscount(invoiceOpen(C_Invoice_ID, 0),C_Currency_ID,C_PaymentTerm_ID,DateInvoiced,?) " + + "invoiceOpen(C_Invoice_ID, ?), IsSOTrx, " // 3..4 + + "invoiceDiscount(C_Invoice_ID,?,?) " // 5 + "FROM C_Invoice WHERE C_Invoice_ID=?"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, null); - pstmt.setTimestamp(1, ts); - pstmt.setInt(2, C_Invoice_ID.intValue()); + pstmt.setInt (1, C_InvoicePaySchedule_ID); + pstmt.setTimestamp (2, ts); + pstmt.setInt (3, C_InvoicePaySchedule_ID); + pstmt.setInt(4, C_Invoice_ID.intValue()); rs = pstmt.executeQuery(); if (rs.next()) {