svn commit: r628551 - /ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r628551 - /ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java

jleroux@apache.org
Author: jleroux
Date: Sun Feb 17 13:23:18 2008
New Revision: 628551

URL: http://svn.apache.org/viewvc?rev=628551&view=rev
Log:
Fix "Sales percent discount doesn't show up in Journal" (https://issues.apache.org/jira/browse/OFBIZ-1608) - OFBIZ-1608

Modified:
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?rev=628551&r1=628550&r2=628551&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Sun Feb 17 13:23:18 2008
@@ -915,13 +915,20 @@
                 Iterator iter = adjustments.iterator();
                 while(iter.hasNext()){
                     GenericValue orderAdjustment = (GenericValue) iter.next();
+                    Double amount = orderAdjustment.getDouble("amount");
+                    Double sourcePercentage = orderAdjustment.getDouble("sourcePercentage");
+                    if (UtilValidate.isNotEmpty(sourcePercentage)) {
+                        double percentage = sourcePercentage.doubleValue()/100.0; // sourcePercentage is negative
+                        amount = total / ((1 + percentage) / percentage);                        
+                    }                    
                     XModel adjustmentLine = Journal.appendNode(model, "tr", "adjustment", "");
                     Journal.appendNode(adjustmentLine, "td", "sku", "");
                     Journal.appendNode(adjustmentLine, "td", "desc",
                             UtilProperties.getMessage("pos", "(SalesDiscount)",defaultLocale));
                     Journal.appendNode(adjustmentLine, "td", "qty", "");
-                    Journal.appendNode(adjustmentLine, "td", "price",
-                            UtilFormatOut.formatPrice(orderAdjustment.getDouble("amount")));
+                    if (UtilValidate.isNotEmpty(amount)) {
+                        Journal.appendNode(adjustmentLine, "td", "price", UtilFormatOut.formatPrice(amount));
+                    }
                     Journal.appendNode(adjustmentLine, "td", "index", "-1");
                 }    
             }