Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] - Codeunit "Alt. Cust. VAT Reg. Doc. Impl." - Procedure UpdateSetupOnBillToCustomerChangeInSalesHeader #27892

Open
DanielHaglo opened this issue Jan 8, 2025 · 0 comments

Comments

@DanielHaglo
Copy link

Describe the request


    procedure UpdateSetupOnBillToCustomerChangeInSalesHeader(var SalesHeader: Record "Sales Header"; xSalesHeader: Record "Sales Header"; BillToCustomer: Record Customer)
    var
        GLSetup: Record "General Ledger Setup";
    begin
        GLSetup.Get();
        if GLSetup."Bill-to/Sell-to VAT Calc." <> GLSetup."Bill-to/Sell-to VAT Calc."::"Bill-to/Pay-to No." then
            exit;

        if IsAltVATRegUsed(SalesHeader) then begin
            if SalesHeader."Bill-to Customer No." = SalesHeader."Sell-to Customer No." then
                exit;
            CopyFromCustomer(SalesHeader, xSalesHeader, BillToCustomer);
            exit;
        end;
        if (SalesHeader."VAT Bus. Posting Group" <> '') and (SalesHeader."VAT Bus. Posting Group" <> BillToCustomer."VAT Bus. Posting Group") then
            SalesHeader.Validate("VAT Bus. Posting Group", BillToCustomer."VAT Bus. Posting Group")
        else
            SalesHeader."VAT Bus. Posting Group" := BillToCustomer."VAT Bus. Posting Group";
        SalesHeader."VAT Country/Region Code" := BillToCustomer."Country/Region Code";
        SalesHeader."VAT Registration No." := BillToCustomer."VAT Registration No.";
        SalesHeader."Registration Number" := BillToCustomer."Registration Number";
        SalesHeader."Gen. Bus. Posting Group" := BillToCustomer."Gen. Bus. Posting Group";
        //NewEvent
        OnAfterUpdateSetupOnBillToCustomerChangeInSalesHeader(SalesHeader,BillToCustomer);
        //NewEvent
    end;

  [IntegrationEvent(false, false)]
    local procedure OnAfterUpdateSetupOnBillToCustomerChangeInSalesHeader(var SalesHeader: Record "Sales Header"; Customer: Record Customer)
    begin
    end;

Additional context

To not replicate code when setting custom VAT Registration field from bill to customer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant