private void NotifyClerkAboutAnyShortFallInWaitlistApprovedStationery(int stationeryId, int clerkEmployeeId)
 {
     if (AnyShortFallInWaitlistApprovedStationery(stationeryId))
     {
         //email clerk
         Stationery s     = stationeryRepo.FindById(stationeryId);
         Employee   clerk = employeeRepo.FindById(clerkEmployeeId);
         emailNotificationService.NotifyClerkShortFallInStationery(s, clerk);
     }
 }
        // method to get all stationery Details from Status == Preparing Requisition Details
        public List <int> RetrieveStationeryDetailsByRequisitionDetailsList(List <RequisitionDetail> requisitionDetailList)
        {
            List <int>        stationeryIdList     = new List <int>();
            List <Stationery> stationeryDetailList = new List <Stationery>();

            foreach (RequisitionDetail reqDet in requisitionDetailList.GroupBy(x => x.StationeryId).Select(g => g.First()).Distinct().ToList())
            {
                Stationery st = (Stationery)stationeryRepo.FindById(reqDet.StationeryId);
                stationeryIdList.Add(st.Id);
            }
            return(stationeryIdList);
        }
示例#3
0
 public void UpdateAdjustmentVoucher(AdjustmentVoucher adj)
 {
     if (adj.Status.Equals("Submitted"))
     {
         foreach (AdjustmentVoucherDetail avd in adj.AdjustmentVoucherDetails)
         {
             int        sId = avd.StationeryId;
             Stationery s   = stationeryRepo.FindById(sId);
             s.Quantity += avd.Quantity;
             stationeryRepo.Update(s);
         }
     }
     adjustmentVoucherRepo.Update(adj);
 }
        private int getReservedBalanceForExistingCartItem(CartDetail cd)
        {
            //Q - requisition reserved - adjustment open - total in front of queue
            int reservedCount       = requisitionDetailRepo.GetReservedCountForStationery(cd.StationeryId);
            int foqCartCount        = cartDetailRepo.GetFrontOfQueueCartCountForStationery(cd.StationeryId, cd.DateTime);
            int openAdjustmentCount = adjustmentVoucherRepo.GetOpenAdjustmentVoucherCountForStationery(cd.StationeryId);
            int totalCount          = stationeryRepo.FindById(cd.StationeryId).Quantity;
            int netCount            = totalCount - reservedCount - foqCartCount + openAdjustmentCount;

            if (netCount <= 0)
            {
                return(0);
            }
            else if (netCount >= cd.Quantity)
            {
                return(cd.Quantity);
            }
            else
            {
                return(netCount);
            }
        }
        public StockAndSupplierDTO RetrieveStockMovement(int stationeryId)
        {
            List <StockMovementDTO>        stockMovement        = new List <StockMovementDTO>();
            List <StockMovementBalanceDTO> stockMovementBalance = new List <StockMovementBalanceDTO>();
            List <SupplierStockRankDTO>    supplierStockRank    = new List <SupplierStockRankDTO>();
            Stationery            s  = stationeryRepo.FindById(stationeryId);
            Category              c  = categoryRepo.FindById(s.CategoryId);
            List <SupplierTender> st = (List <SupplierTender>)supplierTenderRepo.FindBy(x => x.StationeryId == stationeryId);
            List <Supplier>       sp = new List <Supplier>();

            foreach (SupplierTender rankedsupplier in st)
            {
                Supplier supplier = (Supplier)supplierRepo.FindById(rankedsupplier.SupplierId);
                sp.Add(supplier);
            }

            //add Suppliers To SupplierStockRankDTO
            int limit = 3;

            for (int i = 1; i <= limit; i++)
            {
                SupplierStockRankDTO supstockrank = new SupplierStockRankDTO();
                {
                    supstockrank.Rank = i;

                    SupplierTender rankingsupplier = (SupplierTender)supplierTenderRepo.FindOneBy(x => x.StationeryId == stationeryId && x.Rank == i);
                    supstockrank.SupplierCode  = rankingsupplier.Supplier.Code;
                    supstockrank.SupplierName  = rankingsupplier.Supplier.Name;
                    supstockrank.ContactPerson = rankingsupplier.Supplier.ContactName;
                    supstockrank.ContactNumber = rankingsupplier.Supplier.PhoneNo;
                    supstockrank.Price         = rankingsupplier.Price;
                }
                supplierStockRank.Add(supstockrank);
            }

            //retrieve all adjustment voucher Ids that are acknowledged
            List <int> avId = adjustmentVoucherRepo.getAdjustmentVoucherIdsWithAcknowledgedStatus();

            //retrieve all adjustment voucher details with adjustment voucher Ids that are acknowledged and stationeryId
            List <AdjustmentVoucherDetail> avDet = new List <AdjustmentVoucherDetail>();

            foreach (int adjvouch in avId)
            {
                List <AdjustmentVoucherDetail> adjvouchDetail = (List <AdjustmentVoucherDetail>)adjustmentVoucherDetailRepo.FindBy(x => x.AdjustmentVoucherId == adjvouch && x.StationeryId == stationeryId);
                foreach (AdjustmentVoucherDetail aVD in adjvouchDetail)
                {
                    avDet.Add(aVD);
                }
            }

            // set retrieved adjustmentvouchers into StockMovementDTO
            foreach (AdjustmentVoucherDetail adjV in avDet)
            {
                StockMovementDTO stockMovList = new StockMovementDTO();
                {
                    stockMovList.MovementDate         = adjV.DateTime;
                    stockMovList.DepartmentOrSupplier = "Adjustment Voucher - " + adjV.AdjustmentVoucherId;
                    stockMovList.Quantity             = adjV.Quantity;
                }
                stockMovement.Add(stockMovList);
            }

            //retrieve all purchase Order Ids that are closed
            List <int> poId = purchaseOrderRepo.getPurchaseOrderIdsWithClosedStatus();

            //retrieve all PO details with PO Ids that are closed and stationeryId
            List <PurchaseOrderDetail> purchaseOrderDet = new List <PurchaseOrderDetail>();

            foreach (int a in poId)
            {
                PurchaseOrderDetail purOrderDetail = (PurchaseOrderDetail)purchaseOrderDetailRepo.FindOneBy(x => x.PurchaseOrderId == a && x.StationeryId == stationeryId);
                purchaseOrderDet.Add(purOrderDetail);
            }

            // set retrieved PODetails into StockMovementDTO
            foreach (PurchaseOrderDetail poDetail in purchaseOrderDet)
            {
                if (poDetail != null)
                {
                    StockMovementDTO stockMovList = new StockMovementDTO();
                    {
                        stockMovList.MovementDate         = (DateTime)purchaseOrderRepo.FindById(poDetail.PurchaseOrderId).DeliveryDateTime;
                        stockMovList.DepartmentOrSupplier = "Supplier - " + supplierRepo.FindById(purchaseOrderRepo.FindById(poDetail.PurchaseOrderId).SupplierId).Name;
                        stockMovList.Quantity             = (int)poDetail.QuantityDelivered;
                    }
                    stockMovement.Add(stockMovList);
                }
            }

            //retrieve all requisitiondetails that are delivered and are of the input stationeryId
            List <RequisitionDetail> reqDet = (List <RequisitionDetail>)requisitionDetailRepo.FindBy(x => x.Status == "Collected" && x.StationeryId == stationeryId);

            // set retrieved PODetails into StockMovementDTO
            foreach (RequisitionDetail reqDetails in reqDet)
            {
                StockMovementDTO stockMovList = new StockMovementDTO();

                stockMovList.MovementDate = (DateTime)reqDetails.Disbursement.DeliveryDateTime;

                int rcdEmployeeId = (int)disbursementRepo.FindOneBy(x => x.Id == reqDetails.DisbursementId).ReceivedEmployeeId;

                stockMovList.DepartmentOrSupplier = employeeRepo.FindById(rcdEmployeeId).Department.DepartmentName;;

                stockMovList.Quantity = (int)reqDetails.QuantityDelivered * -1;

                stockMovement.Add(stockMovList);
            }

            // order the list by date & alphabetically
            stockMovement = stockMovement.OrderBy(x => x.MovementDate).ToList();
            int runningBal = 0;

            // set StockMovementDTO into StockMovementBalanceDTO
            foreach (StockMovementDTO stkMovDTO in stockMovement)
            {
                StockMovementBalanceDTO stockMovBalList = new StockMovementBalanceDTO();
                stockMovBalList.StockMovement = stkMovDTO;
                runningBal = runningBal + stkMovDTO.Quantity;
                stockMovBalList.Balance = runningBal;
                stockMovementBalance.Add(stockMovBalList);
            }

            stockMovement.Reverse();
            //stockMovementBalance.Reverse();

            // set StockMovementBalanceDTO into StockAndSupplierDTO
            StockAndSupplierDTO stockAndSuppliers = new StockAndSupplierDTO();

            stockAndSuppliers.StationeryId      = s.Id;
            stockAndSuppliers.ItemNumber        = s.Code;
            stockAndSuppliers.Category          = (String)categoryRepo.getCategoryType(s.CategoryId);
            stockAndSuppliers.Description       = s.Description;
            stockAndSuppliers.Location          = s.Bin;
            stockAndSuppliers.UnitOfMeasure     = s.UnitOfMeasure;
            stockAndSuppliers.SupplierStockRank = supplierStockRank;

            foreach (StockMovementBalanceDTO stockMovementBalanceDTO in stockMovementBalance)
            {
                stockMovementBalanceDTO.Balance += s.Quantity - stockMovementBalance.Last().Balance;
            }

            stockAndSuppliers.StockMovementBalance = stockMovementBalance;
            return(stockAndSuppliers);
        }