fixes issue 12366
authorDavid Alsasua <david.alsasua@openbravo.com>
Tue, 23 Feb 2010 15:21:06 +0100
changeset 6474 4e03817a571b
parent 6473 f9187aa87fe8
child 6475 35dc05a84c8b
fixes issue 12366
src-db/database/model/triggers/C_INVOICELINE_TRG4.xml
src-db/database/model/triggers/C_ORDERLINE_TRG3.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java
src/org/openbravo/erpCommon/ad_callouts/SL_Order_Amt.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/C_INVOICELINE_TRG4.xml	Tue Feb 23 15:21:06 2010 +0100
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER C_INVOICELINE_TRG4">
+    <trigger name="C_INVOICELINE_TRG4" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="true" foreach="row">
+      <body><![CDATA[
+  /*************************************************************************
+  * The contents of this file are subject to the Openbravo  Public  License
+  * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+  * Version 1.1  with a permitted attribution clause; you may not  use this
+  * file except in compliance with the License. You  may  obtain  a copy of
+  * the License at http://www.openbravo.com/legal/license.html
+  * Software distributed under the License  is  distributed  on  an "AS IS"
+  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+  * License for the specific  language  governing  rights  and  limitations
+  * under the License.
+  * The Original Code is Openbravo ERP.
+  * The Initial Developer of the Original Code is Openbravo SL
+  * All portions are Copyright (C) 2010 Openbravo SL
+  * All Rights Reserved.
+  * Contributor(s):  ______________________________________.
+  ************************************************************************/
+  V_RATE NUMBER;
+  V_PRECISION NUMBER;
+BEGIN
+
+  IF AD_isTriggerEnabled()='N' THEN RETURN;
+  END IF;
+
+  SELECT T.RATE INTO V_RATE FROM C_TAX T 
+  WHERE T.C_TAX_ID=:NEW.C_TAX_ID;
+
+  SELECT C.STDPRECISION INTO V_PRECISION FROM C_INVOICE I, C_CURRENCY C 
+  WHERE I.C_CURRENCY_ID=C.C_CURRENCY_ID 
+  AND I.C_INVOICE_ID=:NEW.C_INVOICE_ID;
+
+  IF(INSERTING OR UPDATING) THEN
+    IF (ROUND(TO_NUMBER(:NEW.QTYINVOICED) * TO_NUMBER(:NEW.PRICEACTUAL),V_PRECISION)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
+      RAISE_APPLICATION_ERROR(-20501,'Line Amount Is Not Correct');
+    END IF;
+  END IF;
+  END C_INVOICELINE_TRG4]]></body>
+    </trigger>
+  </database>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/C_ORDERLINE_TRG3.xml	Tue Feb 23 15:21:06 2010 +0100
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER C_ORDERLINE_TRG3">
+    <trigger name="C_ORDERLINE_TRG3" table="C_ORDERLINE" fires="before" insert="true" update="true" delete="true" foreach="row">
+      <body><![CDATA[
+
+/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SL
+* All portions are Copyright (C) 2010 Openbravo SL
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+  V_RATE NUMBER;
+  V_PRECISION NUMBER;
+BEGIN
+  IF AD_isTriggerEnabled()='N' THEN RETURN;
+  END IF;
+
+  SELECT T.RATE INTO V_RATE FROM C_TAX T 
+  WHERE T.C_TAX_ID=:NEW.C_TAX_ID;
+
+  SELECT C.STDPRECISION INTO V_PRECISION FROM C_CURRENCY C
+  WHERE C.C_CURRENCY_ID=:NEW.C_CURRENCY_ID;
+
+  IF(INSERTING OR UPDATING) THEN
+    IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),V_PRECISION) != to_number(:NEW.LINENETAMT)) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
+    END IF;
+  END IF;
+  END C_ORDERLINE_TRG3
+  ]]></body>
+    </trigger>
+  </database>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Tue Feb 23 12:13:46 2010 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Feb 23 15:21:06 2010 +0100
@@ -57926,6 +57926,7 @@
 <!--3723-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--3723-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--3723-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--3723-->  <AD_CALLOUT_ID><![CDATA[138]]></AD_CALLOUT_ID>
 <!--3723-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--3723-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--3723-->  <POSITION><![CDATA[31]]></POSITION>
@@ -60189,6 +60190,7 @@
 <!--3844-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--3844-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--3844-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--3844-->  <AD_CALLOUT_ID><![CDATA[127]]></AD_CALLOUT_ID>
 <!--3844-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--3844-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--3844-->  <POSITION><![CDATA[19]]></POSITION>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Tue Feb 23 12:13:46 2010 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Tue Feb 23 15:21:06 2010 +0100
