From 6005e2cfb1f1595827fc814a48f64d801fd1d9fd Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 14 Jan 2008 23:07:58 +0000 Subject: [PATCH] Peer review [ 1867464 ] Incorrect Partner Location when create manual shipment Small refactoring --- base/src/org/compiere/model/CalloutInOut.java | 103 +++++++++--------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/base/src/org/compiere/model/CalloutInOut.java b/base/src/org/compiere/model/CalloutInOut.java index 61c94b9042..cfc6ed14f7 100644 --- a/base/src/org/compiere/model/CalloutInOut.java +++ b/base/src/org/compiere/model/CalloutInOut.java @@ -170,62 +170,60 @@ public class CalloutInOut extends CalloutEngine if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0) return ""; - String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID," - + "p.M_PriceList_ID,p.PaymentRule,p.POReference," - + "p.SO_Description,p.IsDiscountPrinted," - + "p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," - + "l.C_BPartner_Location_ID,c.AD_User_ID " - + "FROM C_BPartner p, C_BPartner_Location l, AD_User c " - + "WHERE l.IsActive='Y' AND p.C_BPartner_ID=l.C_BPartner_ID(+)" - + " AND p.C_BPartner_ID=c.C_BPartner_ID(+)" - + " AND p.C_BPartner_ID=?"; // 1 - - try + String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID," + + "p.M_PriceList_ID,p.PaymentRule,p.POReference," + + "p.SO_Description,p.IsDiscountPrinted," + + "p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," + + "l.C_BPartner_Location_ID,c.AD_User_ID " + + "FROM C_BPartner p, C_BPartner_Location l, AD_User c " + + "WHERE l.IsActive='Y' AND p.C_BPartner_ID=l.C_BPartner_ID(+)" + + " AND p.C_BPartner_ID=c.C_BPartner_ID(+)" + + " AND p.C_BPartner_ID=?"; // 1 + + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, C_BPartner_ID.intValue()); + ResultSet rs = pstmt.executeQuery(); + if (rs.next()) { - PreparedStatement pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, C_BPartner_ID.intValue()); - ResultSet rs = pstmt.executeQuery(); - BigDecimal bd; - if (rs.next()) + //[ 1867464 ] + boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx")); + if (!IsSOTrx) + { + // Location + Integer ii = new Integer(rs.getInt("C_BPartner_Location_ID")); + if (rs.wasNull()) + mTab.setValue("C_BPartner_Location_ID", null); + else + mTab.setValue("C_BPartner_Location_ID", ii); + // Contact + ii = new Integer(rs.getInt("AD_User_ID")); + if (rs.wasNull()) + mTab.setValue("AD_User_ID", null); + else + mTab.setValue("AD_User_ID", ii); + } + + //Bugs item #1679818: checking for SOTrx only + if (IsSOTrx) { - //[ 1867464 ] - boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); - if(!IsSOTrx) - { - // Location - Integer ii = new Integer(rs.getInt("C_BPartner_Location_ID")); - if (rs.wasNull()) - mTab.setValue("C_BPartner_Location_ID", null); - else - mTab.setValue("C_BPartner_Location_ID", ii); - // Contact - ii = new Integer(rs.getInt("AD_User_ID")); - if (rs.wasNull()) - mTab.setValue("AD_User_ID", null); - else - mTab.setValue("AD_User_ID", ii); - } - - //Bugs item #1679818: checking for SOTrx only - //boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); - if (IsSOTrx) - { - // CreditAvailable - double CreditAvailable = rs.getDouble("CreditAvailable"); - if (!rs.wasNull() && CreditAvailable < 0) - mTab.fireDataStatusEEvent("CreditLimitOver", + // CreditAvailable + double CreditAvailable = rs.getDouble("CreditAvailable"); + if (!rs.wasNull() && CreditAvailable < 0) + mTab.fireDataStatusEEvent("CreditLimitOver", DisplayType.getNumberFormat(DisplayType.Amount).format(CreditAvailable), false); - }// - } - rs.close(); - pstmt.close(); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - return e.getLocalizedMessage(); + }// } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql, e); + return e.getLocalizedMessage(); + } return ""; } // bpartner @@ -259,7 +257,6 @@ public class CalloutInOut extends CalloutEngine PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, M_Warehouse_ID.intValue()); ResultSet rs = pstmt.executeQuery(); - BigDecimal bd; if (rs.next()) { // Org @@ -552,4 +549,4 @@ public class CalloutInOut extends CalloutEngine return ""; } // asi -} // CalloutInOut +} // CalloutInOut \ No newline at end of file