public bool SaveProductionStockInByProductionRequistion(long reqId, string status, long orgId, long userId)
        {
            var reqInfo   = _requsitionInfoBusiness.GetRequisitionById(reqId, orgId);
            var reqDetail = _requsitionDetailBusiness.GetRequsitionDetailByReqId(reqId, orgId).ToList();

            if (reqInfo != null && reqInfo.StateStatus == "Approved" && reqDetail.Count > 0)
            {
                List <ProductionStockDetailDTO> productionStockDetailDTOs = new List <ProductionStockDetailDTO>();
                foreach (var item in reqDetail)
                {
                    ProductionStockDetailDTO productionStockDetailDTO = new ProductionStockDetailDTO
                    {
                        WarehouseId      = reqInfo.WarehouseId,
                        ItemTypeId       = item.ItemTypeId,
                        ItemId           = item.ItemId,
                        OrganizationId   = orgId,
                        EUserId          = userId,
                        UnitId           = item.UnitId,
                        StockStatus      = "Stock-In",
                        Remarks          = item.Remarks,
                        Quantity         = (int)item.Quantity.Value,
                        RefferenceNumber = reqInfo.ReqInfoCode
                    };
                    productionStockDetailDTOs.Add(productionStockDetailDTO);
                }
                if (SaveProductionStockIn(productionStockDetailDTOs, userId, orgId) == true)
                {
                    return(_requsitionInfoBusiness.SaveRequisitionStatus(reqId, status, orgId));
                }
            }
            return(false);
        }
Exemple #2
0
        public bool SaveWarehouseStockOutByProductionRequistion(long reqId, string status, long orgId, long userId)
        {
            var reqInfo   = _requsitionInfoBusiness.GetRequisitionById(reqId, orgId);
            var reqDetail = _requsitionDetailBusiness.GetRequsitionDetailByReqId(reqId, orgId);

            if (reqInfo != null && reqDetail.Count() > 0)
            {
                List <WarehouseStockDetailDTO> stockDetailDTOs = new List <WarehouseStockDetailDTO>();
                foreach (var item in reqDetail)
                {
                    WarehouseStockDetailDTO stockDetailDTO = new WarehouseStockDetailDTO
                    {
                        WarehouseId      = reqInfo.WarehouseId,
                        ItemTypeId       = item.ItemTypeId.Value,
                        ItemId           = item.ItemId,
                        UnitId           = item.UnitId.Value,
                        OrganizationId   = item.OrganizationId,
                        Quantity         = (int)item.Quantity.Value,
                        EUserId          = userId,
                        EntryDate        = DateTime.Now,
                        Remarks          = "Stock Out By Production Requistion " + "(" + reqInfo.ReqInfoCode + ")",
                        RefferenceNumber = reqInfo.ReqInfoCode,
                        StockStatus      = "Stock-Out"
                    };

                    stockDetailDTOs.Add(stockDetailDTO);
                }
                if (SaveWarehouseStockOut(stockDetailDTOs, userId, orgId, "Production Requistion") == true)
                {
                    return(_requsitionInfoBusiness.SaveRequisitionStatus(reqId, status, orgId));
                }
            }
            return(false);
        }
        // Used By  GetReqInfoList
        public ActionResult GetReqInfoParitalList(string reqCode, long?warehouseId, string status, long?line, string fromDate, string toDate)
        {
            IEnumerable <RequsitionInfoDTO> requsitionInfoDTO = _requsitionInfoBusiness.GetAllReqInfoByOrgId(OrgId).Where(req => (req.StateStatus == "Pending" || req.StateStatus == "Accepted" || req.StateStatus == "Decline")
                                                                                                                          &&
                                                                                                                          (reqCode == null || reqCode.Trim() == "" || req.ReqInfoCode.Contains(reqCode))
                                                                                                                          &&
                                                                                                                          (warehouseId == null || warehouseId <= 0 || req.WarehouseId == warehouseId)
                                                                                                                          &&
                                                                                                                          (status == null || status.Trim() == "" || req.StateStatus == status.Trim())
                                                                                                                          &&
                                                                                                                          (line == null || line <= 0 || req.LineId == line)
                                                                                                                          &&
                                                                                                                          (
                                                                                                                              (fromDate == null && toDate == null)
                                                                                                                              ||
                                                                                                                              (fromDate == "" && toDate == "")
                                                                                                                              ||
                                                                                                                              (fromDate.Trim() != "" && toDate.Trim() != "" &&

                                                                                                                               req.EntryDate.Value.Date >= Convert.ToDateTime(fromDate).Date&&
                                                                                                                               req.EntryDate.Value.Date <= Convert.ToDateTime(toDate).Date)
                                                                                                                              ||
                                                                                                                              (fromDate.Trim() != "" && req.EntryDate.Value.Date == Convert.ToDateTime(fromDate).Date)
                                                                                                                              ||
                                                                                                                              (toDate.Trim() != "" && req.EntryDate.Value.Date == Convert.ToDateTime(toDate).Date)
                                                                                                                          )
                                                                                                                          ).Select(info => new RequsitionInfoDTO
            {
                ReqInfoId      = info.ReqInfoId,
                ReqInfoCode    = info.ReqInfoCode,
                LineId         = info.LineId,
                LineNumber     = (_productionLineBusiness.GetProductionLineOneByOrgId(info.LineId, OrgId).LineNumber),
                StateStatus    = info.StateStatus,
                Remarks        = info.Remarks,
                OrganizationId = info.OrganizationId,
                EntryDate      = info.EntryDate,
                WarehouseId    = info.WarehouseId,
                WarehouseName  = (_warehouseBusiness.GetWarehouseOneByOrgId(info.WarehouseId, OrgId).WarehouseName),
                Qty            = _requsitionDetailBusiness.GetRequsitionDetailByReqId(info.ReqInfoId, OrgId).Select(s => s.ItemId).Distinct().Count(),
            }).ToList();

            List <RequsitionInfoViewModel> requsitionInfoViewModels = new List <RequsitionInfoViewModel>();

            AutoMapper.Mapper.Map(requsitionInfoDTO, requsitionInfoViewModels);
            return(PartialView(requsitionInfoViewModels));
        }