Environment: Dynamics Ax 2012R3CU13
In our France entity, the purchase invoice journal (Accounts payable/Journals/Invoices/Invoice journal) is significantly slower compared to the other entities, f.e. German, Dutch, Swiss. When enabling the SQL trace the following query is the reason for the additional waiting time during invoice entry.
SELECT TOP 1 T1.RECID FROM LEDGERJOURNALTRANS T1 WHERE
(
(
(PARTITION=5637144576) AND (DATAAREAID=N'fr')
) AND
(
(
((JOURNALNUM=?) AND
(
(
(TAXGROUP<>?) AND (TAXITEMGROUP<>?)
) OR (TAXCODE<>?)
)
) OR (TDSGROUP_IN<>?)
) OR (TCSGROUP_IN<>?)
)
)
In the solution reponse of https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/147168/purchase-order-line-very-slow-update-after-editing the same query is mentioned with a change to the statement, add additional parentheses to the statement.
Somehow this did solve the problem but I don't understand why it did, and changing a standard Ax statement/method is not really upgrade friendly. If I run the query direct in SQL, with the questionmarks replaced with the actual data, it takes 30 seconds to get the result. I tried to add the parentheses in the query but still the query takes 30 seconds, which strikes me as odd. Additional: when I remove the TDSGroup_IN and TCSGROUP_IN from the statement in SQL the result is instant, < 1 second.
Furthermore I have looked into why this code is used in France but not in the other entities, but so far haven't found the parameter, class, or method. One mayor difference between the France entity and the other entities is the setup of Conditional Tax. This is only set for France.
Can the code in LedgerJournalTaxDocument.doTaxGroupExistsForDocument_Server be viewed as a bug? Is code the same in Dynamics 365 F&O?
Does anyone had this issue before and found another reason for the additional delay during purchase invoice entry for a specific entity?
Any information shared regarding my problem is welcome and much appreciated.