microsoft / ALAppExtensions

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

Codeunit 6109 "E-Document Import Helper"- event publisher request #27247

Closed AmineAbdouli closed 4 weeks ago

AmineAbdouli commented 2 months ago

Describe the request

Hello, I would like to request the addition of a new event in the function "ValidateReceivingCompanyInfo" within Codeunit 6109 "E-Document Import Helper". Currently, the validation checks the "VAT Registration No.", but in our case, beacause of Belgian localization we need to check on the "Enterprise No." instead. To accommodate this scenario and allow for greater flexibility, it would be beneficial if you could add a corresponding event to extend this function, enabling developers to override the default validation or add custom logic.

Additional context

procedure ValidateReceivingCompanyInfo(EDocument: Record "E-Document")
var
    CompanyInformation: Record "Company Information";
    IsHandled: Boolean;
begin
    CompanyInformation.Get();

    if (EDocument."Receiving Company GLN" = '') and (EDocument."Receiving Company VAT Reg. No." = '') then begin
        ValidateReceivingCompanyInfoByNameAndAddress(EDocument);
        exit;
    end;

    OnBeforeCheckGLNandVATRegistrationNo(EDocument,IsHandled);
    if not IsHandled then
        if (CompanyInformation.GLN = '') and (CompanyInformation."VAT Registration No." = '') then
            EDocErrorHelper.LogErrorMessage(EDocument, CompanyInformation, CompanyInformation.FieldNo(GLN), MissingCompanyInfoSetupErr);

    if EDocument."Receiving Company GLN" <> '' then
        if not (CompanyInformation.GLN in ['', EDocument."Receiving Company GLN"]) then
            EDocErrorHelper.LogErrorMessage(EDocument, CompanyInformation, CompanyInformation.FieldNo(GLN), StrSubstNo(InvalidCompanyInfoGLNErr, EDocument."Receiving Company GLN"));

    if not (ExtractVatRegNo(CompanyInformation."VAT Registration No.", '') in ['', ExtractVatRegNo(EDocument."Receiving Company VAT Reg. No.", '')]) then
        EDocErrorHelper.LogErrorMessage(EDocument, CompanyInformation, CompanyInformation.FieldNo("VAT Registration No."), StrSubstNo(InvalidCompanyInfoVATRegNoErr, EDocument."Receiving Company VAT Reg. No."));
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckGLNandVATRegistrationNo(var EDocument: Record "E-Document"; var IsHandled: Boolean)
begin
end;

Internal work item: AB#548952

Roglar01 commented 1 month ago

This would be beneficial for everyone extending the e-doc framework, since not all formats uses VAT och GLN identities. To overcome this issue, I had to duplicate code by adding a new format.

Groenbech96 commented 1 month ago

Good points. Will look into it.

Groenbech96 commented 4 weeks ago

I have recorded this on an internal work-item. Do not have an ETA on when this will be picked up by team. Will close this ticket.