public void Transactions()
 {
   Disbursement disbursement = new Disbursement(attributes, gateway);
   ResourceCollection<Transaction> transactions = disbursement.Transactions();
   Assert.IsNotNull(transactions);
   Assert.AreEqual(1, transactions.MaximumCount);
   Assert.AreEqual("sub_merchant_transaction", transactions.FirstItem.Id);
 }
        public JsonResult SaveStatusToCompletedInDisb(string disId)
        {
            Disbursement d = dbcontext.disbursements.Where(x => x.Id == disId).FirstOrDefault();

            d.status = DisbusementStatus.COMPLETED;
            dbcontext.Update(d);
            dbcontext.SaveChanges();
            return(Json("1"));
        }
Beispiel #3
0
        public void Transactions()
        {
            Disbursement disbursement = new Disbursement(attributes, gateway);
            ResourceCollection <Transaction> transactions = disbursement.Transactions();

            Assert.IsNotNull(transactions);
            Assert.AreEqual(1, transactions.MaximumCount);
            Assert.AreEqual("sub_merchant_transaction", transactions.FirstItem.Id);
        }
Beispiel #4
0
 public static void UpdateDisbursementStatus(int disbID)
 {
     using (StationeryEntities context = new StationeryEntities())
     {
         Disbursement disbursement = GetDisbursmentbyDisbID(disbID);
         disbursement.Status = "Closed";
         UpdateDisbursement(disbursement);
     }
 }
