magento / magento/data-migration-tool

Tax rate information missing

Open
#709 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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
![image](https://user-images.githubusercontent.com/455508/61598119-f6e29280-ac6c-11e9-8304-4fd32ff2f7b0.png)
![image](https://user-images.githubusercontent.com/455508/61598142-4923b380-ac6d-11e9-91c5-961d9c35b872.png)

### 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
![image](https://user-images.githubusercontent.com/455508/61598090-a834f880-ac6c-11e9-9705-3488f20c64a3.png)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.