public async Task <PurchaseInvoiceTaxModel> GetPurchaseInvoiceTaxById(int purchaseInvoiceTaxId) { PurchaseInvoiceTaxModel purchaseInvoiceTaxModel = null; IList <PurchaseInvoiceTaxModel> purchaseInvoiceTaxModelList = await GetPurchaseInvoiceTaxList(purchaseInvoiceTaxId, 0); if (null != purchaseInvoiceTaxModelList && purchaseInvoiceTaxModelList.Any()) { purchaseInvoiceTaxModel = purchaseInvoiceTaxModelList.FirstOrDefault(); } return(purchaseInvoiceTaxModel); // returns. }
public async Task <bool> UpdatePurchaseInvoiceTax(PurchaseInvoiceTaxModel purchaseInvoiceTaxModel) { bool isUpdated = false; int multiplier = 1; // get record. Purchaseinvoicetax purchaseInvoiceTax = await GetByIdAsync(w => w.PurchaseInvoiceTaxId == purchaseInvoiceTaxModel.PurchaseInvoiceTaxId); if (null != purchaseInvoiceTax) { // assign values. purchaseInvoiceTax.PurchaseInvoiceId = purchaseInvoiceTaxModel.PurchaseInvoiceId; purchaseInvoiceTax.SrNo = purchaseInvoiceTaxModel.SrNo; purchaseInvoiceTax.TaxLedgerId = purchaseInvoiceTaxModel.TaxLedgerId; purchaseInvoiceTax.TaxPercentageOrAmount = purchaseInvoiceTaxModel.TaxPercentageOrAmount; purchaseInvoiceTax.TaxPerOrAmountFc = purchaseInvoiceTaxModel.TaxPerOrAmountFc; if (DiscountType.Percentage.ToString() == purchaseInvoiceTax.TaxPercentageOrAmount) { purchaseInvoiceTaxModel.TaxAmountFc = (purchaseInvoiceTax.PurchaseInvoice.GrossAmountFc * purchaseInvoiceTaxModel.TaxPerOrAmountFc) / 100; } else { purchaseInvoiceTaxModel.TaxAmountFc = purchaseInvoiceTaxModel.TaxPerOrAmountFc; } if (TaxAddOrDeduct.Deduct.ToString() == purchaseInvoiceTaxModel.TaxAddOrDeduct) { multiplier = -1; } purchaseInvoiceTax.TaxAddOrDeduct = purchaseInvoiceTaxModel.TaxAddOrDeduct; purchaseInvoiceTax.TaxAmountFc = multiplier * purchaseInvoiceTaxModel.TaxAmountFc; purchaseInvoiceTax.TaxAmount = multiplier * purchaseInvoiceTaxModel.TaxAmount; purchaseInvoiceTax.Remark = purchaseInvoiceTaxModel.Remark; isUpdated = await Update(purchaseInvoiceTax); } if (isUpdated != false) { await purchaseInvoice.UpdatePurchaseInvoiceMasterAmount(purchaseInvoiceTax.PurchaseInvoiceId); } return(isUpdated); // returns. }
public async Task <int> CreatePurchaseInvoiceTax(PurchaseInvoiceTaxModel purchaseInvoiceTaxModel) { int purchaseInvoiceTaxId = 0; int multiplier = 1; // assign values. PurchaseInvoiceModel purchaseInvoiceModel = null; purchaseInvoiceModel = await purchaseInvoice.GetPurchaseInvoiceById((int)purchaseInvoiceTaxModel.PurchaseInvoiceId); Purchaseinvoicetax purchaseInvoiceTax = new Purchaseinvoicetax(); purchaseInvoiceTax.PurchaseInvoiceId = purchaseInvoiceTaxModel.PurchaseInvoiceId; purchaseInvoiceTax.SrNo = purchaseInvoiceTaxModel.SrNo; purchaseInvoiceTax.TaxLedgerId = purchaseInvoiceTaxModel.TaxLedgerId; purchaseInvoiceTax.TaxPercentageOrAmount = purchaseInvoiceTaxModel.TaxPercentageOrAmount; purchaseInvoiceTax.TaxPerOrAmountFc = purchaseInvoiceTaxModel.TaxPerOrAmountFc; if (DiscountType.Percentage.ToString() == purchaseInvoiceTax.TaxPercentageOrAmount) { purchaseInvoiceTaxModel.TaxAmountFc = (purchaseInvoiceModel.GrossAmountFc * purchaseInvoiceTaxModel.TaxPerOrAmountFc) / 100; } else { purchaseInvoiceTaxModel.TaxAmountFc = purchaseInvoiceTaxModel.TaxPerOrAmountFc; } if (TaxAddOrDeduct.Deduct.ToString() == purchaseInvoiceTaxModel.TaxAddOrDeduct) { multiplier = -1; } purchaseInvoiceTax.TaxAddOrDeduct = purchaseInvoiceTaxModel.TaxAddOrDeduct; purchaseInvoiceTax.TaxAmountFc = multiplier * purchaseInvoiceTaxModel.TaxAmountFc; purchaseInvoiceTax.TaxAmount = multiplier * purchaseInvoiceTaxModel.TaxAmount; purchaseInvoiceTax.Remark = purchaseInvoiceTaxModel.Remark; purchaseInvoiceTaxId = await Create(purchaseInvoiceTax); if (purchaseInvoiceTaxId != 0) { await purchaseInvoice.UpdatePurchaseInvoiceMasterAmount(purchaseInvoiceTaxId); } return(purchaseInvoiceTaxId); // returns. }
private async Task <PurchaseInvoiceTaxModel> AssignValueToModel(Purchaseinvoicetax purchaseInvoiceTax) { return(await Task.Run(() => { PurchaseInvoiceTaxModel purchaseInvoiceTaxModel = new PurchaseInvoiceTaxModel(); purchaseInvoiceTaxModel.PurchaseInvoiceTaxId = purchaseInvoiceTax.PurchaseInvoiceTaxId; purchaseInvoiceTaxModel.PurchaseInvoiceId = purchaseInvoiceTax.PurchaseInvoiceId; purchaseInvoiceTaxModel.SrNo = purchaseInvoiceTax.SrNo; purchaseInvoiceTaxModel.TaxLedgerId = purchaseInvoiceTax.TaxLedgerId; purchaseInvoiceTaxModel.TaxPercentageOrAmount = purchaseInvoiceTax.TaxPercentageOrAmount; purchaseInvoiceTaxModel.TaxPerOrAmountFc = purchaseInvoiceTax.TaxPerOrAmountFc; purchaseInvoiceTaxModel.TaxAddOrDeduct = purchaseInvoiceTax.TaxAddOrDeduct; purchaseInvoiceTaxModel.TaxAmountFc = purchaseInvoiceTax.TaxAmountFc; purchaseInvoiceTaxModel.TaxAmount = purchaseInvoiceTax.TaxAmount; purchaseInvoiceTaxModel.Remark = purchaseInvoiceTax.Remark; if (null != purchaseInvoiceTax.TaxLedger) { purchaseInvoiceTaxModel.TaxLedgerName = purchaseInvoiceTax.TaxLedger.LedgerName; } return purchaseInvoiceTaxModel; })); }