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 550 - VAT Rate Change Conversion - OnAfterUpdateTable #5316

Closed
MattiLE opened this issue Dec 18, 2019 · 4 comments
Closed
Labels
event-request Request for adding an event ships-in-future-update Fix ships in a future update

Comments

@MattiLE
Copy link
Contributor

MattiLE commented Dec 18, 2019

Hi AL-Team,
can you please add the following publishers to Convert?

local procedure Convert()
    var
        GenProductPostingGroup: Record "Gen. Product Posting Group";
        TempGenProductPostingGroup: Record "Gen. Product Posting Group" temporary;
    begin
        VATRateChangeSetup.TestField("VAT Rate Change Tool Completed", false);
        if VATRateChangeConversion.IsEmpty then
            Error(Text0015);
        if not AreTablesSelected then
            Error(Text0016);
        TestVATPostingSetup;
        ProgressWindow.Open(Text0001 + Text0002);
        with VATRateChangeSetup do begin
            ProgressWindow.Update;
            UpdateTable(
              DATABASE::"Gen. Product Posting Group",
              ConvertVATProdPostGrp("Update Gen. Prod. Post. Groups"), ConvertGenProdPostGrp("Update Gen. Prod. Post. Groups"));
            TempGenProductPostingGroup.DeleteAll;
            if GenProductPostingGroup.Find('-') then
                repeat
                    TempGenProductPostingGroup := GenProductPostingGroup;
                    TempGenProductPostingGroup.Insert;
                    GenProductPostingGroup."Auto Insert Default" := false;
                    GenProductPostingGroup.Modify;
                until GenProductPostingGroup.Next = 0;
            UpdateItem;
            UpdateRessouce;
            UpdateGLAccount;
            UpdateServPriceAdjDetail;
            UpdatePurchase;
            UpdateSales;
            UpdateService;
            UpdateTable(
              DATABASE::"Item Template",
              ConvertVATProdPostGrp("Update Item Templates"), ConvertGenProdPostGrp("Update Item Templates"));
            UpdateTable(
              DATABASE::"Item Charge",
              ConvertVATProdPostGrp("Update Item Charges"), ConvertGenProdPostGrp("Update Item Charges"));
            UpdateTable(
              DATABASE::"Gen. Journal Line",
              ConvertVATProdPostGrp("Update Gen. Journal Lines"), ConvertGenProdPostGrp("Update Gen. Journal Lines"));
            UpdateTable(
              DATABASE::"Gen. Jnl. Allocation",
              ConvertVATProdPostGrp("Update Gen. Journal Allocation"), ConvertGenProdPostGrp("Update Gen. Journal Allocation"));
            UpdateTable(
              DATABASE::"Standard General Journal Line",
              ConvertVATProdPostGrp("Update Std. Gen. Jnl. Lines"), ConvertGenProdPostGrp("Update Std. Gen. Jnl. Lines"));
            UpdateTable(
              DATABASE::"Res. Journal Line",
              ConvertVATProdPostGrp("Update Res. Journal Lines"), ConvertGenProdPostGrp("Update Res. Journal Lines"));
            UpdateTable(
              DATABASE::"Job Journal Line",
              ConvertVATProdPostGrp("Update Job Journal Lines"), ConvertGenProdPostGrp("Update Job Journal Lines"));
            UpdateTable(
              DATABASE::"Requisition Line",
              ConvertVATProdPostGrp("Update Requisition Lines"), ConvertGenProdPostGrp("Update Requisition Lines"));
            UpdateTable(
              DATABASE::"Standard Item Journal Line",
              ConvertVATProdPostGrp("Update Std. Item Jnl. Lines"), ConvertGenProdPostGrp("Update Std. Item Jnl. Lines"));
            UpdateTable(
              DATABASE::"Production Order",
              ConvertVATProdPostGrp("Update Production Orders"), ConvertGenProdPostGrp("Update Production Orders"));
            UpdateTable(
              DATABASE::"Work Center",
              ConvertVATProdPostGrp("Update Work Centers"), ConvertGenProdPostGrp("Update Work Centers"));
            UpdateTable(
              DATABASE::"Machine Center",
              ConvertVATProdPostGrp("Update Machine Centers"), ConvertGenProdPostGrp("Update Machine Centers"));
            UpdateTable(
              DATABASE::"Reminder Line",
              ConvertVATProdPostGrp("Update Reminders"), ConvertGenProdPostGrp("Update Reminders"));
            UpdateTable(
              DATABASE::"Finance Charge Memo Line",
              ConvertVATProdPostGrp("Update Finance Charge Memos"), ConvertGenProdPostGrp("Update Finance Charge Memos"));
            // NEW >>>>
            OnAfterUpdateTable(VATRateChangeSetup);
            // NEW <<<<
            GenProductPostingGroup.DeleteAll;
            if TempGenProductPostingGroup.Find('-') then
                repeat
                    GenProductPostingGroup := TempGenProductPostingGroup;
                    GenProductPostingGroup.Insert;
                    TempGenProductPostingGroup.Delete;
                until TempGenProductPostingGroup.Next = 0;
        end;
        ProgressWindow.Close;
        if VATRateChangeSetup."Perform Conversion" then begin
            VATRateChangeSetup."VAT Rate Change Tool Completed" := true;
            VATRateChangeSetup.Modify;
            VATRateChangeConversion.Reset;
            if VATRateChangeConversion.FindSet(true) then
                repeat
                    VATRateChangeConversion."Converted Date" := WorkDate;
                    VATRateChangeConversion.Modify;
                until VATRateChangeConversion.Next = 0;
        end;
    end;
    [IntegrationEvent(false, false)]
    local procedure OnAfterUpdateTable(VATRateChangeSetup: Record "VAT Rate Change Setup")
    begin
    end;