@@ -32206,7 +32206,7 @@
 <!--2880-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2880-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--2880-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--2880-->  <SEQNO><![CDATA[310]]></SEQNO>
+<!--2880-->  <SEQNO><![CDATA[320]]></SEQNO>
 <!--2880-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--2880-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--2880-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -33841,7 +33841,7 @@
 <!--2995-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2995-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--2995-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--2995-->  <SEQNO><![CDATA[200]]></SEQNO>
+<!--2995-->  <SEQNO><![CDATA[210]]></SEQNO>
 <!--2995-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--2995-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--2995-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -39223,7 +39223,7 @@
 <!--3370-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3370-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--3370-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--3370-->  <SEQNO><![CDATA[190]]></SEQNO>
+<!--3370-->  <SEQNO><![CDATA[200]]></SEQNO>
 <!--3370-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--3370-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--3370-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -40232,7 +40232,7 @@
 <!--3416-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--3416-->  <DISPLAYLENGTH><![CDATA[10]]></DISPLAYLENGTH>
 <!--3416-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--3416-->  <SEQNO><![CDATA[300]]></SEQNO>
+<!--3416-->  <SEQNO><![CDATA[310]]></SEQNO>
 <!--3416-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--3416-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--3416-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -191473,9 +191473,10 @@
 <!--61B11EA6D16C4948910D06E49A728085-->  <AD_TAB_ID><![CDATA[293]]></AD_TAB_ID>
 <!--61B11EA6D16C4948910D06E49A728085-->  <AD_COLUMN_ID><![CDATA[7E011D1981B2E366E040007F01013030]]></AD_COLUMN_ID>
 <!--61B11EA6D16C4948910D06E49A728085-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--61B11EA6D16C4948910D06E49A728085-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--61B11EA6D16C4948910D06E49A728085-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--61B11EA6D16C4948910D06E49A728085-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--61B11EA6D16C4948910D06E49A728085-->  <SEQNO><![CDATA[300]]></SEQNO>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--61B11EA6D16C4948910D06E49A728085-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -191884,9 +191885,10 @@
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <AD_TAB_ID><![CDATA[291]]></AD_TAB_ID>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <AD_COLUMN_ID><![CDATA[7E011D1981B1E366E040007F01013030]]></AD_COLUMN_ID>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <SEQNO><![CDATA[190]]></SEQNO>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--6C50F0BA9E0C43F0813C0D2F9E0D70A8-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193176,7 +193178,7 @@
 <!--7E35F16BB0F8C186E040007F010014C7-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E35F16BB0F8C186E040007F010014C7-->  <SEQNO><![CDATA[210]]></SEQNO>
+<!--7E35F16BB0F8C186E040007F010014C7-->  <SEQNO><![CDATA[220]]></SEQNO>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E35F16BB0F8C186E040007F010014C7-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193200,7 +193202,7 @@
 <!--7E35F16BB0F9C186E040007F010014C7-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E35F16BB0F9C186E040007F010014C7-->  <SEQNO><![CDATA[200]]></SEQNO>
+<!--7E35F16BB0F9C186E040007F010014C7-->  <SEQNO><![CDATA[210]]></SEQNO>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E35F16BB0F9C186E040007F010014C7-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193312,7 +193314,7 @@
 <!--7E37B8136CC375EFE040007F0100360F-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E37B8136CC375EFE040007F0100360F-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E37B8136CC375EFE040007F0100360F-->  <SEQNO><![CDATA[320]]></SEQNO>
+<!--7E37B8136CC375EFE040007F0100360F-->  <SEQNO><![CDATA[330]]></SEQNO>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E37B8136CC375EFE040007F0100360F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -193355,7 +193357,7 @@
 <!--7E37B8136CC575EFE040007F0100360F-->  <DISPLAYLOGIC><![CDATA[@UsesAlternate@='Y']]></DISPLAYLOGIC>
 <!--7E37B8136CC575EFE040007F0100360F-->  <DISPLAYLENGTH><![CDATA[12]]></DISPLAYLENGTH>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7E37B8136CC575EFE040007F0100360F-->  <SEQNO><![CDATA[310]]></SEQNO>
