feat: rewrite custom tax model and add tax categories - #1212
Merged
Merged
Conversation
- cargo fmt --all (module ordering + import wrapping) - replace ProductRow::update_fee_structure's 8 positional args with a ProductRowPatch AsChangeset, matching the RowPatch convention used by the other tables; the store now sends only the fields it actually patches - add the new tax_category_id / default_tax_category_id / tax_provider_id fields to the integration test fixtures - name the non-taxable category key (NONTAXABLE_CATEGORY_KEY) instead of matching a literal, and cover it with a unit test - drop a needless product_ids clone in the tax pipeline
A product could reference any tax_category row by id, including another tenant's custom category once those become insertable. Product create and update now check the category is built-in or owned by the tenant. Replaces the unused, unscoped TaxCategoryRow::get_by_id.
Categories were an inert catalog: only the hardcoded nontaxable key read them, and nothing tied them to the settings where tax code, country, region and rate are defined. Products reached those rates only through per-product product_custom_tax wiring. A custom tax can now target a tax category. Invoicing resolves a line's custom taxes as the union of the taxes wired to its product and the taxes targeting its resolved category, deduped by id. Existing setups keep tax_category_id NULL and behave exactly as before. The settings dialog gains a category picker next to the tax code and rules, so classifying a product is enough to pick up its rates.
Rates are stored and applied as fractions (tax = amount * rate), but the settings screen labelled the input "Rate (%)" and rendered stored values with a % suffix. Entering 20 for 20% therefore configured a 2000% tax. The form and the table now convert between the two, so what is typed and displayed matches the label. Stored values keep their meaning.
…ctor main's payment connector factory matches ConnectorProviderEnum exhaustively; Kintsugi is a tax provider, so it joins Hubspot/Pennylane as unsupported for payment operations. Also restores tax_category_id on the add-on Product built in the portal checkout, which main's rewrite of that block predates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.