ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Change 411871 in BC 19.1 causes bug with intercompany transactions if the salesorder was generated from IC purchase

Open AMCLdoege opened this issue 4 years ago • 1 comments

Hi, our customers use the intercompany processes extensively and one of them reported a bug while testing in Business Central 19. If you send an purchase order to an IC-Partner company and post the invoice of the generated sales order there isn't any transaction send to the purchasing company. The purchasing company will never get any response to their purchase order, not even an invoice. But this should be ensured like described in Documentation:

For sales and purchase documents, the intercompany partner code on the involved customer or vendor ensures that all orders and invoices generated pertaining to transactions with these companies will produce corresponding documents in the partner company, resulting in correct balancing of the accounts.

we traced the error back to the change 411871 in BC 19 CU 1:

411871 | A duplicated Purchase invoice will be incorrectly generated in another company when posting a sales order generated by an IC transaction based on the purchase order from that company.

Codechanges old from BC 17 Codeunit 80 sales-post lines 2395:

IsHandled := false;
            OnFinalizePostingOnBeforeCreateOutboxSalesTrans(SalesHeader, IsHandled, EverythingInvoiced);
            if not IsHandled then
                if Invoice and ("Bill-to IC Partner Code" <> '') then
                    if "Document Type" in ["Document Type"::Order, "Document Type"::Invoice] then
                        ICInboxOutboxMgt.CreateOutboxSalesInvTrans(SalesInvHeader)
                    else
                        ICInboxOutboxMgt.CreateOutboxSalesCrMemoTrans(SalesCrMemoHeader)

new from 19.5 Codunit 80 sales-post lines 2601:

IsHandled := false;
            OnFinalizePostingOnBeforeCreateOutboxSalesTrans(SalesHeader, IsHandled, EverythingInvoiced, SalesInvHeader, SalesCrMemoHeader);

            if not IsHandled then
                if Invoice and "Send IC Document" then
                    if "Document Type" in ["Document Type"::Order, "Document Type"::Invoice] then
                        ICInboxOutboxMgt.CreateOutboxSalesInvTrans(SalesInvHeader)
                    else
                        ICInboxOutboxMgt.CreateOutboxSalesCrMemoTrans(SalesCrMemoHeader);

Proposed Fix: Set field "Send IC Document" true in codeunit 427 ICInboxOutboxMgt and Function CreateSalesDocument.

AMCLdoege avatar Mar 23 '22 10:03 AMCLdoege

Hi @AMCLdoege , This issue was already reported by several partners about half a year ago. On one hand, it is good to have a confirmation that invoice is posted in another company. On the other hand, a duplicated invoice is created in the company which created and posted the original intercompany invoice. So it was decided to leave the current behaviour and to propose an extension to those partners who want to return the old behaviour.

I attached the extension code, please rename it to .al if needed. SendICIncomingDocuments.Codeunit.txt .

AleksanderGladkov avatar Apr 11 '22 10:04 AleksanderGladkov