Beispiel #5
0
 public void CreateDisbursement(Disbursement d, List <DisbursementDetail> dd)
 {
     using (db = new LogicEntities())
     {
         db.Disbursement.Add(d);
         db.DisbursementDetail.AddRange(dd);
         db.SaveChanges();
     }
 }
 public void actionCreateDisbursementTable(int req_dept, String deptRept)
 {
     disbursement = new Disbursement();
     disbursement.department = req_dept;
     disbursement.department_rept = deptRept;
     disbursement.distributed_date = DateTime.Now;
     data.Disbursements.AddObject(disbursement);
     data.SaveChanges();
 }
 static void PrintDisbursement(Disbursement d)
 {
     Console.WriteLine(d.DisbursementCode);
     //Console.WriteLine("Number of Disbursement details: "+ d.DisbursementDetails.Count);
     Console.WriteLine(d.DepartmentCode);
     Console.WriteLine(d.UserName);
     Console.WriteLine(d.DateCreated);
     Console.WriteLine("------------------------");
 }
        public DisbursementViewModel CreateDisbursementAdjustmentVoucher(DisbursementViewModel model, HttpSessionStateBase session)
        {
            Adjustment adjustment = new Adjustment();
            DateTime   date       = DateTime.Now;

            adjustment.date = date.Date;
            string timestamp = date.ToString("yyyyMMddhhmmss");

            adjustment.clerk      = session["EmployeeID"].ToString();
            adjustment.status     = "Submitted";
            adjustment.supervisor = session["HeadID"].ToString();
            adjustment.voucherId  = "ADJ" + adjustment.clerk + timestamp;
            string  disburseID = model.disbursementID;
            decimal totalvalue = 0;
            Dictionary <string, string> storeEmpList = GetStoreEmployeeList(session["Username"].ToString(), session["Password"].ToString());
            string managerIDName = storeEmpList["manager"];

            foreach (DisbursementViewModelDetail dvmd in model.dvmdList)
            {
                if (dvmd.adjQty == 0 || dvmd.adjQty == null)
                {
                    continue;
                }
                AdjustmentDetail adjDetail = new AdjustmentDetail();
                adjDetail.itemId    = dvmd.itemID;
                adjDetail.quantity  = (int)dvmd.adjQty;
                adjDetail.remark    = "Disbursement (" + disburseID + ") Adjustment";
                adjDetail.voucherId = adjustment.voucherId;
                string  supplier  = db.Catalogues.Find(dvmd.itemID).firstSupplier;
                decimal itemPrice = db.SupplierQuotations.Where(x => x.itemId == dvmd.itemID && x.supplierId == supplier).First().price;
                totalvalue += (itemPrice * adjDetail.quantity);
                db.AdjustmentDetails.Add(adjDetail);
            }
            //Set need authority (Logic - if need manager approval, set manager id - else null)
            bool needAuthority = totalvalue > 250M ? true : false;;

            adjustment.needAuthority   = needAuthority == true ? new string(managerIDName.Where(Char.IsDigit).ToArray()) : null;
            adjustment.adjustmentValue = totalvalue;
            db.Adjustments.Add(adjustment);
            Disbursement disbursement = db.Disbursements.Find(disburseID);

            disbursement.adjustmentID = adjustment.voucherId;
            db.SaveChanges();

            model.status       = "Adjustment Performed";
            model.adjustmentID = adjustment.voucherId;

            EmailBusinessLogic emailBizLogic = new EmailBusinessLogic();
            string             receipient    = needAuthority ? adjustment.needAuthority : adjustment.supervisor;
            string             sender        = adjustment.clerk;
            string             linkref       = "http://" + ConstantsConfig.linkrefURLPartial + "/Adjustment/AdjustmentDetail?adjustmentID=" + adjustment.voucherId;

            emailBizLogic.SendEmail("submitAdj", receipient, sender, null, null, linkref);

            return(model);
        }
        public void TestInitialize()
        {
            context = new ApplicationDbContext();

            retrievalService    = new RetrievalService(context);
            itemService         = new ItemService(context);
            disbursementService = new DisbursementService(context);

            retrievalRepository          = new RetrievalRepository(context);
            disbursementRepository       = new DisbursementRepository(context);
            disbursementdetailRepository = new DisbursementDetailRepository(context);
            stockmovementRepository      = new StockMovementRepository(context);
            statusRepository             = new StatusRepository(context);

            Retrieval retrieval = new Retrieval();

            if (retrievalRepository.FindById("TEST") == null)
            {
                //save retrieval object into db

                retrieval.RetrievalId     = "TEST";
                retrieval.CreatedDateTime = DateTime.Now;
                retrievalRepository.Save(retrieval);
                retrieval.Status = statusRepository.FindById(19);
            }
            else
            {
                retrieval = retrievalRepository.FindById("TEST");
            }

            Disbursement disbursement = new Disbursement();

            if (disbursementRepository.FindById("TEST") == null)
            {
                disbursement.DisbursementId  = "TEST";
                disbursement.CreatedDateTime = DateTime.Now;
                disbursement.Retrieval       = retrieval;
            }
            else
            {
                disbursement = disbursementRepository.FindById("TEST");
            }

            disbursementRepository.Save(disbursement);

            //save disbursement detail object into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                Disbursement   = disbursement,
                Item           = context.Item.Where(x => x.ItemCode == "C003").First(),
                PlanQuantity   = 5,
                ActualQuantity = 5
            };

            disbursementdetailRepository.Save(detail);
        }
        public ActionResult SaveDisbursementList()
        {
            if (Request.QueryString["ErrorMessage"] != null)
            {
                TempData["ErrorMessage"] = Request.QueryString["ErrorMessage"];
                ViewBag.Select           = Session["deptCode"].ToString();
                return(RedirectToAction("DisbursementList"));
            }
            var                 actualQty   = Convert.ToInt32((Request.QueryString["key1"]));
            var                 itemCode    = Request.QueryString["key2"];
            var                 allocateQty = Convert.ToInt32(Request.QueryString["key3"]);
            var                 remarks1    = Request.QueryString["key4"];
            var                 deptCode    = Session["deptCode"].ToString();
            Boolean             status      = true;
            List <Disbursement> list        = new List <Disbursement>();

            if (HttpContext.Application["tempDisbursement"] != null)
            {
                list = (List <Disbursement>)HttpContext.Application["tempDisbursement"];
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].departmentCode == deptCode && list[i].itemCode == itemCode)
                    {
                        list[i].actualQty = actualQty;
                        status            = false;
                        break;
                    }
                }
                if (status)
                {
                    Disbursement d = new Disbursement();
                    d.itemCode       = itemCode;
                    d.quantity       = allocateQty;
                    d.departmentCode = deptCode;
                    d.actualQty      = actualQty;
                    list.Add(d);
                }
            }
            else
            {
                Disbursement d = new Disbursement();
                d.itemCode       = itemCode;
                d.quantity       = allocateQty;
                d.departmentCode = deptCode;
                d.actualQty      = actualQty;
                list.Add(d);
            }

            HttpContext.Application.Lock();
            HttpContext.Application["tempDisbursement"] = list;
            HttpContext.Application.UnLock();

            TempData["Successful"] = "Save disbursement successful.";
            ViewBag.Select         = deptCode;
            return(RedirectToAction("DisbursementList"));
        }
 public static Disbursement GetDisbursementByDetailId(int id)
 {
     using (var ctx = new UniDBContext())
     {
         DisbursementDetail dd = ctx.DisbursementDetails.Include("Disbursement").Include("Item")
                                 .Where(d => d.DisbursementDetailId == id).FirstOrDefault();
         Disbursement disbursement = dd.Disbursement;
         return(disbursement);
     }
 }
