Commerce Import From Ubercart Sales Tax Does anyone have any examples of importing Sales Tax data from Ubercart 2 into Drupal Commerce?

The two systems seem to use -very- different schemas (Ubercart uses separate line items and Commerce attaches tax to the product/line item. I looked at the commerce_migrate_ubercart module and it doesn't even try to handle this.

The problem is that we have historical data where rates have changed over time so it's not accurate to simply recalculate based on current rates.

We could live with simply being able to override the tax on the entire order, but I can't find a hook to override that in the commerce_orders table.

Edit: I could use commerce_tax_rate_apply('state_sales_tax',  $line_item);

     $tax_price = commerce_tax_rate_apply('state_sales_tax',  $line_item); 
    // &lt;--- Now what? I don't understand how to apply $tax_price back to the original line item before saving.

     // Save the line item to get its ID.
     commerce_line_item_save($line_item);


Or: After saving the line item, how do I hook into the standard Rules for tax calculation? (Which work fine for new orders.)
The best solution here is a "dumb" migration, one that simply retains the data model of the prior system without trying to shoe horn it into the data model of the new. The reason I changed the tax data model from Ubercart to Commerce is because taxes are actually necessarily tied to the products and services that are being taxes. When we had all taxes added up and stored in a single line item, it's then impossible to do things like refund the taxes collected for one particular product on an order if it's returned. You also cannot generate a very meaningful tax report, though nowadays I'd look to third party systems to do that anyways.

You're going to need to define your own line item type via hook_commerce_line_item_type_info() and then setup your migration to create the line item on migration. I'd call it "Ubercart tax record" or something similar. New taxes going forward should actually become part of the relevant line items when they're calculated.

When you create these tax line items, make sure that you both set the unit price amount / currency code values and update the unit price's components array to match. Look to commerce_product_line_item_populate() around line 1376 where you see the comment about adding the base price to the components array. In your case, you wouldn't use the 'base_price' price component for taxes - you'd either want to define a generic price component type via hook_commerce_price_component_type_info() or if you know the types of the taxes map to price components for tax rates you've defined on the new site, you can use those.