using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace bnhtrade.Core.Logic.Account { public class TaxCalculation { public decimal GetGrossAmount(decimal netAmount, decimal taxPercent) { return netAmount * (1 + (taxPercent / 100)); } public decimal GetGrossAmount(decimal netAmount, Model.Account.TaxCodeInfo taxCodeInfo) { return GetGrossAmount(netAmount, taxCodeInfo.TaxRate); } public decimal GetNetAmount(decimal grossAmount, decimal taxPercent) { return grossAmount / (1 + (taxPercent / 100)); } public decimal GetNetAmount(decimal grossAmount, Model.Account.TaxCodeInfo taxCodeInfo) { return GetNetAmount(grossAmount, taxCodeInfo.TaxRate); } public decimal GetTaxAmount(decimal amount, bool amountIsTaxInclusive, decimal taxPercent) { if (amountIsTaxInclusive) { return amount - GetNetAmount(amount, taxPercent); } else { return amount * (taxPercent / 100); } } public decimal GetTaxAmount(decimal amount, bool amountIsTaxInclusive, Model.Account.TaxCodeInfo taxCodeInfo) { return GetTaxAmount(amount, amountIsTaxInclusive, taxCodeInfo.TaxRate); } public decimal GetMarginTaxRate(DateTime transactionDate) { decimal vatRate = 0; if (transactionDate >= new DateTime(2011, 01, 04)) { vatRate = 20; } else { // more coding required throw new Exception("Transaction is outside the current margin scheme date scope"); } return vatRate; } public decimal GetMarginTaxAmount(decimal marginAmount, DateTime transactionDate) { decimal vatRate = GetMarginTaxRate(transactionDate); return GetTaxAmount(marginAmount, true, vatRate); } public decimal GetMarginTaxAmount(decimal purchasePrice, decimal salePrice, DateTime transactionDate) { return GetMarginTaxAmount(salePrice - purchasePrice, transactionDate); } /// /// Returns a value to multiply margin (sale - purchase price) by to find margin scheme tax amount /// /// Date of transaction /// Value between 0 and 1 public decimal GetMarginMultiplier(DateTime transactionDate) { decimal vatRate = GetMarginTaxRate(transactionDate); return vatRate / (vatRate + 100); } } }