Beispiel #12
0
 public static int AddNewDisbursment(Disbursement disbursment)
 {
     using (StationeryEntities context = new StationeryEntities())
     {
         context.Disbursements.Add(disbursment);
         context.SaveChanges();
         //saving changes get ID for disbursement
         return(disbursment.DisbursementID);
     }
 }
Beispiel #13
0
        public void createDisbursement(string departmentID, string storeStaffID)
        {
            Disbursement dl = new Disbursement();

            dl.deptID       = departmentID;
            dl.storeStaffID = storeStaffID;
            dl.disburseDate = DateTime.Now;
            dl.status       = "Pending";
            model.Disbursements.Add(dl);
        }
Beispiel #14
0
 public static Disbursement GetDeliveredDisbursement(int id)
 {
     using (var ctx = new UniDBContext())
     {
         Disbursement disbursement = ctx.Disbursements.Include("Department").Include("Department.Representative").Include("DisbursementDetails").Include("DisbursementDetails.Item")
                                     .Include("Request").Include("Department.PickupPoint")
                                     .Where(d => d.Status == (int)DisbursementStatus.Delivered && d.DisbursementId == id).SingleOrDefault();
         return(disbursement);
     }
 }
Beispiel #15
0
        public void DeleteDisbursementForDisapprovedRequest(ADProjectDb db, int requestId)
        {
            Disbursement disbursement = db.DisbursementDetail
                                        .Where(dd => dd.Disbursement.RequestId == requestId)
                                        .Select(dd => dd.Disbursement)
                                        .FirstOrDefault();

            db.Disbursement.Remove(disbursement);
            db.SaveChanges();
        }
        public static Disbursement getFirstDisbursement(String disbursementId)
        {
            int Id = Convert.ToInt32(disbursementId);

            SSAEntities  ssae         = new SSAEntities();
            var          qry          = from x in ssae.Disbursements.Where(x => x.DisbursementId.Equals(Id)) select x;
            Disbursement disbursement = qry.First <Disbursement>();

            return(disbursement);
        }
Beispiel #17
0
 public static Disbursement GetDisbursementDetailById(int disbursementId)
 {
     using (var ctx = new UniDBContext())
     {
         Disbursement dis = ctx.Disbursements.Include("Department").Include("DisbursementDetails").Include("DisbursementDetails.Item")
                            .Include("ApprovedBy")
                            .Where(d => d.DisbursementId == disbursementId).SingleOrDefault();
         return(dis);
     }
 }
