solidus icon indicating copy to clipboard operation
solidus copied to clipboard

Add tax reverse charge mode

Open fthobe opened this issue 10 months ago • 6 comments

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 avatar Feb 28 '25 11:02 fthobe

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.

codecov[bot] avatar Feb 28 '25 11:02 codecov[bot]

Dependency Notes:

  1. Configuration dependancy: https://github.com/solidusio/solidus/pull/6136
  2. Columns dependency: https://github.com/solidusio/solidus/pull/6168

JustShah avatar Mar 24 '25 07:03 JustShah

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?

fthobe avatar Apr 07 '25 15:04 fthobe

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

tvdeyen avatar Apr 11 '25 16:04 tvdeyen

@tvdeyen done

fthobe avatar Apr 11 '25 17:04 fthobe

@tvdeyen please Note the dependency on the other PR

fthobe avatar Apr 11 '25 17:04 fthobe