Invoice Batching – Can't Set the Cost Account Key

SOLVED

When invoicing RMA's, we use logic in a custom script to set the cost account key and the sales account key on the line items based on based on the customer division. When I go to the newly created invoice, the sales account key has the correct value, but the cost account key somehow retains its original value as if it were never updated.

I've verified that we are setting the cost account key properly in our custom logic, but somehow it is being reverted to its original value. We have no other custom logic that could set this field.

Any insights on how the cost account key is being reverted to its original value would be appreciated.