Contribution receive_date is incorrectly updated to now when importing historical transactions
Overview
I am importing historical transactions using Order.create followed by Payment.create. When the order is first created, the receive_date I have provided via the API is used for the receive_date of the Contribution. (I will stop providing a receive_date when I create the Contribution now, but I was doing so for debugging.) After applying a payment, and despite passing both trxn_date and receive_date, the Contribution's receive_date is updated to the current date.
Workaround: I am now correcting the receive_date with a supplementary create(update) call to the Contribution API after applying the payment.
I got a little lost in all the many layers of the Order/Contribution/Payments API but I believe that by the time the contribution entry is updated with the payment information, the "irrelevant" fields have been stripped away and there is no value to be applied to the receive_date field, so it reverts to the default of now.
Also - see #1832 (closed) - Event Registration activities also use the incorrect date.
Expected behaviour
I understand there is a lot going on with this API per e.g. #1403, but since receive_date is the most prominent date associated with a contribution after it has been created, there should be a way to correctly set this via the API.
Environment information
- CiviCRM: 5.26.1