Example #1
0
        public ActionResult AddNewPartial(PayableInvoiceDetailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (SessionHelper.PayableInvoice != null)
                    {
                        if (SessionHelper.PayableInvoice.InvoiceDetail != null && SessionHelper.PayableInvoice.InvoiceDetail.Count > 0)
                        {
                            model.Id = SessionHelper.PayableInvoice.InvoiceDetail.LastOrDefault().Id + 1;
                        }
                        else
                        {
                            model.Id = 1;
                        }
                    }
                    else
                    {
                        model.Id = 1;
                    }

                    PayableInvoiceHelper.Insert(model);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_Detail", PayableInvoiceHelper.GetInvoiceDetail()));
        }
Example #2
0
 public ActionResult Delete(string id)
 {
     try
     {
         PayableInvoiceHelper.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", new { message = ex.Message }));
     }
 }
Example #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));
        }
Example #4
0
        public ActionResult SaveInvoice(long periodId, long invoiceTypeId,
                                        string invoiceDate, string remarks, long vendorId, long vendorSiteId,
                                        long?whTaxId, string amount, string status)
        {
            string message = "";

            try
            {
                bool saved = false;
                if (SessionHelper.PayableInvoice != null)
                {
                    if (SessionHelper.PayableInvoice.InvoiceDetail.Count == 0)
                    {
                        message = "No detail information available to save!";
                    }
                    else
                    {
                        SessionHelper.PayableInvoice.PeriodId      = periodId;
                        SessionHelper.PayableInvoice.InvoiceTypeId = invoiceTypeId;
                        SessionHelper.PayableInvoice.InvoiceDate   = Convert.ToDateTime(invoiceDate);
                        SessionHelper.PayableInvoice.Remarks       = remarks;
                        SessionHelper.PayableInvoice.VendorId      = vendorId;
                        SessionHelper.PayableInvoice.VendorSiteId  = vendorSiteId;
                        SessionHelper.PayableInvoice.WHTaxId       = whTaxId;
                        SessionHelper.PayableInvoice.Amount        = SessionHelper.PayableInvoice.InvoiceDetail.Sum(x => x.Amount);
                        SessionHelper.PayableInvoice.Status        = status;
                        if (SessionHelper.PayableInvoice.InvoiceNo == "New")
                        {
                            SessionHelper.PayableInvoice.InvoiceNo = PayableInvoiceHelper.GetInvoiceNo(AuthenticationHelper.CompanyId.Value, SessionHelper.PayableInvoice.SOBId, SessionHelper.PayableInvoice.PeriodId);
                        }

                        PayableInvoiceHelper.Update(SessionHelper.PayableInvoice);
                        SessionHelper.PayableInvoice = null;
                        saved   = true;
                        message = "Saved successfully";
                    }
                }
                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 }));
            }
        }
Example #5
0
 public ActionResult UpdatePartial(PayableInvoiceDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PayableInvoiceHelper.UpdateInvoiceDetail(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_Detail", PayableInvoiceHelper.GetInvoiceDetail()));
 }
Example #6
0
 public ActionResult DeletePartial(PayableInvoiceDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             PayableInvoiceModel invoice = SessionHelper.PayableInvoice;
             PayableInvoiceHelper.DeleteInvoiceDetail(model);
             SessionHelper.PayableInvoice = invoice;
             IList <PayableInvoiceDetailModel> invoiceDetail = PayableInvoiceHelper.GetInvoiceDetail();
             return(PartialView("_Detail", invoiceDetail));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_Detail"));
     //return PartialView("_Detail", InvoiceHelper.GetInvoiceDetail());
 }
Example #7
0
 public ActionResult ListPartial()
 {
     return(PartialView("_List", PayableInvoiceHelper
                        .GetInvoices(SessionHelper.SOBId)));
 }
Example #8
0
 public ActionResult DetailPartial()
 {
     return(PartialView("_Detail", PayableInvoiceHelper.GetInvoiceDetail()));
 }