+<!--7E37B8136CC575EFE040007F0100360F-->  <SEQNO><![CDATA[320]]></SEQNO>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7E37B8136CC575EFE040007F0100360F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -194436,9 +194438,10 @@
 <!--8329181A30D547FBB01E0CD7013069E6-->  <AD_TAB_ID><![CDATA[187]]></AD_TAB_ID>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <AD_COLUMN_ID><![CDATA[7E011D1981B2E366E040007F01013030]]></AD_COLUMN_ID>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--8329181A30D547FBB01E0CD7013069E6-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--8329181A30D547FBB01E0CD7013069E6-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--8329181A30D547FBB01E0CD7013069E6-->  <SEQNO><![CDATA[310]]></SEQNO>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--8329181A30D547FBB01E0CD7013069E6-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -194504,9 +194507,10 @@
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <AD_TAB_ID><![CDATA[270]]></AD_TAB_ID>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <AD_COLUMN_ID><![CDATA[7E011D1981B1E366E040007F01013030]]></AD_COLUMN_ID>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <AD_FIELDGROUP_ID><![CDATA[103]]></AD_FIELDGROUP_ID>
-<!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--86E59478FE6B4DC68BA401230C3DFC17-->  <SEQNO><![CDATA[200]]></SEQNO>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--86E59478FE6B4DC68BA401230C3DFC17-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Feb 23 12:13:46 2010 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Feb 23 15:21:06 2010 +0100
@@ -32203,6 +32203,17 @@
 <!--D62BB9614B02490C848F8731B62BE1FB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--D62BB9614B02490C848F8731B62BE1FB--></AD_MESSAGE>
 
+<!--D64915331A7E41CA81CB3F22164EFAC4--><AD_MESSAGE>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <AD_MESSAGE_ID><![CDATA[D64915331A7E41CA81CB3F22164EFAC4]]></AD_MESSAGE_ID>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <VALUE><![CDATA[LineAmountNotCorrect]]></VALUE>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <MSGTEXT><![CDATA[Line Amount Is Not Correct]]></MSGTEXT>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--D64915331A7E41CA81CB3F22164EFAC4-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D64915331A7E41CA81CB3F22164EFAC4--></AD_MESSAGE>
+
 <!--D64F38CA9A024B87B7D159F0EB4962D2--><AD_MESSAGE>
 <!--D64F38CA9A024B87B7D159F0EB4962D2-->  <AD_MESSAGE_ID><![CDATA[D64F38CA9A024B87B7D159F0EB4962D2]]></AD_MESSAGE_ID>
 <!--D64F38CA9A024B87B7D159F0EB4962D2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java	Tue Feb 23 12:13:46 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Amt.java	Tue Feb 23 15:21:06 2010 +0100
@@ -58,10 +58,11 @@
       String strTabId = vars.getStringParameter("inpTabId");
       String strPriceList = vars.getNumericParameter("inppricelist");
       String strPriceStd = vars.getNumericParameter("inppricestd");
+      String strLineNetAmt = vars.getStringParameter("inplinenetamt");
 
       try {
         printPage(response, vars, strChanged, strQtyInvoice, strPriceActual, strInvoiceId,
-            strProduct, strPriceLimit, strTabId, strPriceList, strPriceStd);
+            strProduct, strPriceLimit, strTabId, strPriceList, strPriceStd, strLineNetAmt);
       } catch (ServletException ex) {
         pageErrorCallOut(response);
       }
@@ -71,8 +72,8 @@
 
   void printPage(HttpServletResponse response, VariablesSecureApp vars, String strChanged,
       String strQtyInvoice, String strPriceActual, String strInvoiceId, String strProduct,
-      String strPriceLimit, String strTabId, String strPriceList, String strPriceStd)
-      throws IOException, ServletException {
+      String strPriceLimit, String strTabId, String strPriceList, String strPriceStd,
+      String strLineNetAmt) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
@@ -92,6 +93,8 @@
       log4j.debug("strPriceActual: " + strPriceActual);
     if (log4j.isDebugEnabled())
       log4j.debug("strPriceLimit: " + strPriceLimit);
+    if (log4j.isDebugEnabled())
+      log4j.debug("strLineNetAmt: " + strLineNetAmt);
 
     BigDecimal qtyInvoice, priceActual, LineNetAmt, priceLimit, priceStd;
 
@@ -101,6 +104,7 @@
         .setScale(PricePrecision, BigDecimal.ROUND_HALF_UP);
     priceLimit = (!Utility.isBigDecimal(strPriceLimit) ? ZERO : (new BigDecimal(strPriceLimit)))
         .setScale(PricePrecision, BigDecimal.ROUND_HALF_UP);
