public TaxRate GetTaxesWithCombinedShippingAndHandling(string ZipCode, double TaxableTotal, double ShippingAndHandling) { if (AuthCred == null) { return(new TaxRate("ERROR: Please supply credentials.")); } if (!Authentication.AuthenticateUser(AuthCred.Username, AuthCred.PasswordHash)) { return(new TaxRate("ERROR: Invalid login.")); } rate.ZipCode = ZipCode; rate.SubTotal = Convert.ToDecimal(TaxableTotal); rate.Shipping = Convert.ToDecimal(ShippingAndHandling); rate = Taxes.GetTaxes(rate); /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is false and TAX_SHIPPING_ALONE is false if (!rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && !rate.TAX_SHIPPING_ALONE) { rate.ShippingTax = 0; } /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is true and TAX_SHIPPING_ALONE is false else if (rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && !rate.TAX_SHIPPING_ALONE) { // don't charge handling b/c it's built in to the shipping cost // shipping will almost always be exempt under this condition rate.ShippingTax = 0; } /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is true and TAX_SHIPPING_ALONE is true else if (rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && rate.TAX_SHIPPING_ALONE) { // shipping will always be taxable (handling is taxable b/c it's built into the shipping) rate.ShippingTax = Math.Round(rate.Rate * rate.Shipping, 2); } rate.SubTotalTax = Math.Round(rate.Rate * rate.SubTotal, 2); rate.Tax = rate.SubTotalTax + rate.ShippingTax; rate.Total = rate.SubTotal + rate.Shipping + rate.Tax; return(rate); }
public TaxRate GetTaxes(string ZipCode, double TaxableTotal) { if (AuthCred == null) { return(new TaxRate("ERROR: Please supply credentials.")); } if (!Authentication.AuthenticateUser(AuthCred.Username, AuthCred.PasswordHash)) { return(new TaxRate("ERROR: Invalid login.")); } rate.ZipCode = ZipCode; rate.SubTotal = Convert.ToDecimal(TaxableTotal); rate = Taxes.GetTaxes(rate); rate.SubTotalTax = Math.Round(rate.Rate * rate.SubTotal, 2); rate.Tax = rate.SubTotalTax; rate.Total = rate.SubTotal + rate.Tax; return(rate); }
public TaxRate GetTaxesTest(string ZipCode, double TaxableTotal, double ShippingAndHandling) { rate.ZipCode = ZipCode; rate.SubTotal = Convert.ToDecimal(TaxableTotal); rate.Shipping = Convert.ToDecimal(ShippingAndHandling); rate = Taxes.GetTaxes(rate); /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is false and TAX_SHIPPING_ALONE is false if (!rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && !rate.TAX_SHIPPING_ALONE) { rate.ShippingTax = 0; } /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is true and TAX_SHIPPING_ALONE is false else if (rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && !rate.TAX_SHIPPING_ALONE) { // don't charge handling b/c it's built in to the shipping cost // shipping will almost always be exempt under this condition rate.ShippingTax = 0; } /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is true and TAX_SHIPPING_ALONE is true else if (rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && rate.TAX_SHIPPING_ALONE) { // shipping will always be taxable (handling is taxable b/c it's built into the shipping) rate.ShippingTax = Math.Round(rate.Rate * rate.Shipping, 2); } rate.SubTotalTax = Math.Round(rate.Rate * rate.SubTotal, 2); rate.Tax = rate.SubTotalTax + rate.ShippingTax; rate.Total = rate.SubTotal + rate.Shipping + rate.Tax; return(rate); }
public TaxCalculation() { rate = new TaxRate(); }
public TaxRate GetTaxesWithShippingAndHandling(string ZipCode, double TaxableTotal, double Shipping, double Handling) { if (AuthCred == null) { return(new TaxRate("ERROR: Please supply credentials.")); } if (!Authentication.AuthenticateUser(AuthCred.Username, AuthCred.PasswordHash)) { return(new TaxRate("ERROR: Invalid login.")); } rate.ZipCode = ZipCode; rate.SubTotal = Convert.ToDecimal(TaxableTotal); rate.Shipping = Convert.ToDecimal(Shipping); rate.Handling = Convert.ToDecimal(Handling); rate = Taxes.GetTaxes(rate); /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is false and TAX_SHIPPING_ALONE is false if (!rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && !rate.TAX_SHIPPING_ALONE) { rate.ShippingTax = 0; } /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is true and TAX_SHIPPING_ALONE is false else if (rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && !rate.TAX_SHIPPING_ALONE) { // if the items purchased are taxable, handling charges are taxable if (TaxableTotal > 0) { rate.HandlingTax = Math.Round(rate.Rate * rate.Handling, 2); } // shipping will almost always be exempt under this condition rate.ShippingTax = 0; } /// if TAX_SHIPPING_AND_HANDLING_TOGETHER is true and TAX_SHIPPING_ALONE is true else if (rate.TAX_SHIPPING_AND_HANDLING_TOGETHER && rate.TAX_SHIPPING_ALONE) { // if the items purchased are taxable, handling charges are taxable if (TaxableTotal > 0) { rate.HandlingTax = Math.Round(rate.Rate * rate.Handling, 2); } // shipping will always be taxable rate.ShippingTax = Math.Round(rate.Rate * rate.Shipping, 2); } #region old //// if TaxShippingAlone is false and TaxShippingAndHandlingTogether is false //// don't charge taxes on shipping or handling //// if TaxShippingAndHandlingTogether is true and TaxShippingAlone is false //// tax should only be applied to the handling fees //// if TaxShippingAndHandlingTogether is false and TaxShippingAlone is true //// then don't charge tax on the Handling //// else if TaxShippingAlone is true and TaxShippingAndHandlingTogether is false //// then don't charge tax on the Handling //// else //// charge taxes on shipping and handling //if (!rate.TAX_SHIPPING_ALONE && !rate.TAX_SHIPPING_AND_HANDLING_TOGETHER) //{ // // don't charge taxes on shipping or handling //} //else if (rate.TAX_SHIPPING_ALONE && !rate.TAX_SHIPPING_AND_HANDLING_TOGETHER) //{ // if (rate.Shipping != 0) // { // rate.ShippingTax = Math.Round(rate.Rate*rate.Shipping, 2); // } //} //else //{ // if (rate.Handling != 0) // { // rate.HandlingTax = Math.Round(rate.Rate*rate.Handling, 2); // } // if (rate.Shipping != 0) // { // rate.ShippingTax = Math.Round(rate.Rate*rate.Shipping, 2); // } //} ////if (rate.Handling != 0) ////{ //// // if TaxShippingAlone is true and TaxShippingAndHandlingTogether is false //// if ((!rate.TAX_SHIPPING_ALONE && rate.TAX_SHIPPING_AND_HANDLING_TOGETHER) || (rate.TAX_SHIPPING_ALONE && rate.TAX_SHIPPING_AND_HANDLING_TOGETHER)) //// { //// rate.HandlingTax = Math.Round(rate.Rate * rate.Handling, 2); //// } ////} ////if (rate.Shipping != 0) ////{ //// if ((rate.TAX_SHIPPING_ALONE && !rate.TAX_SHIPPING_AND_HANDLING_TOGETHER) || (rate.TAX_SHIPPING_ALONE && rate.TAX_SHIPPING_AND_HANDLING_TOGETHER)) //// { //// rate.ShippingTax = Math.Round(rate.Rate * rate.Shipping, 2); //// } ////} #endregion rate.SubTotalTax = Math.Round(rate.Rate * rate.SubTotal, 2); rate.Tax = rate.SubTotalTax + rate.ShippingTax + rate.HandlingTax; rate.Total = rate.SubTotal + rate.Shipping + rate.Handling + rate.Tax; return(rate); }