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));
        }
Пример #3
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));
        }
Пример #4
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 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));
        }
Пример #7
0
 public ActionResult DeleteInline(PayablePeriodModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PayablePeriodHelper.Delete(model.Id.ToString());
             return(PartialView("_List", PayablePeriodHelper.GetPayablePeriods(SessionHelper.SOBId)));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", PayablePeriodHelper.GetPayablePeriods(SessionHelper.SOBId)));
 }
        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));
        }
Пример #9
0
 public void AddCalendarInSession(long periodId)
 {
     SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(periodId.ToString()).CalendarId.ToString());
 }
Пример #10
0
        public JsonResult PeriodList()
        {
            List <SelectListItem> periodList = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);

            return(Json(periodList, JsonRequestBehavior.AllowGet));
        }
Пример #11
0
 public ActionResult GetPayablePeriods()
 {
     return(PartialView("_List", PayablePeriodHelper.GetPayablePeriods(SessionHelper.SOBId)));
 }