+    LineNetAmt = (!Utility.isBigDecimal(strLineNetAmt) ? ZERO : new BigDecimal(strLineNetAmt));
 
     StringBuffer resultado = new StringBuffer();
 
@@ -109,9 +113,14 @@
 
     SLOrderProductData[] dataInvoice = SLOrderProductData.selectInvoice(this, strInvoiceId);
 
+    if (strChanged.equals("inplinenetamt")) {
+      priceActual = LineNetAmt.divide(qtyInvoice, StdPrecision, BigDecimal.ROUND_HALF_UP);
+    }
+    if (priceActual.compareTo(BigDecimal.ZERO) == 0)
+      LineNetAmt = BigDecimal.ZERO;
     // If unit price (actual price) changes, recalculates standard price
     // (std price) applying price adjustments (offers) if any
-    if (strChanged.equals("inppriceactual")) {
+    if (strChanged.equals("inppriceactual") || strChanged.equals("inplinenetamt")) {
       if (log4j.isDebugEnabled())
         log4j.debug("priceActual:" + Double.toString(priceActual.doubleValue()));
       priceStd = new BigDecimal(SLOrderProductData.getOffersStdPriceInvoice(this,
@@ -134,8 +143,9 @@
         priceActual = priceActual.setScale(PricePrecision, BigDecimal.ROUND_HALF_UP);
     }
 
-    // Net amount of a line equals quantity x unit price (actual price)
-    LineNetAmt = qtyInvoice.multiply(priceActual);
+    if (!strChanged.equals("inplinenetamt"))
+      // Net amount of a line equals quantity x unit price (actual price)
+      LineNetAmt = qtyInvoice.multiply(priceActual);
 
     if (LineNetAmt.scale() > StdPrecision)
       LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
@@ -147,7 +157,8 @@
             + FormatUtilities.replaceJS(Utility.messageBD(this, "UnderLimitPrice", vars
                 .getLanguage())) + "\"), ");
     }
-    resultado.append("new Array(\"inplinenetamt\", " + LineNetAmt.toString() + "),");
+    if (!strChanged.equals("inplinenetamt") || LineNetAmt.compareTo(BigDecimal.ZERO) == 0)
+      resultado.append("new Array(\"inplinenetamt\", " + LineNetAmt.toString() + "),");
     resultado.append("new Array(\"inptaxbaseamt\", " + LineNetAmt.toString() + "),");
     resultado.append("new Array(\"inppriceactual\", " + priceActual.toString() + ")");
     resultado.append(");");
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_Order_Amt.java	Tue Feb 23 12:13:46 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Order_Amt.java	Tue Feb 23 15:21:06 2010 +0100
@@ -63,11 +63,12 @@
       String strTabId = vars.getStringParameter("inpTabId");
       String strQty = vars.getNumericParameter("inpqtyordered");
       String cancelPriceAd = vars.getStringParameter("inpcancelpricead");
+      String strLineNetAmt = vars.getStringParameter("inplinenetamt");
 
       try {
         printPage(response, vars, strChanged, strQtyOrdered, strPriceActual, strDiscount,
             strPriceLimit, strPriceList, strCOrderId, strProduct, strUOM, strAttribute, strTabId,
-            strQty, strPriceStd, cancelPriceAd);
+            strQty, strPriceStd, cancelPriceAd, strLineNetAmt);
       } catch (ServletException ex) {
         pageErrorCallOut(response);
       }
