public ActionResult Edit(string id) { if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller) { return(RedirectToAction("Detail", new { id })); } var plant = _plantBll.GetId(id); //NPPBKC Import for the dropdown dikosongkan default value plant.NPPBKC_IMPORT_ID = !string.IsNullOrEmpty(plant.NPPBKC_IMPORT_ID) ? plant.NPPBKC_IMPORT_ID : string.Empty; if (plant == null) { return(HttpNotFound()); } var detail = Mapper.Map <DetailPlantT1001W>(plant); var model = new PlantFormModel { Detail = detail }; return(InitialEdit(model)); }
private bool ValidatePlantCode(string plantCode, out List <string> message, out Plant plantData) { plantData = null; var valResult = false; var messageList = new List <string>(); #region ------------Plant Code Validation------------- if (!string.IsNullOrWhiteSpace(plantCode)) { plantData = _plantBll.GetId(plantCode); if (plantData == null) { messageList.Add("Plant Code/WERKS [" + plantCode + "] not valid"); } else { valResult = true; } } else { messageList.Add("Plant Code/WERKS is empty"); } #endregion message = messageList; return(valResult); }
public ReversalOutput CheckData(ReversalCreateParamInput reversalInput) { var output = new ReversalOutput(); ZAAP_SHIFT_RPT zaapData; INVENTORY_MOVEMENT inventoryMovementData; List <REVERSAL> reversalList; decimal remainingQty; if (reversalInput.InventoryMovementId != 0 && reversalInput.InventoryMovementId != null) { inventoryMovementData = _inventoryMovementService.GetById(reversalInput.InventoryMovementId); reversalList = GetReversalData(x => x.INVENTORY_MOVEMENT_ID == reversalInput.InventoryMovementId, null); remainingQty = (inventoryMovementData == null ? 0 : (inventoryMovementData.QTY.HasValue ? (inventoryMovementData.QTY.Value * -1) : 0)) - (reversalList.Sum(x => x.REVERSAL_QTY.HasValue ? x.REVERSAL_QTY.Value : 0)); } else { zaapData = _zaapShiftRptService.GetById(reversalInput.ZaapShiftId); reversalList = GetReversalData(x => x.ZAAP_SHIFT_RPT_ID == reversalInput.ZaapShiftId, null); remainingQty = (zaapData == null ? 0 : (zaapData.QTY.HasValue ? (zaapData.QTY.Value * -1) : 0)) - (reversalList.Sum(x => x.REVERSAL_QTY.HasValue ? x.REVERSAL_QTY.Value : 0)); } var reversalListByPlantFacodeDate = GetReversalData(x => x.WERKS == reversalInput.Werks && x.FA_CODE == reversalInput.FaCode && x.PRODUCTION_DATE == reversalInput.ProductionDate, null); var totalReversal = reversalListByPlantFacodeDate.Sum(x => x.REVERSAL_QTY.HasValue ? x.REVERSAL_QTY.Value : 0) + reversalInput.ReversalQty; output.IsPackedQtyNotExists = true; output.PackedQty = 0; if (reversalInput.ReversalId > 0) { var existsReversal = GetById(reversalInput.ReversalId); remainingQty = remainingQty + existsReversal.ReversalQty; totalReversal = reversalListByPlantFacodeDate.Where(x => x.REVERSAL_ID != reversalInput.ReversalId).Sum(x => x.REVERSAL_QTY.HasValue ? x.REVERSAL_QTY.Value : 0) + reversalInput.ReversalQty; } if (reversalInput.ProductionDate.HasValue) { var plant = _plantBll.GetId(reversalInput.Werks); var period = 1; var month = reversalInput.ProductionDate.Value.Month; var year = reversalInput.ProductionDate.Value.Year; if (reversalInput.ProductionDate.Value.Day > 14) { period = 2; } var ck4cData = _repositoryCk4c.Get(x => x.NPPBKC_ID == plant.NPPBKC_ID && x.PLANT_ID == reversalInput.Werks && x.REPORTED_PERIOD == period && x.REPORTED_MONTH == month && x.REPORTED_YEAR == year && x.STATUS == Enums.DocumentStatus.Completed); var prodData = _repositoryProd.Get(p => p.PRODUCTION_DATE == reversalInput.ProductionDate.Value && p.WERKS == reversalInput.Werks && p.FA_CODE == reversalInput.FaCode).FirstOrDefault(); if (ck4cData.Count() > 0) { output.IsForCk4cCompleted = true; var ck4cIdRevise = ck4cData.FirstOrDefault().CK4C_ID_REVISED; var ck4cRevise = _repositoryCk4c.Get(x => x.CK4C_ID == ck4cIdRevise && x.STATUS != Enums.DocumentStatus.Completed); if (ck4cRevise.Count() > 0) { output.IsForCk4cCompleted = false; } } if (prodData != null) { if (prodData.QTY_PACKED.Value > 0) { output.IsPackedQtyNotExists = false; output.PackedQty = prodData.QTY_PACKED.Value; } } } if (reversalInput.ReversalQty > remainingQty) { output.IsMoreThanQuota = true; } if (totalReversal > output.PackedQty) { output.IsMoreThanPacked = true; } output.RemainingQuota = remainingQty; return(output); }