public async Task <decimal> GetOrderTotal(Models.Order order) { var result = order.GetSubTotal(); result += await Calculator.CalculateTaxesForOrder(order); return(result); }
public void GetSubTotalTest() { var service = new TaxService(new TaxJarCalculator()); var order = new Models.Order(); order.AddProduct(new Product() { Id = 1, Price = 10m }); var subtotal = order.GetSubTotal(); Assert.IsTrue(subtotal == 10m); }
public async Task <decimal> CalculateTaxesForOrder(Models.Order order) { var taxOrder = new Taxjar.Order() { FromCountry = "US", FromState = order.FromState, ToCountry = order.Country, ToState = order.ToState, ToZip = order.ToZip, Shipping = 0, Amount = order.GetSubTotal() }; var result = await client.TaxForOrderAsync(taxOrder); if (result != null) { return(result.AmountToCollect); } return(0m); }