I also need access to the following functions.

    // local procedure ConvertVATProdPostGrp(UpdateOption: Option): Boolean
    procedure ConvertVATProdPostGrp(UpdateOption: Option): Boolean
    var
        DummyVATRateChangeSetup: Record "VAT Rate Change Setup";
    begin
        if UpdateOption in [DummyVATRateChangeSetup."Update Items"::"VAT Prod. Posting Group",
                            DummyVATRateChangeSetup."Update Items"::Both]
        then
            exit(true);
        exit(false);
    end;

    // local procedure ConvertGenProdPostGrp(UpdateOption: Option): Boolean
    procedure ConvertGenProdPostGrp(UpdateOption: Option): Boolean
    var
        DummyVATRateChangeSetup: Record "VAT Rate Change Setup";
    begin
        if UpdateOption in [DummyVATRateChangeSetup."Update Items"::"Gen. Prod. Posting Group",
                            DummyVATRateChangeSetup."Update Items"::Both]
        then
            exit(true);
        exit(false);
    end;

    // local procedure UpdateTable(TableID: Integer; ConvertVATProdPostingGroup: Boolean; ConvertGenProdPostingGroup: Boolean)
    procedure UpdateTable(TableID: Integer; ConvertVATProdPostingGroup: Boolean; ConvertGenProdPostingGroup: Boolean)
    var
        RecRef: RecordRef;
        I: Integer;
    begin
        if not ConvertVATProdPostingGroup and not ConvertGenProdPostingGroup then
            exit;
        RecRef.Open(TableID);
        ProgressWindow.Update(1, Format(RecRef.Caption));
        I := 0;
        ProgressWindow.Update(3, RecRef.Count);
        if RecRef.Find('-') then
            repeat
                I := I + 1;
                ProgressWindow.Update(2, I);
                UpdateRec(RecRef, ConvertVATProdPostingGroup, ConvertGenProdPostingGroup);
            until RecRef.Next = 0;
    end;
@AlexanderYakunin AlexanderYakunin added the event-request Request for adding an event label Dec 18, 2019
@bc-ghost bc-ghost added the ships-in-future-update Fix ships in a future update label Dec 25, 2019
@bc-ghost
Copy link

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.

@bc-ghost
Copy link

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.

2 similar comments
@bc-ghost
Copy link

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.

@bc-ghost
Copy link

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event ships-in-future-update Fix ships in a future update
Projects
None yet
Development

No branches or pull requests

3 participants