details: https://code.openbravo.com/erp/devel/pi/rev/8f41e7a205f8 changeset: 35533:8f41e7a205f8 user: Atul Gaware <atul.gaware <at> openbravo.com> date: Mon Mar 04 11:04:58 2019 +0530 summary: Fixes Issue 0040285: Error in Copy Lines -> Purchase invoice when the preference Enable UOM Management is active
** Not empty check for product id is done before getting default aum details: https://code.openbravo.com/erp/devel/pi/rev/8351f0739a6c changeset: 35534:8351f0739a6c user: Atul Gaware <atul.gaware <at> openbravo.com> date: Mon Mar 04 11:14:04 2019 +0530 summary: Related To Issue 0040285: Error in Copy Lines -> Purchase invoice when the preference Enable UOM Management is active ** Use StringUtils to avoid NPE details: https://code.openbravo.com/erp/devel/pi/rev/694c66ecffcf changeset: 35535:694c66ecffcf user: Atul Gaware <atul.gaware <at> openbravo.com> date: Tue Mar 05 00:11:39 2019 +0530 summary: Related to Issue 40285:Error in Copy Lines -> Purchase invoice when the preference Enable UOM Management is active ** Use StringUtils to avoid NPE diffstat: src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java | 42 +++++---- 1 files changed, 22 insertions(+), 20 deletions(-) diffs (128 lines): diff -r 92a2f9f50e21 -r 694c66ecffcf src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java --- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java Tue Mar 12 11:59:39 2019 +0100 +++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java Tue Mar 05 00:11:39 2019 +0530 @@ -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-2017 Openbravo SLU + * All portions are Copyright (C) 2001-2019 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringUtils; import org.hibernate.criterion.Restrictions; import org.openbravo.base.exception.OBException; import org.openbravo.base.secureApp.HttpSecureAppServlet; @@ -83,7 +84,7 @@ String strTab = vars.getStringParameter("inpTabId"); String strPriceListCheck = vars.getStringParameter("inpPriceList"); String strWindowPath = Utility.getTabURL(strTab, "R", true); - if (strWindowPath.equals("")) { + if (StringUtils.isEmpty(strWindowPath)) { strWindowPath = strDefaultServlet; } @@ -147,39 +148,40 @@ String strWharehouse = Utility.getContext(this, vars, "#M_Warehouse_ID", strWindowId); String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", strWindowId); - if (isUomManagementEnabled && data[i].mProductUomId.isEmpty() && data[i].cAum.isEmpty() - && data[i].aumqty.isEmpty()) { - String defaultAum = UOMUtil.getDefaultAUMForDocument(data[i].productId, + if (isUomManagementEnabled && StringUtils.isNotEmpty(strmProductId) + && StringUtils.isEmpty(data[i].mProductUomId) && StringUtils.isEmpty(data[i].cAum) + && StringUtils.isEmpty(data[i].aumqty)) { + String defaultAum = UOMUtil.getDefaultAUMForDocument(strmProductId, invToCopy.getTransactionDocument().getId()); data[i].aumqty = data[i].qtyinvoiced; data[i].cAum = defaultAum; - if (!defaultAum.equals(data[i].cUomId)) { + if (!StringUtils.equals(defaultAum, data[i].cUomId)) { data[i].qtyinvoiced = UOMUtil - .getConvertedQty(data[i].productId, new BigDecimal(data[i].aumqty), defaultAum) + .getConvertedQty(strmProductId, new BigDecimal(data[i].aumqty), defaultAum) .toString(); } } String strCTaxID = Tax.get(this, data[i].productId, dataInvoice[0].dateinvoiced, dataInvoice[0].adOrgId, strWharehouse, dataInvoice[0].cBpartnerLocationId, - dataInvoice[0].cBpartnerLocationId, dataInvoice[0].cProjectId, strIsSOTrx.equals("Y"), - data[i].accountId); + dataInvoice[0].cBpartnerLocationId, dataInvoice[0].cProjectId, + StringUtils.equals(strIsSOTrx, "Y"), data[i].accountId); // force get price list price if mixing tax including price lists. boolean forcePriceList = (invoice.getPriceList() .isPriceIncludesTax() != invToCopy.getPriceList().isPriceIncludesTax()); - if ("Y".equals(strPriceListCheck) || forcePriceList) { + if (StringUtils.equals(strPriceListCheck, "Y") || forcePriceList) { CopyFromInvoiceData[] invoicelineprice = CopyFromInvoiceData.selectPriceForProduct(this, strmProductId, strInvPriceList); for (int j = 0; invoicelineprice != null && j < invoicelineprice.length; j++) { - if (invoicelineprice[j].validfrom == null || invoicelineprice[j].validfrom.equals("") - || !DateTimeData - .compare(this, DateTimeData.today(this), invoicelineprice[j].validfrom) - .equals("-1")) { + if (invoicelineprice[j].validfrom == null + || StringUtils.isEmpty(invoicelineprice[j].validfrom) + || !StringUtils.equals(DateTimeData.compare(this, DateTimeData.today(this), + invoicelineprice[j].validfrom), "-1")) { priceList = new BigDecimal(invoicelineprice[j].pricelist); priceLimit = new BigDecimal(invoicelineprice[j].pricelimit); - priceStd = (invoicelineprice[j].pricestd.equals("") ? BigDecimal.ZERO + priceStd = (StringUtils.isEmpty(invoicelineprice[j].pricestd) ? BigDecimal.ZERO : (new BigDecimal(invoicelineprice[j].pricestd))).setScale(pricePrecision, RoundingMode.HALF_UP); priceListGross = BigDecimal.ZERO; @@ -227,7 +229,7 @@ } // Checking, why is not possible to get a tax - if ("".equals(strCTaxID) && lineNetAmt.compareTo(BigDecimal.ZERO) != 0) { + if (StringUtils.isEmpty(strCTaxID) && lineNetAmt.compareTo(BigDecimal.ZERO) != 0) { throwTaxNotFoundException(data[i].accountId, data[i].productId, dataInvoice[0].cBpartnerLocationId); } @@ -288,7 +290,7 @@ ActionButtonDefaultData[] data = null; String strHelp = "", strDescription = ""; - if (vars.getLanguage().equals("en_US")) { + if (StringUtils.equals(vars.getLanguage(), "en_US")) { data = ActionButtonDefaultData.select(this, strProcessId); } else { data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId); @@ -299,7 +301,7 @@ strHelp = data[0].help; } String[] discard = { "" }; - if (strHelp.equals("")) { + if (StringUtils.isEmpty(strHelp)) { discard[0] = new String("helpDiscard"); } XmlDocument xmlDocument = xmlEngine @@ -323,7 +325,7 @@ private void throwTaxNotFoundException(String accountId, String productId, String cBpartnerLocationId) throws OBException { - if (!"".equals(accountId)) { + if (StringUtils.isNotEmpty(accountId)) { GLItem glItem = OBDal.getInstance().get(GLItem.class, accountId); OBCriteria<TaxRate> obcriteria = OBDal.getInstance().createCriteria(TaxRate.class); @@ -340,7 +342,7 @@ glItem.getIdentifier(), glItem.getTaxCategory().getIdentifier(), location.getIdentifier())); } - } else if (!"".equals(productId)) { + } else if (StringUtils.isNotEmpty(productId)) { Product product = OBDal.getInstance().get(Product.class, productId); OBCriteria<TaxRate> obcriteria = OBDal.getInstance().createCriteria(TaxRate.class); _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits