Business Central | How to keep Sales Order after completely shipped and Invoiced

Hello Expert,

I have a question, I want to keep sales order after completely shipped / invoiced in Dynamics BC. How I can achieve this in BC. In older version of NAV we can go in codeunit 80 and update the variable (EverythingInvoiced) but how we can do in BC-16?  Any suggestion?

Thank you

Devesh

Parents
No Data
Reply
  • Hi Devesh,

    You can keep the fully invoiced documents with a bit of development.

    In CU 80 - Sales-Post you can use two events: 

    OnBeforeDeleteAfterPosting - and return the skipdelete parameter as true.

      [EventSubscriber(ObjectType::Codeunit, CodeUnit::"Sales-Post", 'OnBeforeDeleteAfterPosting', '', true, true)]
        local procedure c80_OnBeforeDeleteAfterPosting(var SalesHeader: Record "Sales Header"; var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var SkipDelete: Boolean; CommitIsSuppressed: Boolean)
    
        begin
            if SalesHeader.IsTemporary then
                exit;
    
            if SalesHeader."Document Type" in [SalesHeader."Document Type"::Order, SalesHeader."Document Type"::"Return Order"] then
                SkipDelete := true;
        end;

    If you do that BC is not going to finish the remaining quantity calculation on the lines so you need to do that!

    So to trigger the calculation you can use the event: OnBeforeFinalizePosting and return the parameter EverythingInvoiced as false.

    [EventSubscriber(ObjectType::Codeunit, CodeUnit::"Sales-Post", 'OnBeforeFinalizePosting', '', true, true)]
        local procedure C80_OnBeforeFinalizePosting(var SalesHeader: Record "Sales Header"; var TempSalesLineGlobal: Record "Sales Line"; var EverythingInvoiced: Boolean; SuppressCommit: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line")
        begin
            if SalesHeader.IsTemporary then
                exit;
    
            EverythingInvoiced := false;
        end;

    I`d personally do some more work around enabling and disabling the feature via setup and also filter on a specific document type.

    Regards,

    Szabolcs 

Children
Related
Recommended