示例#1
0
        public Dictionary <string, List <DisbursementListDetails> > GetAllDisbursementDetailsByIdOfRep(long listId)
        {
            List <DisbursementListDetails> disbursementDetails = DisbursementListDetailsDAO.ViewDetails(listId);

            Dictionary <string, List <DisbursementListDetails> > disDict = new Dictionary <string, List <DisbursementListDetails> >
            {
                { "disbursementDetails", disbursementDetails }
            };

            return(disDict);
        }
示例#2
0
 public static void CreateDisbursementLists(List <DisbursementList> disbursementLists)
 {
     foreach (var disbursementList in disbursementLists)
     {
         disbursementList.Department = DepartmentDAO.GetDepartmentById(disbursementList.Department.DeptId);
         long listId = DisbursementListDAO.CreateDisbursementList(disbursementList);
         foreach (var item in disbursementList.DisbursementListDetails)
         {
             DisbursementListDetailsDAO.CreateDisbursementListDetails(listId, item);
         }
     }
 }
示例#3
0
 public static void UpdateDisbursementListDetails(long listId, DisbursementListDetails disbursementListDetails)
 {
     DisbursementListDetailsDAO.UpdateDetailById(listId, disbursementListDetails);
 }
示例#4
0
        public static List <DisbursementListDetails> ViewDisbursementDetails(long listId)
        {
            List <DisbursementListDetails> disbursementListDetails = DisbursementListDetailsDAO.ViewDetails(listId);

            return(disbursementListDetails);
        }
示例#5
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
                    }
                }
            }
        }