Skip to content

Conversation

fthobe
Copy link
Contributor

@fthobe fthobe commented Feb 28, 2025

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:

  1. Tax Applicability Logic:

    • Introduced the tax_applicable? method in the Spree::Tax::TaxHelpers module. This method determines if tax is applicable based on the tax_reverse_charge_mode of the tax category and the reverse_charge_status of the address. The rates_for_item method 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.
  2. Admin Interface Updates:

    • Updated the admin interface to allow users to select the tax_reverse_charge_mode when creating or editing tax categories. The permitted parameters in the TaxCategoriesController have been updated to include tax_reverse_charge_mode.
    • The admin views and components have been updated to display the tax_reverse_charge_mode in the tax categories index and form views. This ensures that users can easily manage and view the reverse charge mode for each tax category.
  3. Model and Spec Updates:

    • Introduced the tax_reverse_charge_mode enum to the Spree::TaxCategory model, with values disabled, loose, and strict. This change includes a migration to add the tax_reverse_charge_mode column to the spree_tax_categories table, with a default value of 0 (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_mode is correctly validated and applied.

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:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@fthobe fthobe requested a review from a team as a code owner February 28, 2025 11:11
@github-actions github-actions bot added changelog:solidus_api Changes to the solidus_api gem changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem changelog:solidus_admin labels Feb 28, 2025
Copy link

codecov bot commented Feb 28, 2025

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 ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvdeyen tvdeyen changed the title [Compliance] Add tax reverse charge mode Add tax reverse charge mode Mar 21, 2025
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Well done PR

Here as well I would like to have a feature toggle

@JustShah JustShah force-pushed the add-tax-reverse-charge-mode branch 2 times, most recently from e3e231d to 95d6b16 Compare March 21, 2025 12:46
@github-actions github-actions bot removed the changelog:solidus_api Changes to the solidus_api gem label Mar 21, 2025
@JustShah
Copy link
Contributor

Dependency Notes:

  1. Configuration dependancy: Add reverse charge status to stores #6136
  2. Columns dependency: Add reverse charge fields to address #6168

@fthobe
Copy link
Contributor Author

fthobe commented Apr 7, 2025

Dependency Notes:

Configuration dependancy: #6136
Columns dependency: #6168

Can we wrap this up end of the week?

@fthobe fthobe mentioned this pull request Apr 9, 2025
4 tasks
@tvdeyen
Copy link
Member

tvdeyen commented Apr 11, 2025

@JustShah please rebase with latest main to fix the flaky test suite. Thanks 🙏🏻

@fthobe fthobe force-pushed the add-tax-reverse-charge-mode branch from 95d6b16 to 23a48b0 Compare April 11, 2025 17:20
@fthobe
Copy link
Contributor Author

fthobe commented Apr 11, 2025

@tvdeyen done

@fthobe
Copy link
Contributor Author

fthobe commented Apr 11, 2025

@tvdeyen please Note the dependency on the other PR

@JustShah JustShah force-pushed the add-tax-reverse-charge-mode branch 2 times, most recently from 2797ee0 to 47e1410 Compare April 28, 2025 13:29
…specs

Introduce the `tax_reverse_charge_mode` enum to the `Spree::TaxCategory` model,
with values `disabled`, `loose`, and `strict`. The change includes a migration to add the `tax_reverse_charge_mode`
column to the `spree_tax_categories` table, with a default value of `0` (disabled).
Additionally, the English locale file has been updated to include translations for the new enum values.

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.
Includes updates to the admin interface to allow users to select the `tax_reverse_charge_mode` when creating
or editing tax categories. The permitted parameters in the `TaxCategoriesController` have been updated
to include `tax_reverse_charge_mode`.

The admin views and components have been updated to display the `tax_reverse_charge_mode` in the tax categories
index and form views. This ensures that users can easily manage and view the reverse charge mode for each tax category.
Enhanced the tax applicability logic by introducing the `tax_applicable?` method in the `Spree::Tax::TaxHelpers` module.
The method determines if tax is applicable based on the `tax_reverse_charge_mode` of the tax category and the `reverse_charge_status`
of the address. The `rates_for_item` method 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 only if the address is not enabled.
- **loose**: Tax applies only if the address is explicitly disabled.
- **disabled**: Tax always applies.
@JustShah JustShah force-pushed the add-tax-reverse-charge-mode branch from 47e1410 to fa4d7a1 Compare April 29, 2025 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_admin changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants