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

Spree::Variant override tax_category association #12394

Open
rioug opened this issue Apr 17, 2024 · 0 comments
Open

Spree::Variant override tax_category association #12394

rioug opened this issue Apr 17, 2024 · 0 comments

Comments

@rioug
Copy link
Collaborator

rioug commented Apr 17, 2024

What we should change and why (this is tech debt)

When an instance set a default tax category, Spree::Variant will override the tax_category association and return the default one if none are set on the variant.

def tax_category
super || TaxCategory.find_by(is_default: true)
end

This is confusing as it doesn't reflect the data in the database, and "None" (as in none set) is valid tax category.
We should remove this override and fix the underlying data.

Fix

Currently only ca_prod, fr_prod, uk_prod, nz_prod, in_prod have a default tax category set. Number of variants with no tax category for each instance :

  • ca_prod 28886
  • fr_prod 44277
  • in_prod 15
  • nz_prod 2309
  • uk_prod 126871

We will need to migrate all these variants to the default tax category.
Then we can remove the association override, and we should update the "Add new product" UI to select the default tax category when there is one set. This should get us close to the current behaviour.

Context

This came up in PR: #12333 , more context #12333 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: All the things 💤
Development

No branches or pull requests

1 participant