# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1453204650 -19800
# Node ID 4b0051b9f5cbc4801d2bc89c1c02f0cecabf0b8f
# Parent  22d168dadc71475402440f344fb6ecba8f4f4677
Related to issue 31820 : Deleting duplicated invoice line after cashup

diff --git a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
@@ -138,11 +138,15 @@
 
       OrderLine[] orderLinesSplittedByShipmentLine = splitOrderLineByShipmentLine(orderLine);
       if (orderLinesSplittedByShipmentLine.length > 1) {
-        InvoiceLine oldInvoiceLine = orderLine.getInvoiceLineList().get(0);
-        Invoice invoice = oldInvoiceLine.getInvoice();
-        Long lineno = oldInvoiceLine.getLineNo();
-        OBDal.getInstance().remove(oldInvoiceLine);
 
+        Invoice invoice = null;
+        for (int i = 0; i < orderLine.getInvoiceLineList().size(); i++) {
+          InvoiceLine oldInvoiceLine = orderLine.getInvoiceLineList().get(i);
+          invoice = oldInvoiceLine.getInvoice();
+          OBDal.getInstance().remove(oldInvoiceLine);
+        }
+
+        Long lineno = (long) 10;
         for (int i = 0; i < orderLinesSplittedByShipmentLine.length; i++) {
           OrderLine olSplitted = orderLinesSplittedByShipmentLine[i];
 
