My guess is that there might be some code running elsewhere, either in your codebase or within Vendr that runs in reaction to an order save event. The problem is, as soon as Finalize is called, any modifications to the order will be blocked as you aren't allowed to modify anything from this point on that would require a recalculation.
Simplest option would probably be to break up the update / finalize into their own units of work so that you can ensure anything that modifies the order is completely done in the first unit of work, and the finalize is called on it's own after this point.
Alternatively, you can try and pinpount the code that is trying to modify the order after Finalize is called and see if that can be moved / triggered prior to the method call.
Finalize an order created programmatically without payment
I'm trying to finalize an order created programmatically without payment, but I get the following exception when trying to save the order:
I can that on the order IsFinalized = false, IsFinalizing = true, FinalizedDate = {3/5/2021 1:29:56 PM} and _originalState.FinalizedDate = null
Here is the code:
Hi Kenni
My guess is that there might be some code running elsewhere, either in your codebase or within Vendr that runs in reaction to an order save event. The problem is, as soon as
Finalize
is called, any modifications to the order will be blocked as you aren't allowed to modify anything from this point on that would require a recalculation.Simplest option would probably be to break up the update / finalize into their own units of work so that you can ensure anything that modifies the order is completely done in the first unit of work, and the finalize is called on it's own after this point.
Alternatively, you can try and pinpount the code that is trying to modify the order after
Finalize
is called and see if that can be moved / triggered prior to the method call.Hope that helps
Matt
is working on a reply...