Payments from Commerce 1 have wrong decimal place

Created on 16 September 2021, about 3 years ago
Updated 9 July 2023, over 1 year ago

Problem/Motivation

I am migrating from Drupal 7 + Commerce 1.x to Drupal 9 + Commerce 2.x. All my payments have the decimal point in the wrong place. This is not a problem with prices.

Steps to reproduce

Migrate from Drupal 7 to Drupal 9. Then check the databases.

I need to skip some values that were not migrated. My D7 database:

MySQL [drupal]> SELECT transaction_id, order_id, payment_method, amount
    -> FROM commerce_payment_transaction                                      
    -> WHERE transaction_id > 171 LIMIT 0,5; 
+----------------+----------+----------------+--------+
| transaction_id | order_id | payment_method | amount |
+----------------+----------+----------------+--------+
|            172 |      215 | authnet_aim    |  22467 |
|            173 |      219 | authnet_aim    |  59500 |
|            174 |      222 | authnet_aim    |  18752 |
|            179 |      231 | authnet_aim    |  14595 |
|            180 |      231 | authnet_aim    |  14595 |
+----------------+----------+----------------+--------+
5 rows in set (0.00 sec)

And my D9 database:

MySQL [default]> SELECT payment_id, order_id, amount__number
    -> FROM commerce_payment LIMIT 0,5;
+------------+----------+----------------+
| payment_id | order_id | amount__number |
+------------+----------+----------------+
|        172 |      215 |     22467.0000 |
|        173 |      219 |   59500.000000 |
|        174 |      222 |   18752.000000 |
|        179 |      231 |   14595.000000 |
|        180 |      231 |   14595.000000 |
+------------+----------+----------------+
5 rows in set (0.000 sec)

In Drupal 9, all those values should have two more digits after the decimal point.

Proposed resolution

Divide by 100 in the prepareRow() method of the migration source.

This works for my use case. We might have to work harder to handle all cases.

Remaining tasks

Add test coverage.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

3.2

Component

Drupal Commerce 1.x

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024