public ActionResult Edit(string id)
        {
            PaymentViewModel model = PaymentHelper.GetPayment(id);

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

            if (model.BankAccount == null)
            {
                model.BankAccount   = BankHelper.GetBankAccountList(model.BankId);
                model.BankAccountId = model.BankAccount.Any() ?
                                      Convert.ToInt32(model.BankAccount.First().Value) : 0;
            }
            if (model.VendorSite == null)
            {
                model.VendorSite = VendorHelper.GetAllSites(model.VendorId)
                                   .Select(x => new SelectListItem
                {
                    Text  = x.Name,
                    Value = x.Id.ToString()
                }).ToList();
                model.VendorSiteId = model.VendorSite.Any() ?
                                     Convert.ToInt32(model.VendorSite.First().Value) : 0;
            }

            model.PaymentInvoiceLines = PaymentHelper.GetPaymentLines(id).ToList();
            model.SOBId           = SessionHelper.SOBId;
            SessionHelper.Payment = model;

            return(View("Create", model));
        }
        public ActionResult GetDatabyPeriod(long periodId)
        {
            PaymentViewModel model = new PaymentViewModel();

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

            if (model.Vendor == null)
            {
                model.Vendor   = VendorHelper.GetVendorList(SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate);
                model.VendorId = model.Vendor.Any() ? Convert.ToInt32(model.Vendor.First().Value) : 0;

                if (model.VendorId > 0)
                {
                    model.VendorSite   = VendorHelper.GetVendorSiteList(model.VendorId);
                    model.VendorSiteId = model.VendorSite.Any() ? Convert.ToInt64(model.VendorSite.First().Value) : 0;
                }
            }

            if (model.Bank == null)
            {
                model.Bank   = BankHelper.GetBankList(model.SOBId);
                model.BankId = model.Bank.Any() ? Convert.ToInt32(model.Bank.First().Value) : 0;

                if (model.BankId > 0)
                {
                    model.BankAccount   = BankHelper.GetBankAccountList(model.BankId);
                    model.BankAccountId = model.BankAccount.Any() ? Convert.ToInt64(model.BankAccount.First().Value) : 0;
                }
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 5
0
 public void AddCalendarInSession(long periodId)
 {
     SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(periodId.ToString()).CalendarId.ToString());
 }