details:   https://code.openbravo.com/erp/devel/pi/rev/f47b0f799713
changeset: 32447:f47b0f799713
user:      Mark <markmm82 <at> gmail.com>
date:      Mon Jul 10 12:15:53 2017 -0400
summary:   Fixes issue 36435: Unlikely argument type warnings

StockReservationPickAndEditDataSource.java
- Fixed comparison between Empty String and OrderLine object.

LCCostMatchFromInvoiceHandler.java
- Remove the matchToRemove object from localIl.getLandedCostMatchedList() 
instead
  of localIl.getLandedCostCostList() list.

SL_InOut_BPartner.java
- Replaced two nested IFs for only one that includes all conditions of both of 
them.
- Used StringUtils methods to avoid NPE.

DocFINReconciliation.java
- Used StringUtils methods to avoid NPE.
- Created two new variables to store accounts required for processing, and avoid
  calculate them twice.

ProductInfo.java
- Removed comparison with Empty String, because it is not needed.

ConvertQuotationIntoOrder.java
- Removed comparison with Empty String, because it is not needed.
- Use BigDecimal.compareTo to compare two BigDecimal objects.

details:   https://code.openbravo.com/erp/devel/pi/rev/a99ac166135b
changeset: 32448:a99ac166135b
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Jul 11 12:30:29 2017 +0200
summary:   Related to issue 36435: Fix warning also in TestCosting.java

diffstat:

 src-test/src/org/openbravo/test/costing/TestCosting.java                       
|   2 +-
 src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java 
|   2 +-
 src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java                   
|   4 +-
 src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java                 
|  21 +++++----
 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java                 
|  11 +++-
 src/org/openbravo/erpCommon/ad_forms/ProductInfo.java                          
|   4 +-
 src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java          
|   6 +-
 7 files changed, 26 insertions(+), 24 deletions(-)

diffs (159 lines):

diff -r 267dc90e6f1f -r a99ac166135b 
src-test/src/org/openbravo/test/costing/TestCosting.java
--- a/src-test/src/org/openbravo/test/costing/TestCosting.java  Tue Jul 11 
11:38:20 2017 +0200
+++ b/src-test/src/org/openbravo/test/costing/TestCosting.java  Tue Jul 11 
12:30:29 2017 +0200
@@ -13176,7 +13176,7 @@
             || document.getEntityName().equals(CostAdjustment.ENTITY_NAME) || 
(document
             .getEntityName().equals(ReceiptInvoiceMatch.ENTITY_NAME) && 
(line.getEntityName()
             .equals(ShipmentInOutLine.ENTITY_NAME) || 
(line.getEntityName().equals(
-            InvoiceLine.ENTITY_NAME) && ((InvoiceLine) 
line).getInvoice().getCurrency()
+            InvoiceLine.ENTITY_NAME) && ((InvoiceLine) 
line).getInvoice().getCurrency().getId()
             .equals(DOLLAR_ID)))))
             && OBDal.getInstance().get(Organization.class, 
ORGANIZATION_ID).getCurrency() != null
             && OBDal.getInstance().get(Organization.class, 
ORGANIZATION_ID).getCurrency().getId()
diff -r 267dc90e6f1f -r a99ac166135b 
src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java
--- 
a/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java
    Tue Jul 11 11:38:20 2017 +0200
+++ 
b/src/org/openbravo/common/datasource/StockReservationPickAndEditDataSource.java
    Tue Jul 11 12:30:29 2017 +0200
