Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ permissionset 4713 "HybridGPUS - Objects"
codeunit "GP Vendor 1099 Mapping Helpers" = X,
codeunit "GP IRS Form Data" = X,
page "GP 1099 Migration Log" = X,
page "GP 1099 Migration Log Factbox" = X;
page "GP 1099 Migration Log Factbox" = X,
codeunit "GP IRS1099 Migration Validator" = X;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ using Microsoft.Purchases.Vendor;

codeunit 42004 "GP Cloud Migration US"
{

[EventSubscriber(ObjectType::Codeunit, CodeUnit::"Data Migration Mgt.", 'OnAfterMigrationFinished', '', false, false)]
local procedure OnAfterMigrationFinishedSubscriber(var DataMigrationStatus: Record "Data Migration Status"; WasAborted: Boolean; StartTime: DateTime; Retry: Boolean)
[EventSubscriber(ObjectType::Codeunit, CodeUnit::"Data Migration Mgt.", OnCreatePostMigrationData, '', false, false)]
local procedure OnCreatePostMigrationDataSubscriber(var DataMigrationStatus: Record "Data Migration Status")
var
HelperFunctions: Codeunit "Helper Functions";
begin
if not (DataMigrationStatus."Migration Type" = HelperFunctions.GetMigrationTypeTxt()) then
if DataMigrationStatus."Migration Type" <> HelperFunctions.GetMigrationTypeTxt() then
exit;

RunPostMigration();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
namespace Microsoft.DataMigration.GP;

using Microsoft.Purchases.Vendor;
using Microsoft.Purchases.Payables;
using Microsoft.Finance.VAT.Reporting;
using Microsoft.DataMigration;

codeunit 42006 "GP IRS1099 Migration Validator"
{
trigger OnRun()
var
GPCompanyAdditionalSettings: Record "GP Company Additional Settings";
begin
if not GPCompanyAdditionalSettings.GetMigrateVendor1099Enabled() then
exit;

ValidatorCodeLbl := GetValidatorCode();
CompanyNameTxt := CompanyName();

RunVendor1099MigrationValidation(GPCompanyAdditionalSettings);

MigrationValidation.ReportCompanyValidated();
end;

local procedure RunVendor1099MigrationValidation(var GPCompanyAdditionalSettings: Record "GP Company Additional Settings")
var
GPPM00200: Record "GP PM00200";
Vendor: Record Vendor;
VendorLedgerEntry: Record "Vendor Ledger Entry";
IRS1099VendorFormBoxSetup: Record "IRS 1099 Vendor Form Box Setup";
GPVendor1099MappingHelpers: Codeunit "GP Vendor 1099 Mapping Helpers";
IRS1099Code: Code[10];
ActualIRS1099Code: Code[20];
TaxAmount: Decimal;
VendorYear1099AmountDictionary: Dictionary of [Code[10], Decimal];
EntityType: Text[50];
VendorNo: Code[20];
begin
if CompanyValidationProgress.Get(CompanyNameTxt, ValidatorCodeLbl, ValidationStepVendor1099Lbl) then
exit;

EntityType := Vendor1099EntityCaptionLbl;

if GPCompanyAdditionalSettings.GetMigrateVendor1099Enabled() then begin
GPPM00200.SetRange(TEN99TYPE, 2, 5);
GPPM00200.SetFilter(VENDORID, '<>%1', '');
if GPPM00200.FindSet() then
repeat
VendorNo := CopyStr(GPPM00200.VENDORID.TrimEnd(), 1, MaxStrLen(VendorNo));
Vendor.SetLoadFields("No.", Name, "Federal ID No.");
if not Vendor.Get(VendorNo) then
continue;

MigrationValidation.SetContext(ValidatorCodeLbl, EntityType, VendorNo);
IRS1099Code := GPVendor1099MappingHelpers.GetIRS1099BoxCode(System.Date2DMY(System.Today(), 3), GPPM00200.TEN99TYPE, GPPM00200.TEN99BOXNUMBER);

Clear(ActualIRS1099Code);
if IRS1099VendorFormBoxSetup.Get(Format(GPCompanyAdditionalSettings.Get1099TaxYear()), VendorNo) then
ActualIRS1099Code := IRS1099VendorFormBoxSetup."Form Box No.";

MigrationValidation.ValidateAreEqual(Test_VEND1099IRS1099CODE_Tok, IRS1099Code, ActualIRS1099Code, IRS1099CodeLbl);
MigrationValidation.ValidateAreEqual(Test_VEND1099FEDIDNO_Tok, CopyStr(GPPM00200.TXIDNMBR.TrimEnd(), 1, MaxStrLen(Vendor."Federal ID No.")), Vendor."Federal ID No.", FederalIdNoLbl);

Clear(VendorYear1099AmountDictionary);
BuildVendor1099Entries(VendorNo, VendorYear1099AmountDictionary);
foreach IRS1099Code in VendorYear1099AmountDictionary.Keys() do begin
TaxAmount := VendorYear1099AmountDictionary.Get(IRS1099Code);

if TaxAmount > 0 then begin
Clear(VendorLedgerEntry);
VendorLedgerEntry.SetLoadFields(Description, Amount);
VendorLedgerEntry.SetRange("Vendor No.", VendorNo);
VendorLedgerEntry.SetRange("Document Type", VendorLedgerEntry."Document Type"::Payment);
VendorLedgerEntry.SetRange(Description, IRS1099Code);

if not MigrationValidation.ValidateRecordExists(Test_VEND1099TRXEXISTS_Tok, VendorLedgerEntry.FindFirst(), StrSubstNo(MissingBoxAndAmountLbl, IRS1099Code, TaxAmount)) then
continue;

VendorLedgerEntry.CalcFields(Amount);

MigrationValidation.ValidateAreEqual(Test_VEND1099TEN99BOX_Tok, IRS1099Code, VendorLedgerEntry.Description, Vendor1099BoxLbl);
MigrationValidation.ValidateAreEqual(Test_VEND1099TEN99TRXAMT_Tok, TaxAmount, VendorLedgerEntry.Amount, Vendor1099BoxAmountLbl);
end;
end;

until GPPM00200.Next() = 0;
end;

LogValidationProgress(ValidationStepVendor1099Lbl);
Commit();
end;

local procedure BuildVendor1099Entries(VendorNo: Code[20]; var VendorYear1099AmountDictionary: Dictionary of [Code[10], Decimal])
var
GPCompanyAdditionalSettings: Record "GP Company Additional Settings";
GPPM00204: Record "GP PM00204";
GPVendor1099MappingHelpers: Codeunit "GP Vendor 1099 Mapping Helpers";
IRS1099Code: Code[10];
TaxAmount: Decimal;
TaxYear: Integer;
begin
TaxYear := GPCompanyAdditionalSettings.Get1099TaxYear();
GPPM00204.SetRange(VENDORID, VendorNo);
GPPM00204.SetRange(YEAR1, TaxYear);
GPPM00204.SetFilter(TEN99AMNT, '>0');
if GPPM00204.FindSet() then
repeat
IRS1099Code := GPVendor1099MappingHelpers.GetIRS1099BoxCode(TaxYear, GPPM00204.TEN99TYPE, GPPM00204.TEN99BOXNUMBER);
if IRS1099Code <> '' then
if VendorYear1099AmountDictionary.Get(IRS1099Code, TaxAmount) then
VendorYear1099AmountDictionary.Set(IRS1099Code, TaxAmount + GPPM00204.TEN99AMNT)
else
VendorYear1099AmountDictionary.Add(IRS1099Code, GPPM00204.TEN99AMNT);
until GPPM00204.Next() = 0;
end;

local procedure LogValidationProgress(ValidationStep: Code[20])
begin
Clear(CompanyValidationProgress);
CompanyValidationProgress.Validate("Company Name", CompanyNameTxt);
CompanyValidationProgress.Validate("Validator Code", ValidatorCodeLbl);
CompanyValidationProgress.Validate("Validation Step", ValidationStep);
CompanyValidationProgress.Insert(true);
end;

internal procedure GetValidatorCode(): Code[20]
begin
exit('GP-US');
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Hybrid Cloud Management", OnPrepareMigrationValidation, '', false, false)]
local procedure OnPrepareMigrationValidation(ProductID: Text[250])
var
HybridGPWizard: Codeunit "Hybrid GP Wizard";
begin
if ProductID <> HybridGPWizard.ProductId() then
exit;

RegisterValidator();

AddTest(Test_VEND1099IRS1099CODE_Tok, Vendor1099EntityCaptionLbl, IRS1099CodeLbl);
AddTest(Test_VEND1099FEDIDNO_Tok, Vendor1099EntityCaptionLbl, FederalIdNoLbl);
AddTest(Test_VEND1099TRXEXISTS_Tok, Vendor1099EntityCaptionLbl, Vendor1099MissingTrxLbl);
AddTest(Test_VEND1099TEN99BOX_Tok, Vendor1099EntityCaptionLbl, Vendor1099TrxBoxNoLbl);
AddTest(Test_VEND1099TEN99TRXAMT_Tok, Vendor1099EntityCaptionLbl, Vendor1099TrxAmtLbl);
end;

local procedure RegisterValidator()
var
MigrationValidatorRegistry: Record "Migration Validator Registry";
HybridGPWizard: Codeunit "Hybrid GP Wizard";
ValidatorCode: Code[20];
MigrationType: Text[250];
ValidatorCodeunitId: Integer;
begin
ValidatorCode := GetValidatorCode();
MigrationType := HybridGPWizard.ProductId();
ValidatorCodeunitId := Codeunit::"GP IRS1099 Migration Validator";
if not MigrationValidatorRegistry.Get(ValidatorCode) then begin
MigrationValidatorRegistry.Validate("Validator Code", ValidatorCode);
MigrationValidatorRegistry.Validate("Migration Type", MigrationType);
MigrationValidatorRegistry.Validate(Description, ValidatorDescriptionLbl);
MigrationValidatorRegistry.Validate("Codeunit Id", ValidatorCodeunitId);
MigrationValidatorRegistry.Validate(Automatic, false);
MigrationValidatorRegistry.Insert(true);
end;
end;

local procedure AddTest(Code: Code[30]; Entity: Text[50]; Description: Text)
var
MigrationValidationTest: Record "Migration Validation Test";
begin
if not MigrationValidationTest.Get(Code, GetValidatorCode()) then begin
MigrationValidationTest.Validate(Code, Code);
MigrationValidationTest.Validate("Validator Code", GetValidatorCode());
MigrationValidationTest.Validate(Entity, Entity);
MigrationValidationTest.Validate("Test Description", Description);
MigrationValidationTest.Insert(true);
end;
end;

var
CompanyValidationProgress: Record "Company Validation Progress";
MigrationValidation: Codeunit "Migration Validation";
ValidatorCodeLbl: Code[20];
CompanyNameTxt: Text;
FederalIdNoLbl: Label 'Federal ID No.';
IRS1099CodeLbl: Label 'IRS 1099 Code';
MissingBoxAndAmountLbl: Label 'Missing 1099 Box Payment. 1099 Box = %1, Amount = %2', Comment = '%1 = 1099 Box Code, %2 = Amount of the payment';
Vendor1099BoxLbl: Label '1099 Box';
Vendor1099BoxAmountLbl: Label '1099 Box Amount';
Vendor1099MissingTrxLbl: Label 'Missing 1099 transaction';
Vendor1099TrxBoxNoLbl: Label '1099 transaction Box No/Description';
Vendor1099TrxAmtLbl: Label '1099 transaction amount';
Vendor1099EntityCaptionLbl: Label 'Vendor 1099', MaxLength = 50;
ValidationStepVendor1099Lbl: Label 'VENDOR1099', MaxLength = 20;
ValidatorDescriptionLbl: Label 'GP IRS 1099 migration validator', MaxLength = 250;
Test_VEND1099IRS1099CODE_Tok: Label 'VEND1099IRS1099CODE', Locked = true;
Test_VEND1099FEDIDNO_Tok: Label 'VEND1099FEDIDNO', Locked = true;
Test_VEND1099TRXEXISTS_Tok: Label 'VEND1099TRXEXISTS', Locked = true;
Test_VEND1099TEN99BOX_Tok: Label 'VEND1099TEN99BOX', Locked = true;
Test_VEND1099TEN99TRXAMT_Tok: Label 'VEND1099TEN99TRXAMT', Locked = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Microsoft.DataMigration.GP;

using Microsoft.DataMigration;

pageextension 41105 "GP Upgrade Settings Ext" extends "GP Upgrade Settings"
{
layout
{
addafter(GPAutomaticValidation)
{
field(GPUSAutomaticValidation; GPIRS1099AutoValidation)
{
ApplicationArea = All;
Caption = 'GP-US (1099)';
ToolTip = 'Specifies whether automatic validation is enabled for the GP-US (1099) migration.';

trigger OnValidate()
var
MigrationValidationRegistry: Record "Migration Validator Registry";
GPIRS1099MigrtionValidator: Codeunit "GP IRS1099 Migration Validator";
begin
if MigrationValidationRegistry.Get(GPIRS1099MigrtionValidator.GetValidatorCode()) then begin
MigrationValidationRegistry.Validate(Automatic, GPIRS1099AutoValidation);
MigrationValidationRegistry.Modify(true);
end;
end;
}
}
}

trigger OnOpenPage()
var
MigrationValidationRegistry: Record "Migration Validator Registry";
GPIRS1099MigrtionValidator: Codeunit "GP IRS1099 Migration Validator";
begin
if MigrationValidationRegistry.Get(GPIRS1099MigrtionValidator.GetValidatorCode()) then
GPIRS1099AutoValidation := MigrationValidationRegistry.Automatic;

end;

var
GPIRS1099AutoValidation: Boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ permissionset 4006 "HBD - Objects"
Permissions = page "Hybrid DA Approval" = X,
page "Add Migration Table Mappings" = X,
table "Hybrid Company Status" = X,
table "Hybrid DA Approval" = X;
table "Hybrid DA Approval" = X,
table "Migration Validation Error" = X,
page "Migration Validation Errors" = X,
codeunit "Migration Validation" = X,
page "Company Migration Status" = X,
table "Migration Validation Test" = X,
page "Migration Validation Results" = X,
table "Company Validation Progress" = X,
table "Migration Validation Buffer" = X,
codeunit "Migration Validator Warning" = X;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ permissionsetextension 4003 "INTELLIGENT CLOUD - HBD" extends "INTELLIGENT CLOUD
tabledata "Hybrid DA Approval" = rmi,
tabledata "Replication Record Link Buffer" = RIMD,
tabledata "Record Link Mapping" = RIMD,
tabledata "Cloud Migration Warning" = RIMD;
tabledata "Cloud Migration Warning" = RIMD,
tabledata "Migration Validator Registry" = RIMD,
tabledata "Migration Validation Error" = RIMD,
tabledata "Migration Validation Test" = RIMD,
tabledata "Company Validation Progress" = RIMD,
tabledata "Migration Validation Buffer" = RIMD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ permissionsetextension 4000 "D365 BASIC - HBD" extends "D365 BASIC"
tabledata "Replication Run Completed Arg" = RIMD,
tabledata "Replication Record Link Buffer" = RIMD,
tabledata "Record Link Mapping" = RIMD,
tabledata "Cloud Migration Warning" = RIMD;
tabledata "Cloud Migration Warning" = RIMD,
tabledata "Migration Validator Registry" = RIMD,
tabledata "Migration Validation Error" = RIMD,
tabledata "Migration Validation Test" = RIMD,
tabledata "Company Validation Progress" = RIMD,
tabledata "Migration Validation Buffer" = RIMD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ permissionsetextension 4001 "D365 BASIC ISV - HBD" extends "D365 BASIC ISV"
tabledata "Hybrid DA Approval" = rmi,
tabledata "Replication Record Link Buffer" = RIMD,
tabledata "Record Link Mapping" = RIMD,
tabledata "Cloud Migration Warning" = RIMD;
tabledata "Cloud Migration Warning" = RIMD,
tabledata "Migration Validator Registry" = RIMD,
tabledata "Migration Validation Error" = RIMD,
tabledata "Migration Validation Test" = RIMD,
tabledata "Company Validation Progress" = RIMD,
tabledata "Migration Validation Buffer" = RIMD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ permissionsetextension 4002 "D365 TEAM MEMBER - HBD" extends "D365 TEAM MEMBER"
tabledata "Replication Run Completed Arg" = RIMD,
tabledata "Replication Record Link Buffer" = RIMD,
tabledata "Record Link Mapping" = RIMD,
tabledata "Cloud Migration Warning" = RIMD;
tabledata "Cloud Migration Warning" = RIMD,
tabledata "Migration Validator Registry" = RIMD,
tabledata "Migration Validation Error" = RIMD,
tabledata "Migration Validation Test" = RIMD,
tabledata "Company Validation Progress" = RIMD,
tabledata "Migration Validation Buffer" = RIMD;
}
Loading
Loading