details:   https://code.openbravo.com/erp/devel/pi/rev/d31e48e598fb
changeset: 20483:d31e48e598fb
user:      Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at> 
openbravo.com>
date:      Tue May 28 16:08:36 2013 +0530
summary:   Fixes issue 23560: Insert Orphan Line when using Price List 
including taxes

diffstat:

 src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java |  14 
+++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diffs (50 lines):

diff -r 14c8d925fdc6 -r d31e48e598fb 
src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java       
Tue May 28 13:07:15 2013 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java       
Tue May 28 16:08:36 2013 +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) 2012 Openbravo SLU 
+ * All portions are Copyright (C) 2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,8 @@
 import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.financial.FinancialUtils;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.order.Order;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.common.order.ReturnReason;
@@ -87,9 +89,14 @@
         newOrderLine.setPriceLimit(productPrice.getPriceLimit());
         newOrderLine.setStandardPrice(productPrice.getStandardPrice());
         if (order.getPriceList().isPriceIncludesTax()) {
+          Currency currency = OBDal.getInstance().get(Currency.class, 
order.getCurrency().getId());
           newOrderLine.setGrossUnitPrice(productPrice.getStandardPrice());
           
newOrderLine.setLineGrossAmount(productPrice.getStandardPrice().multiply(returnedQty)
               .negate());
+          BigDecimal newUnitPrice = 
FinancialUtils.calculateNetFromGross(strTaxId,
+              productPrice.getStandardPrice(), 
currency.getPricePrecision().intValue(),
+              newOrderLine.getTaxableAmount(), returnedQty);
+          newOrderLine.setUnitPrice(newUnitPrice);
         }
       } else {
         BigDecimal unitPrice = new BigDecimal(strUnitPrice);
@@ -98,8 +105,13 @@
         newOrderLine.setPriceLimit(unitPrice);
         newOrderLine.setStandardPrice(unitPrice);
         if (order.getPriceList().isPriceIncludesTax()) {
+          Currency currency = OBDal.getInstance().get(Currency.class, 
order.getCurrency().getId());
           newOrderLine.setGrossUnitPrice(unitPrice);
           
newOrderLine.setLineGrossAmount(unitPrice.multiply(returnedQty).negate());
+          BigDecimal newUnitPrice = FinancialUtils
+              .calculateNetFromGross(strTaxId, unitPrice, 
currency.getPricePrecision().intValue(),
+                  newOrderLine.getTaxableAmount(), 
returnedQty).multiply(returnedQty);
+          newOrderLine.setUnitPrice(newUnitPrice);
         }
       }
       // tax

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to