Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
 public ActionResult DeleteInline(InvoiceTypeModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             InvoiceTypeHelper.Delete(model.Id.ToString());
             return(PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)));
 }
 public ActionResult GetInvoiceTypes()
 {
     return(PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)));
 }
Exemplo n.º 5
0
        public JsonResult InvoiceTypeList()
        {
            List <SelectListItem> invoiceTypeList = InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId, SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);

            return(Json(invoiceTypeList, JsonRequestBehavior.AllowGet));
        }