Simplify Tax Calculation

converted foreach if into where statement
This commit is contained in:
s459315 2022-07-24 00:10:49 +02:00
parent 2b2897e128
commit ea46f598bc

View File

@ -117,13 +117,9 @@ namespace RMWPFUserInterface.ViewModels
decimal taxAmount = 0; decimal taxAmount = 0;
decimal TaxRate = _configHelper.GetTaxRate()/100; decimal TaxRate = _configHelper.GetTaxRate()/100;
foreach (var item in Cart) taxAmount = Cart
{ .Where(x => x.Product.IsTaxable)
if (item.Product.IsTaxable) .Sum(x => x.Product.RetailPrice * x.QuantityInCart * TaxRate);
{
taxAmount += (item.Product.RetailPrice * item.QuantityInCart * TaxRate);
}
}
return taxAmount; return taxAmount;
} }