magento / magento/data-migration-tool
Tax rate information missing
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 339
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions
1. Migrate Magento 1.9.4.2 to Magento 2.3.2 (settings and data)
### Steps to reproduce
1. in Magento 1 place order with a taxed item
2. Enable setting Systems > Configuration > Tax > Orders, Invoices > Display Full Tax Summary
3. Migrate settings and data
### Expected result
1. In Magento 1 the specific applied tax rate is shown but is missing from Magento 2


### Actual result
1. 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:
```
sales_order_tax_item.real_base_amount
```
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
```
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

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with etc/opensource-to-opensource/1.9.4.2/map.xml.dist around the sales_order_tax_item mappings, then compare the source database fields with Magento 2 output and review Magento/Tax/Model/Plugin/OrderSave.php. Done means migrated orders retain the relevant tax amounts so the applied tax rate information is available as in Magento 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100