microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
791 stars 622 forks source link

[Event Request] codeunit 80 "Sales-Post" / 90 "Purch.-Post" - ValidatePostingAndDocumentDate - OnValidatePostingAndDocumentDateOnAfterCalcVATDateExists #27661

Open fvet opened 1 day ago

fvet commented 1 day ago

Describe the request

With the introduction of the 'VAT Date', we would like to read all 'Date' parameters - including the VAT Date parameter - in codeunit 80 "Sales-Post" - ValidatePostingAndDocumentDate via a single publisher.

Please either add the VAT date parameters to OnValidatePostingAndDocumentDateOnAfterCalcPostingDateExists (and move the publishers one line lower), or introduce a new OnValidatePostingAndDocumentDateOnAfterGetParameters publishers will all parameters and obsolete OnValidatePostingAndDocumentDateOnAfterCalcPostingDateExists

OnBeforeValidatePostingAndDocumentDate(SalesHeader, SuppressCommit);

        PostingDateExists :=
          BatchProcessingMgt.GetBooleanParameter(SalesHeader.RecordId, Enum::"Batch Posting Parameter Type"::"Replace Posting Date", ReplacePostingDate) and
          BatchProcessingMgt.GetBooleanParameter(
            SalesHeader.RecordId, Enum::"Batch Posting Parameter Type"::"Replace Document Date", ReplaceDocumentDate) and
          BatchProcessingMgt.GetDateParameter(SalesHeader.RecordId, Enum::"Batch Posting Parameter Type"::"Posting Date", PostingDate);
// OnValidatePostingAndDocumentDateOnAfterCalcPostingDateExists(PostingDateExists, ReplacePostingDate, ReplaceDocumentDate, PostingDate, SalesHeader, ModifyHeader); // Move to include the VAT Date fields

        VATDateExists := BatchProcessingMgt.GetBooleanParameter(SalesHeader.RecordId, Enum::"Batch Posting Parameter Type"::"Replace VAT Date", ReplaceVATDate);
        BatchProcessingMgt.GetDateParameter(SalesHeader.RecordId, Enum::"Batch Posting Parameter Type"::"VAT Date", VATDate);

        OnValidatePostingAndDocumentDateOnAfterGetParameters(PostingDateExists, ReplacePostingDate, ReplaceDocumentDate, PostingDate, VATDateExists, ReplaceVATDate, VATDate, SalesHeader, ModifyHeader); // MOVE AND EXTEND PUBLISHER

        if PostingDateExists and (ReplacePostingDate or (SalesHeader."Posting Date" = 0D)) then begin
            SalesHeader."Posting Date" := PostingDate;
            SalesHeader.SynchronizeAsmHeader();
            SalesHeader.Validate("Currency Code");
            ModifyHeader := true;
        end;
 [IntegrationEvent(false, false)]
    local procedure OnValidatePostingAndDocumentDateOnAfterGetParameters(var PostingDateExists: Boolean; var ReplacePostingDate: Boolean; var ReplaceDocumentDate: Boolean; var PostingDate: Date; var VATDateExists: Boolean; var ReplaceVATDate: Boolean; var VATDate: Date; var SalesHeader: Record "Sales Header"; var ModifyHeader: Boolean)
    begin
    end;

Please provide the same in codeunit 90 "Purch.-Post" as well.

Additional context

x Internal work item: AB#558144

nikolakukrika commented 1 day ago

We cannot move the event because it is a protentional breaking change. We could introduce a new event.