Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.wirabumi.gen.oez.porting;
- import java.math.BigDecimal;
- import java.util.List;
- import org.openbravo.base.exception.OBException;
- import org.openbravo.base.secureApp.VariablesSecureApp;
- import org.openbravo.dal.service.OBDal;
- import org.openbravo.model.ad.ui.Tab;
- import org.openbravo.model.common.plm.Product;
- import org.openbravo.model.materialmgmt.onhandquantity.StorageDetail;
- import org.openbravo.model.materialmgmt.transaction.InternalMovement;
- import org.openbravo.model.materialmgmt.transaction.InternalMovementLine;
- import org.openbravo.model.materialmgmt.transaction.MaterialTransaction;
- import org.wirabumi.gen.oez.event.DocumentRoutingHandlerAction;
- public class GoodsMovementActionHandler extends DocumentRoutingHandlerAction {
- private final String reactiveStatus="RE";
- private final String inoutProcessID="122";
- private final String completeStatus="CO";
- @Override
- public void doRouting(String adWindowId, String adTabId,
- String doc_status_to, VariablesSecureApp vars, List<String> recordId) {
- if (doc_status_to.equalsIgnoreCase(reactiveStatus))
- throw new OBException("@ActionNotAllowedHere@"); //shipment inout tidak boleh di reactive
- for (String goodsMovementID : recordId){
- InternalMovement goodMovId = OBDal.getInstance().get(InternalMovement.class, goodsMovementID);
- if(doc_status_to.equalsIgnoreCase(completeStatus)) {
- for (InternalMovementLine goodMovLineId : goodMovId.getMaterialMgmtInternalMovementLineList())
- {
- Product productId = goodMovLineId.getProduct();
- BigDecimal quantityOnHand = BigDecimal.valueOf(0);
- for (StorageDetail productStorageId : productId.getMaterialMgmtStorageDetailList())
- {
- quantityOnHand = quantityOnHand.add(productStorageId.getQuantityOnHand());
- System.out.println(quantityOnHand);
- }
- if(goodMovLineId.getMovementQuantity().intValue() > quantityOnHand.intValue())
- {
- throw new OBException("@insuffient_stock@");
- }
- }
- }
- doExecuteProcedureCall(goodsMovementID, inoutProcessID);
- }
- }
- @Override
- public String getCoDocumentNo(String recordID, Tab tab) {
- // TODO semengtara null dulu
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement