Fixes issue 32428: Wrong orders created by the Copy Record process
authorMark <m.molina@nectus.com>
Wed, 09 Mar 2016 18:53:24 -0500
changeset 28707 b5115ab17d95
parent 28706 f4eb6b0d41e0
child 28708 201577aba6ba
Fixes issue 32428: Wrong orders created by the Copy Record process

Fixed the wrong Tax Amount and Total Gross Amount calculation in orders created by the Copy Record process
if price list includes taxes. These amounts are calculated when related triggers are fired, due that when
the order is cloned from the original order was necessary to reset calculated amounts and then triggers updates
them again when lines are added to the cloned order.
modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java	Tue Mar 08 10:56:37 2016 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java	Wed Mar 09 18:53:24 2016 -0500
@@ -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) 2011-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2011-2016 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  Mallikarjun M
  ************************************************************************
@@ -60,7 +60,6 @@
       User currentUser = OBContext.getOBContext().getUser();
       Order objOrder = OBDal.getInstance().get(Order.class, orderId);
       Order objCloneOrder = (Order) DalUtil.copy(objOrder, false);
-      BigDecimal bLineNetAmt = getLineNetAmt(orderId);
 
       objCloneOrder.setDocumentAction("CO");
       objCloneOrder.setDocumentStatus("DR");
@@ -87,13 +86,12 @@
       cal.set(Calendar.MILLISECOND, 0);
       objCloneOrder.setOrderDate(cal.getTime());
       objCloneOrder.setScheduledDeliveryDate(cal.getTime());
+      objCloneOrder.setGrandTotalAmount(new BigDecimal(0));
+      objCloneOrder.setSummedLineAmount(new BigDecimal(0));
 
       // save the cloned order object
       OBDal.getInstance().save(objCloneOrder);
 
-      objCloneOrder.setSummedLineAmount(objCloneOrder.getSummedLineAmount().subtract(bLineNetAmt));
-      objCloneOrder.setGrandTotalAmount(objCloneOrder.getGrandTotalAmount().subtract(bLineNetAmt));
-
       // get the lines associated with the order and clone them to the new
       // order line.
       for (OrderLine ordLine : objOrder.getOrderLineList()) {