Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Unable to install UKMakingTaxDigital app

Posted on by 15

Hello,

Our customer has a BC 365 W1 on prem install - version 16.1. Customer has business in the UK and wants to use the UKMakingTaxDigital extension provided on the BC install pack with UK localisation.

I extracted the UKMakingTaxDigital extension from the 16.1 UK install package. Now I am trying to install the app on W1 install, but this fails.

Error:

Publish-NAVApp : Extension compilation failed
src/Setup/MTDInstall.Codeunit.al(136,26): error AL0185: Table 'MTD-Liability' is missing
src/Setup/MTDInstall.Codeunit.al(157,24): error AL0185: Table 'MTD-Payment' is missing
src/Setup/MTDInstall.Codeunit.al(177,30): error AL0185: Table 'MTD-Return Details' is missing
At line:1 char:1
Publish-NAVApp -ServerInstance myService -Path "C:\software\ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidOperation: (:) [Publish-NAVApp], InvalidOperationException
FullyQualifiedErrorId : MicrosoftDynamicsNavServer$myService/nav-systemapplication,Microsoft.Dynamics.Nav.Apps.Management.Cmdlets.PublishNavApp

When I take a look at the source code, there is a change in table names from 'MTD-Liability' to 'MTDLiability' and so on.

// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

codeunit 10539 "MTD Install"
{
    Subtype = Install;

    var
        VATReportLbl: Label 'HMRC MTD', Locked = true;
        NoSeriesCodeTxt: Label 'VATPERIODS', Locked = true;
        NoSeriesDescTxt: Label 'VAT Return Periods';
        VATReturnPeriodStartTxt: Label 'VATPER-0001', Locked = true;
        VATReturnPeriodEndTxt: Label 'VATPER-9999', Locked = true;

    trigger OnInstallAppPerCompany()
    var
        UpgradeTag: Codeunit "Upgrade Tag";
    begin
        OnCompanyInitialize();

        if InitializeDone() then
            exit;

        MoveTableMTDLiability();
        MoveTableMTDPayment();
        MoveTableMTDReturnDetails();

        UpgradeTag.SetAllUpgradeTags();
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Company-Initialize", 'OnCompanyInitialize', '', false, false)]
    local procedure OnCompanyInitialize()
    var
        OAuth20Setup: Record "OAuth 2.0 Setup";
        MTDOAuth20Mgt: Codeunit "MTD OAuth 2.0 Mgt";
        VATReportLabelText: Code[10];
    begin
        if not OAuth20Setup.Get(MTDOAuth20Mgt.GetOAuthPRODSetupCode()) then
            MTDOAuth20Mgt.InitOAuthSetup(OAuth20Setup, MTDOAuth20Mgt.GetOAuthPRODSetupCode());

        VATReportLabelText := CopyStr(VATReportLbl, 1, MaxStrLen(VATReportLabelText));
        InitVATReportsConfiguration(VATReportLabelText);

        InitVATReportSetup(VATReportLabelText);
        ApplyEvaluationClassificationsForPrivacy();
    end;

    local procedure InitializeDone(): boolean
    var
        AppInfo: ModuleInfo;
    begin
        NavApp.GetCurrentModuleInfo(AppInfo);
        exit(AppInfo.DataVersion() <> Version.Create('0.0.0.0'));
    end;

    local procedure InitNoSeries() SeriesCode: Code[20]
    var
        NoSeries: Record "No. Series";
    begin
        SeriesCode := CopyStr(NoSeriesCodeTxt, 1, MaxStrLen(SeriesCode));
        if not NoSeries.Get(SeriesCode) then
            InsertSeries(
              SeriesCode, SeriesCode, CopyStr(NoSeriesDescTxt, 1, 30),
              CopyStr(VATReturnPeriodStartTxt, 1, 20), CopyStr(VATReturnPeriodEndTxt, 1, 20), '', '', 1, true);
    end;

    local procedure InitVATReportSetup(VATReportLabelText: Code[10])
    var
        VATReportSetup: Record "VAT Report Setup";
    begin
        with VATReportSetup do begin
            if not Get() then
                Insert();
            if ("VAT Return Period No. Series" = '') or ("Report Version" = '') then begin
                if "VAT Return Period No. Series" = '' then
                    "VAT Return Period No. Series" := InitNoSeries();
                "Report Version" := VATReportLabelText;
                "Update Period Job Frequency" := "Update Period Job Frequency"::Never;
                "Manual Receive Period CU ID" := Codeunit::"MTD Manual Receive Period";
                "Auto Receive Period CU ID" := Codeunit::"MTD Auto Receive Period";
                "Receive Submitted Return CU ID" := Codeunit::"MTD Receive Submitted";
                InitProductionMode(VATReportSetup);
                InitPeriodReminderCalculation(VATReportSetup);
                "MTD Disable FraudPrev. Headers" := false;
                Modify();
            end;
        end;
    end;

    local procedure InitVATReportsConfiguration(VATReportVersion: Code[10])
    var
        VATReportsConfiguration: Record "VAT Reports Configuration";
    begin
        with VATReportsConfiguration do
            if not Get("VAT Report Type"::"VAT Return", VATReportVersion) then begin
                "VAT Report Type" := "VAT Report Type"::"VAT Return";
                "VAT Report Version" := VATReportVersion;

                "Suggest Lines Codeunit ID" := Codeunit::"VAT Report Suggest Lines";
                "Content Codeunit ID" := Codeunit::"MTD Create Return Content";
                "Submission Codeunit ID" := Codeunit::"MTD Submit Return";
                "Validate Codeunit ID" := Codeunit::"MTD Validate Return";
                Insert();
            end;
    end;

    local procedure ApplyEvaluationClassificationsForPrivacy()
    var
        VATReportSetup: Record "VAT Report Setup";
        Company: Record Company;
        DataClassificationMgt: Codeunit "Data Classification Mgt.";
    begin
        Company.Get(CompanyName());
        if not Company."Evaluation Company" then
            exit;

        DataClassificationMgt.SetTableFieldsToNormal(Database::"MTD Return Details");
        DataClassificationMgt.SetTableFieldsToNormal(Database::"MTD Liability");
        DataClassificationMgt.SetTableFieldsToNormal(Database::"MTD Payment");
        DataClassificationMgt.SetFieldToNormal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD OAuth Setup Option"));
        DataClassificationMgt.SetFieldToNormal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD Gov Test Scenario"));
        DataClassificationMgt.SetFieldToNormal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD Disable FraudPrev. Headers"));
        DataClassificationMgt.SetFieldToNormal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD FP WinClient Due DateTime"));
        DataClassificationMgt.SetFieldToNormal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD FP WebClient Due DateTime"));
        DataClassificationMgt.SetFieldToNormal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD FP Batch Due DateTime"));
        DataClassificationMgt.SetFieldToPersonal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD FP WinClient Json"));
        DataClassificationMgt.SetFieldToPersonal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD FP WebClient Json"));
        DataClassificationMgt.SetFieldToPersonal(Database::"VAT Report Setup", VATReportSetup.FieldNo("MTD FP Batch Json"));
    end;

    local procedure MoveTableMTDLiability();
    var
        MTDLiabilityNew: Record "MTD Liability";
        MTDLiabilityOld: Record "MTD-Liability";
    begin
        if MTDLiabilityOld.FindSet() then begin
            repeat
                MTDLiabilityNew.Init();
                MTDLiabilityNew.Validate("From Date", MTDLiabilityOld."From Date");
                MTDLiabilityNew.Validate("To Date", MTDLiabilityOld."To Date");
                MTDLiabilityNew.Validate(Type, MTDLiabilityOld.Type);
                MTDLiabilityNew.Validate("Original Amount", MTDLiabilityOld."Original Amount");
                MTDLiabilityNew.Validate("Outstanding Amount", MTDLiabilityOld."Outstanding Amount");
                MTDLiabilityNew.Validate("Due Date", MTDLiabilityOld."Due Date");
                MTDLiabilityNew.Insert(true);
            until MTDLiabilityOld.Next() = 0;

            MTDLiabilityOld.DeleteAll();
        end;
    end;

    local procedure MoveTableMTDPayment();
    var
        MTDPaymentNew: Record "MTD Payment";
        MTDPaymentOld: Record "MTD-Payment";
    begin
        if MTDPaymentOld.FindSet() then begin
            repeat
                MTDPaymentNew.Init();
                MTDPaymentNew.Validate("Start Date", MTDPaymentOld."Start Date");
                MTDPaymentNew.Validate("End Date", MTDPaymentOld."End Date");
                MTDPaymentNew.Validate("Entry No.", MTDPaymentOld."Entry No.");
                MTDPaymentNew.Validate("Received Date", MTDPaymentOld."Received Date");
                MTDPaymentNew.Validate(Amount, MTDPaymentOld.Amount);
                MTDPaymentNew.Insert(true);
            until MTDPaymentOld.Next() = 0;

            MTDPaymentOld.DeleteAll();
        end;
    end;

    local procedure MoveTableMTDReturnDetails();
    var
        MTDReturnDetailsNew: Record "MTD Return Details";
        MTDReturnDetailsOld: Record "MTD-Return Details";
    begin
        if MTDReturnDetailsOld.FindSet() then begin
            repeat
                MTDReturnDetailsNew.Init();
                MTDReturnDetailsNew.Validate("Start Date", MTDReturnDetailsOld."Start Date");
                MTDReturnDetailsNew.Validate("End Date", MTDReturnDetailsOld."End Date");
                MTDReturnDetailsNew.Validate("Period Key", MTDReturnDetailsOld."Period Key");
                MTDReturnDetailsNew.Validate("VAT Due Sales", MTDReturnDetailsOld."VAT Due Sales");
                MTDReturnDetailsNew.Validate("VAT Due Acquisitions", MTDReturnDetailsOld."VAT Due Acquisitions");
                MTDReturnDetailsNew.Validate("Total VAT Due", MTDReturnDetailsOld."Total VAT Due");
                MTDReturnDetailsNew.Validate("VAT Reclaimed Curr Period", MTDReturnDetailsOld."VAT Reclaimed Curr Period");
                MTDReturnDetailsNew.Validate("Net VAT Due", MTDReturnDetailsOld."Net VAT Due");
                MTDReturnDetailsNew.Validate("Total Value Sales Excl. VAT", MTDReturnDetailsOld."Total Value Sales Excl. VAT");
                MTDReturnDetailsNew.Validate("Total Value Purchases Excl.VAT", MTDReturnDetailsOld."Total Value Purchases Excl.VAT");
                MTDReturnDetailsNew.Validate("Total Value Goods Suppl. ExVAT", MTDReturnDetailsOld."Total Value Goods Suppl. ExVAT");
                MTDReturnDetailsNew.Validate("Total Acquisitions Excl. VAT", MTDReturnDetailsOld."Total Acquisitions Excl. VAT");
                MTDReturnDetailsNew.Validate(Finalised, MTDReturnDetailsOld.Finalised);
                MTDReturnDetailsNew.Insert(true);
            until MTDReturnDetailsOld.Next() = 0;

            MTDReturnDetailsOld.DeleteAll();
        end;
    end;

    local procedure InsertSeries(var SeriesCode: code[20]; Code: Code[20]; Description: Text[30]; StartingNo: Code[20]; EndingNo: Code[20]; LastNumberUsed: Code[20]; WarningNo: Code[20]; IncrementByNo: Integer; ManualNos: Boolean)
    var
        NoSeries: Record "No. Series";
        NoSeriesLine: Record "No. Series Line";
    begin
        NoSeries.Init();
        NoSeries.Code := Code;
        NoSeries.Description := Description;
        NoSeries."Default Nos." := true;
        NoSeries."Manual Nos." := ManualNos;
        NoSeries.Insert();

        NoSeriesLine.Init();
        NoSeriesLine."Series Code" := NoSeries.Code;
        NoSeriesLine."Line No." := 10000;
        NoSeriesLine.VALIDATE("Starting No.", StartingNo);
        NoSeriesLine.VALIDATE("Ending No.", EndingNo);
        NoSeriesLine.VALIDATE("Last No. Used", LastNumberUsed);
        if WarningNo <> '' then
            NoSeriesLine.VALIDATE("Warning No.", WarningNo);
        NoSeriesLine.VALIDATE("Increment-by No.", IncrementByNo);
        NoSeriesLine.Insert(true);

        SeriesCode := Code;
    end;

    internal procedure InitProductionMode(var VATReportSetup: Record "VAT Report Setup"): Boolean
    begin
        with VATReportSetup do begin
            if "MTD OAuth Setup Option" = "MTD OAuth Setup Option"::Production then
                exit(false);

            "MTD OAuth Setup Option" := "MTD OAuth Setup Option"::Production;
            "MTD Gov Test Scenario" := '';
            exit(true);
        end;
    end;

    internal procedure InitPeriodReminderCalculation(var VATReportSetup: Record "VAT Report Setup"): Boolean
    var
        DateFormulaText: Text;
    begin
        with VATReportSetup do begin
            if IsPeriodReminderCalculation() or ("Period Reminder Time" = 0) then
                exit(false);

            DateFormulaText := StrSubstNo('<>', "Period Reminder Time");
            Evaluate("Period Reminder Calculation", DateFormulaText);
            "Period Reminder Time" := 0;
            exit(true);
        end;
    end;
}