@@ -78,8 +79,8 @@
   private void printPage(HttpServletResponse response, VariablesSecureApp vars, String strChanged,
       String strQtyOrdered, String strPriceActual, String strDiscount, String strPriceLimit,
       String strPriceList, String strCOrderId, String strProduct, String strUOM,
-      String strAttribute, String strTabId, String strQty, String strPriceStd, String cancelPriceAd)
-      throws IOException, ServletException {
+      String strAttribute, String strTabId, String strQty, String strPriceStd,
+      String cancelPriceAd, String strLineNetAmt) throws IOException, ServletException {
     if (log4j.isDebugEnabled()) {
       log4j.debug("Output: dataSheet");
       log4j.debug("CHANGED:" + strChanged);
@@ -107,7 +108,7 @@
     int StdPrecision = Integer.valueOf(strPrecision).intValue();
     int PricePrecision = Integer.valueOf(strPricePrecision).intValue();
 
-    BigDecimal qtyOrdered, priceActual, discount, priceLimit, priceList, stockSecurity, stockNoAttribute, stockAttribute, resultStock, priceStd;
+    BigDecimal qtyOrdered, priceActual, discount, priceLimit, priceList, stockSecurity, stockNoAttribute, stockAttribute, resultStock, priceStd, LineNetAmt;
 
     stockSecurity = new BigDecimal(strStockSecurity);
     qtyOrdered = (strQtyOrdered.equals("") ? ZERO : new BigDecimal(strQtyOrdered));
@@ -120,6 +121,8 @@
         PricePrecision, BigDecimal.ROUND_HALF_UP);
     priceStd = (strPriceStd.equals("") ? ZERO : (new BigDecimal(strPriceStd))).setScale(
         PricePrecision, BigDecimal.ROUND_HALF_UP);
+    LineNetAmt = (strLineNetAmt.equals("") ? ZERO : (new BigDecimal(strLineNetAmt))).setScale(
+        PricePrecision, BigDecimal.ROUND_HALF_UP);
     /*
      * if (enforcedLimit) { String strPriceVersion = ""; PriceListVersionComboData[] data1 =
      * PriceListVersionComboData.selectActual(this, data[0].mPricelistId, DateTimeData.today(this));
@@ -132,9 +135,14 @@
     resultado.append("var calloutName='SL_Order_Amt';\n\n");
     resultado.append("var respuesta = new Array(");
 
+    if (strChanged.equals("inplinenetamt")) {
+      priceActual = LineNetAmt.divide(qtyOrdered, StdPrecision, BigDecimal.ROUND_HALF_UP);
+      if (priceActual.compareTo(BigDecimal.ZERO) == 0)
+        LineNetAmt = BigDecimal.ZERO;
+    }
     // Calculating prices for offers...
     SLOrderProductData[] dataOrder = SLOrderProductData.select(this, strCOrderId);
-    if (strChanged.equals("inppriceactual")) {
+    if (strChanged.equals("inppriceactual") || strChanged.equals("inplinenetamt")) {
       if (log4j.isDebugEnabled())
         log4j.debug("priceActual:" + Double.toString(priceActual.doubleValue()));
       if ("Y".equals(cancelPriceAd)) {
@@ -174,7 +182,8 @@
      */
 
     // calculating discount
-    if (strChanged.equals("inppricelist") || strChanged.equals("inppriceactual")) {
+    if (strChanged.equals("inppricelist") || strChanged.equals("inppriceactual")
+        || strChanged.equals("inplinenetamt")) {
       if (priceList.compareTo(BigDecimal.ZERO) == 0)
         discount = ZERO;
       else {
@@ -261,7 +270,8 @@
     }
     if (log4j.isDebugEnabled())
       log4j.debug(resultado.toString());
-    if (!strChanged.equals("inpqtyordered")) { // Check PriceLimit
+    if (!strChanged.equals("inpqtyordered") || strChanged.equals("inplinenetamt")) { // Check
+      // PriceLimit
       boolean enforced = SLOrderAmtData.listPriceType(this, strPriceList);
       // Check Price Limit?
       if (enforced && priceLimit.compareTo(BigDecimal.ZERO) != 0
@@ -271,17 +281,20 @@
     }
 
     // Multiply
-    BigDecimal lineNetAmt;
     if ("Y".equals(cancelPriceAd)) {
-      lineNetAmt = qtyOrdered.multiply(priceStd);
+      LineNetAmt = qtyOrdered.multiply(priceStd);
     } else {
-      lineNetAmt = qtyOrdered.multiply(priceActual);
+      if (!strChanged.equals("inplinenetamt")) {
+        LineNetAmt = qtyOrdered.multiply(priceActual);
+        if (LineNetAmt.scale() > StdPrecision)
+          LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
+      }
     }
-
-    if (lineNetAmt.scale() > StdPrecision)
-      lineNetAmt = lineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
-    resultado.append("new Array(\"inptaxbaseamt\", " + lineNetAmt.toString() + "),");
-    resultado.append("new Array(\"inplinenetamt\", " + lineNetAmt.toString() + ")");
+    if (strChanged.equals("inplinenetamt"))
+      resultado.append("new Array(\"inppriceactual\", " + priceActual.toString() + "),");
+    if (!strChanged.equals("inplinenetamt") || priceActual.compareTo(BigDecimal.ZERO) == 0)
+      resultado.append("new Array(\"inplinenetamt\", " + LineNetAmt.toString() + "),");
+    resultado.append("new Array(\"inptaxbaseamt\", " + LineNetAmt.toString() + ")");
 
     resultado.append(");");
     xmlDocument.setParameter("array", resultado.toString());