-
Notifications
You must be signed in to change notification settings - Fork 685
Set Additional Reporting Currency demo data for financial reporting #28760
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
tuan-nguyen-fenwick
wants to merge
7
commits into
microsoft:main
Choose a base branch
from
tuan-nguyen-fenwick:uptake/acy-demo-data
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.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
02e425d
Set Additional Reporting Currency
346f424
Created residual FX accounts
edb7458
Set residual FX accounts to EUR & GBP currencies
d8dc05f
Merged PR 35656: Set Additional Currency Code during G/L Setup demo d…
523359f
Changed hardcoded currency codes to use the currency functions
908b84c
Added "Create Add. Reporting Currency" codeunit and moved data creati…
bb87255
Updated account numbers for residual FX gains/losses
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
96 changes: 96 additions & 0 deletions
96
...ffeeDemoDataset/app/DemoData/Finance/2.Master data/CreateAddReportingCurrency.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,96 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| namespace Microsoft.DemoData.Finance; | ||
|
|
||
| using Microsoft.Finance.GeneralLedger.Setup; | ||
| using Microsoft.DemoTool.Helpers; | ||
| using Microsoft.Finance.GeneralLedger.Account; | ||
| using Microsoft.Foundation.Enums; | ||
| using Microsoft.Finance.Currency; | ||
|
|
||
| codeunit 5627 "Create Add. Reporting Currency" | ||
| { | ||
| InherentEntitlements = X; | ||
| InherentPermissions = X; | ||
| Permissions = | ||
| tabledata "General Ledger Setup" = rm, | ||
| tabledata Currency = rm; | ||
|
|
||
| trigger OnRun() | ||
| begin | ||
| ConfigureAdditionalReportingCurrency(); | ||
| GenerateGLAccountsForReportingCurrency(); | ||
| UpdateCurrencyResidualAccounts(); | ||
| end; | ||
|
|
||
| procedure ConfigureAdditionalReportingCurrency() | ||
| var | ||
| GeneralLedgerSetup: Record "General Ledger Setup"; | ||
| CreateCurrency: Codeunit "Create Currency"; | ||
| ACYCode: Code[10]; | ||
| begin | ||
| GeneralLedgerSetup.Get(); | ||
| ACYCode := GeneralLedgerSetup."LCY Code" = CreateCurrency.EUR() ? CreateCurrency.USD() : CreateCurrency.EUR(); | ||
| GeneralLedgerSetup."Additional Reporting Currency" := ACYCode; | ||
| GeneralLedgerSetup.Modify(true); | ||
| end; | ||
|
|
||
| procedure GenerateGLAccountsForReportingCurrency() | ||
| var | ||
| GLAccountCategory: Record "G/L Account Category"; | ||
| SubCategory: Text[80]; | ||
| begin | ||
| ContosoGLAccount.AddAccountForLocalization(ResidualFXGainsName(), '9335'); | ||
| ContosoGLAccount.AddAccountForLocalization(ResidualFXLossesName(), '9345'); | ||
|
|
||
| SubCategory := Format(GLAccountCategory."Account Category"::Income, 80); | ||
| ContosoGLAccount.InsertGLAccount(ResidualFXGains(), ResidualFXGainsName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Income, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); | ||
|
|
||
| SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); | ||
| ContosoGLAccount.InsertGLAccount(ResidualFXLosses(), ResidualFXLossesName(), Enum::"G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); | ||
| end; | ||
|
|
||
| procedure UpdateCurrencyResidualAccounts() | ||
| var | ||
| Currency: Record "Currency"; | ||
| CreateGLAccount: Codeunit "Create G/L Account"; | ||
| CreateCurrency: Codeunit "Create Currency"; | ||
| begin | ||
| Currency.SetFilter(Code, '%1|%2', CreateCurrency.EUR(), CreateCurrency.USD()); | ||
| if Currency.FindSet(true) then begin | ||
| repeat | ||
| Currency.Validate("Residual Gains Account", ResidualFXGains()); | ||
| Currency.Validate("Residual Losses Account", ResidualFXLosses()); | ||
| Currency.Modify(true); | ||
| until Currency.Next() = 0; | ||
| end; | ||
| end; | ||
|
|
||
| procedure ResidualFXGains(): Code[20] | ||
| begin | ||
| exit(ContosoGLAccount.GetAccountNo(ResidualFXGainsName())); | ||
| end; | ||
|
|
||
| procedure ResidualFXGainsName(): Text[100] | ||
| begin | ||
| exit(ResidualFXGainsLbl); | ||
| end; | ||
|
|
||
| procedure ResidualFXLosses(): Code[20] | ||
| begin | ||
| exit(ContosoGLAccount.GetAccountNo(ResidualFXLossesName())); | ||
| end; | ||
|
|
||
| procedure ResidualFXLossesName(): Text[100] | ||
| begin | ||
| exit(ResidualFXLossesLbl); | ||
| end; | ||
|
|
||
| var | ||
| ContosoGLAccount: Codeunit "Contoso GL Account"; | ||
| ResidualFXGainsLbl: Label 'Residual FX Gains', MaxLength = 100; | ||
| ResidualFXLossesLbl: Label 'Residual FX Losses', MaxLength = 100; | ||
| } | ||
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
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.
GL account introduced in W1 need to be localized in all countries