Learn about step to calculate remain order unit at back office screen.

Procedure


  1. From ONEWEB workspace, create java file name "com.manual.doc.order.java.OrderRequestItemBackOfficeUpdateMode" in MasterWeb and override method "modifyInsertMany(String moduleID, HashMap hStoreHashMap, String processMode, int row)" with coding below.


package com.manual.doc.order.java;


import java.util.HashMap;

import java.util.Vector;


import org.apache.log4j.Logger;


import com.master.form.MasterFormHandler;

import com.master.util.ProcessAction;

import com.master.util.ProcessHelper;


public class OrderRequestItemBackOfficeUpdateMode extends ProcessHelper implements ProcessAction {

       private static Logger logger = Logger.getLogger(OrderRequestItemBackOfficeUpdateMode.class);

       

       @Override

       public void modifyInsertMany(String moduleID, HashMap hStoreHashMap, String processMode, int row) {

               logger.debug("hStoreHashMap=" + hStoreHashMap);

               logger.debug("row=" + row);

               MasterFormHandler orderRequestformData = (MasterFormHandler)request.getSession().getAttribute("MD9443222701_session");

               HashMap orderRequestformHash = orderRequestformData.getStoreHashMap();

               logger.debug("orderRequestformHash="+orderRequestformHash);

               HashMap orderRequestHash = (HashMap)orderRequestformHash.get("WF_ORDER_REQ_ITEM");

               String orderUnit = (String)orderRequestHash.get("UNIT");

               logger.debug("orderUnit="+orderUnit);

               int orderUnitAmt = Integer.parseInt(orderUnit);

                               

               MasterFormHandler supplierformData = (MasterFormHandler)request.getSession().getAttribute(moduleID + "_session");

               Vector supplierformVect = supplierformData.getStoreActionList();

               if(supplierformVect != null && supplierformVect.size() > 0){

                       for(int i=0;i<supplierformVect.size();i++){

                               if(i != row){

                                       HashMap supplierformHash = (HashMap)supplierformVect.get(i);

                                       logger.debug("supplierformHash="+supplierformHash);

                                       HashMap updateSupplierHash = (HashMap)supplierformHash.get("UPDATE");

                                       HashMap supplierHash = (HashMap)updateSupplierHash.get("WF_ORDER_REQ_ITEM_SUPPLIER");

                                       String unitSelected = (String)supplierHash.get("UNIT_BY_BACK_OFFICE");

                                       logger.debug("unitSelected="+unitSelected);

                                       if(unitSelected != null && !"".equals(unitSelected)){

                                               orderUnitAmt -= Integer.parseInt(unitSelected);

                                       }

                               }

                       }

               }

               logger.debug("orderUnitAmt after calculate="+orderUnitAmt);

               

               HashMap supplierHash = (HashMap)hStoreHashMap.get("WF_ORDER_REQ_ITEM_SUPPLIER");

               supplierHash.put("REMAIN_ORDER_UNIT", String.valueOf(orderUnitAmt));

                               

               super.modifyInsertMany(moduleID, hStoreHashMap, processMode, row);

       }        

}


  1. Replace "MD9443222701_session" with module id of module "Order Item" in entity "Doc Order Request Item - Back Office" (concatenate module id with "_session")
    • Click edit at module "Order Item" and find module id at property name "Module ID"


  1. From ONEWEB workspace, export EafMasterEar.ear and deploy update to server. The class name "com.manual.doc.order.java.OrderRequestItemBackOfficeUpdateMode" will update to server.


  1. Go to App Designer and open entity name "Doc Order Request Item - Back Office" to edit.


  1. From Tools > Action drag Module Action to the box under module Supplier (Tab Supplier List). The action name "SEARCH" shows then click icon pencil to edit it. The dialog of Action Field Configuration opens.
    • Change Process Name to "UPDATE"
    • Put "com.manual.doc.order.java.OrderRequestItemBackOfficeUpdateMode" to Class Action.
    • Click OK.


  1. Click Save this Entity.


  1. Test by log in to FrontWeb.
    • Login with Back Office user.
    • Go to To Do List and claim job.
    • Click edit Order Item.
    • Click edit Supplier.
    • The system must calculate remain order unit.