microsoft / ALAppExtensions

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

[Event Request] Codeunit 5700 User Setup Management - Procedure GetSalesInvoicePostingPolicy / GetPurchaseInvoicePostingPolicy - OnGetSalesInvoicePostingPolicy / OnAfterGetPurchaseInvoicePostingPolicy #27429

Open MH1612 opened 1 month ago

MH1612 commented 1 month ago

Describe the request

Please add the following Event/-s OnGetSalesInvoicePostingPolicy, OnAfterGetPurchaseInvoicePostingPolicy to Procedure GetSalesInvoicePostingPolicy, GetPurchaseInvoicePostingPolicy in Codeunit 5700 User Setup Management.

[Event Request] COD5700 - Acc. Schedule Line - User Setup Management GetSalesInvoicePostingPolicy / GetPurchaseInvoicePostingPolicy
    procedure GetSalesInvoicePostingPolicy(var PostQty: Boolean; var PostAmount: Boolean)
    var
        LocalUserSetup: Record "User Setup";
    begin
        PostQty := false;
        PostAmount := false;

        if UserId <> '' then
            if LocalUserSetup.Get(UserId) then
                case LocalUserSetup."Sales Invoice Posting Policy" of
                    Enum::"Invoice Posting Policy"::Prohibited:
                        begin
                            PostQty := true;
                            PostAmount := false;
                        end;
                    Enum::"Invoice Posting Policy"::Mandatory:
                        begin
                            PostQty := true;
                            PostAmount := true;
                        end;
                end;
         // NEW
         OnGetSalesInvoicePostingPolicy(PostQty,PostAmount)
         // NEW
    end;

    procedure GetPurchaseInvoicePostingPolicy(var PostQty: Boolean; var PostAmount: Boolean)
    var
        LocalUserSetup: Record "User Setup";
    begin
        PostQty := false;
        PostAmount := false;

        if UserId <> '' then
            if LocalUserSetup.Get(UserId) then
                case LocalUserSetup."Purch. Invoice Posting Policy" of
                    Enum::"Invoice Posting Policy"::Prohibited:
                        begin
                            PostQty := true;
                            PostAmount := false;
                        end;
                    Enum::"Invoice Posting Policy"::Mandatory:
                        begin
                            PostQty := true;
                            PostAmount := true;
                        end;
                end;
         // NEW
         OnAfterGetPurchaseInvoicePostingPolicy(PostQty,PostAmount)
         // NEW
    end;
 [IntegrationEvent(false, false)]
 local procedure OnGetSalesInvoicePostingPolicy(var PostQty: Boolean; var PostAmount: Boolean)
    begin
    end;

 [IntegrationEvent(false, false)]
 local procedure OnAfterGetPurchaseInvoicePostingPolicy(var PostQty: Boolean; var PostAmount: Boolean)
    begin
    end;

Additional context

Change default values for User without User Setup Internal work item: AB#555533

JakovljevicDusan commented 1 day ago

Hi @MH1612, Can you add more details about what do you want to achieve? Maybe we should do something more generic in BaseApp.

SKeiler commented 17 hours ago

Hi @JakovljevicDusan ,

We want to overwrite the user setup with a setup on vendor card /customer card. Often it is not a user generic setup if a vendor/customer will be directly invoiced. More often it is a controlled from vendor/customer of it is allowed to Invoice him directly via Order. In the case it is not allowed, a seperate sales or purchase invoice will be created.