svn commit: r835730 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

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

svn commit: r835730 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

lektran
Author: lektran
Date: Fri Nov 13 04:07:26 2009
New Revision: 835730

URL: http://svn.apache.org/viewvc?rev=835730&view=rev
Log:
If we only have an OrderItem to work with when creating an InvoiceItem then take the cancelled and already invoiced quantities into account, the start of a fix for OFBIZ-3084

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=835730&r1=835729&r2=835730&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Fri Nov 13 04:07:26 2009
@@ -374,7 +374,6 @@
                 }
 
                 // get some quantities
-                BigDecimal orderedQuantity = orderItem.getBigDecimal("quantity");
                 BigDecimal billingQuantity = null;
                 if (itemIssuance != null) {
                     billingQuantity = itemIssuance.getBigDecimal("quantity");
@@ -386,9 +385,13 @@
                 } else if (shipmentReceipt != null) {
                     billingQuantity = shipmentReceipt.getBigDecimal("quantityAccepted");
                 } else {
-                    billingQuantity = orderedQuantity;
+                    BigDecimal orderedQuantity = OrderReadHelper.getOrderItemQuantity(orderItem);
+                    BigDecimal invoicedQuantity = OrderReadHelper.getOrderItemInvoicedQuantity(orderItem);
+                    billingQuantity = orderedQuantity.subtract(invoicedQuantity);
+                    if (billingQuantity.compareTo(ZERO) < 0) {
+                        billingQuantity = ZERO;
+                    }
                 }
-                if (orderedQuantity == null) orderedQuantity = ZERO;
                 if (billingQuantity == null) billingQuantity = ZERO;
 
                 // check if shipping applies to this item.  Shipping is calculated for sales invoices, not purchase invoices.