vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.6k stars 993 forks source link

Attempting to add manual payment to order with multiple modifications result in 'duplicate key' error #2677

Open promisetochi opened 7 months ago

promisetochi commented 7 months ago

Describe the bug When multiple modifications (adjustOrderLines and addItems specifically) are made on an order, attempting to add manual payment to the order results in the error, duplicate key value violates unique constraint REL_ad29....

To Reproduce Steps to reproduce the behavior:

  1. Transition an order from PaymentSettled to Modifying
  2. Make multiple modifications to the order via API
  3. Transition order to ArrangingAdditionalPayment
  4. Attempt to add manual payment to order
  5. API returns an error

Expected behavior Manual payment is added to order and the order can be transitioned to PaymentSettled

Environment (please complete the following information):

Additional context Add any other context about the problem here.

michaelbromley commented 7 months ago

Is upgrading an option? You are on a version that was released in 2022 - lots has changed since then!

promisetochi commented 7 months ago

Hey @michaelbromley Upgrading is not an option in the short term (1-6 weeks), although I fully agree that an upgrade is needed. I took a look at the core implementation on the latest version tho and it seemed like the same issue should be happening, that's why I went ahead and opened the issue.

https://github.com/vendure-ecommerce/vendure/blob/f02fc563cd38517d3c8cc572fd47c676aff4c974/packages/core/src/service/services/order.service.ts#L1146

I'll try to see if the same thing happens on the latest version.

ghosttly commented 1 day ago

Hello @michaelbromley, i just wanna say that at version 2.3.0 problem still exists. After first order modification we are able add manual payment to order. When we are modifying order second time, we can't.