mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
87 lines
2.8 KiB
C#
87 lines
2.8 KiB
C#
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a value to multiply margin (sale - purchase price) by to find margin scheme tax amount
|
|
/// </summary>
|
|
/// <param name="transactionDate">Date of transaction</param>
|
|
/// <returns>Value between 0 and 1</returns>
|
|
public decimal GetMarginMultiplier(DateTime transactionDate)
|
|
{
|
|
decimal vatRate = GetMarginTaxRate(transactionDate);
|
|
return vatRate / (vatRate + 100);
|
|
}
|
|
}
|
|
}
|