コード例 #1
0
        public ActionResult Create()
        {
            PayableInvoiceModel model = SessionHelper.PayableInvoice;

            if (model == null)
            {
                model = new PayableInvoiceModel
                {
                    CompanyId     = AuthenticationHelper.CompanyId.Value,
                    InvoiceDetail = new List <PayableInvoiceDetailModel>(),
                    Periods       = new List <SelectListItem>(),
                    Vendors       = new List <SelectListItem>(),
                    VendorSites   = new List <SelectListItem>(),
                    WHTaxes       = new List <SelectListItem>(),
                    InvoiceTypes  = new List <SelectListItem>(),
                    InvoiceNo     = "New",
                    SOBId         = SessionHelper.SOBId
                };
            }

            model.Periods = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);

            if (model.Periods != null && model.Periods.Count() > 0)
            {
                model.PeriodId         = Convert.ToInt64(model.Periods.FirstOrDefault().Value);
                SessionHelper.Calendar = CalendarHelper.GetCalendar(model.PeriodId.ToString());
                model.InvoiceDate      = SessionHelper.Calendar.StartDate;

                model.InvoiceTypes = InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId, SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);

                if (model.InvoiceTypes != null && model.InvoiceTypes.Count() > 0)
                {
                    model.InvoiceTypeId = Convert.ToInt64(model.InvoiceTypes.FirstOrDefault().Value);
                }

                model.Vendors = VendorHelper.GetVendorList(SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);

                if (model.Vendors != null && model.Vendors.Count() > 0)
                {
                    model.VendorId    = Convert.ToInt64(model.Vendors.FirstOrDefault().Value);
                    model.VendorSites = VendorHelper.GetVendorSiteList(model.VendorId);

                    if (model.VendorSites != null && model.VendorSites.Count() > 0)
                    {
                        model.VendorSiteId = Convert.ToInt64(model.VendorSites.FirstOrDefault().Value);
                        model.WHTaxes      = WithholdingHelper.GetWithHoldingList(model.VendorId, model.VendorSiteId, SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);

                        if (model.WHTaxId != null && model.WHTaxes.Count() > 0)
                        {
                            model.WHTaxId = Convert.ToInt64(model.WHTaxes.FirstOrDefault().Value);
                        }
                    }
                }
            }

            SessionHelper.PayableInvoice = model;
            return(View("Edit", model));
        }
コード例 #2
0
        public ActionResult Edit(string id, long periodId)
        {
            PayableInvoiceModel model = PayableInvoiceHelper.GetInvoice(id);

            SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(periodId.ToString()).CalendarId.ToString());

            model.InvoiceDetail = PayableInvoiceHelper.GetInvoiceDetail(id);
            model.SOBId         = SessionHelper.SOBId;
            model.PeriodId      = periodId;
            model.Periods       = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);

            VendorModel      vendors      = VendorHelper.GetSingle(model.VendorId.ToString());
            VendorSiteModel  vendorSites  = VendorHelper.GetSingle(model.VendorSiteId);
            InvoiceTypeModel invoiceTypes = InvoiceTypeHelper.GetInvoiceType(model.InvoiceTypeId.ToString());

            ///TODO: Plz do the code audit.
            model.Vendors = new List <SelectListItem>();
            model.Vendors.Add(new SelectListItem
            {
                Value = vendors.Id.ToString(),
                Text  = vendors.Name
            });
            model.VendorSites = new List <SelectListItem>();
            model.VendorSites.Add(new SelectListItem
            {
                Value = vendorSites.Id.ToString(),
                Text  = vendorSites.Name
            });

            model.WHTaxes = new List <SelectListItem>();
            if (model.WHTaxId != null)
            {
                WithholdingModel withHoldingTaxes = WithholdingHelper.GetWithholding(model.WHTaxId.ToString());
                model.WHTaxes.Add(new SelectListItem
                {
                    Value = withHoldingTaxes.Id.ToString(),
                    Text  = withHoldingTaxes.Description
                });
            }

            model.InvoiceTypes = new List <SelectListItem>();
            model.InvoiceTypes.Add(new SelectListItem
            {
                Value = invoiceTypes.Id.ToString(),
                Text  = invoiceTypes.Description
            });

            SessionHelper.PayableInvoice = model;
            return(View(model));
        }
コード例 #3
0
 public ActionResult DeleteInline(WithholdingModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             WithholdingHelper.Delete(model.Id.ToString());
             return(PartialView("_List", WithholdingHelper.GetWithholdings(model.SOBId, model.CodeCombinitionId, model.VendorId)));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", WithholdingHelper.GetWithholdings(model.SOBId, model.CodeCombinitionId, model.VendorId)));
 }
コード例 #4
0
        public ActionResult AddNewInline(WithholdingModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.VendorId          = SessionHelper.VendorId;
                    model.SOBId             = SessionHelper.SOBId;
                    model.CodeCombinitionId = SessionHelper.CodeCombinitionId;

                    WithholdingHelper.Save(model);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_List", WithholdingHelper.GetWithholdings(model.SOBId, model.CodeCombinitionId, model.VendorId)));
        }
コード例 #5
0
        public JsonResult WHTaxList(long vendorId, long vendorSiteId)
        {
            List <SelectListItem> whTaxList = WithholdingHelper.GetWithHoldingList(vendorId, vendorSiteId, SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);

            return(Json(whTaxList, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
 public ActionResult GetWithholdings(long codeCombinitionId, long vendorId)
 {
     SessionHelper.CodeCombinitionId = codeCombinitionId;
     SessionHelper.VendorId          = vendorId;
     return(PartialView("_List", WithholdingHelper.GetWithholdings(SessionHelper.SOBId, codeCombinitionId, vendorId)));
 }
コード例 #7
0
 public ActionResult CreatePartial()
 {
     return(PartialView("_List", WithholdingHelper.GetWithholdings(SessionHelper.SOBId, SessionHelper.CodeCombinitionId, SessionHelper.VendorId)));
 }