Advertisement
tko_pb

GoodsMovementActionHandler25September

Sep 24th, 2018
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. package org.wirabumi.gen.oez.porting;
  2.  
  3. import java.math.BigDecimal;
  4. import java.util.List;
  5.  
  6. import org.openbravo.base.exception.OBException;
  7. import org.openbravo.base.secureApp.VariablesSecureApp;
  8. import org.openbravo.dal.service.OBDal;
  9. import org.openbravo.model.ad.ui.Tab;
  10. import org.openbravo.model.common.plm.Product;
  11. import org.openbravo.model.materialmgmt.onhandquantity.StorageDetail;
  12. import org.openbravo.model.materialmgmt.transaction.InternalMovement;
  13. import org.openbravo.model.materialmgmt.transaction.InternalMovementLine;
  14. import org.openbravo.model.materialmgmt.transaction.MaterialTransaction;
  15. import org.wirabumi.gen.oez.event.DocumentRoutingHandlerAction;
  16.  
  17. public class GoodsMovementActionHandler extends DocumentRoutingHandlerAction {
  18.     private final String reactiveStatus="RE";
  19.     private final String inoutProcessID="122";
  20.     private final String completeStatus="CO";
  21.  
  22.     @Override
  23.     public void doRouting(String adWindowId, String adTabId,
  24.             String doc_status_to, VariablesSecureApp vars, List<String> recordId) {
  25.         if (doc_status_to.equalsIgnoreCase(reactiveStatus))
  26.             throw new OBException("@ActionNotAllowedHere@"); //shipment inout tidak boleh di reactive
  27.  
  28.         for (String goodsMovementID : recordId){
  29.  
  30.             InternalMovement goodMovId = OBDal.getInstance().get(InternalMovement.class, goodsMovementID);
  31.             if(doc_status_to.equalsIgnoreCase(completeStatus)) {
  32.                 for (InternalMovementLine goodMovLineId : goodMovId.getMaterialMgmtInternalMovementLineList())
  33.                 {
  34.                     Product productId = goodMovLineId.getProduct();
  35.                     BigDecimal quantityOnHand = BigDecimal.valueOf(0);
  36.                     for (StorageDetail productStorageId : productId.getMaterialMgmtStorageDetailList())
  37.                     {
  38.                         quantityOnHand = quantityOnHand.add(productStorageId.getQuantityOnHand());
  39.                         System.out.println(quantityOnHand);
  40.                     }
  41.  
  42.                    
  43.                     if(goodMovLineId.getMovementQuantity().intValue() > quantityOnHand.intValue())
  44.                     {
  45.                         throw new OBException("@insuffient_stock@");
  46.                     }
  47.                 }
  48.             }
  49.             doExecuteProcedureCall(goodsMovementID, inoutProcessID);
  50.         }
  51.  
  52.     }
  53.  
  54.     @Override
  55.     public String getCoDocumentNo(String recordID, Tab tab) {
  56.         // TODO semengtara null dulu
  57.         return null;
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement