Simplify Tax Calculation
converted foreach if into where statement
This commit is contained in:
parent
2b2897e128
commit
ea46f598bc
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user