public async Task <JsonResult> SaveInvoiceTaxMaster(SalesInvoiceTaxModel salesInvoiceTaxModel) { JsonData <JsonStatus> data = new JsonData <JsonStatus>(new JsonStatus()); if (ModelState.IsValid) { if (salesInvoiceTaxModel.InvoiceTaxId > 0) { // update record. if (true == await _salesInvoiceTax.UpdateSalesInvoiceTax(salesInvoiceTaxModel)) { data.Result.Status = true; } } else { // add new record. if (await _salesInvoiceTax.CreateSalesInvoiceTax(salesInvoiceTaxModel) > 0) { data.Result.Status = true; } } } return(Json(data)); }
public async Task <SalesInvoiceTaxModel> GetSalesInvoiceTaxById(int salesInvoiceTaxId) { SalesInvoiceTaxModel salesInvoiceTaxModel = null; IList <SalesInvoiceTaxModel> salesInvoiceTaxModelList = await GetSalesInvoiceTaxList(salesInvoiceTaxId, 0); if (null != salesInvoiceTaxModelList && salesInvoiceTaxModelList.Any()) { salesInvoiceTaxModel = salesInvoiceTaxModelList.FirstOrDefault(); } return(salesInvoiceTaxModel); // returns. }
/// <summary> /// edit invoice tax master. /// </summary> /// <param name="invoiceId"></param> /// <returns></returns> public async Task <IActionResult> EditInvoiceTaxMaster(int invoiceTaxId) { ViewBag.DiscountTypeList = EnumHelper.GetEnumListFor <DiscountType>(); ViewBag.TaxAddOrDeductList = EnumHelper.GetEnumListFor <TaxAddOrDeduct>(); ViewBag.TaxLedgerList = await _ledger.GetLedgerSelectList(17); SalesInvoiceTaxModel salesInvoiceTaxModel = await _salesInvoiceTax.GetSalesInvoiceTaxById(invoiceTaxId); return(await Task.Run(() => { return PartialView("_AddInvoiceTaxMaster", salesInvoiceTaxModel); })); }
public async Task <int> CreateSalesInvoiceTax(SalesInvoiceTaxModel salesInvoiceTaxModel) { int salesInvoiceTaxId = 0; int multiplier = 1; // assign values. SalesInvoiceModel salesInvoiceModel = null; salesInvoiceModel = await salesInvoice.GetSalesInvoiceById((int)salesInvoiceTaxModel.InvoiceId); Salesinvoicetax salesInvoiceTax = new Salesinvoicetax(); salesInvoiceTax.InvoiceId = salesInvoiceTaxModel.InvoiceId; salesInvoiceTax.SrNo = salesInvoiceTaxModel.SrNo; salesInvoiceTax.TaxLedgerId = salesInvoiceTaxModel.TaxLedgerId; salesInvoiceTax.TaxPercentageOrAmount = salesInvoiceTaxModel.TaxPercentageOrAmount; salesInvoiceTax.TaxPerOrAmountFc = salesInvoiceTaxModel.TaxPerOrAmountFc; if (DiscountType.Percentage.ToString() == salesInvoiceTax.TaxPercentageOrAmount) { salesInvoiceTaxModel.TaxAmountFc = (salesInvoiceModel.GrossAmountFc * salesInvoiceTaxModel.TaxPerOrAmountFc) / 100; } else { salesInvoiceTaxModel.TaxAmountFc = salesInvoiceTaxModel.TaxPerOrAmountFc; } if (TaxAddOrDeduct.Deduct.ToString() == salesInvoiceTaxModel.TaxAddOrDeduct) { multiplier = -1; } salesInvoiceTax.TaxAddOrDeduct = salesInvoiceTaxModel.TaxAddOrDeduct; salesInvoiceTax.TaxAmountFc = multiplier * salesInvoiceTaxModel.TaxAmountFc; salesInvoiceTax.TaxAmount = multiplier * salesInvoiceTaxModel.TaxAmount; salesInvoiceTax.Remark = salesInvoiceTaxModel.Remark; await Create(salesInvoiceTax); salesInvoiceTaxId = salesInvoiceTax.InvoiceTaxId; if (salesInvoiceTaxId != 0) { await salesInvoice.UpdateSalesInvoiceMasterAmount(salesInvoiceTaxId); } return(salesInvoiceTaxId); // returns. }
public async Task <bool> UpdateSalesInvoiceTax(SalesInvoiceTaxModel salesInvoiceTaxModel) { bool isUpdated = false; int multiplier = 1; // get record. Salesinvoicetax salesInvoiceTax = await GetByIdAsync(w => w.InvoiceTaxId == salesInvoiceTaxModel.InvoiceTaxId); if (null != salesInvoiceTax) { // assign values. salesInvoiceTax.InvoiceId = salesInvoiceTaxModel.InvoiceId; salesInvoiceTax.SrNo = salesInvoiceTaxModel.SrNo; salesInvoiceTax.TaxLedgerId = salesInvoiceTaxModel.TaxLedgerId; salesInvoiceTax.TaxPercentageOrAmount = salesInvoiceTaxModel.TaxPercentageOrAmount; salesInvoiceTax.TaxPerOrAmountFc = salesInvoiceTaxModel.TaxPerOrAmountFc; if (DiscountType.Percentage.ToString() == salesInvoiceTax.TaxPercentageOrAmount) { salesInvoiceTaxModel.TaxAmountFc = (salesInvoiceTax.Invoice.GrossAmountFc * salesInvoiceTaxModel.TaxPerOrAmountFc) / 100; } else { salesInvoiceTaxModel.TaxAmountFc = salesInvoiceTaxModel.TaxPerOrAmountFc; } if (TaxAddOrDeduct.Deduct.ToString() == salesInvoiceTaxModel.TaxAddOrDeduct) { multiplier = -1; } salesInvoiceTax.TaxAddOrDeduct = salesInvoiceTaxModel.TaxAddOrDeduct; salesInvoiceTax.TaxAmountFc = multiplier * salesInvoiceTaxModel.TaxAmountFc; salesInvoiceTax.TaxAmount = multiplier * salesInvoiceTaxModel.TaxAmount; salesInvoiceTax.Remark = salesInvoiceTaxModel.Remark; isUpdated = await Update(salesInvoiceTax); } if (isUpdated != false) { await salesInvoice.UpdateSalesInvoiceMasterAmount(salesInvoiceTax.InvoiceId); } return(isUpdated); // returns. }
private async Task <SalesInvoiceTaxModel> AssignValueToModel(Salesinvoicetax salesInvoiceTax) { return(await Task.Run(() => { SalesInvoiceTaxModel salesInvoiceTaxModel = new SalesInvoiceTaxModel(); salesInvoiceTaxModel.InvoiceTaxId = salesInvoiceTax.InvoiceTaxId; salesInvoiceTaxModel.InvoiceId = salesInvoiceTax.InvoiceId; salesInvoiceTaxModel.SrNo = salesInvoiceTax.SrNo; salesInvoiceTaxModel.TaxLedgerId = salesInvoiceTax.TaxLedgerId; salesInvoiceTaxModel.TaxPercentageOrAmount = salesInvoiceTax.TaxPercentageOrAmount; salesInvoiceTaxModel.TaxPerOrAmountFc = salesInvoiceTax.TaxPerOrAmountFc; salesInvoiceTaxModel.TaxAddOrDeduct = salesInvoiceTax.TaxAddOrDeduct; salesInvoiceTaxModel.TaxAmountFc = salesInvoiceTax.TaxAmountFc; salesInvoiceTaxModel.TaxAmount = salesInvoiceTax.TaxAmount; salesInvoiceTaxModel.Remark = salesInvoiceTax.Remark; salesInvoiceTaxModel.TaxLedgerName = null != salesInvoiceTax.TaxLedger ? salesInvoiceTax.TaxLedger.LedgerName : null; return salesInvoiceTaxModel; })); }