public ActionResult Index(string message = "") { ViewBag.ErrorMessage = message; ReceiptListModel model = new ReceiptListModel(); model.SOBId = SessionHelper.SOBId; if (model.Periods == null) { model.Periods = ReceivablePeriodHelper.GetPeriodList(Convert.ToInt64(SessionHelper.SOBId)); model.PeriodId = model.Periods.Any() ? Convert.ToInt32(model.Periods.First().Value) : 0; } else if (model.Periods == null) { model.Periods = new List <SelectListItem>(); } CalendarViewModel calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(model.PeriodId.ToString()).CalendarId.ToString()); if (calendar == null) { SessionHelper.Calendar.StartDate = DateTime.Now; SessionHelper.Calendar.EndDate = DateTime.Now; } else { SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(model.PeriodId.ToString()).CalendarId.ToString()); } if (model.Customers == null) { model.Customers = customerService.GetAll(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId, SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate). Select(a => new SelectListItem { Text = a.CustomerName.ToString(), Value = a.Id.ToString() }).ToList(); } model.CustomerId = model.Customers.Count() > 0 ? Convert.ToInt64(model.Customers.FirstOrDefault().Value) : 0; if (model.Currency == null) { model.Currency = CurrencyHelper.GetCurrencies(Convert.ToInt32(SessionHelper.SOBId)) .Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList(); model.CurrencyId = model.Currency.Any() ? Convert.ToInt32(model.Currency.First().Value) : 0; } else if (model.Currency == null) { model.Currency = new List <SelectListItem>(); } return(View(model)); }
public JsonResult CustomerList(long periodId) { SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(periodId.ToString()).CalendarId.ToString()); List <SelectListItem> customerList = CustomerHelper.GetCustomers(SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate).Select(x => new SelectListItem { Text = x.CustomerName, Value = x.Id.ToString() }).ToList(); return(Json(customerList, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(long periodId, long customerId, long currencyId) { ReceiptViewModel receipt = new ReceiptViewModel(); SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(periodId.ToString()).CalendarId.ToString()); receipt.PeriodId = SessionHelper.Calendar.Id; receipt.SOBId = SessionHelper.SOBId; receipt.CustomerId = customerId; receipt.CurrencyId = currencyId; receipt.ConversionRate = 1; receipt.ReceiptDate = SessionHelper.Calendar.StartDate; SessionHelper.PrecisionLimit = CurrencyHelper.GetCurrency(currencyId.ToString()).Precision; if (receipt.CustomerSites == null) { receipt.CustomerSites = CustomerHelper.GetCustomerSites(receipt.CustomerId).Select(a => new SelectListItem { Text = a.SiteName.ToString(), Value = a.Id.ToString() }).ToList(); } else { receipt.CustomerSites = new List <SelectListItem>(); } if (receipt.Banks == null) { receipt.Banks = BankHelper.GetBankList(receipt.SOBId); } else { receipt.Banks = new List <SelectListItem>(); } receipt.BankId = receipt.Banks.Count() > 0 ? Convert.ToInt64(receipt.Banks.FirstOrDefault().Value) : 0; if (receipt.BankAccounts == null) { receipt.BankAccounts = BankHelper.GetBankAccountList(receipt.BankId); } else { receipt.BankAccounts = new List <SelectListItem>(); } return(View(receipt)); }
public ActionResult Create() { InvoiceModel model = SessionHelper.Invoice; if (model == null) { model = new InvoiceModel { CompanyId = AuthenticationHelper.CompanyId.Value, InvoiceDetail = new List <InvoiceDetailModel>(), InvoiceNo = "New", SOBId = SessionHelper.SOBId, ConversionRate = 1 }; SessionHelper.Invoice = model; } model.Currencies = CurrencyHelper.GetCurrencyList(SessionHelper.SOBId); //model.Periods = CalendarHelper.GetCalendarsList(SessionHelper.SOBId); model.Periods = ReceivablePeriodHelper.GetPeriodList(SessionHelper.SOBId); if (model.Currencies != null && model.Currencies.Count() > 0) { model.CurrencyId = Convert.ToInt64(model.Currencies.FirstOrDefault().Value); SessionHelper.PrecisionLimit = CurrencyHelper.GetCurrency(model.CurrencyId.ToString()).Precision; } if (model.Periods != null && model.Periods.Count() > 0) { model.PeriodId = Convert.ToInt64(model.Periods.FirstOrDefault().Value); //SessionHelper.Calendar = CalendarHelper.GetCalendar(model.PeriodId.ToString()); SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(model.PeriodId.ToString()).CalendarId.ToString()); model.InvoiceDate = SessionHelper.Calendar.StartDate; model.Customers = CustomerHelper.GetCustomersCombo(SessionHelper.Calendar.StartDate, SessionHelper.Calendar.EndDate); if (model.Customers != null && model.Customers.Count() > 0) { model.CustomerId = Convert.ToInt64(model.Customers.FirstOrDefault().Value); model.CustomerSites = CustomerHelper.GetCustomerSitesCombo(model.CustomerId); if (model.CustomerSites != null && model.CustomerSites.Count() > 0) { model.CustomerSiteId = Convert.ToInt64(model.CustomerSites.FirstOrDefault().Value); } } } return(View("Edit", model)); }
public ActionResult Delete(string id) { List <InventoryPeriod> inventoryPeriods = InventoryPeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList(); List <PayablePeriod> payablePeriods = PayablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList(); List <ReceivablePeriod> receivablePeriods = ReceivablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList(); if (inventoryPeriods.Any() || payablePeriods.Any() || receivablePeriods.Any()) { throw new Exception("Delete Error", new Exception { Source = "Calendar cannot be deleted because it is being used." }); } CalendarHelper.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Edit(string id) { List <InventoryPeriod> inventoryPeriods = InventoryPeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList(); List <PayablePeriod> payablePeriods = PayablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList(); List <ReceivablePeriod> receivablePeriods = ReceivablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList(); if (inventoryPeriods.Any() || payablePeriods.Any() || receivablePeriods.Any()) { throw new Exception("Edit Error", new Exception { Source = "Calendar cannot be deleted because it is being used." }); } CalendarViewModel model = CalendarHelper.GetCalendar(id); return(View(model)); }
public ActionResult DeleteInline(ReceivablePeriodModel model) { if (ModelState.IsValid) { try { ReceivablePeriodHelper.Delete(model.Id.ToString()); return(PartialView("_List", ReceivablePeriodHelper.GetReceivablePeriods(SessionHelper.SOBId))); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_List", ReceivablePeriodHelper.GetReceivablePeriods(SessionHelper.SOBId))); }
public ActionResult UpdateInline(ReceivablePeriodModel model) { if (ModelState.IsValid) { try { model.SOBId = SessionHelper.SOBId; model.CompanyId = AuthenticationHelper.CompanyId.Value; ReceivablePeriodHelper.Save(model); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_List", ReceivablePeriodHelper.GetReceivablePeriods(SessionHelper.SOBId))); }
public ActionResult Edit(string id, long currencyId, long periodId) { InvoiceModel model = InvoiceHelper.GetInvoice(id); SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(periodId.ToString()).CalendarId.ToString()); SessionHelper.PrecisionLimit = CurrencyHelper.GetCurrency(currencyId.ToString()).Precision; model.InvoiceDetail = InvoiceHelper.GetInvoiceDetail(id); model.CurrencyId = currencyId; model.SOBId = SessionHelper.SOBId; model.PeriodId = periodId; CustomerModel customer = CustomerHelper.GetCustomer(model.CustomerId.ToString()); CustomerSiteModel customerSite = CustomerHelper.GetCustomerSite(model.CustomerSiteId.ToString()); ///TODO: Plz check the code. model.Customers = new List <SelectListItem>(); model.Customers.Add(new SelectListItem { Value = customer.Id.ToString(), Text = customer.CustomerName }); model.CustomerSites = new List <SelectListItem>(); model.CustomerSites.Add(new SelectListItem { Value = customerSite.Id.ToString(), Text = customerSite.SiteName }); model.Currencies = CurrencyHelper.GetCurrencyList(SessionHelper.SOBId); //model.Periods = CalendarHelper.GetCalendarsList(SessionHelper.SOBId); model.Periods = ReceivablePeriodHelper.GetPeriodList(SessionHelper.SOBId); SessionHelper.Invoice = model; return(View(model)); }
public JsonResult PeriodList() { List <SelectListItem> periodList = ReceivablePeriodHelper.GetPeriodList(SessionHelper.SOBId); return(Json(periodList, JsonRequestBehavior.AllowGet)); }
public ActionResult ListPartial(long periodId, long customerId, long currencyId) { SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(periodId.ToString()).CalendarId.ToString()); return(PartialView("_List", ReceiptHelper.GetReceipts(SessionHelper.SOBId, SessionHelper.Calendar.Id, customerId, currencyId))); }
public void AddCalendarinSession(long periodId) { SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(periodId.ToString()).CalendarId.ToString()); }
public ActionResult GetReceivablePeriods(long sobId) { return(PartialView("_List", ReceivablePeriodHelper.GetReceivablePeriods(SessionHelper.SOBId))); }