Exemple #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));
        }
Exemple #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 Create()
        {
            PaymentViewModel model = new PaymentViewModel();

            model.Period   = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);
            model.PeriodId = model.Period.Any() ? Convert.ToInt64(model.Period.First().Value) : 0;
            if (model.Period != null && model.Period.Count() > 0)
            {
                SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(model.PeriodId.ToString()).CalendarId.ToString());

                model.Bank   = BankHelper.GetBankList(SessionHelper.SOBId);
                model.BankId = model.Bank.Any() ? Convert.ToInt64(model.Bank.First().Value) : 0;
                if (model.Bank != null && model.Bank.Count() > 0)
                {
                    model.BankAccount   = BankHelper.GetBankAccountList(model.BankId);
                    model.BankAccountId = model.BankAccount.Any() ?
                                          Convert.ToInt32(model.BankAccount.First().Value) : 0;
                }

                model.Vendor   = VendorHelper.GetVendorList(SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);
                model.VendorId = model.Vendor.Any() ? Convert.ToInt64(model.Vendor.First().Value) : 0;
                if (model.Vendor != null && model.Vendor.Count() > 0)
                {
                    model.VendorSite   = VendorHelper.GetVendorSiteList(model.VendorId);
                    model.VendorSiteId = model.VendorSite.Any() ? Convert.ToInt64(model.VendorSite.First().Value) : 0;
                }
            }

            SessionHelper.Payment = model;
            if (SessionHelper.Payment.PaymentInvoiceLines == null)
            {
                SessionHelper.Payment.PaymentInvoiceLines = new List <PaymentInvoiceLinesModel>();
            }


            return(View(model));
        }
Exemple #4
0
        public JsonResult PeriodList()
        {
            List <SelectListItem> periodList = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);

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