Tax rate information missing
Preconditions
- Migrate Magento 1.9.4.2 to Magento 2.3.2 (settings and data)
Steps to reproduce
- in Magento 1 place order with a taxed item
- Enable setting Systems > Configuration > Tax > Orders, Invoices > Display Full Tax Summary
- Migrate settings and data
Expected result
- In Magento 1 the specific applied tax rate is shown but is missing from Magento 2
Actual result
- see above
Additional notes
This seems to be intended behaviour?! as the values are simply zeroed out here https://github.com/magento/data-migration-tool/blob/2.3.2/etc/opensource-to-opensource/1.9.4.2/map.xml.dist#L1882
The values are available in the source database. The below seems to work for me using a custom handler:
<transform>
<field>sales_order_tax_item.real_base_amount</field>
<handler class="\Fooman\Migration\Handler\FieldCopyFromSeparateTableHandler">
<param name="tableFrom" value="sales_order_item" />
<param name="fieldCopy" value="base_tax_amount" />
<param name="commonIdField" value="item_id" />
<param name="fieldCopyTo" value="real_base_amount" />
</handler>
</transform>
for each of the 4 fields real_base_amount, real_amount, base_amount and amount with base and real being the same (which works in most cases where there is only 1 tax rate applied - see https://github.com/magento/magento2/blob/2.3.2/app/code/Magento/Tax/Model/Plugin/OrderSave.php#L95.
The handler looks like this
<?php
namespace Fooman\Migration\Handler;
use Migration\ResourceModel\Record;
use Migration\Handler\AbstractHandler;
use Migration\ResourceModel\Destination;
class FieldCopyFromSeparateTableHandler extends AbstractHandler
{
protected $destinationAdapter;
protected $destination;
private $tableFrom;
private $fieldCopy;
private $fieldCopyTo;
private $commonIdField;
/**
* @param Destination $destination
* @param $tableFrom
* @param $fieldCopy
* @param $fieldCopyTo
*/
public function __construct(Destination $destination, $tableFrom, $fieldCopy, $fieldCopyTo, $commonIdField)
{
$this->destination = $destination;
$this->destinationAdapter = $destination->getAdapter();
$this->tableFrom = $tableFrom;
$this->commonIdField = $commonIdField;
$this->fieldCopy = $fieldCopy;
$this->fieldCopyTo = $fieldCopyTo;
}
public function handle(Record $recordToHandle, Record $oppositeRecord)
{
$this->validate($recordToHandle);
$fieldCopyValue = $this->getOppFieldValue($recordToHandle->getValue($this->commonIdField)) ;
$oppositeRecord->setValue($this->fieldCopyTo, $fieldCopyValue);
}
public function getOppFieldValue($id)
{
/** @var \Magento\Framework\DB\Select $select */
$select = $this->destinationAdapter->getSelect();
$select->from(['opp' => $this->destination->addDocumentPrefix($this->tableFrom)], [])
->where('opp.'.$this->commonIdField.'=?', $id);
$select->columns([$this->fieldCopy]);
return $select->getAdapter()->fetchOne($select);
}
}
and results in

Hi @fooman
Thank you for reporting and fixing this issue! Internal ticket MC-18494 to process it.
Thanks @victor-v-rad - just to note the solution that I posted would likely not work for jurisdictions that apply multiple tax rates on the same item (Canada comes to mind). But at least for most other cases this change would improve status quo.
Thank you @fooman . It will be taken into account.