@@ -1679,7 +1679,7 @@
 
   private BigDecimal getQtyOnHand(Product product, Locator storageBin,
       AttributeSetInstance attribute, OrderLine orderline) {
-    if (orderline != null && !"".equals(orderline)) {
+    if (orderline != null) {
       return getQtyOnHandFromOrderLine(orderline);
     }
     final StringBuilder hqlString = new StringBuilder();
diff -r 267dc90e6f1f -r a99ac166135b 
src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java
--- a/src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java      Tue Jul 
11 11:38:20 2017 +0200
+++ b/src/org/openbravo/costing/LCCostMatchFromInvoiceHandler.java      Tue Jul 
11 12:30:29 2017 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014-2015 Openbravo SLU
+ * All portions are Copyright (C) 2014-2017 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -197,7 +197,7 @@
         lcCost = OBDal.getInstance().get(LandedCostCost.class,
             matchToRemove.getLandedCostCost().getId());
         lcCost.getLandedCostMatchedList().remove(matchToRemove);
-        localIl.getLandedCostCostList().remove(matchToRemove);
+        localIl.getLandedCostMatchedList().remove(matchToRemove);
         OBDal.getInstance().save(lcCost);
         OBDal.getInstance().remove(matchToRemove);
       }
diff -r 267dc90e6f1f -r a99ac166135b 
src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java    Tue Jul 
11 11:38:20 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java    Tue Jul 
11 12:30:29 2017 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -240,16 +240,17 @@
     final String rMatReceipt = "123271B9AD60469BAE8A924841456B63";
     String strwindow = vars.getStringParameter("inpwindowId");
     String message = "";
-    if ((!(strwindow.equals(rtvendorship) || strwindow.equals(rMatReceipt)))) {
-      if ((!bpartner.equals(""))
-          && FIN_Utility.isBlockedBusinessPartner(strBPartner, 
"Y".equals(strIsSOTrx), 2)) {
-        // If the Business Partner is blocked for this document, show an 
information message.
-        if (message.length() > 0) {
-          message = message + "<br>";
-        }
-        message = message + OBMessageUtils.messageBD("ThebusinessPartner") + " 
"
-            + bpartner.getIdentifier() + " " + 
OBMessageUtils.messageBD("BusinessPartnerBlocked");
+    if (!StringUtils.equals(strwindow, rtvendorship)
+        && !StringUtils.equals(strwindow, rMatReceipt)
+        && bpartner != null
+        && FIN_Utility.isBlockedBusinessPartner(bpartner.getId(),
+            StringUtils.equals(strIsSOTrx, "Y"), 2)) {
+      // If the Business Partner is blocked for this document, show an 
information message.
+      if (message.length() > 0) {
+        message = message + "<br>";
       }
+      message = message + OBMessageUtils.messageBD("ThebusinessPartner") + " "
+          + bpartner.getIdentifier() + " " + 
OBMessageUtils.messageBD("BusinessPartnerBlocked");
     }
     if (data != null && data.length > 0
         && new BigDecimal(data[0].creditavailable).compareTo(BigDecimal.ZERO) 
< 0
diff -r 267dc90e6f1f -r a99ac166135b 
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Tue Jul 
11 11:38:20 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Tue Jul 
11 12:30:29 2017 +0200
@@ -31,6 +31,7 @@
 
 import javax.servlet.ServletException;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.hibernate.criterion.Restrictions;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
@@ -969,13 +970,15 @@
         line2.m_DateAcct = OBDateUtils.formatDate(invoice.getAccountingDate());
         // checking if the prepayment account and ReceivablesNo account in the 
Business Partner
         // is the same.In this case we do not need to create more accounting 
lines
-        if (!getAccountBPartner(bpartnerId, as, isReceipt, false, 
conn).Account_ID
-            .equals(getAccountBPartner(bpartnerId, as, isReceipt, true, 
conn))) {
-          fact.createLine(line2, getAccountBPartner(bpartnerId, as, isReceipt, 
false, conn),
+        Account accountIDReceivablesNo = getAccountBPartner(bpartnerId, as, 
isReceipt, false, conn);
+        Account accountIDPrePayment = getAccountBPartner(bpartnerId, as, 
isReceipt, true, conn);
+        if (!StringUtils.equals(accountIDReceivablesNo.getAccount_ID(),
+            accountIDPrePayment.getAccount_ID())) {
+          fact.createLine(line2, accountIDReceivablesNo,
               paymentCurrency.getId(), !isReceipt ? 
bpAmountConverted.toString() : "",
               isReceipt ? bpAmountConverted.toString() : "", 
Fact_Acct_Group_ID2, nextSeqNo(SeqNo),
               DocumentType, line2.m_DateAcct, null, conn);
-          fact.createLine(line2, getAccountBPartner(bpartnerId, as, isReceipt, 
true, conn),
+          fact.createLine(line2, accountIDPrePayment,
               paymentCurrency.getId(), isReceipt ? 
bpAmountConverted.toString() : "",
               !isReceipt ? bpAmountConverted.toString() : "", 
Fact_Acct_Group_ID2,
               nextSeqNo(SeqNo), DocumentType, line2.m_DateAcct, null, conn);
diff -r 267dc90e6f1f -r a99ac166135b 
src/org/openbravo/erpCommon/ad_forms/ProductInfo.java
--- a/src/org/openbravo/erpCommon/ad_forms/ProductInfo.java     Tue Jul 11 
11:38:20 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/ProductInfo.java     Tue Jul 11 
12:30:29 2017 +0200
@@ -11,7 +11,7 @@
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
  * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
  * Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2017 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -324,7 +324,7 @@
       Warehouse wh, Currency currency) throws OBException {
     BigDecimal qty = null;
     Product product = OBDal.getInstance().get(Product.class, m_M_Product_ID);
-    if (_qty == null || "".equals(_qty)) {
+    if (_qty == null) {
       qty = new BigDecimal(m_qty);
     } else {
       qty = _qty;
diff -r 267dc90e6f1f -r a99ac166135b 
src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java
--- a/src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java     
Tue Jul 11 11:38:20 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/ConvertQuotationIntoOrder.java     
Tue Jul 11 12:30:29 2017 +0200
@@ -281,8 +281,7 @@
     BigDecimal bdPriceList = getPriceList(ordLine.getProduct().getId(), 
strPriceVersionId);
     BigDecimal bdPriceStd = getPriceStd(ordLine.getProduct().getId(), 
strPriceVersionId);
 
-    if (!"".equals(bdPriceList) && bdPriceList != null
-        && !bdPriceList.equals(BigDecimal.ZERO.setScale(bdPriceList.scale()))) 
{
+    if (bdPriceList != null && bdPriceList.compareTo(BigDecimal.ZERO) != 0) {
       // List Price
       if (objOrder.getPriceList().isPriceIncludesTax()) {
         // If is Price Including Taxes, change only gross
@@ -294,8 +293,7 @@
       }
     }
 
-    if (!"".equals(bdPriceStd) && bdPriceStd != null
-        && !bdPriceStd.equals(BigDecimal.ZERO.setScale(bdPriceStd.scale()))) {
+    if (bdPriceStd != null && bdPriceStd.compareTo(BigDecimal.ZERO) != 0) {
       // Unit Price
       if (objOrder.getPriceList().isPriceIncludesTax()) {
         // If is Price Including Taxes, change only gross

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to