Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0054399Openbravo ERP07. Sales managementpublic2024-01-19 14:222024-01-19 15:07
sdossantos 
Triage Omni OMS 
normalminoralways
newopen 
5
pi 
 
Core
No
0054399: Issue sales order line POS does not generate delivery note lines
An order that has a product of type BOM, which when registering the order generates two more lines.
When the issue sales order line is made from the POS, the attached error does not appear
It is not possible to exploit the lines on the delivery note and when processing the shipment the error occurs.
1 - Do a order with product BOM
2- Try to do issue sales order
Nothing
For a new message in this situation:

--- a/modules/org.openbravo.retail.posterminal/src/org/openbravo/retail/posterminal/process/IssueSalesOrderLines.java 2024-01-19 12:32:53.271300000 +0100
+++ b/modules/org.openbravo.retail.posterminal/src/org/openbravo/retail/posterminal/process/IssueSalesOrderLines.java 2024-01-19 13:20:23.250272000 +0100
@@ -42,6 +42,7 @@
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.common.plm.Product;
 import org.openbravo.model.materialmgmt.transaction.ShipmentInOut;
+import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine;
 import org.openbravo.retail.posterminal.InvoiceShipmentHook;
 import org.openbravo.retail.posterminal.JSONProcessSimple;
 import org.openbravo.service.json.JsonConstants;
@@ -77,6 +78,8 @@
             .getInstanceFromStaticBeanManager(GoodsShipmentGenerator.class);
         ShipmentInOut shipment = createNewShipment(orderFromJson);
 
+ addExplodeLines(orderFromJson.getString("order"), linesFromJson);
+
         addLinesForIndependentService(orderFromJson.getString("order"), linesFromJson);
 
         Set<String> orders = new HashSet<>();
@@ -90,6 +93,7 @@
         OBDal.getInstance().flush(); // Persists the shipment document in order to be ready for
                                      // further processing
         ServiceDeliverUtility.deliverServices(shipment);
+ checkExplodeLines(shipment);
         shipmentGenerator.processShipment();
         final Invoice invoice = shipmentGenerator.invoiceShipmentIfPossible(orderFromJson);
 
@@ -130,6 +134,46 @@
     return jsonResponse;
   }
 
+ private void checkExplodeLines(ShipmentInOut shipment) {
+ for (ShipmentInOutLine shipmentLine : shipment.getMaterialMgmtShipmentInOutLineList()) {
+ shipmentLine = OBDal.getInstance().get(ShipmentInOutLine.class, shipmentLine.getId());
+ shipmentLine.setExplode(shipmentLine.getSalesOrderLine().isExplode());
+ }
+
+ }
+
+ private void addExplodeLines(String orderId, JSONArray linesFromJson) throws JSONException {
+ for (int j = 0; j < linesFromJson.length(); j++) {
+ JSONObject jsonLine = linesFromJson.getJSONObject(j);
+ BigDecimal qtyToDeliver = new BigDecimal(jsonLine.getString("toPrepare"));
+
+ OBQuery<OrderLine> productQuery = OBDal.getInstance()
+ .createQuery(OrderLine.class, " e where e.bOMParent.id=:orderLineId");
+ productQuery.setNamedParameter("orderLineId", jsonLine.getString("lineId"));
+ List<OrderLine> productList = productQuery.list();
+ if (productList.size() > 0) {
+ for (OrderLine orderLine : productList) {
+ boolean hasPendingDelivery = true;
+ if (!orderLine.getOrderedQuantity()
+ .equals(orderLine.getDeliveredQuantity().add(qtyToDeliver))) {
+ hasPendingDelivery = false;
+ }
+
+ if (hasPendingDelivery) {
+ JSONObject json = new JSONObject();
+ json.put("lineId", orderLine.getId());
+ json.put("orderId", orderLine.getSalesOrder().getId());
+ json.put("productId", orderLine.getProduct().getId());
+ json.put("qtyOrdered", orderLine.getOrderedQuantity());
+ json.put("qtyDelivered", orderLine.getDeliveredQuantity());
+ json.put("toPrepare", qtyToDeliver);
+ linesFromJson.put(json);
+ }
+ }
+ }
+ }
+ }
+
   private ShipmentInOut createNewShipment(final JSONObject orderFromJson) throws JSONException {
     Organization organization = OBDal.getInstance()
         .getProxy(Organization.class, orderFromJson.getString("organizationId"));
No tags attached.
diff IssueSalesOrderLines_1.diff (3,610) 2024-01-19 14:22
https://issues.openbravo.com/file_download.php?file_id=19351&type=bug
Issue History
2024-01-19 14:22sdossantosNew Issue
2024-01-19 14:22sdossantosAssigned To => Triage Omni OMS
2024-01-19 14:22sdossantosFile Added: IssueSalesOrderLines_1.diff
2024-01-19 14:22sdossantosModules => Core
2024-01-19 14:22sdossantosTriggers an Emergency Pack => No
2024-01-19 14:52PracticsIssue Monitored: Practics
2024-01-19 15:07ivazquezTypefeature request => defect

There are no notes attached to this issue.