Skip to content

[Compliance] Add tax reverse charge mode#13

Open
JustShah wants to merge 3 commits intomainfrom
add-tax-reverse-charge-mode
Open

[Compliance] Add tax reverse charge mode#13
JustShah wants to merge 3 commits intomainfrom
add-tax-reverse-charge-mode

Conversation

@JustShah
Copy link
Collaborator

@JustShah JustShah commented Feb 27, 2025

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.

@fthobe
Copy link

fthobe commented Feb 27, 2025

@JustShah I see some tests failing can you check?

@JustShah JustShah force-pushed the add-tax-reverse-charge-mode branch 2 times, most recently from 71c9856 to 65e99c9 Compare February 28, 2025 07:21
@fthobe fthobe changed the title Add tax reverse charge mode [Compliance] Add tax reverse charge mode Feb 28, 2025
@JustShah JustShah force-pushed the add-compliance-fields-to-address branch 2 times, most recently from 1efe6c8 to 30b9a6d Compare March 21, 2025 11:02
@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
@JustShah JustShah force-pushed the add-compliance-fields-to-address branch from 30b9a6d to c81aace Compare March 24, 2025 07:59
@fthobe fthobe force-pushed the add-compliance-fields-to-address branch from fdd1a75 to 1bccaea Compare April 10, 2025 16:04
@fthobe fthobe force-pushed the add-tax-reverse-charge-mode branch from 95d6b16 to 23a48b0 Compare April 11, 2025 17:20
@fthobe fthobe force-pushed the add-compliance-fields-to-address branch from 1bccaea to 1be1631 Compare April 12, 2025 10:20
@JustShah JustShah force-pushed the add-compliance-fields-to-address branch from 1be1631 to 0963b8e Compare April 28, 2025 13:11
@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
@JustShah JustShah changed the base branch from add-compliance-fields-to-address to main April 29, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants