Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SalesTaxService.php #4

Merged
merged 1 commit into from Sep 6, 2019

Conversation

mildlygeeky
Copy link
Contributor

Would appreciate you checking to make sure that my logic is sound, but we were running into an issue where discounts for a specific line item were being applied always with the default discount code, though our line items were using the Avatax Tax Code override field.

This checks a discount adjustment to see if it applies to a specific line item, and if so checks that Product to see if there is an Avatax tax code override — if so, then that will be the discountCode used.

Makes sure discounts for specific line items take in any Avatax Tax Code overrides that may be present for that line item.
@imagehat
Copy link
Collaborator

Hi @mildlygeeky - I guess I thought that discounts needed their own discount-specific code but that test case you sent over definitely shows line item discounts need to be handled differently especially when tax exemptions are in the mix.

Let me do some testing and maybe verify with Avalara the right way to send those line item discounts.

@mildlygeeky
Copy link
Contributor Author

mildlygeeky commented Apr 23, 2019

thanks for looking @imagehat — taking a look at https://developer.avalara.com/avatax/dev-guide/discounts-and-overrides/discounts/ and looking at "Negative Amount Line Items" (the way you are sending them over), you can see that the Expected API Call shows that the Tax Codes are expected to match between a taxable line item and its discount adjustment.

From their instructions (emphasis mine):

With this, exercise, you will simply add an additional line that contains the discounted amount as a negative extended amount. Please ensure to use the same taxCode on the discount line as the item being discounted. This will ensure that any taxability rules applied to the product/service are also applied to the discount.

Without the tax codes matching, Avalara just assumes that any/all tax code line items are subject to the discount, and can result in some pretty odd results (for us, we had negative sales tax being calculated for a low-priced item that was in the same order as a discounted high-price item that was sales tax exempt).

@mildlygeeky
Copy link
Contributor Author

I would even say that their note on how they think about discounts should probably negate the need for the defaultDiscountCode setting — rather, discounts should default to the defaultTaxCode, and then use the new code in this PR to override on a per-lineItem basis as needed.

@mildlygeeky
Copy link
Contributor Author

Hey @imagehat / @siffring — any ETA on when this fix could be integrated? I don't mean to be a pest, only that we have a site going live with this plugin on May 15, and just want to figure out if I will be able to use this fix as part of your plugin, or if I should do a fork.

@imagehat
Copy link
Collaborator

@mildlygeeky - No worries. I'm just checking with Avalara since we specifically went over discounts as part of their certification process. Their main stipulation was that a store owner could set their own discount code, but I think the way you're seeing as just matching either the default or line item tax codes makes more sense.

I'd say we're aiming to get an answer and test your patch early next week at the latest.

@mildlygeeky
Copy link
Contributor Author

Hey @imagehat - any chance this could be pushed to a dev branch while it goes through internal testing? That way I could point to it with composer while it goes through validation with Avalara. Thanks!

@imagehat
Copy link
Collaborator

@mildlygeeky - For now I've pushed this pr into a new dev-discounts branch. I think you should be able to grab it with composer require surprisehighway/craft-avatax:dev-discounts.

The Avalara folks laid out several discount scenarios I'm hoping to get to spend some time digesting and getting implemented in the next few days (along with a couple other bugfixes).

@imagehat imagehat merged commit 7b12b9e into surprisehighway:master Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants