public JsonResult GetPackedData(string plantWerk, string faCode, DateTime prodDate) { var paramInput = new ReversalCreateParamInput(); paramInput.ZaapShiftId = 0; paramInput.ReversalQty = 0; paramInput.ReversalId = 0; paramInput.Werks = plantWerk; paramInput.FaCode = faCode; paramInput.ProductionDate = prodDate; var checkData = _reversalBll.CheckData(paramInput); return(Json(checkData.PackedQty)); }
public JsonResult GetRemainingQuota(string zaapShift, string inventoryMovement) { if (zaapShift == "") { zaapShift = "0"; } if (inventoryMovement == "") { inventoryMovement = "0"; } var paramInput = new ReversalCreateParamInput(); paramInput.ZaapShiftId = Convert.ToInt32(zaapShift); paramInput.InventoryMovementId = Convert.ToInt32(inventoryMovement); paramInput.ReversalQty = 0; paramInput.ReversalId = 0; paramInput.Werks = string.Empty; paramInput.FaCode = string.Empty; var checkData = _reversalBll.CheckData(paramInput); return(Json(checkData.RemainingQuota)); }
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); }