private JournalVoucherViewModel mapModel(JournalVoucherCreateModel model, JournalVoucherViewModel jv) { jv.CompanyId = AuthenticationHelper.User.CompanyId; jv.ConversionRate = model.ConversionRate; jv.CurrencyId = model.CurrencyId; jv.Description = model.Description; jv.DocumentNo = model.DocumentNo; jv.GLDate = model.GLDate; jv.Id = model.HeaderId; jv.JournalName = model.JournalName; if (jv.JournalVoucherDetail == null) { jv.JournalVoucherDetail = new List<JournalVoucherDetailModel>(); } jv.JournalVoucherDetail.Add(new JournalVoucherDetailModel { AccountedCr = model.AccountedCr, AccountedDr = model.AccountedDr, CodeCombinationId = model.CodeCombinationId, Description = model.GLLinesDescription, EnteredCr = model.EnteredCr, EnteredDr = model.EnteredDr, HeaderId = model.HeaderId, Id = model.Id, Qty = model.Qty, TaxRateCode = model.TaxRateCode }); jv.PeriodId = model.PeriodId; jv.SOBId = model.SOBId; return jv; }
public ActionResult Create(long sobId, long periodId, long currencyId) { if (sobId > 0 && periodId > 0 && currencyId > 0) { JournalVoucherCreateModel model = new JournalVoucherCreateModel(); model.SOBId = sobId; model.PeriodId = periodId; model.CurrencyId = currencyId; model.SOBName = sobService.GetSingle(sobId.ToString(), AuthenticationHelper.User.CompanyId).Name; SessionHelper.Calendar = new CalendarViewModel(calendarService.GetSingle(periodId.ToString(), AuthenticationHelper.User.CompanyId)); model.GLDate = SessionHelper.Calendar.StartDate; model.ConversionRate = 1; model.PeriodName = SessionHelper.Calendar.PeriodName; model.CurrencyName = currencyService.GetSingle(currencyId.ToString(), AuthenticationHelper.User.CompanyId).Name; model.CodeCombinationList = codeCombinitionService.GetAll(AuthenticationHelper.User.CompanyId, model.SOBId, "", false, null, "", "") .Select(x => new SelectListItem { Text = x.CodeCombinitionCode, Value = x.Id.ToString() }).ToList(); return View(model); } else { return RedirectToAction("Index"); } }
public ActionResult Edit(JournalVoucherCreateModel model) { model.CodeCombinationList = codeCombinitionService.GetAll(AuthenticationHelper.User.CompanyId, model.SOBId, "", false, null, "", "") .Select(x => new SelectListItem { Text = x.CodeCombinitionCode, Value = x.Id.ToString() }).ToList(); return View(model); }
public ActionResult Create(JournalVoucherCreateModel model) { if (ModelState.IsValid) { if (model.GLDate < SessionHelper.Calendar.StartDate || model.GLDate > SessionHelper.Calendar.EndDate) { ModelState.AddModelError("Error", "Invalid Effective date"); } else { SessionHelper.JournalVoucher = mapModel(model, SessionHelper.JournalVoucher); ////model.HeaderId = ?????, ////model.Id = ????, ////model.CodeCombinationId = ????; model.GLLinesDescription = ""; model.EnteredDr = 0; model.AccountedDr = 0; model.EnteredCr = 0; model.AccountedCr = 0; model.Qty = 0; model.TaxRateCode = 0; return RedirectToAction("Edit", model); } } return View(model); }
public ActionResult Edit(JournalVoucherCreateModel model, string submit) { if (ModelState.IsValid) { if (model.GLDate < SessionHelper.Calendar.StartDate || model.GLDate > SessionHelper.Calendar.EndDate) { ModelState.AddModelError("Error", "Invalid Effective date"); } else { SessionHelper.JournalVoucher = mapModel(model, SessionHelper.JournalVoucher); if (submit == "Save") { long result = saveJournalVoucher(SessionHelper.JournalVoucher); if (result > 0) { return RedirectToAction("Index"); } else { ModelState.AddModelError("Error", "Unable to save!"); } } else { ////model.HeaderId = ?????, ////model.Id = ????, ////model.CodeCombinationId = ????; model.GLLinesDescription = ""; model.EnteredDr = 0; model.AccountedDr = 0; model.EnteredCr = 0; model.AccountedCr = 0; model.Qty = 0; model.TaxRateCode = 0; return RedirectToAction("Edit", model); //return View("Edit", model); } } } return View(model); }