Commits

Josh Berry committed 057af31

ComputeTax should return tax amount, not the rate

Comments (0)

Files changed (2)

Models/ZipCodeTaxPart.cs

             double shippingCost, string country, string zipCode) {
 
             var rates = GetRates();
-            if (country == Country.UnitedStates && rates.ContainsKey(zipCode)) return rates[zipCode];
+            if (country == Country.UnitedStates && rates.ContainsKey(zipCode)) {
+                var rate = rates[zipCode];
+                var tax = (subtotal + shippingCost) * rate;
+                return tax;
+            }
 
             return 0;
         }

Nwazet.Commerce.Tests/TaxByZipTests.cs

             cart.Country = "United States";
             cart.ZipCode = "52627";
 
-            CheckTaxes(cart.Taxes().Amount, 0.05);
+            CheckTaxes(cart.Taxes().Amount, 6.95);
         }
 
         [Test]
             cart.Country = "United States";
             cart.ZipCode = "52412";
 
-            CheckTaxes(cart.Taxes().Amount, 0.08);
+            CheckTaxes(cart.Taxes().Amount, 11.12);
         }
 
         [Test]