It would be great to be able to export tax rates configuration as part of features components.

Comments

artusamak’s picture

Status: Needs work » Needs review

Ok it's implemented in my sandbox, to review it here is where you can fetch it:

git remote add artusamak-commerce-features http://git.drupal.org/sandbox/Artusamak/1252122.git 
git checkout -b haza-1197692
git pull artusamak-commerce-features 1252126-Artusamak
git diff 7.x-1.x
git merge 1252126-Artusamak

URL of the branch for core reeading review:
http://drupalcode.org/sandbox/Artusamak/1252122.git/shortlog/refs/heads/...

pcambra’s picture

It would be great indeed, looks fine. Just a question, I think that this new feature provides in the base a rules component exporter through features, couldn't this be done in a generic way (maybe in rules module itself) so you can export any rules component?

artusamak’s picture

Yeah that's the idea that i'm going to try to implements, so far this is working. I'll update the issue if needed.

artusamak’s picture

After digging a bit into the issue, i found out that we can't directly rely on Rules export because the rules components when they are exported as features are attached to the commerce_tax module and we can't alter this override before the export.
That means that this patch will have to stay on commerce features right now.
I slightly changed the code to let the exported taxes being displayed on the taxes page list because commerce_tax was hidding every tax that doesn't have the admin_list property to TRUE.
See this commit for review: http://drupalcode.org/sandbox/Artusamak/1252122.git/commitdiff/e141eb534...

pcambra’s picture

Status: Needs review » Needs work
StatusFileSize
new7.64 KB

Hi,

I've tried this patch and I've managed to get the tax types correctly exported by replacing the $type['type'] by $type['name'] so the revert works correctly.

The export of the rates, on the other hand doesn't seem to work properly, you can actually export rates, but those don't get imported correctly. I'd say that hook_commerce_tax_rate_info_alter is not working as expected in this case.

Attaching the patch modified.

rfay’s picture

This seemed at first to bring in the tax rates, but didn't get the rules correct. The rules appear in the feature code, but don't get properly imported.

Also, when the feature is enabled it hides already-created existing tax rates. You actually have to disable commerce_features to get them back. Just enabling Commerce Features with this patch (enabling no feature at all) causes all existing tax rates to disappear.

rfay’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB
new7.22 KB

Here's a patch (and interdiff) that works for tax rates (I haven't tried tax types yet). As you can see from the interdiff there are just a couple of changes.

I used this patch to create Commerce Canadian Taxes

However, there are at least these issues.

  • As you can see in the .module file I had to implement hook_commerce_tax_rate_info(),
  • I had to create a .install file to make the weight of this module higher than commerce_tax.
  • You can alter the rules associated with tax rates, but you can't alter the tax rates themselves.

Thanks for the great work on this, @Artusamak - maybe with some of the great brains here we can sort out the remaining issues.

pcambra’s picture

StatusFileSize
new8.32 KB

Ok, I've give this a rework, commerce_tax module doesn't take in account that other modules may provide taxes and therefore the edit button doesn't appear (I think that this is why Randy had to do all that rework including stuff in the module and install files, which should not be required anymore).

I think this patch is way safer, I'd appreciate testing.

rfay’s picture

Status: Needs review » Reviewed & tested by the community

Ah, wonderful to see the master at work!

I tried to break this every way I could, and I failed. I've exported new features, changed stuff, updated the feature, installed the feature on a new clean install. It all "just works".

I'm not sure I'm going to be able to recover my Canadian Taxes work without re-doing it, but that comes later.

Fantastic, and thanks!

pcambra’s picture

Status: Reviewed & tested by the community » Fixed

Just committed this!
Many thanks to Julien and Randy :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.