Error in Workflow in AX 2012 R2


We are working on AX 2012 R2.

When we tick on prepayment option while posting vendor invoice, we get following error on the Workflow & the workflow stops:

“Unable to cast object of type ‘Dynamics.Ax.Application.TaxReverseTax’ to type ‘Dynamics.Ax.Application.TaxCalculation’.”.

When we post a vendor invoice without ticking on prepayment option, the workflow completes successfully.

But then when trying to apply prepayment after the invoice is generated, we get the following error.

“Function SourceDocumentStateModel.getValidTargetSourceDocAccountingStatus has been incorrectly called.”

Please help in resolving atleast one of the errors so that the process can work further without any issue.


Same problem, does anybody have an answer for this ??

I found that Accounting distribution template was not setup for the Purchase Order.

If it is not setup, it cannot find the required Accounting Status of the Purchase Order from the actual Accounting Distribution, thus assuming it to be “None”. But the accounting status of the Purchase Order was “Completed”.
Due to mismatch between the Accounting Status of the Purchase Order & Accounting Distribution, it was throwing the error.