fixed bug 28530: can't enter 2nd matched amount in Match LC Costs
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 13 Jan 2015 09:58:54 +0100
changeset 25681 bb4b71f58c54
parent 25680 54ad451b0485
child 25682 d655a11691ef
fixed bug 28530: can't enter 2nd matched amount in Match LC Costs

When trying to edit the 2nd line in Match LC Costs, UI didn't allow to enter
then matched amount field. After this failure it was needed to reload the
whole page in order make it work again.

The problem was in this situation validation for amount fields is triggered for
all selected records including the new one where the amount is '', it was tried
to be converted to BigDecimal resulting on a JavaScript exception thrown.

Fix check if the amount has a value (or 0) to only sum it in this case.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js	Wed Jan 14 09:39:32 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/costing/ob-lc-matchfrominvoice.js	Tue Jan 13 09:58:54 2015 +0100
@@ -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 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -34,7 +34,9 @@
   // Check that matched amount is not higher than invoice line net amount
   for (i = 0; i < selectedRecordsLength; i++) {
     editedRecord = isc.addProperties({}, selectedRecords[i], item.grid.getEditedRecord(selectedRecords[i]));
-    matchedamt = matchedamt.add(new BigDecimal(String(editedRecord.matchedAmt)));
+    if (editedRecord.matchedAmt) {
+      matchedamt = matchedamt.add(new BigDecimal(String(editedRecord.matchedAmt)));
+    }
   }
   if (matchedamt.compareTo(invoiceamt) > 0) {
     item.grid.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('OBUIAPP_Costing_MachedMoreThanInvoice', [invoiceamt.toString()]));