OrchardCMS / OrchardCore.Commerce

The commerce module for Orchard Core.
MIT License
210 stars 87 forks source link

Handle taxes differently for corporations and private individuals. (OCC-162) #301

Closed sarahelsaig closed 1 year ago

sarahelsaig commented 1 year ago

Is your feature request related to a problem? Please describe

In some cases they are taxed differently, e.g. the corporation doesn't have to pay VAT for certain regions.

Describe the solution you'd like

Add a checkbox to checkout for corporation. Also VAT number.

Describe alternatives you've considered

Not sure, let's discuss!

Jira issue

porgabi commented 1 year ago

So, on the Checkout page, there needs to be a "Corporation" checkbox, that part seems clear enough. However, what exactly should ticking it affect?

sarahelsaig commented 1 year ago

The value of the checkbox during checkout should be added to PromotionAndTaxProviderContext, so any tax provider can use it for calculation.

For the OrchardCore.Commerce.Tax.CustomTaxRates feature you want to be able to match if the checkbox is checked, unchecked or don't care. This happens in TaxRateTaxProvider. So OrchardCore.Commerce.Tax.CustomTaxRates needs another property (enum or three-state bool) to configure this option with TaxRateSettings_Edit.cshtml.

Same for the VAT number text field.

porgabi commented 1 year ago
  1. The value of the checkbox during checkout should be added to PromotionAndTaxProviderContext

So the IsCorporation bool (i.e. the checkbox on Checkout) is to be used based on the value of the new enum site setting.

I'm certain I got this wrong. Please elaborate, for I am confusion.

2.

Same for the VAT number text field

Other than adding this to PromotionAndTaxProviderContext as well, is it to be somehow used for matching in TaxRateTaxProvider too? Or anywhere else?

sarahelsaig commented 1 year ago
  1. Sorry, I think I did a bad job at describing the idea. You should have one enum for each tax rate row, in other words put it into the TaxRateSetting class. Then when matching the tax rates check its value along with the rest of the TaxRateSetting properties:

    • If the TaxRateSetting.IsCorporation is set to Checked, match the tax rate if PromotionAndTaxProviderContext.IsCorporation == true and the other conditions match too.
    • If the TaxRateSetting.IsCorporation is set to Unchecked, match the tax rate if PromotionAndTaxProviderContext.IsCorporation == false and the other conditions match too.
    • If the TaxRateSetting.IsCorporation is set to Ignored, match the tax rate if the other conditions match.
  2. Add a string property to the TaxRateSetting class. Since this is just another text field you can use the IsMatchingOrEmptyPattern method in TaxRateTaxProvider.MatchTaxRate to check it just like e.g. taxCode is done there.

Add two new columns in TaxRateSettings_Edit.cshtml for these two new TaxRateSetting properties and update TaxRateSettingsDisplayDriver. If it's still not clear, ping me and let's have a call.