-
Notifications
You must be signed in to change notification settings - Fork 687
GP - Post migration validation feature #29395
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
Open
jaymckinney-enavate
wants to merge
12
commits into
microsoft:main
Choose a base branch
from
Enavate-EPS-Product:GPUpdates202511
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,802
−175
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fb47d8f
Post migration validation feature
jaymckinney 9604166
Most of the changes after review
jaymckinney 79eb54e
Changes after review
jaymckinney e564021
Removed unused namespace
jaymckinney a761d03
Removed unused using statements, corrected. Corrected Migration Type/…
jaymckinney 10dee8a
Removed unused tests
jaymckinney c920ee4
Handle duplicate account records better
jaymckinney 709af84
Added missing using statement
jaymckinney a459da5
Commit changes in the loop. Correct counters.
jaymckinney 26e1a94
Added Validator Code to any error messages
jaymckinney 4ed5197
Better manual starting of validation by using either the job queue or…
jaymckinney 41fc523
Updated tests to match refactoring changes
jaymckinney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
203 changes: 203 additions & 0 deletions
203
Apps/US/HybridGP_US/app/src/Codeunits/GPIRS1099MigrationValidator.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
Apps/US/HybridGP_US/app/src/PageExt/GPUpgradeSettingsExt.PageExt.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - i it is not a lbl it is txt.
Lbl is used in the UI