Add tax reverse charge mode
Important
[!IMPORTANT]
Blocked by #6168
Summary
Description
This pull request introduces enhancements to the tax applicability logic and updates the admin interface to support the new functionality.
Changes:
-
Tax Applicability Logic:
- Introduced the
tax_applicable?method in theSpree::Tax::TaxHelpersmodule. This method determines if tax is applicable based on thetax_reverse_charge_modeof the tax category and thereverse_charge_statusof the address. Therates_for_itemmethod has been updated to use this new logic, ensuring that only applicable tax rates are selected. - The
tax_applicable?method supports three modes:- strict: Tax applies if the address reverse_charge_status is not equal to enabled (reverse charge).
- loose: Tax applies if the address reverse_charge_status is not equal to disabled.
- disabled: Tax always applies.
- Introduced the
-
Admin Interface Updates:
- Updated the admin interface to allow users to select the
tax_reverse_charge_modewhen creating or editing tax categories. The permitted parameters in theTaxCategoriesControllerhave been updated to includetax_reverse_charge_mode. - The admin views and components have been updated to display the
tax_reverse_charge_modein the tax categories index and form views. This ensures that users can easily manage and view the reverse charge mode for each tax category.
- Updated the admin interface to allow users to select the
-
Model and Spec Updates:
- Introduced the
tax_reverse_charge_modeenum to theSpree::TaxCategorymodel, with valuesdisabled,loose, andstrict. This change includes a migration to add thetax_reverse_charge_modecolumn to thespree_tax_categoriestable, with a default value of0(disabled). Additionally, the English locale file has been updated to include translations for the new enum values. - The related specs have been updated to test the new enum values and ensure that the
tax_reverse_charge_modeis correctly validated and applied.
- Introduced the
The tax_reverse_charge_mode enum allows for more granular control over tax applicability based on the reverse charge status of an address. This enhancement improves the flexibility and accuracy of tax calculations by enabling different tax handling modes. The updates to the admin interface ensure that users can easily manage and view the reverse charge mode for each tax category, providing a better user experience.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
- [X] I agree that my PR will be published under the same license as Solidus.
- [X] I have written a thorough PR description.
- [X] I have kept my commits small and atomic.
- [X] I have used clear, explanatory commit messages.
The following are not always needed:
Codecov Report
Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
Project coverage is 88.79%. Comparing base (
0f0fca2) to head (fa4d7a1).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...ts/solidus_admin/tax_categories/index/component.rb | 50.00% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #6169 +/- ##
==========================================
- Coverage 88.80% 88.79% -0.01%
==========================================
Files 842 842
Lines 18235 18247 +12
==========================================
+ Hits 16193 16203 +10
- Misses 2042 2044 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Dependency Notes:
- Configuration dependancy: https://github.com/solidusio/solidus/pull/6136
- Columns dependency: https://github.com/solidusio/solidus/pull/6168
Dependency Notes:
Configuration dependancy: https://github.com/solidusio/solidus/pull/6136 Columns dependency: https://github.com/solidusio/solidus/pull/6168
Can we wrap this up end of the week?
@JustShah please rebase with latest main to fix the flaky test suite. Thanks 🙏🏻
@tvdeyen done
@tvdeyen please Note the dependency on the other PR