public ActionResult Edit(string id)
        {
            TaxModel model = TaxHelper.GetTax(id);

            model.TaxDetails  = TaxHelper.GetTaxDetail(id);
            SessionHelper.Tax = model;
            return(View(model));
        }
 public ActionResult UpdatePartial(TaxDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             TaxHelper.UpdateTaxDetail(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_TaxDetailPartial", TaxHelper.GetTaxDetail()));
 }
        public ActionResult AddNewPartial(TaxDetailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool validInput = false;
                    if (SessionHelper.Tax.TaxDetails.Count != 0)
                    {
                        if (SessionHelper.Tax.TaxDetails.Any(rec => rec.CodeCombinationId == model.CodeCombinationId))
                        {
                            ViewData["EditError"] = "Duplicate accounts can not be added.";
                        }
                        else
                        {
                            validInput = true;
                            model.Id   = SessionHelper.Tax.TaxDetails.Last().Id + 1;
                        }
                    }
                    else
                    {
                        model.Id   = 1;
                        validInput = true;
                    }

                    if (validInput)
                    {
                        TaxHelper.Insert(model);
                    }
                }
                catch (Exception ex)
                {
                    ViewData["EditError"] = ex.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_TaxDetailPartial", TaxHelper.GetTaxDetail()));
        }
Beispiel #4
0
        public ActionResult SaveInvoice(string invoiceType, string invoiceDate, string conversionRate, string remarks, long customerId, long customerSiteId, long periodId, long currencyId)
        {
            string message = "";

            try
            {
                bool saved = false;
                if (SessionHelper.Invoice != null)
                {
                    if (SessionHelper.Invoice.InvoiceDetail.Count == 0)
                    {
                        message = "No detail information available to save!";
                    }
                    else
                    {
                        SessionHelper.Invoice.InvoiceType    = invoiceType;
                        SessionHelper.Invoice.InvoiceDate    = Convert.ToDateTime(invoiceDate);
                        SessionHelper.Invoice.ConversionRate = Convert.ToDecimal(conversionRate);
                        SessionHelper.Invoice.Remarks        = remarks;
                        SessionHelper.Invoice.CustomerId     = customerId;
                        SessionHelper.Invoice.CustomerSiteId = customerSiteId;
                        SessionHelper.Invoice.PeriodId       = periodId;
                        SessionHelper.Invoice.CurrencyId     = currencyId;

                        if (SessionHelper.Invoice.InvoiceDate >= SessionHelper.Calendar.StartDate && SessionHelper.Invoice.InvoiceDate <= SessionHelper.Calendar.EndDate)
                        {
                            if (SessionHelper.Invoice.InvoiceNo == "New")
                            {
                                SessionHelper.Invoice.InvoiceNo = InvoiceHelper.GetInvoiceNo(AuthenticationHelper.CompanyId.Value, SessionHelper.Invoice.SOBId, SessionHelper.Invoice.PeriodId, SessionHelper.Invoice.CurrencyId);
                            }

                            foreach (InvoiceDetailModel invoiceDetail in SessionHelper.Invoice.InvoiceDetail)
                            {
                                invoiceDetail.Amount = invoiceDetail.Quantity * invoiceDetail.Rate;

                                if (invoiceDetail.TaxId != null)
                                {
                                    TaxDetailModel taxDetail = TaxHelper.GetTaxDetail(invoiceDetail.TaxId.ToString()).FirstOrDefault(x => x.StartDate <= SessionHelper.Invoice.InvoiceDate && x.EndDate >= SessionHelper.Invoice.InvoiceDate);

                                    if (taxDetail != null)
                                    {
                                        invoiceDetail.TaxAmount = invoiceDetail.Amount * taxDetail.Rate / 100;
                                    }
                                    else
                                    {
                                        invoiceDetail.TaxAmount = 0;
                                    }
                                }
                            }

                            InvoiceHelper.Update(SessionHelper.Invoice);
                            SessionHelper.Invoice = null;
                            saved   = true;
                            message = "Saved successfully";
                        }
                        else
                        {
                            message = "GL Date must lie in the range of the selected period";
                        }
                    }
                }
                else
                {
                    message = "No information available to save!";
                }
                return(Json(new { success = saved, message = message }));
            }
            catch (Exception e)
            {
                message = e.Message;
                return(Json(new { success = false, message = message }));
            }
        }
 public ActionResult TaxDetailPartial()
 {
     return(PartialView("_TaxDetailPartial", TaxHelper.GetTaxDetail()));
 }