Beispiel #18
0
        public List <Disbursement> GetRequisitionByDept(string deptCode)
        {
            List <Disbursement>       disbursementList = new List <Disbursement>();
            StationeryModel           entity           = new StationeryModel();
            List <Requisition_Record> list;

            if (deptCode != "")
            {
                list = entity.Requisition_Records.Where(x => x.deptCode == deptCode && (x.status == "Approved and Processing" || x.status == "Partially fulfilled")).ToList();
            }
            else
            {
                list = entity.Requisition_Records.Where(x => x.status == "Approved and Processing" || x.status == "Partially fulfilled").ToList();
            }
            List <string> itemCodes = new List <string>();
            List <int?>   Qty       = new List <int?>();

            foreach (var item in list)
            {
                List <Requisition_Detail> rd = item.Requisition_Detail.Where(x => x.allocatedQty > 0).ToList();
                foreach (var a in rd)
                {
                    if (!itemCodes.Contains(a.itemCode))
                    {
                        itemCodes.Add(a.itemCode);
                    }
                }
            }
            for (int i = 0; i < itemCodes.Count; i++)
            {
                Qty.Add((int?)0);
            }
            for (int i = 0; i < itemCodes.Count; i++)
            {
                foreach (var b in list)
                {
                    if ((b.Requisition_Detail.Where(x => x.itemCode == itemCodes[i]).Count()) > 0)
                    {
                        Qty[i] = Qty[i] + b.Requisition_Detail.Where(x => x.itemCode == itemCodes[i]).First().allocatedQty;
                    }
                }
            }
            for (int i = 0; i < itemCodes.Count; i++)
            {
                Disbursement disbursement = new Disbursement();
                disbursement.itemCode = itemCodes[i];
                var A = itemCodes[i];
                disbursement.itemDescription = entity.Stationeries.Where(x => x.itemCode == A).First().description;
                disbursement.quantity        = Qty[i];
                disbursement.actualQty       = 0;
                disbursement.departmentCode  = deptCode;
                disbursementList.Add(disbursement);
            }
            return(disbursementList);
        }
        //public ActionResult OutstandingDisbursementList()
        //{
        //    DateTime cutoff = DateTime.Now.Date;
        //    List<Department> departments = new List<Department>();
        //    departments = departmentDAO.GetDepartmentsWithOutstandingOrders(cutoff);

        //    ViewData["departments"] = departments;

        //    return View();
        //}

        public ActionResult GenerateDisbursementLists()
        {
            DateTime          cutoff      = DateTime.Now.Date; //Ensures that orders only up to yesterday 2359 is taken into consideration
            List <Department> departments = departmentDAO.GetDepartmentsWithOutstandingOrders(cutoff);
            List <DisbursementDetailViewModel> consolidatedOrders = new List <DisbursementDetailViewModel>();

            foreach (Department d in departments)
            {
                DepartmentStaff rep = departmentStaffDAO.getDeptRep(d.DeptId);
                using (db = new LogicEntities())
                {
                    var resultSet = from rd in db.RequestDetail
                                    from r in db.Request
                                    where (r.Status.Contains("New") || r.Status.Contains("Outstanding")) &&
                                    r.RequestId == rd.RequestId && r.DeptId == d.DeptId &&
                                    r.ReqDate < cutoff
                                    group rd by new { rd.ProductId, r.DeptId } into g
                        select new DisbursementDetailViewModel            //Note to self: Groupby only works with enums or primitive data types
                    {
                        ProductId    = g.Key.ProductId,
                        DepartmentId = g.Key.DeptId,
                        Quantity     = g.Sum(x => x.ReqQty)
                    };
                    consolidatedOrders = resultSet.ToList();

                    Disbursement dis = new Disbursement
                    {
                        DisDate           = DateTime.Now,
                        Status            = "Pending",
                        DeptId            = d.DeptId,
                        StoreStaffId      = null,
                        ReceiveStaffId    = rep.StaffId,
                        CollectionPointId = d.CollectionPt
                    };
                    List <DisbursementDetail> disbursementdetails = new List <DisbursementDetail>();
                    foreach (DisbursementDetailViewModel p in consolidatedOrders)
                    {
                        DisbursementDetail dd = new DisbursementDetail
                        {
                            ProductId   = p.ProductId,
                            RequiredQty = p.Quantity,
                            ReceivedQty = 0,
                            DisId       = dis.DisId
                        };
                        disbursementdetails.Add(dd);
                    }
                    db.Disbursement.Add(dis);
                    db.DisbursementDetail.AddRange(disbursementdetails);
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("FindDisbursementList"));
        }
Beispiel #20
0
        public List <Requisition> UpdateRequisitionStatus(Disbursement disbursement)
        {
            int count = 0;
            //get list of requisitions with the same retrieval id as the disbursement
            List <Requisition> requisitions = disbursement.Retrieval.Requisitions;
            List <Requisition> updated      = new List <Requisition>();

            foreach (DisbursementDetail d in disbursement.DisbursementDetails)
            {
                foreach (Requisition requisition in requisitions)
                {
                    count = 0;
                    RequisitionDetail r = requisition.RequisitionDetails.Find(x => x.Item == d.Item);

                    if (r == null)
                    {
                        continue;
                    }

                    if (r.Item == d.Item)
                    {
                        if (r.Quantity > d.ActualQuantity)
                        {
                            //set requisition detail status to be partially fulfilled IF NOT ZERO
                            r.Status = statusService.FindStatusByStatusId(9);
                        }

                        else if (r.Quantity < d.ActualQuantity)
                        {
                            //set requisition detail status to be fully delivered
                            r.Status          = statusService.FindStatusByStatusId(10);
                            d.ActualQuantity -= r.Quantity;
                            count++;
                        }

                        requisition.Status = statusService.FindStatusByStatusId(10);
                    }

                    //if (count > 0)
                    //{
                    //    requisition.Status = statusService.FindStatusByStatusId(9);
                    //}
                    //if (count == requisition.RequisitionDetails.Count)
                    //{

                    //}


                    updated.Add(requisition);
                }
            }

            return(updated);
        }
        protected int AddDisbursement(string deptId)
        {
            Disbursement disb = new Disbursement();

            disb.DeptId           = deptId;
            disb.StoreClerkId     = storeClerkId;
            disb.RepresentativeId = myBz.FindDeptByDeptId(deptId).RepresentativeId;
            disb.DateCreated      = DateTime.Now;
            disb.Status           = "Pending";
            return(myBz.AddDisbursement(disb));
        }
Beispiel #22
0
        internal void UpdateDisbursementToDisbursed(int id, int disbursementId)
        {
            Disbursement d = FindById(disbursementId);

            if (d.CollectedBy != null)
            {
                d.IdDisbursedBy = id;
                d.IdStatus      = 7;//Disbursed
            }
            context.SaveChanges();
        }
Beispiel #23
0
    ////Set DisbursementListItem Details
    public DisbursementListItems CreateDisbursementListItem(Disbursement disb)
    {
        string depCode         = disb.DeptCode;
        string depName         = disb.Department.DeptName;
        string collectionDate  = disb.CollectionDate.Value.ToLongDateString();
        string collectionTime  = disb.CollectionTime.ToString();
        string collectionPoint = EFBroker_DeptEmployee.GetCollectionPointbyDeptCode(disb.DeptCode).CollectionPoint1;
        DisbursementListItems disbursementListItems = new DisbursementListItems(disb.DisbursementID, collectionDate, collectionTime, depCode, depName, collectionPoint);

        return(disbursementListItems);
    }
        //3
        public int RequestForAcknowledgement(int storeClerkId, int currentDisbId)
        {
            try
            {
                Disbursement currentDisb         = FindDisbById(currentDisbId);
                List <DisbursementDetail> ddList = FindDisbDetByDisbId(currentDisbId);
                Department currentDept           = FindDeptByDeptId(currentDisb.DeptId);

                //create Req Details
                Dictionary <string, int> reqList = new Dictionary <string, int>();
                for (int i = 0; i < ddList.Count; i++)
                {
                    int qtyReq      = ddList[i].QuantityRequested;
                    int qtyReceived = ddList[i].QuantityReceived;

                    if (qtyReceived < qtyReq)
                    {
                        reqList.Add(ddList[i].ItemCode, qtyReq - qtyReceived);
                    }
                }

                //create new requisition to store data for things not disbursed
                if (reqList.Count != 0)
                {
                    Requisition req = new Requisition();
                    req.EmployeeId           = storeClerkId;
                    req.RequisitionDate      = DateTime.Today;
                    req.RequisitionStatus    = "Approved";
                    req.Remark               = $"Additional Requisition due to not fullfilled Disbursement: {currentDisb.DisbursementId}";
                    req.ApprovedByEmployeeId = currentDept.HeadId;
                    AddRequisiton(req);

                    Requisition currentReq = FindLatestReq();
                    foreach (KeyValuePair <string, int> r in reqList)
                    {
                        RequisitionDetail rd = new RequisitionDetail();
                        rd.RequisitionId   = currentReq.RequisitionId;
                        rd.ItemCode        = r.Key;
                        rd.QuantityRequest = r.Value;
                        AddRequisitionDetail(rd);
                    }
                }

                //change disb status to "Waiting for Acknowledgement"
                currentDisb.Status = "Waiting for Acknowledgement";
                UpdateDisbursement(currentDisb);
                return(1);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
Beispiel #25
0
 public DisbursementBO convertDisbursementBO(Disbursement e)
 {
     dbo = new DisbursementBO();
     dbo.DepartmentId         = e.DepartmentID;
     dbo.DisbursementId       = e.DisbursementID;
     dbo.ItemNumber           = e.ItemNumber;
     dbo.OrderQuantity        = e.OrderQuantity;
     dbo.DisbursementQuantity = e.DisbursementQuantity;
     dbo.Status        = e.Status;
     dbo.RequisitionId = e.RequisitionID;
     return(dbo);
 }
Beispiel #26
0
        //Can only allow to decrease Qty and can only change Qty one time.
        public static bool UpdateDisbursement(string ItemID, int newQty)
        {
            //delete the temporary outstandings related to this ItemID
            List <Outstanding> outslist = context.Outstanding.Where(x => x.Status == null && x.ItemID == ItemID).ToList <Outstanding>();

            foreach (Outstanding o in outslist)
            {
                Disbursement d = context.Disbursement.Where(x => x.ItemID == o.ItemID && x.DepartmentID == o.DepartmentID && x.DeliveryID == null).ToList <Disbursement>().FirstOrDefault();
                d.DisbursedQty += o.Qty;
                context.Outstanding.Remove(o);
            }
            context.SaveChanges();

            //restore the request qty
            int outQty = RequestQty(ItemID) - newQty;
            int count  = 0;

            //if the newQty >= the total request Qty, cannot accept
            if (outQty < 0)
            {
                return(false);
            }
            else
            {
                while (outQty > 0)
                {
                    int          lastDep         = LastDepartment(ItemID)[count];
                    Disbursement b               = context.Disbursement.Where(x => x.ItemID == ItemID && x.DepartmentID == lastDep && x.DeliveryID == null).ToList <Disbursement>().First();
                    int          newDisbursedQty = (int)b.DisbursedQty - outQty;
                    Outstanding  o               = new Outstanding();
                    o.DepartmentID = b.DepartmentID;
                    o.ItemID       = b.ItemID;

                    if (newDisbursedQty >= 0)
                    {
                        b.DisbursedQty = newDisbursedQty;
                        o.Qty          = outQty;
                        outQty         = 0;
                    }
                    else
                    {
                        o.Qty          = b.DisbursedQty;
                        b.DisbursedQty = 0;
                        outQty         = -newDisbursedQty;
                    }
                    context.Outstanding.Add(o);
                    context.SaveChanges();
                    count++;
                }

                return(true);
            }
        }
Beispiel #27
0
        public int addDisbursementFromRequisition(int reqId, int disDutyId)
        {
            Disbursement disbursement = new Disbursement();

            disbursement.RequisitionID      = reqId;
            disbursement.DisbursementDutyID = disDutyId;

            context.Disbursements.Add(disbursement);
            context.SaveChanges();

            return(disbursement.DisbursementID);
        }
        public void UpdateRequisitionStatusTest_MultipleRequisition()
        {
            //Act
            //Get test requisition object from db
            Disbursement disbursement = context.Disbursement.Where(x => x.DisbursementId == "TEST").First();
            Requisition  requisition1 = context.Requisition.Where(x => x.RequisitionId == "TEST").First();


            Item item = context.Item.First();

            //Make 2nd Requsition test object
            Requisition requisition2 = new Requisition()
            {
                RequisitionId   = "TEST2",
                Retrieval       = requisition1.Retrieval,
                CreatedDateTime = DateTime.Now
            };

            requisitionRepository.Save(requisition2);


            //make and save  1 requisition detail objects to each requisition
            RequisitionDetail rd1 = new RequisitionDetail()
            {
                Requisition = requisition1,

                Item     = item,
                Quantity = 1
            };

            requisitiondetailRepository.Save(rd1);


            RequisitionDetail rd2 = new RequisitionDetail()
            {
                Requisition = requisition2,
                Item        = item,
                Quantity    = 500
            };

            requisitiondetailRepository.Save(rd2);

            //Arrange
            var result = disbursementService.UpdateRequisitionStatus(disbursement);

            //Assert
            RequisitionDetail result1 = result.Find(x => x.RequisitionId == "TEST").RequisitionDetails.First();
            RequisitionDetail result2 = result.Find(x => x.RequisitionId == "TEST2").RequisitionDetails.First();

            Assert.AreEqual(10, result1.Status.StatusId);
            Assert.AreEqual(9, result2.Status.StatusId);
            Assert.AreEqual(10, result.First().Status.StatusId);
        }
Beispiel #29
0
        /*
         * helper method step 2
         */
        private List <Disbursement> GenerateDisbursementsWithUnfullfilled(List <Disbursement> targetDisbursementsList,
                                                                          DateTime collectionDate)
        {
            var unfufilledDisbursementDetails = _disbursementRepo.GetUnfulfilledDisbursementDetails().ToList();

            foreach (var ufdDetail in unfufilledDisbursementDetails)
            {
                //refactor the remaining qty from unfulfilled details into the new disbursement details
                var unfulfilledDetail         = new DisbursementDetail(ufdDetail);
                var isDisbursementForSameDept = false;
                foreach (var d in targetDisbursementsList)
                {
                    if (d.DeptCode == ufdDetail.Disbursement.DeptCode)
                    {
                        unfulfilledDetail.Stationery = ufdDetail.Stationery;
                        //depends on itemNum, add qty or add as new detail
                        d.Add(unfulfilledDetail);
                        isDisbursementForSameDept = true;
                        break;
                    }
                }

                if (isDisbursementForSameDept)
                {
                    continue;
                }

                //if not for same dept, construct a new disbursement
                var disbursement = new Disbursement(ufdDetail.Disbursement, collectionDate);
                disbursement.Add(unfulfilledDetail);
                targetDisbursementsList.Add(disbursement);
            }

            //since the remaining qty (if any) has been factored into the new disbursement details' requested qty
            //mark processed unfulfilled disbursements fulfilled, and their detail lists' requested qty to be updated to tally status

            foreach (var detail in unfufilledDisbursementDetails)
            {
                detail.RequestedQty = detail.ActualQty;
                _disbursementRepo.UpdateDisbursementDetail(detail);
            }

            var unfulfilledDisList = _disbursementRepo.GetUnfulfilledDisbursements().ToList();

            foreach (var unfd in unfulfilledDisList)
            {
                unfd.Status = DisbursementStatus.Fulfilled;
                _disbursementRepo.Update(unfd);
            }

            return(targetDisbursementsList);
        }
 private void s_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(searchtb.Text))
     {
         List <Disbursement> disbursementList = new List <Disbursement>();
         if (SystemClass.CheckConnection())
         {
             ImusCityHallEntities db = new ImusCityHallEntities();
             foreach (var item in db.Disbursements)
             {
                 var disbursement = new Disbursement()
                 {
                     DisbursementID = item.DisbursementID,
                     VoucherNo      = item.VoucherNo,
                     PayeeName      = item.Payee == null ? item.PayeeName : item.Payee.CompanyName
                 };
                 disbursementList.Add(disbursement);
             }
             voucherlistdg.ItemsSource       = disbursementList;
             voucherlistdg.SelectedValuePath = "DisbursementID";
         }
         else
         {
             MessageBox.Show(SystemClass.DBConnectionErrorMessage);
         }
     }
     else
     {
         List <Disbursement> disbursementList = new List <Disbursement>();
         if (SystemClass.CheckConnection())
         {
             ImusCityHallEntities db = new ImusCityHallEntities();
             foreach (var item in db.Disbursements.Where(m => m.VoucherNo.Contains(searchtb.Text) || m.PayeeName.Contains(searchtb.Text) || m.Payee.CompanyName.Contains(searchtb.Text)))
             {
                 var disbursement = new Disbursement()
                 {
                     DisbursementID = item.DisbursementID,
                     VoucherNo      = item.VoucherNo,
                     PayeeName      = item.Payee == null ? item.PayeeName : item.Payee.CompanyName,
                     DateCreated    = item.DateCreated
                 };
                 disbursementList.Add(disbursement);
             }
             voucherlistdg.ItemsSource       = disbursementList;
             voucherlistdg.SelectedValuePath = "DisbursementID";
         }
         else
         {
             MessageBox.Show(SystemClass.DBConnectionErrorMessage);
         }
     }
 }
        public IHttpActionResult ApproveRequisition([FromBody] RequisitionMobileViewModel requisition)
        {
            try
            {
                // Update requisition status to Approved
                var req = requisitionService.Get(requisition.RequisitionId);
                req.Status = CustomStatus.Approved;
                requisitionService.Save(req);

                var inventoryList        = (List <Inventory>)inventoryService.GetAll();
                var itemRequisitionList  = itemRequisitionService.GetAllByRequisitionId(requisition.RequisitionId);
                var itemDisbursementList = new List <ItemDisbursement>();

                // Add Disbursement
                var disbursement = new Disbursement()
                {
                    DepartmentId = requisition.DepartmentId,
                    Status       = CustomStatus.ForRetrieval
                };

                //Retrieve all itemDisbursements meant for retrieval
                var allItemDisbursements = (List <ItemDisbursement>)disbursementService.getAllItemDisbursementsByStatus(CustomStatus.ForRetrieval);

                //Allocate itemrequisition details to itemdisbursement
                foreach (var itemReq in itemRequisitionList)
                {
                    var itemDisbursement = new ItemDisbursement()
                    {
                        DisbursementId    = disbursement.Id,
                        ItemId            = itemReq.ItemId,
                        RequestedQuantity = itemReq.Quantity,
                        AvailableQuantity = 0
                    };
                    itemDisbursementList.Add(itemDisbursement);
                }

                disbursementService.Save(disbursement);

                //Allocate available quantity by inventory availability
                List <ItemDisbursement> finalItemDisbursementList = AllocateAvailableQtyAndStatus(itemDisbursementList, inventoryList, allItemDisbursements);
                foreach (var ib in finalItemDisbursementList)
                {
                    itemDisbursementService.Save(ib);
                }
            }
            catch (Exception)
            {
                return(BadRequest("Requisition already approved"));
            }

            return(Ok());
        }
Beispiel #32
0
        public static DisbursementAPIModel DisbursementConverttoDisbursementAPIModel(Disbursement d)
        {
            DisbursementAPIModel apimodel = new DisbursementAPIModel
            {
                Id = d.Id,
                CollectionPointId = d.Department.CollectionPointId,
                DateRequested     = d.DateRequested,
                DepartmentName    = d.Department.Name,
                DisbursedDate     = d.DisbursedDate
            };

            return(apimodel);
        }
        // without currency and associated cheque
        public static Payment SaveToDisburseCash(DateTime transactdate, DateTime entrydate, Payment parent, int processedTo, int processedby, decimal AmountTodisburse, SpecificPaymentType specifictype, DisbursementType distype, string DisbursedToName)
        {
            Payment cashpayment = new Payment();
            cashpayment.PaymentMethodType = PaymentMethodType.CashType;
            cashpayment.Payment2 = parent;
            cashpayment.ProcessedToPartyRoleId = processedTo;
            cashpayment.ProcessedByPartyRoleId = processedby;

            cashpayment.TransactionDate = transactdate;
            cashpayment.EntryDate = entrydate;
            cashpayment.TotalAmount = AmountTodisburse;
            cashpayment.PaymentType = PaymentType.Disbursement;
            cashpayment.SpecificPaymentType = specifictype;
            ObjectContext.Payments.AddObject(cashpayment);

            Disbursement disbursement = new Disbursement();
            disbursement.Payment = cashpayment;
            disbursement.DisbursementType = distype;
            if (string.IsNullOrEmpty(DisbursedToName) == false)
                disbursement.DisbursedToName = DisbursedToName;
            ObjectContext.Disbursements.AddObject(disbursement);
            return cashpayment;
        }
        public static void SaveToDisbursementCheques(DateTime transactdate, DateTime entrydate, Payment parent, List<AddChequesModel> Cheques, int processedTo, int processedby, SpecificPaymentType specifictype, DisbursementType distype, string DisbursedToName, int CurrencyId)
        {
            foreach (var cheque in Cheques)
            {
                PaymentMethodType type = PaymentMethodType.PayCheckType;
                if (cheque.CheckType == PaymentMethodType.PersonalCheckType.Name)
                    type = PaymentMethodType.PersonalCheckType;
                Payment chequepayment = new Payment();

                chequepayment.PaymentMethodType = type;
                chequepayment.Payment2 = parent;
                chequepayment.ProcessedToPartyRoleId = processedTo;
                chequepayment.ProcessedByPartyRoleId = processedby;
                chequepayment.PaymentReferenceNumber = cheque.CheckNumber;
                chequepayment.TransactionDate = transactdate;
                chequepayment.EntryDate = entrydate;
                chequepayment.TotalAmount = cheque.Amount;
                chequepayment.PaymentType = PaymentType.Disbursement;
                chequepayment.SpecificPaymentType = specifictype;
                ObjectContext.Payments.AddObject(chequepayment);

                Disbursement disbursement = new Disbursement();
                disbursement.Payment = chequepayment;
                disbursement.DisbursementType = distype;
                if (string.IsNullOrEmpty(DisbursedToName) == false)
                    disbursement.DisbursedToName = DisbursedToName;
                ObjectContext.Disbursements.AddObject(disbursement);

                Cheque newCheque = new Cheque();
                newCheque.BankPartyRoleId = cheque.BankPartyRoleId;
                newCheque.Payment = chequepayment;
                newCheque.CheckDate = cheque.CheckDate;
                ObjectContext.Cheques.AddObject(newCheque);

                ChequeStatu newChequeStatus = new ChequeStatu();
                newChequeStatus.Cheque = newCheque;
                newChequeStatus.CheckStatusTypeId = ChequeStatusType.ClearedType.Id;
                newChequeStatus.TransitionDateTime = entrydate;
                newChequeStatus.IsActive = true;
                ObjectContext.ChequeStatus.AddObject(newChequeStatus);

                Currency.CreatePaymentCurrencyAssoc(chequepayment, CurrencyId);

            }
        }
        public void actionUpdateToDisbursement(int req_dept, int stationery)
        {
            FulfillmentController fc = new FulfillmentController();

            rf=fc.actionGetFulfillmentByDepartmentAndStationery(req_dept, stationery);

            // -------------- Disbursement Table Process ----------
            disbursement = actionGetDisbursementByDepartmentAndTodayDate(req_dept);

            if (disbursement == null)
                actionCreateDisbursementTable(req_dept, getDeptRept(req_dept));

            disbursementId=actionGetDisbursementIdByDepartmentAndDate(req_dept, disbursement.distributed_date);

            // -------------- Disbursement Detail Table Process ----------
            disbursementDetail = actionGetDisbursementDetailByDepartmentAndStationery(stationery);

            if (disbursementDetail == null)
                actionCreateDisbursementDetailTable();
            else
                actionUpdateDisbursementDetailTable();

            // -------------- Update Stationery Process ----------
            new StationeryController().actionUpdateQty(rf.stationery, rf.fulfill_quantity);

            // -------------- Update StockTransaction Process ----------
            new StockTransactionController().actionCreateStockTransaction(stationery, new StationeryController().actionGetQtyInStock(stationery),
                "Disbursement", "- "+rf.fulfill_quantity.ToString());

            // -------------- Remaining Requisition Fulfillment Process ----------
            unfulfillQty = rf.requested_quantity - rf.fulfill_quantity;
            if (unfulfillQty == 0)
                fc.actionDeleteFulfillmentByObject(rf);
            else
                fc.actionUpdateFulfillmentByObject(rf, unfulfillQty);

            // -------------- Update Requisition Status Process ----------
            new RequisitionController().actionRequisitionStatusChangeToDistributedByDepartment(stationery, req_dept);
        }