package com.cim.idm.mwmsextend.materialshiprequestToOEM.service;

import com.cim.idm.framework.data.EventInfo;
import com.cim.idm.framework.orm.service.CommonServiceDAO;
import com.cim.idm.wmspackage.materialshiprequesttooem.MaterialShipRequestToOEMServiceProxy;
import com.cim.idm.wmspackage.materialshiprequesttooem.management.data.MaterialShipRequestToOEM;
import com.cim.idm.wmspackage.materialshiprequesttooem.management.data.MaterialShipRequestToOEMKey;
import com.cim.idm.wmspackage.materialshiprequesttooem.management.info.MakeOEMAssignedInfo;
import com.cim.idm.wmspackage.materialshiprequesttooem.management.info.MakeOEMDecreaseAssignedInfo;

public class MaterialShipRequestToOEMServiceImpl extends CommonServiceDAO<MaterialShipRequestToOEMKey, MaterialShipRequestToOEM>{
	
	public void MakeOEMAssignedQty(EventInfo eventInfo,String siteName, String invoiceNo, String invoiceDetailNo,String subMaterialSpecName, String boxQty,String flag){
		MaterialShipRequestToOEMKey keyInfo = new MaterialShipRequestToOEMKey(siteName, invoiceNo,invoiceDetailNo,subMaterialSpecName);
		//MaterialShipRequestToOEM selectByKey = selectByKey(keyInfo);
		
		MakeOEMAssignedInfo makeOEMAssignedInfo=new MakeOEMAssignedInfo();
		MakeOEMDecreaseAssignedInfo makeOEMDecreaseAssignedInfo = new MakeOEMDecreaseAssignedInfo();
		double qty = Double.parseDouble(boxQty);
		if("Assign".equals(flag)){
			makeOEMAssignedInfo.setAssignedQuantity(qty);
			MaterialShipRequestToOEMServiceProxy.getMaterialShipRequestToOEMService().increaseAssignedQuantity(keyInfo, eventInfo, makeOEMAssignedInfo);
		} else if("Deassign".equals(flag)){
			makeOEMDecreaseAssignedInfo.setAssignedQuantity(qty);
			MaterialShipRequestToOEMServiceProxy.getMaterialShipRequestToOEMService().decreaseAssignedQuantity(keyInfo, eventInfo, makeOEMDecreaseAssignedInfo);
		}
	}
	
}
