Fixed bug 28905 Create Lines From is not working under some circumstancies
authorSandra Huguet <sandra.huguet@openbravo.com>
Tue, 10 Feb 2015 12:45:35 +0100
changeset 25892 79bb6781bc77
parent 25891 05b7936848de
child 25893 04daf492cab4
child 25895 24bb109056f1
Fixed bug 28905 Create Lines From is not working under some circumstancies
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java	Tue Feb 10 10:52:58 2015 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java	Tue Feb 10 12:45:35 2015 +0100
@@ -1583,11 +1583,15 @@
               grossAmt = grossAmt.setScale(curPrecision, BigDecimal.ROUND_HALF_UP);
             }
             if (!strPO.equals("")) {
-              String invoiceprepaymentamt = CreateFromInvoiceData.selectInvoicePrepaymentAmt(this,
-                  strKey);
-              String prepaymentamt = CreateFromInvoiceData.selectPrepaymentAmt(this, strPO);
-              BigDecimal totalprepayment = new BigDecimal(invoiceprepaymentamt).add(new BigDecimal(
-                  prepaymentamt));
+              String strInvoiceprepaymentamt = CreateFromInvoiceData.selectInvoicePrepaymentAmt(
+                  this, strKey);
+              BigDecimal invoiceprepaymentamt = (strInvoiceprepaymentamt.equals("") ? new BigDecimal(
+                  0) : new BigDecimal(strInvoiceprepaymentamt));
+              String strprepaymentamt = CreateFromInvoiceData.selectPrepaymentAmt(this, strPO);
+              BigDecimal prepaymentamt = (strprepaymentamt.equals("") ? new BigDecimal(0)
+                  : new BigDecimal(strprepaymentamt));
+
+              BigDecimal totalprepayment = invoiceprepaymentamt.add(prepaymentamt);
               CreateFromInvoiceData.updatePrepaymentAmt(conn, this, totalprepayment.toString(),
                   strKey);
             }