avadev/AvaTax-REST-V2-Python-SDK

Support TaxIncluded in AvaTax Line Items

raymondberg opened this issue · 1 comments

Happy to move this elsewhere if there's a formal process for submitting issues.

Problem statement

The TransactionBuilder doesn't support the taxIncluded attribute which is required
on a per-line item basis if used. See full docs here: https://developer.avalara.com/avatax/dev-guide/customizing-transaction/using-tax-included/

Desired Behavior

As a user of the transaction builder I would like to be able to use something like the following

builder.with_line(amount=100, quantity=1, tax_code=MY_TAX_CODE, tax_included=True)

or (less ideal)

(
  builder
    .with_line(amount=100, quantity=1, tax_code=MY_TAX_CODE)
    .with_tax_included()
)

Workaround

One can work around this by abandoning the TransactionBuilder or by breaking into the model a bit.
This could be done with conditions for item info, but a simple pass for all items is:

for item in builder.create_model["items"]:
  item["taxIncluded"] = True

Notes

It's worth noting two items related to this:

  1. the builder currently requires tax_code which is also not a true requirement.
  2. with_exempt_line is currently a single quantity, but almost entirely the same as add item

Suggestion for improving might be to do three, backwards-compatible steps to align all three:

  • move tax_code to be optional (non-breaking) so that it is only added to the request if not-none
  • with_exempt_line calls with_line with minimal alteration (quantity=1 for backwards compatibility, tax_code=None)
  • add tax_included to with_line

I'd be happy to PR if you would be amenable.

Released in v22.9.0