public ActionResult SaveVoucher(string journalName, string glDate, string cRate, string descr, long periodId, long currencyId) { string message = ""; try { bool saved = false; if (SessionHelper.JV != null) { if (SessionHelper.JV.GlLines.Count == 0) { message = "No Voucher Detail information available!"; } else if (SessionHelper.JV.GlLines.Sum(cri => cri.EnteredDr) == SessionHelper.JV.GlLines.Sum(cri => cri.EnteredCr)) { SessionHelper.PrecisionLimit = CurrencyHelper.GetCurrency(currencyId.ToString()).Precision; SessionHelper.JV.JournalName = journalName; SessionHelper.JV.GLDate = Convert.ToDateTime(glDate); SessionHelper.JV.ConversionRate = Convert.ToDecimal(cRate); SessionHelper.JV.Description = descr; SessionHelper.JV.PeriodId = periodId; SessionHelper.JV.CurrencyId = currencyId; if (SessionHelper.JV.GLDate >= SessionHelper.Calendar.StartDate && SessionHelper.JV.GLDate <= SessionHelper.Calendar.EndDate) { if (SessionHelper.JV.DocumentNo == "New") { SessionHelper.JV.DocumentNo = JVHelper.GetDocNo(AuthenticationHelper.CompanyId.Value, SessionHelper.JV.PeriodId, SessionHelper.JV.SOBId, SessionHelper.JV.CurrencyId); } JVHelper.Update(SessionHelper.JV); SessionHelper.JV = null; saved = true; } else { message = "GL Date must lie in the range of the selected period"; } } else { message = "The sum of Debit and Credit should be equal."; } } else { message = "No voucher information available!"; } return(Json(new { success = saved, message = message })); } catch (Exception e) { message = e.Message; return(Json(new { success = false, message = message })); } }
public ActionResult Delete(string id) { try { JVHelper.Delete(id); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index", new { message = ex.Message })); } }
public ActionResult AddNewPartial(GLLinesModel model) { if (ModelState.IsValid) { try { bool validated = false; if (model.EnteredCr > 0 && model.EnteredDr > 0) { ViewData["EditError"] = "Both debit and credit can not be entered in one entry."; return(PartialView("createPartial", JVHelper.GetGLLines())); } if (SessionHelper.JV.GlLines.Count != 0) { if (SessionHelper.JV.GlLines.Any(rec => rec.CodeCombinationId == model.CodeCombinationId)) { ViewData["EditError"] = "Duplicate accounts can not be added."; } else { validated = true; model.Id = SessionHelper.JV.GlLines.Last().Id + 1; } } else { model.Id = 1; validated = true; } if (validated) { JVHelper.Insert(model); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", JVHelper.GetGLLines())); }
public ActionResult Edit(string id, long currencyId, long periodId) { GLHeaderModel model = JVHelper.GetGLHeaders(id); SessionHelper.Calendar = new CalendarViewModel(calendarService.GetSingle(periodId.ToString(), AuthenticationHelper.CompanyId.Value)); SessionHelper.PrecisionLimit = currencyService.GetSingle(currencyId.ToString(), AuthenticationHelper.CompanyId.Value).Precision; model.GlLines = JVHelper.GetGLLines(id); model.CurrencyId = currencyId; model.SOBId = SessionHelper.SOBId; model.PeriodId = periodId; SessionHelper.JV = model; model.Currencies = CurrencyHelper.GetCurrencyList(SessionHelper.SOBId); model.Periods = CalendarHelper.GetCalendarsList(SessionHelper.SOBId); return(View("Create", model)); }
public ActionResult UpdatePartial(GLLinesModel model) { if (ModelState.IsValid) { try { JVHelper.UpdateGLLine(model); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", JVHelper.GetGLLines())); }
public ActionResult DeletePartial(GLLinesModel model) { if (ModelState.IsValid) { try { GLHeaderModel header = SessionHelper.JV; JVHelper.DeleteGLLine(model); SessionHelper.JV = header; IList <GLLinesModel> glLines = JVHelper.GetGLLines(); return(PartialView("createPartial", glLines)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial")); }
public ActionResult CreatePartial() { return(PartialView("createPartial", JVHelper.GetGLLines())); }
public ActionResult ListPartial() { return(PartialView("_List", JVHelper .GetGLHeaders(SessionHelper.SOBId))); }