This is the first install of the 'Microsoft_Making Tax Digital Localization for United Kingdom.app' on this environment - So for the moment there is no need to bother about the 'old' tables.

Does anyone know how to get around this error? 

Many thanks for your help!

Best regards,

Guy

  

  • Suggested answer
    GuyF Profile Picture
    GuyF 15 on at
    RE: Unable to install UKMakingTaxDigital app

    I did some investigation and you're right.

    Thanks Dirk

  • Suggested answer
    Dirk Profile Picture
    Dirk on at
    RE: Unable to install UKMakingTaxDigital app

    As far as I know the UKMakingTaxDigital app works only on a UK installation.

    Not on W1 or any local version, except the UK version.

    Hope this helps

  • GuyF Profile Picture
    GuyF 15 on at
    RE: Unable to install UKMakingTaxDigital app

    Just some more information:

    The following install commands were executed, but no luck so far:

    Publish-NAVApp -ServerInstance MyService -Path "C:\software\Business Central\Extensions\Microsoft_Making Tax Digital Localizationfor United Kingdom.app" -SkipVerification

    Publish-NAVApp -ServerInstance MyService -Path "C:\software\Business Central\Extensions\Microsoft_Making Tax Digital Localization for United Kingdom.app" -SkipVerification -Force

    Publish-NAVApp -ServerInstance MyService -Path "C:\software\Business Central\Extensions\Microsoft_Making Tax Digital Localization for United Kingdom.app" -Force

    Publish-NAVApp -ServerInstance MyService -Path "C:\software\Business Central\Extensions\Microsoft_Making Tax Digital Localization for United Kingdom.app" -Debug

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans