Esempio n. 1
0
        public Dictionary <string, List <Inventory> > GetAllInventories()
        {
            Dictionary <string, List <Inventory> > invDict = new Dictionary <string, List <Inventory> >
            {
                { "inventories", CatalogueService.GetAllCatalogue() }
            };

            return(invDict);
        }
        public static List <AdjVoucher> GetAdjByStatus(int status)
        {
            List <AdjVoucher> adjVouchers = new List <AdjVoucher>();

            adjVouchers = AdjVoucherDAO.GetAdjByStatus(status);
            if (adjVouchers != null)
            {
                foreach (AdjVoucher adj in adjVouchers)
                {
                    adj.ItemCode = CatalogueService.GetCatalogueById(adj.ItemId).ItemCode;
                }
            }

            return(adjVouchers);
        }
Esempio n. 3
0
        public static void CreateStockCardFromAdj(long adjId, long itemId, int adjQty)
        {
            StockCard stockCard = new StockCard();

            stockCard.Date     = DateTime.Now;
            stockCard.ItemId   = itemId;
            stockCard.SourceId = adjId;
            if (adjQty < 0)
            {
                stockCard.Qty = "ADJ - " + Math.Abs(adjQty);
            }
            else
            {
                stockCard.Qty = "ADJ + " + Math.Abs(adjQty);
            }
            stockCard.Balance = CatalogueService.GetCatalogueById(itemId).StockLevel;
            StockCardDAO.CreateStockCardFromAdj(stockCard);
        }
Esempio n. 4
0
        public Dictionary <string, object> GetAllRetrievalFormsOfStockClerk()
        {
            List <RetrievalForm> retrievalForms = retrievalForms = RetrievalFormService.ViewRetrievalForm();
            bool isPending = (DisbursementListService.CheckForPendingDisbursements().Count != 0);

            for (int i = 0; i < retrievalForms.Count; i++)
            {
                Inventory inv = CatalogueService.GetCatalogueById(retrievalForms[i].itemId);
                retrievalForms[i].totalRetrieved = inv.StockLevel;
            }

            Dictionary <string, object> retrievalDict = new Dictionary <string, object>
            {
                { "retrievalForms", retrievalForms },
                { "pending", isPending }
            };

            return(retrievalDict);
        }
Esempio n. 5
0
        public static void CreateStockCardFromOrder(PurchaseOrder order, List <long> itemIds, List <int> itemQuantities)
        {
            int totalQuantity = itemQuantities.Sum(m => m);

            if (totalQuantity != 0)
            {
                for (int i = 0; i < itemIds.Count; i++)
                {
                    if (itemQuantities[i] != 0)
                    {
                        StockCard stockCard = new StockCard();
                        stockCard.Date     = DateTime.Now;
                        stockCard.ItemId   = itemIds[i];
                        stockCard.SourceId = order.SupplierId;
                        stockCard.Qty      = "+ " + itemQuantities[i];
                        stockCard.Balance  = CatalogueService.GetCatalogueById(itemIds[i]).StockLevel + itemQuantities[i];
                        StockCardDAO.CreateStockCardFromOrder(stockCard);
                    }
                }
            }
        }
Esempio n. 6
0
        private void UpdateChargeBack(long listId)
        {
            /* Move the following code to RestRepresentativeController*/
            ////Attention: DisbursementList can only disburse once, date for that list is not null

            ///*The following code is for ChargeBack table*/
            ////By the time disburse item, calculate the amount of this list, update ChargeBack table

            DisbursementList disbursementList = DisbursementListService.GetDisbursementListByListId(listId);
            List <DisbursementListDetails> disbursementListDetails = DisbursementListDetailsDAO.ViewDetails(listId);

            foreach (DisbursementListDetails details in disbursementListDetails)
            {
                PriceList priceList = PriceListService.GetPriceListByItemId(details.Item.ItemId);
                double    price     = 0;
                if (priceList != null)
                {
                    price = priceList.Supplier1UnitPrice;
                }

                double amount = price * details.Quantity;
                ChargeBackService.UpdateChargeBackData(amount, disbursementList);

                ///*The following code is for StockCard table*/
                ////By the time disburse item, update StockCard table with itemId, deptId and date, souceType = 2

                int balance = CatalogueService.GetCatalogueById(details.Item.ItemId).StockLevel - details.Quantity;
                StockCardService.CreateStockCardFromDisburse(details, disbursementList, balance);
                StockDAO.UpdateWithReduceInventoryStockById(details.Item.ItemId, details.Quantity);

                ////following code will update and close requisitions
                int disbursedAmount             = details.Quantity;
                List <Requisition> requisitions = RequisitionDAO.GetOutstandingRequisitionsAndDetailsByDeptIdAndItemId(disbursementList.Department.DeptId, details.Item.ItemId, listId); //will get those status assigned/partially completed(assigned)

                foreach (var requisition in requisitions)
                {
                    if (requisition.RequisitionDetail.Balance <= disbursedAmount)                                     // if the balance is less than what was disbursed
                    {
                        RequisitionDetailsDAO.UpdateBalanceAmount(requisition.ReqId, details.Item.ItemId, 0);         //change balance to 0

                        if (RequisitionDetailsDAO.GetRemainingRequisitionDetailsByReqId(requisition.ReqId).Count > 0) //will get those the remaining amounts !=0 if
                        {
                            RequisitionDAO.UpdateStatus(requisition.ReqId, "Partially Completed");
                        }
                        else
                        {
                            RequisitionDAO.UpdateStatus(requisition.ReqId, "Completed");
                        }
                        disbursedAmount -= requisition.RequisitionDetail.Balance; // minusing the balance from what was disbursed
                    }
                    else// when the balance amount is more than the remainder of the disbursed amount
                    {
                        RequisitionDetailsDAO.UpdateBalanceAmount(requisition.ReqId, details.Item.ItemId, disbursedAmount);// change balance to remainder of disbursed amount

                        RequisitionDAO.UpdateStatus(requisition.ReqId, "Partially Completed");

                        break;//break out of for loop when disbursed amount become 0
                    }
                }
            }
        }