bporcelli/simplesalestax

Add support for fallback rates

bporcelli opened this issue · 0 comments

Users would like to be able to specify per-state fallback tax rates to apply when there are issues with connectivity to the TaxCloud API during checkout.

Requirements

  • Add a "Enable Fallback Rates" checkbox on the Simple Sales Tax Settings page
  • When "Enable Fallback Rates" is checked, reveal a table where the user can enter an optional fallback rate for each US state
    • The fallback rate value for each state will either be a number like 10 for 10%, or blank to denote a zero rate
  • If a network error is encountered while making the Lookup request during checkout, check whether the user has entered a fallback rate for the state the user's shipping address is in. If a nonzero fallback rate is found, calculate tax using the fallback rate, else apply a zero rate. If a fallback rate is applied, save it to the order for future reference.
  • If an order was not synchronized to TaxCloud due to fallback rate being applied:
    • Display a warning icon next to the order on the WooCommerce Orders list screen, with a clear message that indicates the order needs to be synchronized to TaxCloud that appears on hover.
    • Add a button in the Simple Sales Tax box on the Edit Order screen that allows the user to synchronize the order to TaxCloud. When this button is clicked, perform any API calls required to sync the order to TaxCoud (e.g. LookupForDate and AuthorizedWithCapture or AddTransactions). If an error occurs, display an alert box. On success, hide the sync button.
      • TBD: Do we need to include as special comment in the AuthorizedWithCapture request body to signify the fallback rate that was applied? Would it be better to use AddTransactions to sync orders where a fallback was applied, specifying the actual tax amounts collected in the request body?
      • IMPORTANT: Using the "Sync" button SHOULD NOT change the tax amount applied on the WooCommerce order, i.e. the Sales Tax line for the order should still reflect the fallback tax amount charged to the customer during checkout.

Screenshot 2023-09-01 at 12-00-55 Edit order #90814 ‹ Simple Sales Tax — WordPress