From 8560787d4492cd17b74e9da0000ca79a0844f8aa Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 07:46:26 +0530 Subject: [PATCH 01/25] Removed publisher calling and added interface --- .../CreateExpenseCategories.Codeunit.al | 47 ------------- .../CreateExpenseGLAccount.Codeunit.al | 5 -- .../ExpAgentCountryResolver.Codeunit.al | 49 ++++++++++++++ .../Country/ExpenseAgentCountry.Enum.al | 66 +++++++++++++++++++ .../ExpenseAgentCountryData.Interface.al | 13 ++++ .../Country/W1/W1CountryData.Codeunit.al | 44 +++++++++++++ .../ExpenseAgentContosoModule.Codeunit.al | 35 +++++----- src/Apps/W1/ExpenseAgent/demo data/app.json | 2 +- 8 files changed, 192 insertions(+), 69 deletions(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountryData.Interface.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al index 05b2c49c9ff..23caec182fb 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al @@ -101,8 +101,6 @@ codeunit 6973 "Create Expense Categories" AddPostingGroupSeed(TempPostingGroup, XEXPENSEMILEAGETxt, XExpenseMileageDescTxt, CreateExpenseGLAccount.ExpenseMileageRefundableDebitAccountNo()); AddPostingGroupSeed(TempPostingGroup, XEXPENSEMEALSTxt, XExpenseMealsDescTxt, CreateExpenseGLAccount.ExpenseMealsRefundableDebitAccountNo()); AddPostingGroupSeed(TempPostingGroup, XEXPENSEENTERTAINTxt, XExpenseEntertainDescTxt, CreateExpenseGLAccount.ExpenseEntertainRefundableDebitAccountNo()); - - OnAfterBuildPostingGroupSeeds(TempPostingGroup); end; /// @@ -136,13 +134,7 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary; Code: Code[20]; Description: Text[100]; RefundableDebitAccount: Code[20]) - var - IsHandled: Boolean; begin - OnBeforeAddPostingGroupSeed(Code, Description, RefundableDebitAccount, IsHandled); - if IsHandled then - exit; - TempPostingGroup.Init(); TempPostingGroup.Code := Code; TempPostingGroup.Description := Description; @@ -151,7 +143,6 @@ codeunit 6973 "Create Expense Categories" TempPostingGroup."Prepayment Credit Account" := CreateExpenseGLAccount.ExpensePrepaymentDebitAccountNo(); TempPostingGroup."Debit Rounding Account" := CreateExpenseGLAccount.ExpenseDebitRoundingAccountNo(); TempPostingGroup."Credit Rounding Account" := CreateExpenseGLAccount.ExpenseCreditRoundingAccountNo(); - OnBeforeInsertPostingGroupSeed(TempPostingGroup); TempPostingGroup.Insert(); end; @@ -239,8 +230,6 @@ codeunit 6973 "Create Expense Categories" AddCategorySeed(TempCategory, XSUBSCRIPTIONTxt, XProfessionalSubscriptionsTxt, XSubscriptionsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCARDTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" "); AddCategorySeed(TempCategory, XTIPSTxt, XTipsDescTxt, XTipsPostingTxt, XFOODBEVERAGETxt, XEXPENSEOTHERTxt, XCASHTxt, false, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::" "); AddCategorySeed(TempCategory, XTOLLSTxt, XTollRoadUsageFeeTxt, XTollsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCASHTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" "); - - OnAfterBuildCategorySeeds(TempCategory); end; /// @@ -355,8 +344,6 @@ codeunit 6973 "Create Expense Categories" // FINES AddSubcategorySeed(TempSubcategory, XFINESTxt, XFINESTxt, XFinesSubDescTxt, XFinesPostingTxt, true, false); - - OnAfterBuildSubcategorySeeds(TempSubcategory); end; internal procedure GetTRAVELTxt(): Code[20] @@ -616,13 +603,7 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddCategorySeed(var TempCategory: Record "Expense Category" temporary; Code: Code[20]; Description: Text[250]; PostingDescription: Text[100]; ExpenseGroupCode: Code[20]; PostingGroupCode: Code[20]; PaymentMethod: Code[10]; IsRefundable: Boolean; IsPrepayment: Boolean; AttachmentEnforcement: Enum "Expense Attachment Enforcement"; DetailRequired: Enum "Expense Detail Needed") - var - IsHandled: Boolean; begin - OnBeforeAddCategorySeed(Code, Description, PostingDescription, ExpenseGroupCode, PostingGroupCode, PaymentMethod, IsRefundable, IsPrepayment, AttachmentEnforcement, DetailRequired, IsHandled); - if IsHandled then - exit; - TempCategory.Init(); TempCategory.Code := Code; TempCategory.Description := Description; @@ -638,13 +619,7 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddSubcategorySeed(var TempSubcategory: Record "Expense Subcategory" temporary; SubcategoryCode: Code[20]; CategoryCode: Code[20]; Description: Text[250]; PostingDescription: Text[100]; Refundable: Boolean; DescriptionMandatory: Boolean) - var - IsHandled: Boolean; begin - OnBeforeAddSubcategorySeed(SubcategoryCode, CategoryCode, Description, PostingDescription, Refundable, DescriptionMandatory, IsHandled); - if IsHandled then - exit; - TempSubcategory.Init(); TempSubcategory."Expense Category Code" := CategoryCode; TempSubcategory.Code := SubcategoryCode; @@ -828,8 +803,6 @@ codeunit 6973 "Create Expense Categories" AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XGERMANYALLTxt, 'EUR', "Expense Justification"::" "); AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUKOTHERTxt, 'GBP', "Expense Justification"::" "); AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUSAOTHERTxt, 'USD', "Expense Justification"::" "); - - OnAfterBuildRuleSeeds(TempRuleHeader); end; /// @@ -850,8 +823,6 @@ codeunit 6973 "Create Expense Categories" AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XGERMANYALLTxt, "Expense Rule Condition Type"::"Daily Rate", 105); AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUKOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 115); AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUSAOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 120); - - OnAfterBuildRuleConditionSeeds(TempRuleCondition); end; /// @@ -933,31 +904,19 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; CurrencyCode: Code[10]; JustificationRequired: Enum "Expense Justification") - var - IsHandled: Boolean; begin - OnBeforeAddRuleSeed(TempRuleHeader, CategoryCode, ExpenseLocationCode, CurrencyCode, JustificationRequired, IsHandled); - if IsHandled then - exit; - TempRuleHeader.Init(); TempRuleHeader."Expense Category Code" := CategoryCode; TempRuleHeader."Expense Location" := ExpenseLocationCode; TempRuleHeader."Currency Code" := CurrencyCode; TempRuleHeader."Justification Required" := JustificationRequired; - OnBeforeInsertRuleSeed(TempRuleHeader); TempRuleHeader.Insert(); end; internal procedure AddRuleConditionSeed(var TempRuleCondition: Record "Expense Rule Condition" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; ConditionType: Enum "Expense Rule Condition Type"; Value: Decimal) var NextLineNo: Integer; - IsHandled: Boolean; begin - OnBeforeAddRuleConditionSeed(TempRuleCondition, CategoryCode, ExpenseLocationCode, ConditionType, Value, IsHandled); - if IsHandled then - exit; - TempRuleCondition.Reset(); TempRuleCondition.SetRange("Expense Category Code", CategoryCode); TempRuleCondition.SetRange("Expense Location", ExpenseLocationCode); @@ -1293,13 +1252,7 @@ codeunit 6973 "Create Expense Categories" end; internal procedure UpdateEmployeePostingGroup(Code: Code[20]; ExpenseReportPayableAccount: Code[20]; ExpensePayableBankPaidAccount: Code[20]; ExpensePayableCardPaidAccount: Code[20]; ExpenseReportPrepaymentAccount: Code[20]) - var - IsHandled: Boolean; begin - OnBeforeUpdateEmployeePostingGroup(Code, ExpenseReportPayableAccount, ExpensePayableBankPaidAccount, ExpensePayableCardPaidAccount, ExpenseReportPrepaymentAccount, IsHandled); - if IsHandled then - exit; - if not EmployeePostingGroup.Get(Code) then exit; diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al index f9cf33b2c2a..c457823998d 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al @@ -50,12 +50,7 @@ codeunit 6971 "Create Expense GL Account" local procedure CreateGLAccount() var GLAccountIndent: Codeunit "G/L Account-Indent"; - IsHandled: Boolean; begin - OnBeforeCreateGLAccount(IsHandled); - if IsHandled then - exit; - InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al new file mode 100644 index 00000000000..40ddf0d27d5 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al @@ -0,0 +1,49 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.Foundation.Company; + +codeunit 8221 "Exp. Agent Country Resolver" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure Resolve() CountryData: Interface "Expense Agent Country Data" + begin + CountryData := ResolveCountry(); + end; + + procedure ResolveCountry() Country: Enum "Expense Agent Country" + var + CompanyInformation: Record "Company Information"; + begin + if CompanyInformation.Get() then + case CompanyInformation."Country/Region Code" of + 'US': + exit(Country::US); + 'GB': + exit(Country::GB); + 'CA': + exit(Country::CA); + 'NZ': + exit(Country::NZ); + 'AU': + exit(Country::AU); + 'ES': + exit(Country::ES); + 'DK': + exit(Country::DK); + 'FR': + exit(Country::FR); + 'DE': + exit(Country::DE); + 'AT': + exit(Country::AT); + end; + exit(Country::Default); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al new file mode 100644 index 00000000000..42c55dab916 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -0,0 +1,66 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" +{ + Extensible = false; + + value(0; Default) + { + Caption = 'Default'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(1; US) + { + Caption = 'US'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(2; GB) + { + Caption = 'GB'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(3; CA) + { + Caption = 'CA'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(4; NZ) + { + Caption = 'NZ'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(5; AU) + { + Caption = 'AU'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(6; ES) + { + Caption = 'ES'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(7; DK) + { + Caption = 'DK'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(8; FR) + { + Caption = 'FR'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(9; DE) + { + Caption = 'DE'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } + value(10; AT) + { + Caption = 'AT'; + Implementation = "Expense Agent Country Data" = "W1 Country Data"; + } +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountryData.Interface.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountryData.Interface.al new file mode 100644 index 00000000000..9741b31ffb8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountryData.Interface.al @@ -0,0 +1,13 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +interface "Expense Agent Country Data" +{ + procedure CreateSetupData(); + procedure CreateMasterData(); + procedure CreateTransactionalData(); + procedure CreateHistoricalData(); +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al new file mode 100644 index 00000000000..597990fe8e2 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al @@ -0,0 +1,44 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8222 "W1 Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + begin + Codeunit.Run(Codeunit::"Create Expense Payment Method"); + Codeunit.Run(Codeunit::"Create Expense No. Series DM"); + Codeunit.Run(Codeunit::"Create Expense Group"); + Codeunit.Run(Codeunit::"Create Expense G/L Account"); + Codeunit.Run(Codeunit::"Create Expense Posting Group"); + Codeunit.Run(Codeunit::"Create Expense Team"); + Codeunit.Run(Codeunit::"Create Exp. Agent Setup"); + end; + + procedure CreateMasterData() + begin + Codeunit.Run(Codeunit::"Create Expense Location"); + Codeunit.Run(Codeunit::"Create Expense Categories DM"); + Codeunit.Run(Codeunit::"Create Expense Subcategories"); + Codeunit.Run(Codeunit::"Create Expense Rule Header"); + Codeunit.Run(Codeunit::"Create Expense Rule Condition"); + Codeunit.Run(Codeunit::"Create Expense User"); + end; + + procedure CreateTransactionalData() + begin + Codeunit.Run(Codeunit::"Create Expense"); + Codeunit.Run(Codeunit::"Create Exp. Report"); + end; + + procedure CreateHistoricalData() + begin + Codeunit.Run(Codeunit::"Create Posted Expense Report"); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al index 77da9374d0f..cf268322849 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al @@ -26,35 +26,38 @@ codeunit 8202 "Expense Agent Contoso Module" implements "Contoso Demo Data Modul procedure CreateSetupData() var ExpenseAgentModuleSetup: Record "Expense Agent Module Setup"; + Resolver: Codeunit "Exp. Agent Country Resolver"; + CountryData: Interface "Expense Agent Country Data"; begin ExpenseAgentModuleSetup.InitRecord(); - Codeunit.Run(Codeunit::"Create Expense Payment Method"); - Codeunit.Run(Codeunit::"Create Expense No. Series DM"); - Codeunit.Run(Codeunit::"Create Expense Group"); - Codeunit.Run(Codeunit::"Create Expense G/L Account"); - Codeunit.Run(Codeunit::"Create Expense Posting Group"); - Codeunit.Run(Codeunit::"Create Expense Team"); - Codeunit.Run(Codeunit::"Create Exp. Agent Setup"); + CountryData := Resolver.Resolve(); + CountryData.CreateSetupData(); end; procedure CreateMasterData() + var + Resolver: Codeunit "Exp. Agent Country Resolver"; + CountryData: Interface "Expense Agent Country Data"; begin - Codeunit.Run(Codeunit::"Create Expense Location"); - Codeunit.Run(Codeunit::"Create Expense Categories DM"); - Codeunit.Run(Codeunit::"Create Expense Subcategories"); - Codeunit.Run(Codeunit::"Create Expense Rule Header"); - Codeunit.Run(Codeunit::"Create Expense Rule Condition"); - Codeunit.Run(Codeunit::"Create Expense User"); + CountryData := Resolver.Resolve(); + CountryData.CreateMasterData(); end; procedure CreateTransactionalData() + var + Resolver: Codeunit "Exp. Agent Country Resolver"; + CountryData: Interface "Expense Agent Country Data"; begin - Codeunit.Run(Codeunit::"Create Expense"); - Codeunit.Run(Codeunit::"Create Exp. Report"); + CountryData := Resolver.Resolve(); + CountryData.CreateTransactionalData(); end; procedure CreateHistoricalData() + var + Resolver: Codeunit "Exp. Agent Country Resolver"; + CountryData: Interface "Expense Agent Country Data"; begin - Codeunit.Run(Codeunit::"Create Posted Expense Report"); + CountryData := Resolver.Resolve(); + CountryData.CreateHistoricalData(); end; } \ No newline at end of file diff --git a/src/Apps/W1/ExpenseAgent/demo data/app.json b/src/Apps/W1/ExpenseAgent/demo data/app.json index 6567deda989..31d0ccf937b 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/app.json +++ b/src/Apps/W1/ExpenseAgent/demo data/app.json @@ -83,7 +83,7 @@ "idRanges": [ { "from": 8201, - "to": 8222 + "to": 8399 } ], "target": "OnPrem", From 7836033ffac09daa08b91b95c93ddeb24d8795da Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 07:59:13 +0530 Subject: [PATCH 02/25] US Handled --- .../Country/ExpenseAgentCountry.Enum.al | 2 +- .../Country/US/USCountryData.Codeunit.al | 61 +++++++ .../Country/US/USExpCategories.Codeunit.al | 31 ++++ .../Country/US/USExpGLAccount.Codeunit.al | 52 ++++++ .../Country/US/USExpPostingGrp.Codeunit.al | 63 +++++++ .../Country/US/USExpRuleCondition.Codeunit.al | 26 +++ .../Country/US/USExpRuleHeader.Codeunit.al | 29 +++ .../Country/US/USExpSubCategories.Codeunit.al | 39 ++++ .../Country/US/USExpense.Codeunit.al | 51 ++++++ .../Country/US/USGLAccountNames.Codeunit.al | 74 ++++++++ .../Country/US/USPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/US/USUpdEmpPostingGrp.Codeunit.al | 32 ++++ 12 files changed, 627 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 42c55dab916..269a06e1d79 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -16,7 +16,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(1; US) { Caption = 'US'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "US Country Data"; } value(2; GB) { diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al new file mode 100644 index 00000000000..5f8dab09554 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8223 "US Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + USExpGLAccount: Codeunit "US Exp. GL Account"; + USExpPostingGrp: Codeunit "US Exp. Posting Grp"; + begin + BindSubscription(USExpGLAccount); + BindSubscription(USExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"US Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"US Exp. Posting Grp"); + + UnbindSubscription(USExpPostingGrp); + UnbindSubscription(USExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"US Exp. Categories"); + Codeunit.Run(Codeunit::"US Exp. SubCategories"); + Codeunit.Run(Codeunit::"US Exp. Rule Header"); + Codeunit.Run(Codeunit::"US Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"US Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + USPostedExpReport: Codeunit "US Posted Exp. Report"; + begin + BindSubscription(USPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"US Posted Exp. Report"); + + UnbindSubscription(USPostedExpReport); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al new file mode 100644 index 00000000000..c43bc444861 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8227 "US Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + USExpPostingGrp: Codeunit "US Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, USExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..f97f4886555 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al @@ -0,0 +1,52 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8224 "US Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.CompanyCreditCardsAccount(), ExpenseGLAccount.CompanyCreditCardsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.CompanyCreditCardsAccountName(), '18600'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '62350'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '62360'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '62370'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '62380'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '62390'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '68285'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..3638e41b226 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al @@ -0,0 +1,63 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8225 "US Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + USGLAccountNames: Codeunit "US GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.BusinessEntertainingDeductibleName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.MiscExternalExpensesName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherTravelExpensesName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..fd885936d20 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8230 "US Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + USExpCategories: Codeunit "US Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..371f4aed2f9 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8229 "US Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + USExpCategories: Codeunit "US Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..e9d714fe328 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8228 "US Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + USExpCategories: Codeunit "US Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), USExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), USExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al new file mode 100644 index 00000000000..01c114bfe84 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8231 "US Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), USExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + USExpCategories: Codeunit "US Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al new file mode 100644 index 00000000000..f27e4e6c052 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al @@ -0,0 +1,74 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8220 "US GL Account Names" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + BusinessEntertainingDeductibleTok: Label 'Business Entertaining, deductible', MaxLength = 100; + OtherIncidentalRevenueTok: Label 'Other Incidental Revenue', MaxLength = 100; + OtherPrepaidExpensesAndAccruedIncomeTok: Label 'Other prepaid expenses and accrued income', MaxLength = 100; + PayableInvoiceRoundingTok: Label 'Payable Invoice Rounding', MaxLength = 100; + MiscExternalExpensesTok: Label 'Misc. external expenses', MaxLength = 100; + OtherTravelExpensesTok: Label 'Other travel expenses', MaxLength = 100; + RentalVehiclesTok: Label 'Rental vehicles', MaxLength = 100; + AccountsPayableDomesticTok: Label 'Accounts Payable, Domestic', MaxLength = 100; + OtherBankAccountsTok: Label 'Other bank accounts ', MaxLength = 100; + SaleofResourcesTok: Label 'Sale of Resources', MaxLength = 100; + + procedure BusinessEntertainingDeductibleName(): Text[100] + begin + exit(BusinessEntertainingDeductibleTok); + end; + + procedure OtherIncidentalRevenueName(): Text[100] + begin + exit(OtherIncidentalRevenueTok); + end; + + procedure OtherPrepaidExpensesAndAccruedIncomeName(): Text[100] + begin + exit(OtherPrepaidExpensesAndAccruedIncomeTok); + end; + + procedure PayableInvoiceRoundingName(): Text[100] + begin + exit(PayableInvoiceRoundingTok); + end; + + procedure MiscExternalExpensesName(): Text[100] + begin + exit(MiscExternalExpensesTok); + end; + + procedure OtherTravelExpensesName(): Text[100] + begin + exit(OtherTravelExpensesTok); + end; + + procedure RentalVehiclesName(): Text[100] + begin + exit(RentalVehiclesTok); + end; + + procedure AccountsPayableDomesticName(): Text[100] + begin + exit(AccountsPayableDomesticTok); + end; + + procedure OtherBankAccountsName(): Text[100] + begin + exit(OtherBankAccountsTok); + end; + + procedure SaleofResourcesName(): Text[100] + begin + exit(SaleofResourcesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..0452bed56b2 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8232 "US Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + USGLAccountNames: Codeunit "US GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.SaleofResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + USExpCategories: Codeunit "US Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), USExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), USExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), USExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..6c8acc31157 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,32 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8226 "US Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + USGLAccountNames: Codeunit "US GL Account Names"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.AccountsPayableDomesticName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.CashName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherBankAccountsName()), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} From ed47fa2afea9360775fa0d546c85abb733a9211e Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 08:09:03 +0530 Subject: [PATCH 03/25] GB Handled --- .../Country/ExpenseAgentCountry.Enum.al | 2 +- .../Country/GB/GBCountryData.Codeunit.al | 61 +++++++ .../Country/GB/GBExpCategories.Codeunit.al | 31 ++++ .../Country/GB/GBExpGLAccount.Codeunit.al | 52 ++++++ .../Country/GB/GBExpPostingGrp.Codeunit.al | 63 +++++++ .../Country/GB/GBExpRuleCondition.Codeunit.al | 26 +++ .../Country/GB/GBExpRuleHeader.Codeunit.al | 29 +++ .../Country/GB/GBExpSubCategories.Codeunit.al | 39 ++++ .../Country/GB/GBExpense.Codeunit.al | 51 ++++++ .../Country/GB/GBGLAccountNames.Codeunit.al | 68 +++++++ .../Country/GB/GBPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/GB/GBUpdEmpPostingGrp.Codeunit.al | 32 ++++ 12 files changed, 621 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 269a06e1d79..e21820ada7f 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -21,7 +21,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(2; GB) { Caption = 'GB'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "GB Country Data"; } value(3; CA) { diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al new file mode 100644 index 00000000000..5fb2ca846cb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8234 "GB Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + GBExpGLAccount: Codeunit "GB Exp. GL Account"; + GBExpPostingGrp: Codeunit "GB Exp. Posting Grp"; + begin + BindSubscription(GBExpGLAccount); + BindSubscription(GBExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"GB Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"GB Exp. Posting Grp"); + + UnbindSubscription(GBExpPostingGrp); + UnbindSubscription(GBExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"GB Exp. Categories"); + Codeunit.Run(Codeunit::"GB Exp. SubCategories"); + Codeunit.Run(Codeunit::"GB Exp. Rule Header"); + Codeunit.Run(Codeunit::"GB Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"GB Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + GBPostedExpReport: Codeunit "GB Posted Exp. Report"; + begin + BindSubscription(GBPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"GB Posted Exp. Report"); + + UnbindSubscription(GBPostedExpReport); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al new file mode 100644 index 00000000000..f054881cd68 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8239 "GB Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + GBExpPostingGrp: Codeunit "GB Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, GBExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..55aa053e6ff --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al @@ -0,0 +1,52 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8236 "GB Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.CompanyCreditCardsAccount(), ExpenseGLAccount.CompanyCreditCardsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.CompanyCreditCardsAccountName(), '78410'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '30550'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '30560'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '30535'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '30840'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '30850'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '31545'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..9337c030760 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al @@ -0,0 +1,63 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8237 "GB Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + GBGLAccountNames: Codeunit "GB GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.BusinessEntertainingDeductibleName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.MiscExternalExpensesName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherTravelExpensesName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..c106f380a33 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8242 "GB Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + GBExpCategories: Codeunit "GB Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..bf8261c17f3 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8241 "GB Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + GBExpCategories: Codeunit "GB Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..46a383cc9b7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8240 "GB Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + GBExpCategories: Codeunit "GB Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), GBExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), GBExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al new file mode 100644 index 00000000000..95bb196c26e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8243 "GB Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), GBExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + GBExpCategories: Codeunit "GB Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al new file mode 100644 index 00000000000..c79a028f691 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al @@ -0,0 +1,68 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8235 "GB GL Account Names" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + BusinessEntertainingDeductibleTok: Label 'Business Entertaining, deductible', MaxLength = 100; + OtherIncidentalRevenueTok: Label 'Other Incidental Revenue', MaxLength = 100; + OtherPrepaidExpensesAndAccruedIncomeTok: Label 'Other prepaid expenses and accrued income', MaxLength = 100; + PayableInvoiceRoundingTok: Label 'Payable Invoice Rounding', MaxLength = 100; + MiscExternalExpensesTok: Label 'Misc. external expenses', MaxLength = 100; + OtherTravelExpensesTok: Label 'Other travel expenses', MaxLength = 100; + RentalVehiclesTok: Label 'Rental vehicles', MaxLength = 100; + OtherBankAccountsTok: Label 'Other bank accounts ', MaxLength = 100; + SaleofResourcesTok: Label 'Sale of Resources', MaxLength = 100; + + procedure BusinessEntertainingDeductibleName(): Text[100] + begin + exit(BusinessEntertainingDeductibleTok); + end; + + procedure OtherIncidentalRevenueName(): Text[100] + begin + exit(OtherIncidentalRevenueTok); + end; + + procedure OtherPrepaidExpensesAndAccruedIncomeName(): Text[100] + begin + exit(OtherPrepaidExpensesAndAccruedIncomeTok); + end; + + procedure PayableInvoiceRoundingName(): Text[100] + begin + exit(PayableInvoiceRoundingTok); + end; + + procedure MiscExternalExpensesName(): Text[100] + begin + exit(MiscExternalExpensesTok); + end; + + procedure OtherTravelExpensesName(): Text[100] + begin + exit(OtherTravelExpensesTok); + end; + + procedure RentalVehiclesName(): Text[100] + begin + exit(RentalVehiclesTok); + end; + + procedure OtherBankAccountsName(): Text[100] + begin + exit(OtherBankAccountsTok); + end; + + procedure SaleofResourcesName(): Text[100] + begin + exit(SaleofResourcesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..5a05b6526c0 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8244 "GB Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + GBGLAccountNames: Codeunit "GB GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.SaleofResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + GBExpCategories: Codeunit "GB Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), GBExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), GBExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), GBExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..51a9072c619 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,32 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8238 "GB Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + GBGLAccountNames: Codeunit "GB GL Account Names"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.CashName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherBankAccountsName()), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} From 20860bbfb95c2be048de64042e15111ae252d3f3 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 08:24:02 +0530 Subject: [PATCH 04/25] CA Handled --- .../Country/CA/CACountryData.Codeunit.al | 61 +++++++ .../Country/CA/CAExpCategories.Codeunit.al | 31 ++++ .../Country/CA/CAExpGLAccount.Codeunit.al | 64 +++++++ .../Country/CA/CAExpPostingGrp.Codeunit.al | 65 +++++++ .../Country/CA/CAExpRuleCondition.Codeunit.al | 26 +++ .../Country/CA/CAExpRuleHeader.Codeunit.al | 29 +++ .../Country/CA/CAExpSubCategories.Codeunit.al | 39 ++++ .../Country/CA/CAExpense.Codeunit.al | 51 ++++++ .../Country/CA/CAPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/CA/CAUpdEmpPostingGrp.Codeunit.al | 34 ++++ .../Country/ExpenseAgentCountry.Enum.al | 2 +- 11 files changed, 569 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al new file mode 100644 index 00000000000..77bda558d1d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8245 "CA Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + CAExpGLAccount: Codeunit "CA Exp. GL Account"; + CAExpPostingGrp: Codeunit "CA Exp. Posting Grp"; + begin + BindSubscription(CAExpGLAccount); + BindSubscription(CAExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"CA Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"CA Exp. Posting Grp"); + + UnbindSubscription(CAExpPostingGrp); + UnbindSubscription(CAExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"CA Exp. Categories"); + Codeunit.Run(Codeunit::"CA Exp. SubCategories"); + Codeunit.Run(Codeunit::"CA Exp. Rule Header"); + Codeunit.Run(Codeunit::"CA Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"CA Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + CAPostedExpReport: Codeunit "CA Posted Exp. Report"; + begin + BindSubscription(CAPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"CA Posted Exp. Report"); + + UnbindSubscription(CAPostedExpReport); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al new file mode 100644 index 00000000000..7509f594143 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8249 "CA Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CAExpPostingGrp: Codeunit "CA Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CAExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..a2019bf208b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8246 "CA Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.CompanyCreditCardsAccount(), ExpenseGLAccount.CompanyCreditCardsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsAccount(), ExpenseGLAccount.EmployeePrepaymentsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.EmployeePrepaymentsExpensesAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsTotalAccount(), ExpenseGLAccount.EmployeePrepaymentsTotalAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', '', 0, ExpenseGLAccount.EmployeePrepaymentsAccount() + '..' + ExpenseGLAccount.EmployeePrepaymentsTotalAccount(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.RentalVehiclesAccount(), ExpenseGLAccount.RentalVehiclesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.BusinessEntertainingNondeductibleAccount(), ExpenseGLAccount.BusinessEntertainingNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.CompanyCreditCardsAccountName(), '11160'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsAccountName(), '13600'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsExpensesAccountName(), '13610'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsTotalAccountName(), '13690'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '61310'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '61320'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '61330'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '67410'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '67420'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '67430'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.RentalVehiclesAccountName(), '63110'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.BusinessEntertainingNondeductibleAccountName(), '61120'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherTravelExpensesAccountName(), '61340'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..09923dee6c9 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al @@ -0,0 +1,65 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8247 "CA Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EntertainmentandPRName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.RentalVehiclesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..a0148255636 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8252 "CA Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..8161f920459 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8251 "CA Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..3cea8233897 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8250 "CA Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CAExpCategories: Codeunit "CA Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CAExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CAExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al new file mode 100644 index 00000000000..5c66e613c53 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8253 "CA Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CAExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..7ee1e98d313 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8254 "CA Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.SalesResourcesExportName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CAExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CAExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CAExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..68f4f3b3f3d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,34 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8248 "CA Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.VacationCompensationPayableName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(BankCheckingLbl), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; + + var + BankCheckingLbl: Label 'Bank, Checking', MaxLength = 100; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index e21820ada7f..6681a1fd95e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -26,7 +26,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(3; CA) { Caption = 'CA'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "CA Country Data"; } value(4; NZ) { From 66cd6ed5a229d2545e1ab878c5fd8a4d644c9e50 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 08:32:05 +0530 Subject: [PATCH 05/25] NZ Handled --- .../Country/ExpenseAgentCountry.Enum.al | 2 +- .../Country/NZ/NZCountryData.Codeunit.al | 61 +++++++ .../Country/NZ/NZExpCategories.Codeunit.al | 31 ++++ .../Country/NZ/NZExpGLAccount.Codeunit.al | 60 +++++++ .../Country/NZ/NZExpPostingGrp.Codeunit.al | 65 +++++++ .../Country/NZ/NZExpRuleCondition.Codeunit.al | 26 +++ .../Country/NZ/NZExpRuleHeader.Codeunit.al | 29 +++ .../Country/NZ/NZExpSubCategories.Codeunit.al | 39 ++++ .../Country/NZ/NZExpense.Codeunit.al | 51 ++++++ .../Country/NZ/NZPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/NZ/NZUpdEmpPostingGrp.Codeunit.al | 31 ++++ 11 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 6681a1fd95e..0dfdf55c272 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -31,7 +31,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(4; NZ) { Caption = 'NZ'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "NZ Country Data"; } value(5; AU) { diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al new file mode 100644 index 00000000000..61c4dee22b4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8255 "NZ Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + NZExpGLAccount: Codeunit "NZ Exp. GL Account"; + NZExpPostingGrp: Codeunit "NZ Exp. Posting Grp"; + begin + BindSubscription(NZExpGLAccount); + BindSubscription(NZExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"NZ Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"NZ Exp. Posting Grp"); + + UnbindSubscription(NZExpPostingGrp); + UnbindSubscription(NZExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"NZ Exp. Categories"); + Codeunit.Run(Codeunit::"NZ Exp. SubCategories"); + Codeunit.Run(Codeunit::"NZ Exp. Rule Header"); + Codeunit.Run(Codeunit::"NZ Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"NZ Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + NZPostedExpReport: Codeunit "NZ Posted Exp. Report"; + begin + BindSubscription(NZPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"NZ Posted Exp. Report"); + + UnbindSubscription(NZPostedExpReport); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al new file mode 100644 index 00000000000..4b2bf7403cb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8259 "NZ Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + NZExpPostingGrp: Codeunit "NZ Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, NZExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..37b76823dce --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al @@ -0,0 +1,60 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8256 "NZ Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.CompanyCreditCardsAccount(), ExpenseGLAccount.CompanyCreditCardsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsAccount(), ExpenseGLAccount.EmployeePrepaymentsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', false, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.EmployeePrepaymentsExpensesAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsTotalAccount(), ExpenseGLAccount.EmployeePrepaymentsTotalAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', '', 0, ExpenseGLAccount.EmployeePrepaymentsAccount() + '..' + ExpenseGLAccount.EmployeePrepaymentsTotalAccount(), Enum::"General Posting Type"::" ", '', '', false, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.RentalVehiclesAccount(), ExpenseGLAccount.RentalVehiclesAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.CompanyCreditCardsAccountName(), '2950'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsAccountName(), '2500'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsExpensesAccountName(), '2510'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsTotalAccountName(), '2590'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '8431'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '8432'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '8433'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '8421'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '8650'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '8660'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.RentalVehiclesAccountName(), '8435'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..515904a598b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al @@ -0,0 +1,65 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8257 "NZ Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EntertainmentandPRName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.TravelName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.RentalVehiclesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..7ad4573bc47 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8262 "NZ Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + NZExpCategories: Codeunit "NZ Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..d683da5442e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8261 "NZ Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + NZExpCategories: Codeunit "NZ Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..110d963af00 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8260 "NZ Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + NZExpCategories: Codeunit "NZ Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), NZExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), NZExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al new file mode 100644 index 00000000000..adec4da6464 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8263 "NZ Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), NZExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + NZExpCategories: Codeunit "NZ Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..661e36af095 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8264 "NZ Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.SalesResourcesExportName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + NZExpCategories: Codeunit "NZ Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), NZExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), NZExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), NZExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..36b465160c5 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8258 "NZ Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLCYName()), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} From 0accaed4fa729369377a1940f869973a70b8f91e Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 08:36:10 +0530 Subject: [PATCH 06/25] AU Handled --- .../Country/AU/AUCountryData.Codeunit.al | 61 +++++++ .../Country/AU/AUExpCategories.Codeunit.al | 31 ++++ .../Country/AU/AUExpGLAccount.Codeunit.al | 60 +++++++ .../Country/AU/AUExpPostingGrp.Codeunit.al | 65 +++++++ .../Country/AU/AUExpRuleCondition.Codeunit.al | 26 +++ .../Country/AU/AUExpRuleHeader.Codeunit.al | 29 +++ .../Country/AU/AUExpSubCategories.Codeunit.al | 39 ++++ .../Country/AU/AUExpense.Codeunit.al | 51 ++++++ .../Country/AU/AUPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/AU/AUUpdEmpPostingGrp.Codeunit.al | 31 ++++ .../Country/ExpenseAgentCountry.Enum.al | 2 +- 11 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al new file mode 100644 index 00000000000..6be231090ed --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8265 "AU Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + AUExpGLAccount: Codeunit "AU Exp. GL Account"; + AUExpPostingGrp: Codeunit "AU Exp. Posting Grp"; + begin + BindSubscription(AUExpGLAccount); + BindSubscription(AUExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"AU Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"AU Exp. Posting Grp"); + + UnbindSubscription(AUExpPostingGrp); + UnbindSubscription(AUExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"AU Exp. Categories"); + Codeunit.Run(Codeunit::"AU Exp. SubCategories"); + Codeunit.Run(Codeunit::"AU Exp. Rule Header"); + Codeunit.Run(Codeunit::"AU Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"AU Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + AUPostedExpReport: Codeunit "AU Posted Exp. Report"; + begin + BindSubscription(AUPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"AU Posted Exp. Report"); + + UnbindSubscription(AUPostedExpReport); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al new file mode 100644 index 00000000000..e70cdbe067d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8269 "AU Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + AUExpPostingGrp: Codeunit "AU Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, AUExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..3308784413b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al @@ -0,0 +1,60 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8266 "AU Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.CompanyCreditCardsAccount(), ExpenseGLAccount.CompanyCreditCardsAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.EmployeePrepaymentsExpensesAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.RentalVehiclesAccount(), ExpenseGLAccount.RentalVehiclesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.BusinessEntertainingNondeductibleAccount(), ExpenseGLAccount.BusinessEntertainingNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.CompanyCreditCardsAccountName(), '1025'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.EmployeePrepaymentsExpensesAccountName(), '1512'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '6246'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '6247'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '6248'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '6237'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '6416'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '6415'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.RentalVehiclesAccountName(), '6250'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.BusinessEntertainingNondeductibleAccountName(), '6236'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherTravelExpensesAccountName(), '6249'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..fbd87d448d7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al @@ -0,0 +1,65 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8267 "AU Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EntertainmentandPRName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.BusinessEntertainingNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.RentalVehiclesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.FinanceChargestoVendorsName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.InvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..f7e977cc3b1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8272 "AU Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..1539a091850 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8271 "AU Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..a237c36552f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8270 "AU Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + AUExpCategories: Codeunit "AU Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), AUExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), AUExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al new file mode 100644 index 00000000000..da9c5ebe688 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8273 "AU Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), AUExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..11861cb44c8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8274 "AU Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.SalesResourcesExportName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), AUExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), AUExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), AUExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..4e41480d7c6 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8268 "AU Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), ExpenseGLAccount.EmployeePrepaymentsExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 0dfdf55c272..d0ba2b8b5b7 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -36,7 +36,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(5; AU) { Caption = 'AU'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "AU Country Data"; } value(6; ES) { From e28904d4480ad7a3a55b5d12ed7a346b7f0a6721 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 08:48:34 +0530 Subject: [PATCH 07/25] ES Handled --- .../Country/ES/ESCountryData.Codeunit.al | 70 ++++++++ .../Country/ES/ESCurrencySwapSub.Codeunit.al | 24 +++ .../Country/ES/ESExpCategories.Codeunit.al | 31 ++++ .../Country/ES/ESExpGLAccount.Codeunit.al | 168 ++++++++++++++++++ .../Country/ES/ESExpPostingGrp.Codeunit.al | 65 +++++++ .../Country/ES/ESExpRuleCondition.Codeunit.al | 26 +++ .../Country/ES/ESExpRuleHeader.Codeunit.al | 29 +++ .../Country/ES/ESExpSubCategories.Codeunit.al | 39 ++++ .../Country/ES/ESExpense.Codeunit.al | 51 ++++++ .../Country/ES/ESGLAccountNames.Codeunit.al | 44 +++++ .../Country/ES/ESPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/ES/ESUpdEmpPostingGrp.Codeunit.al | 31 ++++ .../Country/ES/ESUpdEmployee.Codeunit.al | 44 +++++ .../Country/ExpenseAgentCountry.Enum.al | 2 +- 14 files changed, 791 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al new file mode 100644 index 00000000000..b7bc8b66c76 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al @@ -0,0 +1,70 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8275 "ES Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + ESExpGLAccount: Codeunit "ES Exp. GL Account"; + ESExpPostingGrp: Codeunit "ES Exp. Posting Grp"; + begin + BindSubscription(ESExpGLAccount); + BindSubscription(ESExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"ES Upd. Employee"); + Codeunit.Run(Codeunit::"ES Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"ES Exp. Posting Grp"); + + UnbindSubscription(ESExpPostingGrp); + UnbindSubscription(ESExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"ES Exp. Categories"); + Codeunit.Run(Codeunit::"ES Exp. SubCategories"); + Codeunit.Run(Codeunit::"ES Exp. Rule Header"); + Codeunit.Run(Codeunit::"ES Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + ESCurrencySwapSub: Codeunit "ES Currency Swap Sub"; + begin + BindSubscription(ESCurrencySwapSub); + + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"ES Expense"); + + UnbindSubscription(ESCurrencySwapSub); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + ESCurrencySwapSub: Codeunit "ES Currency Swap Sub"; + ESPostedExpReport: Codeunit "ES Posted Exp. Report"; + begin + BindSubscription(ESCurrencySwapSub); + BindSubscription(ESPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"ES Posted Exp. Report"); + + UnbindSubscription(ESPostedExpReport); + UnbindSubscription(ESCurrencySwapSub); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al new file mode 100644 index 00000000000..2b698862020 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8287 "ES Currency Swap Sub" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al new file mode 100644 index 00000000000..f1488f5c145 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8280 "ES Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + ESExpPostingGrp: Codeunit "ES Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, ESExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..2663aacaebb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8277 "ES Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(CompanyCreditCardsClearingAccount(), CompanyCreditCardsClearingAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpensesPrepayments(), ExpensesPrepaymentsName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RentalCarExpenses(), RentalCarExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(TravelExpenses(), TravelExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EntertainmentExpensesAccount(), EntertainmentExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RoundingExpensesOperatingAccount(), RoundingExpensesOperatingAccountName(), "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"::Purchase, '', '', true, false, false); + + UpdateIncomeStatementBalanceAccount(); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCreditCardsClearingAccountName(), '5721001'); + ContosoGLAccount.AddAccountForLocalization(ExpensesPrepaymentsName(), '4800001'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '6291002'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '6291003'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '6292001'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '6292002'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '6299001'); + ContosoGLAccount.AddAccountForLocalization(RentalCarExpensesName(), '6291004'); + ContosoGLAccount.AddAccountForLocalization(TravelExpensesName(), '6291001'); + ContosoGLAccount.AddAccountForLocalization(EntertainmentExpensesAccountName(), '6293001'); + ContosoGLAccount.AddAccountForLocalization(RoundingExpensesOperatingAccountName(), '6298001'); + end; + + local procedure UpdateIncomeStatementBalanceAccount() + begin + UpdateIncomeStmtBalAcc(CompanyCreditCardsClearingAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpensesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(RentalCarExpenses(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(TravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(EntertainmentExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(RoundingExpensesOperatingAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + end; + + local procedure UpdateIncomeStmtBalAcc(No: Code[20]; IncomeStmtBalAcc: Code[20]) + var + GLAccount: Record "G/L Account"; + RecRef: RecordRef; + FieldRef: FieldRef; + i: Integer; + begin + // "Income Stmt. Bal. Acc." is added by the ES localization to table G/L Account. + // Look it up dynamically via FieldRef so this demo data works without an ES-loc + // compile-time dependency; silently skip when the field is not present. + if not GLAccount.Get(No) then + exit; + + RecRef.GetTable(GLAccount); + for i := 1 to RecRef.FieldCount do begin + FieldRef := RecRef.FieldIndex(i); + if FieldRef.Name = 'Income Stmt. Bal. Acc.' then begin + FieldRef.Validate(IncomeStmtBalAcc); + RecRef.Modify(); + exit; + end; + end; + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ESGLAccountNames: Codeunit "ES GL Account Names"; + CompanyCreditCardsClearingAccountTok: Label 'Company credit card clearing account', MaxLength = 100; + TravelExpensesTok: Label 'Travel expenses', MaxLength = 100; + ExpensesPrepaymentsTok: Label 'Expenses Prepayments', MaxLength = 100; + RentalCarExpensesTok: Label 'Rental Car Expenses', MaxLength = 100; + EntertainmentExpensesTok: Label 'Entertainment expenses', MaxLength = 100; + RoundingExpensesOperatingTok: Label 'Rounding Expenses (Operating)', MaxLength = 100; + + procedure CompanyCreditCardsClearingAccount(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCreditCardsClearingAccountName())); + end; + + procedure CompanyCreditCardsClearingAccountName(): Text[100] + begin + exit(CompanyCreditCardsClearingAccountTok); + end; + + procedure TravelExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(TravelExpensesName())); + end; + + procedure TravelExpensesName(): Text[100] + begin + exit(TravelExpensesTok); + end; + + procedure ExpensesPrepayments(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(ExpensesPrepaymentsName())); + end; + + procedure ExpensesPrepaymentsName(): Text[100] + begin + exit(ExpensesPrepaymentsTok); + end; + + procedure RentalCarExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(RentalCarExpensesName())); + end; + + procedure RentalCarExpensesName(): Text[100] + begin + exit(RentalCarExpensesTok); + end; + + procedure EntertainmentExpensesAccount(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EntertainmentExpensesAccountName())); + end; + + procedure EntertainmentExpensesAccountName(): Text[100] + begin + exit(EntertainmentExpensesTok); + end; + + procedure RoundingExpensesOperatingAccount(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(RoundingExpensesOperatingAccountName())); + end; + + procedure RoundingExpensesOperatingAccountName(): Text[100] + begin + exit(RoundingExpensesOperatingTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..e7fd2ba3e9f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al @@ -0,0 +1,65 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + + +codeunit 8278 "ES Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ESExpGLAccount: Codeunit "ES Exp. GL Account"; + ESGLAccountNames: Codeunit "ES GL Account Names"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ESExpGLAccount.EntertainmentExpensesAccount(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.OtherBusinessExpensesName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ESExpGLAccount.TravelExpenses(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ESExpGLAccount.RentalCarExpenses(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..dadd21d2422 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8283 "ES Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ESExpCategories: Codeunit "ES Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..66a12401f7b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8282 "ES Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + ESExpCategories: Codeunit "ES Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..f474a3fba63 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8281 "ES Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + ESExpCategories: Codeunit "ES Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), ESExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), ESExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al new file mode 100644 index 00000000000..e6c4d5c4af4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8284 "ES Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ESExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + ESExpCategories: Codeunit "ES Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al new file mode 100644 index 00000000000..f8bfa91f839 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al @@ -0,0 +1,44 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8276 "ES GL Account Names" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + OtherBusinessExpensesTok: Label 'Other Business Expenses', MaxLength = 100; + RemunerationAdvancesTok: Label 'Remuneration Advances', MaxLength = 100; + BanksEuroTok: Label 'Banks Euro', MaxLength = 100; + InternalResourcesTok: Label 'Internal Resources', MaxLength = 100; + ProfitOrLossTok: Label 'Profit or Loss', MaxLength = 100; + + procedure OtherBusinessExpensesName(): Text[100] + begin + exit(OtherBusinessExpensesTok); + end; + + procedure RemunerationAdvancesName(): Text[100] + begin + exit(RemunerationAdvancesTok); + end; + + procedure BanksEuroName(): Text[100] + begin + exit(BanksEuroTok); + end; + + procedure InternalResourcesName(): Text[100] + begin + exit(InternalResourcesTok); + end; + + procedure ProfitOrLossName(): Text[100] + begin + exit(ProfitOrLossTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..b6452ca00d9 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8285 "ES Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ESGLAccountNames: Codeunit "ES GL Account Names"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.InternalResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + ESExpCategories: Codeunit "ES Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), ESExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ESExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ESExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..8dddad50362 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8279 "ES Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ESExpGLAccount: Codeunit "ES Exp. GL Account"; + ESGLAccountNames: Codeunit "ES GL Account Names"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.RemunerationAdvancesName()), ESExpGLAccount.ExpensesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.BanksEuroName()), ESExpGLAccount.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al new file mode 100644 index 00000000000..5a11120ff7c --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al @@ -0,0 +1,44 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; +using Microsoft.HumanResources.Employee; + +codeunit 8286 "ES Upd. Employee" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata Employee = rm; + + trigger OnRun() + begin + UpdateEmployees(); + end; + + local procedure UpdateEmployees() + var + CreateEmployee: Codeunit "Create Employee"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + SetEmployeePostingGroup(CreateEmployee.ManagingDirector(), CreateEmployeePostingGroup.EmployeeExpenses()); + SetEmployeePostingGroup(CreateEmployee.SalesManager(), CreateEmployeePostingGroup.EmployeeExpenses()); + SetEmployeePostingGroup(CreateEmployee.Designer(), CreateEmployeePostingGroup.EmployeeExpenses()); + SetEmployeePostingGroup(CreateEmployee.ProductionAssistant(), CreateEmployeePostingGroup.EmployeeExpenses()); + SetEmployeePostingGroup(CreateEmployee.ProductionManager(), CreateEmployeePostingGroup.EmployeeExpenses()); + SetEmployeePostingGroup(CreateEmployee.Secretary(), CreateEmployeePostingGroup.EmployeeExpenses()); + SetEmployeePostingGroup(CreateEmployee.InventoryManager(), CreateEmployeePostingGroup.EmployeeExpenses()); + end; + + local procedure SetEmployeePostingGroup(EmployeeNo: Code[20]; PostingGroupCode: Code[20]) + var + Employee: Record Employee; + begin + if Employee.Get(EmployeeNo) then begin + Employee.Validate("Employee Posting Group", PostingGroupCode); + Employee.Modify(); + end; + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index d0ba2b8b5b7..676f5ee74fa 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -41,7 +41,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(6; ES) { Caption = 'ES'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "ES Country Data"; } value(7; DK) { From ad3aeb77ca38cefdb31b7340dc861dcf9fd57308 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:05:24 +0530 Subject: [PATCH 08/25] DK Handled --- .../Country/DK/DKCountryData.Codeunit.al | 64 +++++++ .../Country/DK/DKCurrencySwapSub.Codeunit.al | 24 +++ .../Country/DK/DKExpCategories.Codeunit.al | 31 ++++ .../Country/DK/DKExpGLAccount.Codeunit.al | 105 +++++++++++ .../Country/DK/DKExpPostingGrp.Codeunit.al | 64 +++++++ .../Country/DK/DKExpRuleCondition.Codeunit.al | 26 +++ .../Country/DK/DKExpRuleHeader.Codeunit.al | 29 +++ .../Country/DK/DKExpSubCategories.Codeunit.al | 39 ++++ .../Country/DK/DKExpense.Codeunit.al | 51 ++++++ .../Country/DK/DKGLAccountNames.Codeunit.al | 68 +++++++ .../Country/DK/DKPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/DK/DKUpdEmpPostingGrp.Codeunit.al | 31 ++++ .../Country/ExpenseAgentCountry.Enum.al | 2 +- 13 files changed, 701 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al new file mode 100644 index 00000000000..c04f734f319 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8288 "DK Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + DKExpGLAccount: Codeunit "DK Exp. GL Account"; + DKExpPostingGrp: Codeunit "DK Exp. Posting Grp"; + begin + BindSubscription(DKExpGLAccount); + BindSubscription(DKExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"DK Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"DK Exp. Posting Grp"); + + UnbindSubscription(DKExpPostingGrp); + UnbindSubscription(DKExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"DK Exp. Categories"); + Codeunit.Run(Codeunit::"DK Exp. SubCategories"); + Codeunit.Run(Codeunit::"DK Exp. Rule Header"); + Codeunit.Run(Codeunit::"DK Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"DK Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + DKCurrencySwapSub: Codeunit "DK Currency Swap Sub"; + DKPostedExpReport: Codeunit "DK Posted Exp. Report"; + begin + BindSubscription(DKCurrencySwapSub); + BindSubscription(DKPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"DK Posted Exp. Report"); + + UnbindSubscription(DKPostedExpReport); + UnbindSubscription(DKCurrencySwapSub); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al new file mode 100644 index 00000000000..c758e910d02 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8299 "DK Currency Swap Sub" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.DKK() then + CurrencyCode := ''; + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al new file mode 100644 index 00000000000..7daebfd0570 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8293 "DK Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + DKExpPostingGrp: Codeunit "DK Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, DKExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..a12d64bf42b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al @@ -0,0 +1,105 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8290 "DK Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(CompanyCreditCards(), CompanyCreditCardsName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(TravelAllowancesPerDiem(), TravelAllowancesPerDiemName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(NonDeductibleTravelExpenses(), NonDeductibleTravelExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RentalCarExpenses(), RentalCarExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherExpenses(), OtherExpensesName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCreditCardsName(), '18300'); + ContosoGLAccount.AddAccountForLocalization(TravelAllowancesPerDiemName(), '03652'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '03661'); + ContosoGLAccount.AddAccountForLocalization(NonDeductibleTravelExpensesName(), '03655'); + ContosoGLAccount.AddAccountForLocalization(RentalCarExpensesName(), '03654'); + ContosoGLAccount.AddAccountForLocalization(OtherExpensesName(), '05699'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CompanyCreditCardsTok: Label 'Company credit cards', MaxLength = 100; + TravelAllowancesPerDiemTok: Label 'Travel allowances (per diem)', MaxLength = 100; + RentalCarExpensesTok: Label 'Rental car expenses', MaxLength = 100; + NonDeductibleTravelExpensesTok: Label 'Non-deductible travel expenses', MaxLength = 100; + OtherExpensesTok: Label 'Other expenses', MaxLength = 100; + + procedure CompanyCreditCards(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCreditCardsName())); + end; + + procedure CompanyCreditCardsName(): Text[100] + begin + exit(CompanyCreditCardsTok); + end; + + procedure TravelAllowancesPerDiem(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(TravelAllowancesPerDiemName())); + end; + + procedure TravelAllowancesPerDiemName(): Text[100] + begin + exit(TravelAllowancesPerDiemTok); + end; + + procedure RentalCarExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(RentalCarExpensesName())); + end; + + procedure RentalCarExpensesName(): Text[100] + begin + exit(RentalCarExpensesTok); + end; + + procedure NonDeductibleTravelExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonDeductibleTravelExpensesName())); + end; + + procedure NonDeductibleTravelExpensesName(): Text[100] + begin + exit(NonDeductibleTravelExpensesTok); + end; + + procedure OtherExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(OtherExpensesName())); + end; + + procedure OtherExpensesName(): Text[100] + begin + exit(OtherExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..239a998e5fb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8291 "DK Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + DKGLAccountNames: Codeunit "DK GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + DKExpGLAccount: Codeunit "DK Exp. GL Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.EntwinetobaccospiritsName()), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.RestaurantdiningName()), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.MileagerateName()), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, DKExpGLAccount.OtherExpenses(), DKExpGLAccount.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, DKExpGLAccount.TravelAllowancesPerDiem(), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.TravelingtradefairsetcName()), DKExpGLAccount.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, DKExpGLAccount.RentalCarExpenses(), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..1307ba6672d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8296 "DK Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + DKExpCategories: Codeunit "DK Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..b2497fbfa4d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8295 "DK Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + DKExpCategories: Codeunit "DK Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..d4f5e16164a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8294 "DK Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + DKExpCategories: Codeunit "DK Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), DKExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), DKExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al new file mode 100644 index 00000000000..1d7bdc59341 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8297 "DK Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DKExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + DKExpCategories: Codeunit "DK Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al new file mode 100644 index 00000000000..f318d36cf2b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al @@ -0,0 +1,68 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8289 "DK GL Account Names" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + EntwinetobaccospiritsTok: Label 'Ent., Wine / Tobacco / Spirits', MaxLength = 100; + PrepaymentsAccruedCostsTok: Label 'Prepayments - Accrued Costs', MaxLength = 100; + CentdiscrepanciesTok: Label 'Cent Discrepancies', MaxLength = 100; + RestaurantdiningTok: Label 'Restaurant Dining', MaxLength = 100; + MileagerateTok: Label 'Mileage Rate', MaxLength = 100; + TravelingtradefairsetcTok: Label 'Traveling, Trade Fairs etc.', MaxLength = 100; + AccountsPayablePostingTok: Label 'Accounts Payables', MaxLength = 100; + BankTok: Label 'Bank', MaxLength = 100; + DomesticsalesofgoodsandservicesTok: Label 'Domestic Sales of Goods and Services', MaxLength = 100; + + procedure EntwinetobaccospiritsName(): Text[100] + begin + exit(EntwinetobaccospiritsTok); + end; + + procedure PrepaymentsAccruedCostsName(): Text[100] + begin + exit(PrepaymentsAccruedCostsTok); + end; + + procedure CentdiscrepanciesName(): Text[100] + begin + exit(CentdiscrepanciesTok); + end; + + procedure RestaurantdiningName(): Text[100] + begin + exit(RestaurantdiningTok); + end; + + procedure MileagerateName(): Text[100] + begin + exit(MileagerateTok); + end; + + procedure TravelingtradefairsetcName(): Text[100] + begin + exit(TravelingtradefairsetcTok); + end; + + procedure AccountsPayablePostingName(): Text[100] + begin + exit(AccountsPayablePostingTok); + end; + + procedure BankName(): Text[100] + begin + exit(BankTok); + end; + + procedure DomesticsalesofgoodsandservicesName(): Text[100] + begin + exit(DomesticsalesofgoodsandservicesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..26157d0fd23 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8298 "DK Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + DKGLAccountNames: Codeunit "DK GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.DomesticsalesofgoodsandservicesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + DKExpCategories: Codeunit "DK Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), DKExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DKExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DKExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..7938ed50e9e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8292 "DK Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + DKExpGLAccount: Codeunit "DK Exp. GL Account"; + DKGLAccountNames: Codeunit "DK GL Account Names"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.AccountsPayablePostingName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.BankName()), DKExpGLAccount.CompanyCreditCards()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 676f5ee74fa..6813ddd4293 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -46,7 +46,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(7; DK) { Caption = 'DK'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "DK Country Data"; } value(8; FR) { From 1c77cacafcdb00f55eaa77bf6aba2f7ef3cc4384 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:13:01 +0530 Subject: [PATCH 09/25] Document porting judgment calls per country --- .../demo data/Country/PORTING_NOTES.md | 212 ++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md new file mode 100644 index 00000000000..60cd83666cf --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md @@ -0,0 +1,212 @@ +# Expense Agent — Country Demo Data Consolidation Notes + +This file catalogs the technical workarounds applied while porting the ten +per-country Expense Agent demo-data extensions into the consolidated +`Expense Agent Demo Data` (W1) extension. + +## Rationale + +The consolidated demo data extension must be installable on **any** BC +localization — it can only depend on: + +- `Expense Agent (Preview)` (base app) +- `Contoso Coffee Demo Dataset` (base W1 Contoso Coffee) +- `Expense Agent Demo Data` (itself, framework layer) + +It cannot add hard dependencies on `Contoso Coffee Demo Dataset ()` or on +any country localization pack (which would restrict installability to that +country only). + +The original per-country apps (`ExpenseAgent_/demo data`) freely referenced +`Create GL Accounts` codeunits from `Contoso Coffee Demo Dataset ()` +and, in the ES case, the `Income Stmt. Bal. Acc.` field added by the ES +localization. Neither is available here. + +**All data written on the target locale (numbers, names, categories, +income/balance flags, posting types, etc.) is byte-identical to the original +per-country app output.** The workarounds change *how* a value is looked up, +not *what* value is written. + +## Data preservation + +For every country, the following are copied verbatim from the original +`CreateExpenseGLAccount.Codeunit.al` / `ExpenseEventSubscriber.Codeunit.al`: + +- G/L account numbers (`AddAccountForLocalization(name, number)`) +- G/L account names (`Label` values) +- Income/Balance flag +- G/L Account Category + SubCategory +- Account Type (Posting / Begin-Total / End-Total) +- Begin-Total / End-Total Totaling ranges (CA, NZ) +- General Posting Type +- Direct Posting / Reconciliation / Blocked flags +- Expense Posting Group account mappings (Refundable/Non-refundable/Prepayment/Rounding) +- Employee Posting Group mappings +- Categories / SubCategories / Rule Header / Rule Condition / Expense / + Posted Expense Report data (labels, dates, amounts, vendors, participants) + +--- + +## Judgment calls (per country) + +### Pattern A — Inlined `Contoso Coffee (CC)` name-lookup labels + +**Problem:** original per-country apps look up G/L accounts by name using +`Create GL Account.()` from `Contoso Coffee Demo Dataset ()`. +The consolidated extension cannot depend on the country ContosoCoffee. + +**Workaround:** create a per-country ` GL Account Names` codeunit that +duplicates the `Tok`/`Lbl` string constants verbatim. The base W1 +`Create Expense G/L Account.FindGLAccountByName(...)` resolves the account by +name at runtime, so on a ``-loc install where the ContosoCoffee-`` pack +is installed, the returned account is identical to the original code path. + +**Alternative rejected:** adding `Contoso Coffee Demo Dataset ()` as a +dependency of the consolidated extension → would make the extension only +installable on `` loc. + +#### US +| # | Label | Value | +|---|-------|-------| +| 1 | `BusinessEntertainingDeductibleName` | `Business Entertaining, deductible` | +| 2 | `OtherIncidentalRevenueName` | `Other Incidental Revenue` | +| 3 | `OtherPrepaidExpensesAndAccruedIncomeName` | `Other prepaid expenses and accrued income` | +| 4 | `PayableInvoiceRoundingName` | `Payable Invoice Rounding` | +| 5 | `MiscExternalExpensesName` | `Misc. external expenses` | +| 6 | `OtherTravelExpensesName` | `Other travel expenses` | +| 7 | `RentalVehiclesName` | `Rental vehicles` | +| 8 | `AccountsPayableDomesticName` | `Accounts Payable, Domestic` | +| 9 | `OtherBankAccountsName` | `Other bank accounts ` (trailing space) | +| 10 | `SaleofResourcesName` | `Sale of Resources` | + +- **Before (original US):** `Create US GL Account.OtherIncidentalRevenue()` and siblings — from `src/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateUSGLAccount.Codeunit.al`. +- **After (ported):** [demo data/Country/US/USGLAccountNames.Codeunit.al](demo%20data/Country/US/USGLAccountNames.Codeunit.al) — codeunit 8220. +- **Used by:** [demo data/Country/US/USExpGLAccount.Codeunit.al](demo%20data/Country/US/USExpGLAccount.Codeunit.al), [demo data/Country/US/USExpPostingGrp.Codeunit.al](demo%20data/Country/US/USExpPostingGrp.Codeunit.al), [demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/US/USUpdEmpPostingGrp.Codeunit.al), [demo data/Country/US/USPostedExpReport.Codeunit.al](demo%20data/Country/US/USPostedExpReport.Codeunit.al). + +#### GB +| # | Label | Value | +|---|-------|-------| +| 1 | `BusinessEntertainingDeductibleName` | `Business Entertaining, deductible` | +| 2 | `OtherIncidentalRevenueName` | `Other Incidental Revenue` | +| 3 | `OtherPrepaidExpensesAndAccruedIncomeName` | `Other prepaid expenses and accrued income` | +| 4 | `PayableInvoiceRoundingName` | `Payable Invoice Rounding` | +| 5 | `MiscExternalExpensesName` | `Misc. external expenses` | +| 6 | `OtherTravelExpensesName` | `Other travel expenses` | +| 7 | `RentalVehiclesName` | `Rental vehicles` | +| 8 | `OtherBankAccountsName` | `Other bank accounts ` (trailing space) | +| 9 | `SaleofResourcesName` | `Sale of Resources` | + +- **Before (original GB):** `Create UK GL Account.()` from `src/Apps/GB/ContosoCoffeeDemoDatasetGB/app/DemoData/Finance/1.Setup Data/CreateUKGLAccount.Codeunit.al` (or equivalent). +- **After (ported):** [demo data/Country/GB/GBGLAccountNames.Codeunit.al](demo%20data/Country/GB/GBGLAccountNames.Codeunit.al) — codeunit 8235. +- **Used by:** [demo data/Country/GB/GBExpGLAccount.Codeunit.al](demo%20data/Country/GB/GBExpGLAccount.Codeunit.al), [demo data/Country/GB/GBExpPostingGrp.Codeunit.al](demo%20data/Country/GB/GBExpPostingGrp.Codeunit.al), [demo data/Country/GB/GBPostedExpReport.Codeunit.al](demo%20data/Country/GB/GBPostedExpReport.Codeunit.al). + +#### CA +Single label inlined directly in [demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L33](demo%20data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L33): + +```al +BankCheckingLbl: Label 'Bank, Checking', MaxLength = 100; +``` + +- **Before (original CA):** `Create CA GL Account.BankCheckingName()` from `src/Apps/CA/ContosoCoffeeDemoDatasetCA/app/DemoData/Finance/1.Setup Data/CreateCAGLAccount.Codeunit.al`. +- **After (ported):** [demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L28](demo%20data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L28) uses `ExpenseGLAccount.FindGLAccountByName(BankCheckingLbl)`. + +#### ES +| # | Label | Value | +|---|-------|-------| +| 1 | `OtherBusinessExpensesName` | `Other Business Expenses` | +| 2 | `RemunerationAdvancesName` | `Remuneration Advances` | +| 3 | `BanksEuroName` | `Banks Euro` | +| 4 | `InternalResourcesName` | `Internal Resources` | +| 5 | `ProfitOrLossName` | `Profit or Loss` | + +- **Before (original ES):** `Create ES GL Accounts.()` from `src/Apps/ES/ContosoCoffeeDemoDatasetES/app/DemoData/Finance/1.Setup Data/CreateESGLAccounts.Codeunit.al`. +- **After (ported):** [demo data/Country/ES/ESGLAccountNames.Codeunit.al](demo%20data/Country/ES/ESGLAccountNames.Codeunit.al) — codeunit 8276. +- **Used by:** [demo data/Country/ES/ESExpGLAccount.Codeunit.al](demo%20data/Country/ES/ESExpGLAccount.Codeunit.al), [demo data/Country/ES/ESExpPostingGrp.Codeunit.al](demo%20data/Country/ES/ESExpPostingGrp.Codeunit.al), [demo data/Country/ES/ESUpdEmployee.Codeunit.al](demo%20data/Country/ES/ESUpdEmployee.Codeunit.al), [demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al), [demo data/Country/ES/ESPostedExpReport.Codeunit.al](demo%20data/Country/ES/ESPostedExpReport.Codeunit.al). + +#### DK +| # | Label | Value | +|---|-------|-------| +| 1 | `EntwinetobaccospiritsName` | `Ent., Wine / Tobacco / Spirits` | +| 2 | `PrepaymentsAccruedCostsName` | `Prepayments - Accrued Costs` | +| 3 | `CentdiscrepanciesName` | `Cent Discrepancies` | +| 4 | `RestaurantdiningName` | `Restaurant Dining` | +| 5 | `MileagerateName` | `Mileage Rate` | +| 6 | `TravelingtradefairsetcName` | `Traveling, Trade Fairs etc.` | +| 7 | `AccountsPayablePostingName` | `Accounts Payables` | +| 8 | `BankName` | `Bank` | +| 9 | `DomesticsalesofgoodsandservicesName` | `Domestic Sales of Goods and Services` | + +- **Before (original DK):** `Create GL Acc. DK.()` from `src/Apps/DK/ContosoCoffeeDemoDatasetDK/app/DemoData/Finance/1.Setup Data/CreateGLAccDK.Codeunit.al`. +- **After (ported):** [demo data/Country/DK/DKGLAccountNames.Codeunit.al](demo%20data/Country/DK/DKGLAccountNames.Codeunit.al) — codeunit 8289. +- **Used by:** [demo data/Country/DK/DKExpGLAccount.Codeunit.al](demo%20data/Country/DK/DKExpGLAccount.Codeunit.al), [demo data/Country/DK/DKExpPostingGrp.Codeunit.al](demo%20data/Country/DK/DKExpPostingGrp.Codeunit.al), [demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al), [demo data/Country/DK/DKPostedExpReport.Codeunit.al](demo%20data/Country/DK/DKPostedExpReport.Codeunit.al). + +#### NZ, AU +None. Both countries' original apps only reference base W1 Contoso Coffee names (`EmployeesPayableName`, `BankLCYName`, etc.) which are available via `Create G/L Account` in the base `Contoso Coffee Demo Dataset`. + +--- + +### Pattern B — ES `"Income Stmt. Bal. Acc."` late-bound field write + +**Problem:** the original `ExpenseAgent_ES` app strongly types +`GLAccount.Validate("Income Stmt. Bal. Acc.", )` on 11 G/L accounts. +That field is added to table `G/L Account` by the ES localization pack +(unavailable in W1). Adding a dep on that pack would restrict the whole +consolidated extension to ES loc. + +**Before (original ES):** +`src/Apps/ES/ExpenseAgent_ES/demo data/Demo Data/1.Setup Data/CreateExpenseGLAccountES.Codeunit.al` line 78: +```al +GLAccount.Validate("Income Stmt. Bal. Acc.", IncomeStmtBalAcc); +``` + +**After (ported):** [demo data/Country/ES/ESExpGLAccount.Codeunit.al#L74-L96](demo%20data/Country/ES/ESExpGLAccount.Codeunit.al#L74-L96): +```al +local procedure UpdateIncomeStmtBalAcc(No: Code[20]; IncomeStmtBalAcc: Code[20]) +var + GLAccount: Record "G/L Account"; + RecRef: RecordRef; + FieldRef: FieldRef; + i: Integer; +begin + // "Income Stmt. Bal. Acc." is added by the ES localization to table G/L Account. + // Look it up dynamically via FieldRef so this demo data works without an ES-loc + // compile-time dependency; silently skip when the field is not present. + if not GLAccount.Get(No) then + exit; + + RecRef.GetTable(GLAccount); + for i := 1 to RecRef.FieldCount do begin + FieldRef := RecRef.FieldIndex(i); + if FieldRef.Name = 'Income Stmt. Bal. Acc.' then begin + FieldRef.Validate(IncomeStmtBalAcc); + RecRef.Modify(); + exit; + end; + end; +end; +``` + +**Behavior:** +- On an ES-loc install: the field is present, `FieldRef.Validate` fires, + demo data written is byte-identical to the original. +- On a non-ES install: the loop completes without finding the field, + `UpdateIncomeStmtBalAcc` no-ops. This is safe because on a non-ES install + the country resolver returns something other than `ES` and this codepath + is never reached anyway. + +**Caveat:** field name comparison is against the English identifier +`'Income Stmt. Bal. Acc.'`. If a future BC build renames this field's +`Name` property (unlikely — captions are separate from names), this +lookup would miss and no `Income Stmt. Bal. Acc.` would be written. + +--- + +## Countries with no judgment calls + +Countries where the port is a pure 1:1 rename/renumber with no +technique changes: + +- **NZ** ([demo data/Country/NZ/](demo%20data/Country/NZ/)): base W1 names only. +- **AU** ([demo data/Country/AU/](demo%20data/Country/AU/)): base W1 names only. + +Countries not yet ported (as of this doc): **FR, DE, AT**. From 7b843da1c9e8418d7d324ee3a7ba1a8429192737 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:18:11 +0530 Subject: [PATCH 10/25] DK Handled --- .../demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al index 7938ed50e9e..06a0528020e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al @@ -3,7 +3,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; - using Microsoft.DemoData.HumanResources; codeunit 8292 "DK Upd. Emp. Posting Grp" From a31c187068fbfd87de8be30c1d64fb19ac71d9c6 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:34:05 +0530 Subject: [PATCH 11/25] FR Handled --- .../Country/ExpenseAgentCountry.Enum.al | 2 +- .../Country/FR/FRCountryData.Codeunit.al | 64 +++++++ .../Country/FR/FRCurrencySwapSub.Codeunit.al | 24 +++ .../Country/FR/FRExpCategories.Codeunit.al | 31 ++++ .../Country/FR/FRExpGLAccount.Codeunit.al | 89 ++++++++++ .../Country/FR/FRExpPostingGrp.Codeunit.al | 66 +++++++ .../Country/FR/FRExpRuleCondition.Codeunit.al | 26 +++ .../Country/FR/FRExpRuleHeader.Codeunit.al | 29 +++ .../Country/FR/FRExpSubCategories.Codeunit.al | 39 ++++ .../Country/FR/FRExpense.Codeunit.al | 51 ++++++ .../Country/FR/FRPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/FR/FRUpdEmpPostingGrp.Codeunit.al | 32 ++++ 12 files changed, 620 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 6813ddd4293..0d7c90a5575 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -51,7 +51,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(8; FR) { Caption = 'FR'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "FR Country Data"; } value(9; DE) { diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al new file mode 100644 index 00000000000..5e516821672 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8300 "FR Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + FRExpGLAccount: Codeunit "FR Exp. GL Account"; + FRExpPostingGrp: Codeunit "FR Exp. Posting Grp"; + begin + BindSubscription(FRExpGLAccount); + BindSubscription(FRExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"FR Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"FR Exp. Posting Grp"); + + UnbindSubscription(FRExpPostingGrp); + UnbindSubscription(FRExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"FR Exp. Categories"); + Codeunit.Run(Codeunit::"FR Exp. SubCategories"); + Codeunit.Run(Codeunit::"FR Exp. Rule Header"); + Codeunit.Run(Codeunit::"FR Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"FR Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + FRCurrencySwapSub: Codeunit "FR Currency Swap Sub"; + FRPostedExpReport: Codeunit "FR Posted Exp. Report"; + begin + BindSubscription(FRCurrencySwapSub); + BindSubscription(FRPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"FR Posted Exp. Report"); + + UnbindSubscription(FRPostedExpReport); + UnbindSubscription(FRCurrencySwapSub); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al new file mode 100644 index 00000000000..0b3b6c2b739 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8310 "FR Currency Swap Sub" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al new file mode 100644 index 00000000000..139298315d8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8304 "FR Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + FRExpPostingGrp: Codeunit "FR Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, FRExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..2687affdbd0 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al @@ -0,0 +1,89 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8301 "FR Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(CompanyCreditCards(), CompanyCreditCardsName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpensePrepaymentAccount(), ExpensePrepaymentAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(RentalCarExpenses(), RentalCarExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCreditCardsName(), '512900'); + ContosoGLAccount.AddAccountForLocalization(ExpensePrepaymentAccountName(), '486200'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '625110'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '625120'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '625200'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '625210'); + ContosoGLAccount.AddAccountForLocalization(RentalCarExpensesName(), '625130'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherTravelExpensesAccountName(), '625180'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccountName(), '625290'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CompanyCreditCardsTok: Label 'Company credit cards', MaxLength = 100; + ExpensePrepaymentAccountTok: Label 'Expense prepayment account', MaxLength = 100; + RentalCarExpensesTok: Label 'Rental car expenses', MaxLength = 100; + + procedure CompanyCreditCards(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCreditCardsName())); + end; + + procedure CompanyCreditCardsName(): Text[100] + begin + exit(CompanyCreditCardsTok); + end; + + procedure ExpensePrepaymentAccount(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(ExpensePrepaymentAccountName())); + end; + + procedure ExpensePrepaymentAccountName(): Text[100] + begin + exit(ExpensePrepaymentAccountTok); + end; + + procedure RentalCarExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(RentalCarExpensesName())); + end; + + procedure RentalCarExpensesName(): Text[100] + begin + exit(RentalCarExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..ab370d6780f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al @@ -0,0 +1,66 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8302 "FR Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + FRExpGLAccount: Codeunit "FR Exp. GL Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EntertainmentandPRName()), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.TravelName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, FRExpGLAccount.RentalCarExpenses(), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..151833e0143 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8307 "FR Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + FRExpCategories: Codeunit "FR Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..7c3cfd823af --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8306 "FR Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + FRExpCategories: Codeunit "FR Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..898fec78585 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8305 "FR Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + FRExpCategories: Codeunit "FR Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), FRExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), FRExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al new file mode 100644 index 00000000000..0006405f379 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8308 "FR Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), FRExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + FRExpCategories: Codeunit "FR Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..ff70818d5db --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8309 "FR Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.SalesResourcesExportName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + FRExpCategories: Codeunit "FR Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), FRExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), FRExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), FRExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..9da17fbd6fd --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,32 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8303 "FR Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + FRExpGLAccount: Codeunit "FR Exp. GL Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), FRExpGLAccount.CompanyCreditCards()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} From f3ff5589a61ede0270697bc59dc32b325bf727e0 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:34:49 +0530 Subject: [PATCH 12/25] Update porting notes for FR --- src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md index 60cd83666cf..ca51fff0aee 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md @@ -143,6 +143,9 @@ BankCheckingLbl: Label 'Bank, Checking', MaxLength = 100; #### NZ, AU None. Both countries' original apps only reference base W1 Contoso Coffee names (`EmployeesPayableName`, `BankLCYName`, etc.) which are available via `Create G/L Account` in the base `Contoso Coffee Demo Dataset`. +#### FR +None (no ContosoCoffee-FR name-lookups). FR introduces three FR-unique local G/L accounts (`CompanyCreditCards=512900`, `ExpensePrepaymentAccount=486200`, `RentalCarExpenses=625130`) with local `Tok` labels declared inside [demo data/Country/FR/FRExpGLAccount.Codeunit.al](demo%20data/Country/FR/FRExpGLAccount.Codeunit.al) — same as the original per-country app's own local declarations. + --- ### Pattern B — ES `"Income Stmt. Bal. Acc."` late-bound field write @@ -208,5 +211,6 @@ technique changes: - **NZ** ([demo data/Country/NZ/](demo%20data/Country/NZ/)): base W1 names only. - **AU** ([demo data/Country/AU/](demo%20data/Country/AU/)): base W1 names only. +- **FR** ([demo data/Country/FR/](demo%20data/Country/FR/)): base W1 names only; three FR-local G/L accounts inlined verbatim from the original per-country app. -Countries not yet ported (as of this doc): **FR, DE, AT**. +Countries not yet ported (as of this doc): **DE, AT**. From 99b386263ba052d2bb5585af3bdae4bea7654cf8 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:51:11 +0530 Subject: [PATCH 13/25] DE Handled --- .../Country/DE/DECountryData.Codeunit.al | 64 +++++++ .../Country/DE/DECurrencySwapSub.Codeunit.al | 24 +++ .../Country/DE/DEExpCategories.Codeunit.al | 31 ++++ .../Country/DE/DEExpGLAccount.Codeunit.al | 57 ++++++ .../Country/DE/DEExpPostingGrp.Codeunit.al | 63 +++++++ .../Country/DE/DEExpRuleCondition.Codeunit.al | 26 +++ .../Country/DE/DEExpRuleHeader.Codeunit.al | 29 +++ .../Country/DE/DEExpSubCategories.Codeunit.al | 39 ++++ .../Country/DE/DEExpense.Codeunit.al | 51 ++++++ .../Country/DE/DEGLAccountNames.Codeunit.al | 68 +++++++ .../Country/DE/DEPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/DE/DEUpdEmpPostingGrp.Codeunit.al | 32 ++++ .../Country/ExpenseAgentCountry.Enum.al | 2 +- .../demo data/Country/PORTING_NOTES.md | 21 ++- 14 files changed, 673 insertions(+), 2 deletions(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al new file mode 100644 index 00000000000..cad89122b34 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8311 "DE Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + DEExpGLAccount: Codeunit "DE Exp. GL Account"; + DEExpPostingGrp: Codeunit "DE Exp. Posting Grp"; + begin + BindSubscription(DEExpGLAccount); + BindSubscription(DEExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"DE Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"DE Exp. Posting Grp"); + + UnbindSubscription(DEExpPostingGrp); + UnbindSubscription(DEExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"DE Exp. Categories"); + Codeunit.Run(Codeunit::"DE Exp. SubCategories"); + Codeunit.Run(Codeunit::"DE Exp. Rule Header"); + Codeunit.Run(Codeunit::"DE Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"DE Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + DECurrencySwapSub: Codeunit "DE Currency Swap Sub"; + DEPostedExpReport: Codeunit "DE Posted Exp. Report"; + begin + BindSubscription(DECurrencySwapSub); + BindSubscription(DEPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"DE Posted Exp. Report"); + + UnbindSubscription(DEPostedExpReport); + UnbindSubscription(DECurrencySwapSub); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al new file mode 100644 index 00000000000..71dc49cbd8b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8322 "DE Currency Swap Sub" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al new file mode 100644 index 00000000000..0c718c48e85 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8316 "DE Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + DEExpPostingGrp: Codeunit "DE Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, DEExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..add2d151b54 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al @@ -0,0 +1,57 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8313 "DE Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(CompanyCreditCardsClearingAccount(), CompanyCreditCardsClearingAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.PerDiemTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.MileageTravelExpensesAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCreditCardsClearingAccountName(), '3510'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.PerDiemTravelExpensesAccountName(), '6664'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MileageTravelExpensesAccountName(), '6658'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '6662'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CompanyCreditCardsClearingAccountTok: Label 'Company credit card clearing account', MaxLength = 100; + + procedure CompanyCreditCardsClearingAccount(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCreditCardsClearingAccountName())); + end; + + procedure CompanyCreditCardsClearingAccountName(): Text[100] + begin + exit(CompanyCreditCardsClearingAccountTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..1d0e86e0dd1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al @@ -0,0 +1,63 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8314 "DE Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + DEGLAccountNames: Codeunit "DE GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.BusinessEntertainingdeductibleName()), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.BoardandlodgingName()), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.MiscexternalexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.RentalvehiclesName()), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..2468e6693c0 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8319 "DE Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..7af023f38f8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8318 "DE Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..03d3e292967 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8317 "DE Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + DEExpCategories: Codeunit "DE Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), DEExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), DEExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al new file mode 100644 index 00000000000..99c1b2547a3 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8320 "DE Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DEExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al new file mode 100644 index 00000000000..c5badd3457e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al @@ -0,0 +1,68 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8312 "DE GL Account Names" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + BusinessaccountOperatingDomesticTok: Label 'Business account, Operating, Domestic', MaxLength = 100; + SaleofResourcesTok: Label 'Sale of Resource', MaxLength = 100; + AssetsintheformofprepaidexpensesTok: Label 'Assets in the form of prepaid expenses', MaxLength = 100; + SalesInvoiceRoundingTok: Label 'Sales Invoice Rounding', MaxLength = 100; + BoardandlodgingTok: Label 'Board and lodging', MaxLength = 100; + MiscexternalexpensesTok: Label 'Misc. external expenses', MaxLength = 100; + OthertravelexpensesTok: Label 'Other travel expenses', MaxLength = 100; + RentalvehiclesTok: Label 'Rental vehicles', MaxLength = 100; + BusinessEntertainingdeductibleTok: Label 'Business Entertaining, deductible', MaxLength = 100; + + procedure BusinessaccountOperatingDomesticName(): Text[100] + begin + exit(BusinessaccountOperatingDomesticTok); + end; + + procedure SaleofResourcesName(): Text[100] + begin + exit(SaleofResourcesTok); + end; + + procedure AssetsintheformofprepaidexpensesName(): Text[100] + begin + exit(AssetsintheformofprepaidexpensesTok); + end; + + procedure SalesInvoiceRoundingName(): Text[100] + begin + exit(SalesInvoiceRoundingTok); + end; + + procedure BoardandlodgingName(): Text[100] + begin + exit(BoardandlodgingTok); + end; + + procedure MiscexternalexpensesName(): Text[100] + begin + exit(MiscexternalexpensesTok); + end; + + procedure OthertravelexpensesName(): Text[100] + begin + exit(OthertravelexpensesTok); + end; + + procedure RentalvehiclesName(): Text[100] + begin + exit(RentalvehiclesTok); + end; + + procedure BusinessEntertainingdeductibleName(): Text[100] + begin + exit(BusinessEntertainingdeductibleTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..356596ff253 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8321 "DE Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + DEGLAccountNames: Codeunit "DE GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SaleofResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), DEExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DEExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DEExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..7d807dc1436 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,32 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8315 "DE Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + HRGLAccount: Codeunit "Create HR GL Account"; + DEGLAccountNames: Codeunit "DE GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + DEExpGLAccount: Codeunit "DE Exp. GL Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(HRGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.BusinessaccountOperatingDomesticName()), DEExpGLAccount.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 0d7c90a5575..3c8abf76e41 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -56,7 +56,7 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(9; DE) { Caption = 'DE'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "DE Country Data"; } value(10; AT) { diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md index ca51fff0aee..63c76029bd9 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md @@ -146,6 +146,25 @@ None. Both countries' original apps only reference base W1 Contoso Coffee names #### FR None (no ContosoCoffee-FR name-lookups). FR introduces three FR-unique local G/L accounts (`CompanyCreditCards=512900`, `ExpensePrepaymentAccount=486200`, `RentalCarExpenses=625130`) with local `Tok` labels declared inside [demo data/Country/FR/FRExpGLAccount.Codeunit.al](demo%20data/Country/FR/FRExpGLAccount.Codeunit.al) — same as the original per-country app's own local declarations. +#### DE +| # | Label | Value | +|---|-------|-------| +| 1 | `BusinessaccountOperatingDomesticName` | `Business account, Operating, Domestic` | +| 2 | `SaleofResourcesName` | `Sale of Resource` | +| 3 | `AssetsintheformofprepaidexpensesName` | `Assets in the form of prepaid expenses` | +| 4 | `SalesInvoiceRoundingName` | `Sales Invoice Rounding` | +| 5 | `BoardandlodgingName` | `Board and lodging` | +| 6 | `MiscexternalexpensesName` | `Misc. external expenses` | +| 7 | `OthertravelexpensesName` | `Other travel expenses` | +| 8 | `RentalvehiclesName` | `Rental vehicles` | +| 9 | `BusinessEntertainingdeductibleName` | `Business Entertaining, deductible` | + +- **Before (original DE):** `Create DE GL Acc.()` from `src/Apps/DE/ContosoCoffeeDemoDatasetDE/app/DemoData/Finance/1.Setup data/CreateDEGLAcc.Codeunit.al`. +- **After (ported):** [demo data/Country/DE/DEGLAccountNames.Codeunit.al](demo%20data/Country/DE/DEGLAccountNames.Codeunit.al) — codeunit 8312. +- **Used by:** [demo data/Country/DE/DEExpPostingGrp.Codeunit.al](demo%20data/Country/DE/DEExpPostingGrp.Codeunit.al), [demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al), [demo data/Country/DE/DEPostedExpReport.Codeunit.al](demo%20data/Country/DE/DEPostedExpReport.Codeunit.al). + +DE also introduces one DE-unique local G/L account (`CompanyCreditCardsClearingAccount=3510`, label `'Company credit card clearing account'`) declared inside [demo data/Country/DE/DEExpGLAccount.Codeunit.al](demo%20data/Country/DE/DEExpGLAccount.Codeunit.al) — same as the original per-country app's own local declaration. + --- ### Pattern B — ES `"Income Stmt. Bal. Acc."` late-bound field write @@ -213,4 +232,4 @@ technique changes: - **AU** ([demo data/Country/AU/](demo%20data/Country/AU/)): base W1 names only. - **FR** ([demo data/Country/FR/](demo%20data/Country/FR/)): base W1 names only; three FR-local G/L accounts inlined verbatim from the original per-country app. -Countries not yet ported (as of this doc): **DE, AT**. +Countries not yet ported (as of this doc): **AT**. From f33cfbed14c4884c9cf09ab1f2635d77743ec0a9 Mon Sep 17 00:00:00 2001 From: "Rishabh Shukla (All e Technologies Ltd)" Date: Fri, 7 Aug 2026 09:59:22 +0530 Subject: [PATCH 14/25] AT Handled --- .../Country/AT/ATCountryData.Codeunit.al | 64 +++++++ .../Country/AT/ATCurrencySwapSub.Codeunit.al | 24 +++ .../Country/AT/ATExpCategories.Codeunit.al | 39 ++++ .../Country/AT/ATExpGLAccount.Codeunit.al | 57 ++++++ .../Country/AT/ATExpPostingGrp.Codeunit.al | 76 ++++++++ .../Country/AT/ATExpRuleCondition.Codeunit.al | 26 +++ .../Country/AT/ATExpRuleHeader.Codeunit.al | 29 +++ .../Country/AT/ATExpSubCategories.Codeunit.al | 39 ++++ .../Country/AT/ATExpense.Codeunit.al | 51 ++++++ .../Country/AT/ATGLAccountNames.Codeunit.al | 62 +++++++ .../Country/AT/ATPostedExpReport.Codeunit.al | 168 ++++++++++++++++++ .../Country/AT/ATUpdEmpPostingGrp.Codeunit.al | 34 ++++ .../Country/ExpenseAgentCountry.Enum.al | 2 +- .../demo data/Country/PORTING_NOTES.md | 47 ++++- 14 files changed, 716 insertions(+), 2 deletions(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al new file mode 100644 index 00000000000..1155ae8f275 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8323 "AT Country Data" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + W1CountryData: Codeunit "W1 Country Data"; + ATExpGLAccount: Codeunit "AT Exp. GL Account"; + ATExpPostingGrp: Codeunit "AT Exp. Posting Grp"; + begin + BindSubscription(ATExpGLAccount); + BindSubscription(ATExpPostingGrp); + + W1CountryData.CreateSetupData(); + Codeunit.Run(Codeunit::"AT Upd. Emp. Posting Grp"); + Codeunit.Run(Codeunit::"AT Exp. Posting Grp"); + + UnbindSubscription(ATExpPostingGrp); + UnbindSubscription(ATExpGLAccount); + end; + + procedure CreateMasterData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateMasterData(); + Codeunit.Run(Codeunit::"AT Exp. Categories"); + Codeunit.Run(Codeunit::"AT Exp. SubCategories"); + Codeunit.Run(Codeunit::"AT Exp. Rule Header"); + Codeunit.Run(Codeunit::"AT Exp. Rule Condition"); + end; + + procedure CreateTransactionalData() + var + W1CountryData: Codeunit "W1 Country Data"; + begin + W1CountryData.CreateTransactionalData(); + Codeunit.Run(Codeunit::"AT Expense"); + end; + + procedure CreateHistoricalData() + var + W1CountryData: Codeunit "W1 Country Data"; + ATCurrencySwapSub: Codeunit "AT Currency Swap Sub"; + ATPostedExpReport: Codeunit "AT Posted Exp. Report"; + begin + BindSubscription(ATCurrencySwapSub); + BindSubscription(ATPostedExpReport); + + W1CountryData.CreateHistoricalData(); + Codeunit.Run(Codeunit::"AT Posted Exp. Report"); + + UnbindSubscription(ATPostedExpReport); + UnbindSubscription(ATCurrencySwapSub); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al new file mode 100644 index 00000000000..18889b92e61 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8336 "AT Currency Swap Sub" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al new file mode 100644 index 00000000000..f4b508c2b8b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8328 "AT Exp. Categories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + ATExpPostingGrp: Codeunit "AT Exp. Posting Grp"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiemI(), PerDiemByAssignedPolicyLbl, PerDiemIByAssignedPolicyPostingLbl, ATExpPostingGrp.ExpensePerDiemI(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiemA(), PerDiemByAssignedPolicyLbl, PerDiemAByAssignedPolicyPostingLbl, ATExpPostingGrp.ExpensePerDiemA(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemITok: Label 'PER-DIEM-I', MaxLength = 20, Locked = true; + PerDiemATok: Label 'PER-DIEM-A', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemIByAssignedPolicyPostingLbl: Label 'Per-diem (international) by assigned policy', MaxLength = 100; + PerDiemAByAssignedPolicyPostingLbl: Label 'Per-diem (local) by assigned policy', MaxLength = 100; + + procedure PerDiemI(): Code[20] + begin + exit(PerDiemITok); + end; + + procedure PerDiemA(): Code[20] + begin + exit(PerDiemATok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al new file mode 100644 index 00000000000..e34f38ddbad --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al @@ -0,0 +1,57 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8325 "AT Exp. GL Account" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80); + ContosoGLAccount.InsertGLAccount(CompanyCreditCardsClearingAccount(), CompanyCreditCardsClearingAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "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"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCreditCardsClearingAccountName(), '2830'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '7691'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '7692'); + ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '7745'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CompanyCreditCardsClearingAccountTok: Label 'Company credit card clearing account', MaxLength = 100; + + procedure CompanyCreditCardsClearingAccount(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCreditCardsClearingAccountName())); + end; + + procedure CompanyCreditCardsClearingAccountName(): Text[100] + begin + exit(CompanyCreditCardsClearingAccountTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..c32604d5ef7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al @@ -0,0 +1,76 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8326 "AT Exp. Posting Grp" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiemI(), ExpensePerDiemInCountryLbl); + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiemA(), ExpensePerDiemAbroadLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateGLAccount: Codeunit "Create G/L Account"; + ATGLAccountNames: Codeunit "AT GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.HospitalityDomesticDeductibleAmountName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.KilometerAllowanceName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.OtherName()), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ExpensePerDiemI(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.MealExpensesDomesticName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ExpensePerDiemA(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.MealExpensesAbroadName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.TransportationThirdPartiesName()), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.TransportationThirdPartiesName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMITok: Label 'EXPENSE-PERDIEM-I', MaxLength = 20, Locked = true; + ExpensePerDiemInCountryLbl: Label 'Expense - Per Diem in country', MaxLength = 100; + ExpensePERDIEMATok: Label 'EXPENSE-PERDIEM-A', MaxLength = 20, Locked = true; + ExpensePerDiemAbroadLbl: Label 'Expense - Per Diem abroad', MaxLength = 100; + + procedure ExpensePerDiemI(): Code[20] + begin + exit(ExpensePERDIEMITok); + end; + + procedure ExpensePerDiemA(): Code[20] + begin + exit(ExpensePERDIEMATok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al new file mode 100644 index 00000000000..84496f32359 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8331 "AT Exp. Rule Condition" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemA(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al new file mode 100644 index 00000000000..09dfcbe87d7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8330 "AT Exp. Rule Header" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemA(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al new file mode 100644 index 00000000000..5217ff5c5a4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8329 "AT Exp. SubCategories" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + ATExpCategories: Codeunit "AT Exp. Categories"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), ATExpCategories.PerDiemA(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), ATExpCategories.PerDiemI(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al new file mode 100644 index 00000000000..449b8feaf69 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8332 "AT Expense" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ATExpCategories.PerDiemI(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al new file mode 100644 index 00000000000..75baf158068 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al @@ -0,0 +1,62 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8324 "AT GL Account Names" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + SettlementAccountCashBankTok: Label 'Settlement account cash bank', MaxLength = 100; + SalesRevenuesResourcesExportTok: Label 'Sales revenues resources export', MaxLength = 100; + TransportationThirdPartiesTok: Label 'Transportation third parties', MaxLength = 100; + KilometerAllowanceTok: Label 'Kilometer allowance', MaxLength = 100; + MealExpensesDomesticTok: Label 'Meal expenses domestic', MaxLength = 100; + MealExpensesAbroadTok: Label 'Meal expenses abroad', MaxLength = 100; + HospitalityDomesticDeductibleAmountTok: Label 'Hospitality domestic deductible amount', MaxLength = 100; + OtherTok: Label 'Other', MaxLength = 100; + + procedure SettlementAccountCashBankName(): Text[100] + begin + exit(SettlementAccountCashBankTok); + end; + + procedure SalesRevenuesResourcesExportName(): Text[100] + begin + exit(SalesRevenuesResourcesExportTok); + end; + + procedure TransportationThirdPartiesName(): Text[100] + begin + exit(TransportationThirdPartiesTok); + end; + + procedure KilometerAllowanceName(): Text[100] + begin + exit(KilometerAllowanceTok); + end; + + procedure MealExpensesDomesticName(): Text[100] + begin + exit(MealExpensesDomesticTok); + end; + + procedure MealExpensesAbroadName(): Text[100] + begin + exit(MealExpensesAbroadTok); + end; + + procedure HospitalityDomesticDeductibleAmountName(): Text[100] + begin + exit(HospitalityDomesticDeductibleAmountTok); + end; + + procedure OtherName(): Text[100] + begin + exit(OtherTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al new file mode 100644 index 00000000000..d85e3e23b3b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8335 "AT Posted Exp. Report" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ATGLAccountNames: Codeunit "AT GL Account Names"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SalesRevenuesResourcesExportName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), ATExpCategories.PerDiemI(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ATExpCategories.PerDiemI(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ATExpCategories.PerDiemA(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al new file mode 100644 index 00000000000..02d880a92dd --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al @@ -0,0 +1,34 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8327 "AT Upd. Emp. Posting Grp" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + HRGLAccount: Codeunit "Create HR GL Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ATExpGLAccount: Codeunit "AT Exp. GL Account"; + ATGLAccountNames: Codeunit "AT GL Account Names"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(HRGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), ATExpGLAccount.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 3c8abf76e41..690968c387e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -61,6 +61,6 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(10; AT) { Caption = 'AT'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "AT Country Data"; } } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md index 63c76029bd9..f7a97b6594e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md @@ -165,6 +165,51 @@ None (no ContosoCoffee-FR name-lookups). FR introduces three FR-unique local G/L DE also introduces one DE-unique local G/L account (`CompanyCreditCardsClearingAccount=3510`, label `'Company credit card clearing account'`) declared inside [demo data/Country/DE/DEExpGLAccount.Codeunit.al](demo%20data/Country/DE/DEExpGLAccount.Codeunit.al) — same as the original per-country app's own local declaration. +#### AT +| # | Label | Value | +|---|-------|-------| +| 1 | `SettlementAccountCashBankName` | `Settlement account cash bank` | +| 2 | `SalesRevenuesResourcesExportName` | `Sales revenues resources export` | +| 3 | `TransportationThirdPartiesName` | `Transportation third parties` | +| 4 | `KilometerAllowanceName` | `Kilometer allowance` | +| 5 | `MealExpensesDomesticName` | `Meal expenses domestic` | +| 6 | `MealExpensesAbroadName` | `Meal expenses abroad` | +| 7 | `HospitalityDomesticDeductibleAmountName` | `Hospitality domestic deductible amount` | +| 8 | `OtherName` | `Other` | + +- **Before (original AT):** `Create AT GL Account.()` from `src/Apps/AT/ContosoCoffeeDemoDatasetAT/app/DemoData/Finance/1. Setup Data/CreateATGLAccount.Codeunit.al`. +- **After (ported):** [demo data/Country/AT/ATGLAccountNames.Codeunit.al](demo%20data/Country/AT/ATGLAccountNames.Codeunit.al) — codeunit 8324. +- **Used by:** [demo data/Country/AT/ATExpPostingGrp.Codeunit.al](demo%20data/Country/AT/ATExpPostingGrp.Codeunit.al), [demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al), [demo data/Country/AT/ATPostedExpReport.Codeunit.al](demo%20data/Country/AT/ATPostedExpReport.Codeunit.al). + +AT also introduces one AT-unique local G/L account (`CompanyCreditCardsClearingAccount=2830`, label `'Company credit card clearing account'`) declared inside [demo data/Country/AT/ATExpGLAccount.Codeunit.al](demo%20data/Country/AT/ATExpGLAccount.Codeunit.al) — same as the original per-country app's own local declaration. + +### Pattern C — AT event subscribers bind/unbind gating + +**Problem:** the original `ExpenseAgent_AT` app declared its +`OnDefineExpenseAccountNo` and `OnBeforeValidateCurrencyCodeInExpense` +subscribers as plain (non-Manual) event subscribers on +[AT Exp. Contoso Localization.Codeunit.al](../../../../AT/ExpenseAgent_AT/demo%20data/Demo%20Data/ATExpContosoLocalization.Codeunit.al) — safe because that app was only ever installed on the AT loc. In the +consolidated extension the same static registration would fire on every +locale, silently rewriting expense account numbers and currency codes for +non-AT companies. + +**Workaround:** move both subscribers into Manual `SingleInstance` codeunits +([demo data/Country/AT/ATPostedExpReport.Codeunit.al](demo%20data/Country/AT/ATPostedExpReport.Codeunit.al) 8335 and [demo data/Country/AT/ATCurrencySwapSub.Codeunit.al](demo%20data/Country/AT/ATCurrencySwapSub.Codeunit.al) 8336) and let the AT orchestrator +[demo data/Country/AT/ATCountryData.Codeunit.al](demo%20data/Country/AT/ATCountryData.Codeunit.al) `BindSubscription` / `UnbindSubscription` them around `CreateHistoricalData`. Same technique used by FR and DE for their currency-swap and historical-account overrides. + +### ID collision — 8333, 8334, 8347, 8348 reserved by System Application + +The demo data extension's `idRanges` in [demo data/app.json](demo%20data/app.json) is `8201-8399`, but four codeunits inside that range are shipped by the base **System Application** and cannot be redefined here: + +| ID | System Application object | +|---|---| +| 8333 | `VS Code Integration Impl.` | +| 8334 | `VS Code Integration` | +| 8347 | `Feature Configuration` | +| 8348 | `Feature Configuration Impl.` | + +AT files that would naturally have received the next sequential IDs 8333/8334 were shifted to **8335 (`AT Posted Exp. Report`)** and **8336 (`AT Currency Swap Sub`)** for that reason. + --- ### Pattern B — ES `"Income Stmt. Bal. Acc."` late-bound field write @@ -232,4 +277,4 @@ technique changes: - **AU** ([demo data/Country/AU/](demo%20data/Country/AU/)): base W1 names only. - **FR** ([demo data/Country/FR/](demo%20data/Country/FR/)): base W1 names only; three FR-local G/L accounts inlined verbatim from the original per-country app. -Countries not yet ported (as of this doc): **AT**. +All ten countries ported. From cb3a58c778c25dc149f27491e1fe0565a26e48f5 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Tue, 11 Aug 2026 13:47:34 +0530 Subject: [PATCH 15/25] Rename and reorganize country demo data objects Rename per-country demo data codeunits to Create/Update/Expense naming convention with country-code suffix, organize files into Setup Data/Master Data/Transactions/Historical subfolders, and update object references and variable names accordingly. --- .../CreateExpenseCategories.Codeunit.al | 47 +++++ .../CreateExpenseGLAccount.Codeunit.al | 5 + .../CreateExpGLAccountAT.Codeunit.al} | 2 +- .../CreateExpPostingGrpAT.Codeunit.al} | 20 +-- .../UpdateEmpPostingGrpAT.Codeunit.al} | 8 +- .../CreateExpCategoriesAT.Codeunit.al} | 8 +- .../CreateExpRuleConditionAT.Codeunit.al | 26 +++ .../CreateExpRuleHeaderAT.Codeunit.al | 29 +++ .../CreateExpSubCategoriesAT.Codeunit.al | 39 ++++ .../CreateExpenseAT.Codeunit.al} | 6 +- .../CreatePostedExpReportAT.Codeunit.al | 168 ++++++++++++++++++ .../Country/AT/ATCountryData.Codeunit.al | 64 ------- .../Country/AT/ATExpRuleCondition.Codeunit.al | 26 --- .../Country/AT/ATExpRuleHeader.Codeunit.al | 29 --- .../AT/CreateExpenseCountryDataAT.Codeunit.al | 64 +++++++ .../ExpDemoDataSubscriberAT.Codeunit.al} | 2 +- ...al => ExpenseGLAccountNamesAT.Codeunit.al} | 2 +- .../CreateExpGLAccountAU.Codeunit.al} | 2 +- .../CreateExpPostingGrpAU.Codeunit.al} | 2 +- .../UpdateEmpPostingGrpAU.Codeunit.al} | 2 +- .../CreateExpCategoriesAU.Codeunit.al} | 6 +- .../CreateExpRuleConditionAU.Codeunit.al | 26 +++ .../CreateExpRuleHeaderAU.Codeunit.al | 29 +++ .../CreateExpSubCategoriesAU.Codeunit.al} | 8 +- .../CreateExpenseAU.Codeunit.al} | 6 +- .../CreatePostedExpReportAU.Codeunit.al} | 10 +- .../Country/AU/AUCountryData.Codeunit.al | 61 ------- .../Country/AU/AUExpRuleCondition.Codeunit.al | 26 --- .../Country/AU/AUExpRuleHeader.Codeunit.al | 29 --- .../AU/CreateExpenseCountryDataAU.Codeunit.al | 61 +++++++ .../CreateExpGLAccountCA.Codeunit.al} | 2 +- .../CreateExpPostingGrpCA.Codeunit.al} | 2 +- .../UpdateEmpPostingGrpCA.Codeunit.al} | 2 +- .../CreateExpCategoriesCA.Codeunit.al} | 6 +- .../CreateExpRuleConditionCA.Codeunit.al | 26 +++ .../CreateExpRuleHeaderCA.Codeunit.al | 29 +++ .../CreateExpSubCategoriesCA.Codeunit.al} | 8 +- .../CreateExpenseCA.Codeunit.al | 51 ++++++ .../CreatePostedExpReportCA.Codeunit.al} | 10 +- .../Country/CA/CACountryData.Codeunit.al | 61 ------- .../Country/CA/CAExpRuleCondition.Codeunit.al | 26 --- .../Country/CA/CAExpRuleHeader.Codeunit.al | 29 --- .../CA/CreateExpenseCountryDataCA.Codeunit.al | 61 +++++++ .../CreateExpGLAccountDE.Codeunit.al} | 2 +- .../CreateExpPostingGrpDE.Codeunit.al} | 18 +- .../UpdateEmpPostingGrpDE.Codeunit.al} | 8 +- .../CreateExpCategoriesDE.Codeunit.al} | 6 +- .../CreateExpRuleConditionDE.Codeunit.al | 26 +++ .../CreateExpRuleHeaderDE.Codeunit.al | 29 +++ .../CreateExpSubCategoriesDE.Codeunit.al} | 8 +- .../CreateExpenseDE.Codeunit.al} | 6 +- .../CreatePostedExpReportDE.Codeunit.al} | 14 +- .../DE/CreateExpenseCountryDataDE.Codeunit.al | 64 +++++++ .../Country/DE/DECountryData.Codeunit.al | 64 ------- .../Country/DE/DEExpRuleCondition.Codeunit.al | 26 --- .../Country/DE/DEExpRuleHeader.Codeunit.al | 29 --- .../ExpDemoDataSubscriberDE.Codeunit.al} | 2 +- ...al => ExpenseGLAccountNamesDE.Codeunit.al} | 2 +- .../CreateExpGLAccountDK.Codeunit.al} | 2 +- .../CreateExpPostingGrpDK.Codeunit.al} | 20 +-- .../UpdateEmpPostingGrpDK.Codeunit.al} | 8 +- .../CreateExpCategoriesDK.Codeunit.al} | 6 +- .../CreateExpRuleConditionDK.Codeunit.al | 26 +++ .../CreateExpRuleHeaderDK.Codeunit.al | 29 +++ .../CreateExpSubCategoriesDK.Codeunit.al} | 8 +- .../CreateExpenseDK.Codeunit.al | 51 ++++++ .../CreatePostedExpReportDK.Codeunit.al | 168 ++++++++++++++++++ .../DK/CreateExpenseCountryDataDK.Codeunit.al | 64 +++++++ .../Country/DK/DKCountryData.Codeunit.al | 64 ------- .../Country/DK/DKExpRuleCondition.Codeunit.al | 26 --- .../Country/DK/DKExpRuleHeader.Codeunit.al | 29 --- .../Country/DK/DKExpSubCategories.Codeunit.al | 39 ---- .../Country/DK/DKExpense.Codeunit.al | 51 ------ .../Country/DK/DKPostedExpReport.Codeunit.al | 168 ------------------ ...al => ExpDemoDataSubscriberDK.Codeunit.al} | 2 +- ...al => ExpenseGLAccountNamesDK.Codeunit.al} | 2 +- .../CreateExpGLAccountES.Codeunit.al} | 26 +-- .../CreateExpPostingGrpES.Codeunit.al} | 20 +-- .../UpdateEmpPostingGrpES.Codeunit.al} | 8 +- .../CreateExpCategoriesES.Codeunit.al | 31 ++++ .../CreateExpRuleConditionES.Codeunit.al | 26 +++ .../CreateExpRuleHeaderES.Codeunit.al | 29 +++ .../CreateExpSubCategoriesES.Codeunit.al | 39 ++++ .../UpdateEmployeeES.Codeunit.al} | 2 +- .../CreateExpenseES.Codeunit.al | 51 ++++++ .../CreatePostedExpReportES.Codeunit.al | 168 ++++++++++++++++++ .../ES/CreateExpenseCountryDataES.Codeunit.al | 70 ++++++++ .../Country/ES/ESCountryData.Codeunit.al | 70 -------- .../Country/ES/ESExpCategories.Codeunit.al | 31 ---- .../Country/ES/ESExpRuleCondition.Codeunit.al | 26 --- .../Country/ES/ESExpRuleHeader.Codeunit.al | 29 --- .../Country/ES/ESExpSubCategories.Codeunit.al | 39 ---- .../Country/ES/ESExpense.Codeunit.al | 51 ------ .../Country/ES/ESPostedExpReport.Codeunit.al | 168 ------------------ .../ExpDemoDataSubscriberES.Codeunit.al} | 2 +- ...al => ExpenseGLAccountNamesES.Codeunit.al} | 2 +- .../Country/ExpenseAgentCountry.Enum.al | 22 +-- .../CreateExpGLAccountFR.Codeunit.al} | 2 +- .../CreateExpPostingGrpFR.Codeunit.al} | 18 +- .../UpdateEmpPostingGrpFR.Codeunit.al} | 6 +- .../CreateExpCategoriesFR.Codeunit.al | 31 ++++ .../CreateExpRuleConditionFR.Codeunit.al | 26 +++ .../CreateExpRuleHeaderFR.Codeunit.al | 29 +++ .../CreateExpSubCategoriesFR.Codeunit.al | 39 ++++ .../CreateExpenseFR.Codeunit.al} | 6 +- .../CreatePostedExpReportFR.Codeunit.al} | 10 +- .../FR/CreateExpenseCountryDataFR.Codeunit.al | 64 +++++++ ...al => ExpDemoDataSubscriberFR.Codeunit.al} | 2 +- .../Country/FR/FRCountryData.Codeunit.al | 64 ------- .../Country/FR/FRExpCategories.Codeunit.al | 31 ---- .../Country/FR/FRExpRuleCondition.Codeunit.al | 26 --- .../Country/FR/FRExpRuleHeader.Codeunit.al | 29 --- .../Country/FR/FRExpSubCategories.Codeunit.al | 39 ---- .../Country/FR/FRExpense.Codeunit.al | 51 ------ .../CreateExpGLAccountGB.Codeunit.al} | 2 +- .../CreateExpPostingGrpGB.Codeunit.al} | 18 +- .../UpdateEmpPostingGrpGB.Codeunit.al} | 6 +- .../CreateExpCategoriesGB.Codeunit.al | 31 ++++ .../CreateExpRuleConditionGB.Codeunit.al | 26 +++ .../CreateExpRuleHeaderGB.Codeunit.al | 29 +++ .../CreateExpSubCategoriesGB.Codeunit.al | 39 ++++ .../CreateExpenseGB.Codeunit.al | 51 ++++++ .../CreatePostedExpReportGB.Codeunit.al} | 14 +- .../GB/CreateExpenseCountryDataGB.Codeunit.al | 61 +++++++ ...al => ExpenseGLAccountNamesGB.Codeunit.al} | 2 +- .../Country/GB/GBCountryData.Codeunit.al | 61 ------- .../Country/GB/GBExpCategories.Codeunit.al | 31 ---- .../Country/GB/GBExpRuleCondition.Codeunit.al | 26 --- .../Country/GB/GBExpRuleHeader.Codeunit.al | 29 --- .../Country/GB/GBExpSubCategories.Codeunit.al | 39 ---- .../Country/GB/GBExpense.Codeunit.al | 51 ------ .../Country/GB/GBPostedExpReport.Codeunit.al | 168 ------------------ .../CreateExpGLAccountNZ.Codeunit.al} | 2 +- .../CreateExpPostingGrpNZ.Codeunit.al} | 2 +- .../UpdateEmpPostingGrpNZ.Codeunit.al} | 2 +- .../CreateExpCategoriesNZ.Codeunit.al | 31 ++++ .../CreateExpRuleConditionNZ.Codeunit.al | 26 +++ .../CreateExpRuleHeaderNZ.Codeunit.al | 29 +++ .../CreateExpSubCategoriesNZ.Codeunit.al | 39 ++++ .../CreateExpenseNZ.Codeunit.al | 51 ++++++ .../CreatePostedExpReportNZ.Codeunit.al} | 10 +- .../NZ/CreateExpenseCountryDataNZ.Codeunit.al | 61 +++++++ .../Country/NZ/NZCountryData.Codeunit.al | 61 ------- .../Country/NZ/NZExpCategories.Codeunit.al | 31 ---- .../Country/NZ/NZExpRuleCondition.Codeunit.al | 26 --- .../Country/NZ/NZExpRuleHeader.Codeunit.al | 29 --- .../Country/NZ/NZExpSubCategories.Codeunit.al | 39 ---- .../Country/NZ/NZExpense.Codeunit.al | 51 ------ .../CreateExpGLAccountUS.Codeunit.al} | 2 +- .../CreateExpPostingGrpUS.Codeunit.al} | 18 +- .../UpdateEmpPostingGrpUS.Codeunit.al | 32 ++++ .../CreateExpCategoriesUS.Codeunit.al | 31 ++++ .../CreateExpRuleConditionUS.Codeunit.al | 26 +++ .../CreateExpRuleHeaderUS.Codeunit.al | 29 +++ .../CreateExpSubCategoriesUS.Codeunit.al | 39 ++++ .../CreateExpenseUS.Codeunit.al | 51 ++++++ .../CreatePostedExpReportUS.Codeunit.al | 168 ++++++++++++++++++ .../US/CreateExpenseCountryDataUS.Codeunit.al | 61 +++++++ ...al => ExpenseGLAccountNamesUS.Codeunit.al} | 2 +- .../Country/US/USCountryData.Codeunit.al | 61 ------- .../Country/US/USExpCategories.Codeunit.al | 31 ---- .../Country/US/USExpRuleCondition.Codeunit.al | 26 --- .../Country/US/USExpRuleHeader.Codeunit.al | 29 --- .../Country/US/USExpSubCategories.Codeunit.al | 39 ---- .../Country/US/USExpense.Codeunit.al | 51 ------ .../Country/US/USPostedExpReport.Codeunit.al | 168 ------------------ .../Country/US/USUpdEmpPostingGrp.Codeunit.al | 32 ---- ...=> CreateExpenseCountryDataW1.Codeunit.al} | 2 +- 168 files changed, 2850 insertions(+), 2798 deletions(-) rename src/Apps/W1/ExpenseAgent/demo data/Country/AT/{ATExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountAT.Codeunit.al} (98%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AT/{ATExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpAT.Codeunit.al} (56%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AT/{ATUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpAT.Codeunit.al} (76%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AT/{ATExpCategories.Codeunit.al => 2.Master Data/CreateExpCategoriesAT.Codeunit.al} (67%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleConditionAT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleHeaderAT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpSubCategoriesAT.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{DE/DEExpense.Codeunit.al => AT/3. Transactions/CreateExpenseAT.Codeunit.al} (80%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/4. Historical/CreatePostedExpReportAT.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{ES/ESCurrencySwapSub.Codeunit.al => AT/ExpDemoDataSubscriberAT.Codeunit.al} (95%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AT/{ATGLAccountNames.Codeunit.al => ExpenseGLAccountNamesAT.Codeunit.al} (97%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AU/{AUExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountAU.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AU/{AUExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpAU.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AU/{AUUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpAU.Codeunit.al} (97%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{CA/CAExpCategories.Codeunit.al => AU/2.Master Data/CreateExpCategoriesAU.Codeunit.al} (74%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleConditionAU.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleHeaderAU.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{CA/CAExpSubCategories.Codeunit.al => AU/2.Master Data/CreateExpSubCategoriesAU.Codeunit.al} (78%) rename src/Apps/W1/ExpenseAgent/demo data/Country/AU/{AUExpense.Codeunit.al => 3. Transactions/CreateExpenseAU.Codeunit.al} (80%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{FR/FRPostedExpReport.Codeunit.al => AU/4. Historical/CreatePostedExpReportAU.Codeunit.al} (91%) delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/AU/CreateExpenseCountryDataAU.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/CA/{CAExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountCA.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/CA/{CAExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpCA.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/CA/{CAUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpCA.Codeunit.al} (97%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{DE/DEExpCategories.Codeunit.al => CA/2.Master Data/CreateExpCategoriesCA.Codeunit.al} (74%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleConditionCA.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleHeaderCA.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{AT/ATExpSubCategories.Codeunit.al => CA/2.Master Data/CreateExpSubCategoriesCA.Codeunit.al} (78%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/3. Transactions/CreateExpenseCA.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{AU/AUPostedExpReport.Codeunit.al => CA/4. Historical/CreatePostedExpReportCA.Codeunit.al} (91%) delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CA/CreateExpenseCountryDataCA.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/DE/{DEExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountDE.Codeunit.al} (98%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DE/{DEExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpDE.Codeunit.al} (54%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DE/{DEUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpDE.Codeunit.al} (73%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{DK/DKExpCategories.Codeunit.al => DE/2.Master Data/CreateExpCategoriesDE.Codeunit.al} (74%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleConditionDE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleHeaderDE.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/DE/{DEExpSubCategories.Codeunit.al => 2.Master Data/CreateExpSubCategoriesDE.Codeunit.al} (78%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{AT/ATExpense.Codeunit.al => DE/3. Transactions/CreateExpenseDE.Codeunit.al} (80%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{AT/ATPostedExpReport.Codeunit.al => DE/4. Historical/CreatePostedExpReportDE.Codeunit.al} (90%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{AT/ATCurrencySwapSub.Codeunit.al => DE/ExpDemoDataSubscriberDE.Codeunit.al} (95%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DE/{DEGLAccountNames.Codeunit.al => ExpenseGLAccountNamesDE.Codeunit.al} (98%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DK/{DKExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountDK.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DK/{DKExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpDK.Codeunit.al} (50%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DK/{DKUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al} (70%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{AU/AUExpCategories.Codeunit.al => DK/2.Master Data/CreateExpCategoriesDK.Codeunit.al} (74%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleConditionDK.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleHeaderDK.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{AU/AUExpSubCategories.Codeunit.al => DK/2.Master Data/CreateExpSubCategoriesDK.Codeunit.al} (78%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/3. Transactions/CreateExpenseDK.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/4. Historical/CreatePostedExpReportDK.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/DK/{DKCurrencySwapSub.Codeunit.al => ExpDemoDataSubscriberDK.Codeunit.al} (95%) rename src/Apps/W1/ExpenseAgent/demo data/Country/DK/{DKGLAccountNames.Codeunit.al => ExpenseGLAccountNamesDK.Codeunit.al} (98%) rename src/Apps/W1/ExpenseAgent/demo data/Country/ES/{ESExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountES.Codeunit.al} (90%) rename src/Apps/W1/ExpenseAgent/demo data/Country/ES/{ESExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpES.Codeunit.al} (60%) rename src/Apps/W1/ExpenseAgent/demo data/Country/ES/{ESUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpES.Codeunit.al} (71%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpCategoriesES.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleConditionES.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleHeaderES.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpSubCategoriesES.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/ES/{ESUpdEmployee.Codeunit.al => 2.Master Data/UpdateEmployeeES.Codeunit.al} (98%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/3. Transactions/CreateExpenseES.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/4. Historical/CreatePostedExpReportES.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{DE/DECurrencySwapSub.Codeunit.al => ES/ExpDemoDataSubscriberES.Codeunit.al} (95%) rename src/Apps/W1/ExpenseAgent/demo data/Country/ES/{ESGLAccountNames.Codeunit.al => ExpenseGLAccountNamesES.Codeunit.al} (96%) rename src/Apps/W1/ExpenseAgent/demo data/Country/FR/{FRExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountFR.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/FR/{FRExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpFR.Codeunit.al} (64%) rename src/Apps/W1/ExpenseAgent/demo data/Country/FR/{FRUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpFR.Codeunit.al} (78%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpCategoriesFR.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleConditionFR.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleHeaderFR.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpSubCategoriesFR.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{CA/CAExpense.Codeunit.al => FR/3. Transactions/CreateExpenseFR.Codeunit.al} (80%) rename src/Apps/W1/ExpenseAgent/demo data/Country/{NZ/NZPostedExpReport.Codeunit.al => FR/4. Historical/CreatePostedExpReportFR.Codeunit.al} (91%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/FR/{FRCurrencySwapSub.Codeunit.al => ExpDemoDataSubscriberFR.Codeunit.al} (95%) delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/GB/{GBExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountGB.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/GB/{GBExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpGB.Codeunit.al} (53%) rename src/Apps/W1/ExpenseAgent/demo data/Country/GB/{GBUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpGB.Codeunit.al} (84%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpCategoriesGB.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleConditionGB.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleHeaderGB.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpSubCategoriesGB.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/3. Transactions/CreateExpenseGB.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{DE/DEPostedExpReport.Codeunit.al => GB/4. Historical/CreatePostedExpReportGB.Codeunit.al} (90%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/CreateExpenseCountryDataGB.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/GB/{GBGLAccountNames.Codeunit.al => ExpenseGLAccountNamesGB.Codeunit.al} (98%) delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/NZ/{NZExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountNZ.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/NZ/{NZExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpNZ.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/NZ/{NZUpdEmpPostingGrp.Codeunit.al => 1.Setup Data/UpdateEmpPostingGrpNZ.Codeunit.al} (97%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpCategoriesNZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleConditionNZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleHeaderNZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpSubCategoriesNZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/3. Transactions/CreateExpenseNZ.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/{CA/CAPostedExpReport.Codeunit.al => NZ/4. Historical/CreatePostedExpReportNZ.Codeunit.al} (91%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/CreateExpenseCountryDataNZ.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/US/{USExpGLAccount.Codeunit.al => 1.Setup Data/CreateExpGLAccountUS.Codeunit.al} (99%) rename src/Apps/W1/ExpenseAgent/demo data/Country/US/{USExpPostingGrp.Codeunit.al => 1.Setup Data/CreateExpPostingGrpUS.Codeunit.al} (53%) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/UpdateEmpPostingGrpUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpCategoriesUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleConditionUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleHeaderUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpSubCategoriesUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/3. Transactions/CreateExpenseUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/4. Historical/CreatePostedExpReportUS.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/CreateExpenseCountryDataUS.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/US/{USGLAccountNames.Codeunit.al => ExpenseGLAccountNamesUS.Codeunit.al} (98%) delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al rename src/Apps/W1/ExpenseAgent/demo data/Country/W1/{W1CountryData.Codeunit.al => CreateExpenseCountryDataW1.Codeunit.al} (95%) diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al index 23caec182fb..05b2c49c9ff 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al @@ -101,6 +101,8 @@ codeunit 6973 "Create Expense Categories" AddPostingGroupSeed(TempPostingGroup, XEXPENSEMILEAGETxt, XExpenseMileageDescTxt, CreateExpenseGLAccount.ExpenseMileageRefundableDebitAccountNo()); AddPostingGroupSeed(TempPostingGroup, XEXPENSEMEALSTxt, XExpenseMealsDescTxt, CreateExpenseGLAccount.ExpenseMealsRefundableDebitAccountNo()); AddPostingGroupSeed(TempPostingGroup, XEXPENSEENTERTAINTxt, XExpenseEntertainDescTxt, CreateExpenseGLAccount.ExpenseEntertainRefundableDebitAccountNo()); + + OnAfterBuildPostingGroupSeeds(TempPostingGroup); end; /// @@ -134,7 +136,13 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary; Code: Code[20]; Description: Text[100]; RefundableDebitAccount: Code[20]) + var + IsHandled: Boolean; begin + OnBeforeAddPostingGroupSeed(Code, Description, RefundableDebitAccount, IsHandled); + if IsHandled then + exit; + TempPostingGroup.Init(); TempPostingGroup.Code := Code; TempPostingGroup.Description := Description; @@ -143,6 +151,7 @@ codeunit 6973 "Create Expense Categories" TempPostingGroup."Prepayment Credit Account" := CreateExpenseGLAccount.ExpensePrepaymentDebitAccountNo(); TempPostingGroup."Debit Rounding Account" := CreateExpenseGLAccount.ExpenseDebitRoundingAccountNo(); TempPostingGroup."Credit Rounding Account" := CreateExpenseGLAccount.ExpenseCreditRoundingAccountNo(); + OnBeforeInsertPostingGroupSeed(TempPostingGroup); TempPostingGroup.Insert(); end; @@ -230,6 +239,8 @@ codeunit 6973 "Create Expense Categories" AddCategorySeed(TempCategory, XSUBSCRIPTIONTxt, XProfessionalSubscriptionsTxt, XSubscriptionsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCARDTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" "); AddCategorySeed(TempCategory, XTIPSTxt, XTipsDescTxt, XTipsPostingTxt, XFOODBEVERAGETxt, XEXPENSEOTHERTxt, XCASHTxt, false, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::" "); AddCategorySeed(TempCategory, XTOLLSTxt, XTollRoadUsageFeeTxt, XTollsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCASHTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" "); + + OnAfterBuildCategorySeeds(TempCategory); end; /// @@ -344,6 +355,8 @@ codeunit 6973 "Create Expense Categories" // FINES AddSubcategorySeed(TempSubcategory, XFINESTxt, XFINESTxt, XFinesSubDescTxt, XFinesPostingTxt, true, false); + + OnAfterBuildSubcategorySeeds(TempSubcategory); end; internal procedure GetTRAVELTxt(): Code[20] @@ -603,7 +616,13 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddCategorySeed(var TempCategory: Record "Expense Category" temporary; Code: Code[20]; Description: Text[250]; PostingDescription: Text[100]; ExpenseGroupCode: Code[20]; PostingGroupCode: Code[20]; PaymentMethod: Code[10]; IsRefundable: Boolean; IsPrepayment: Boolean; AttachmentEnforcement: Enum "Expense Attachment Enforcement"; DetailRequired: Enum "Expense Detail Needed") + var + IsHandled: Boolean; begin + OnBeforeAddCategorySeed(Code, Description, PostingDescription, ExpenseGroupCode, PostingGroupCode, PaymentMethod, IsRefundable, IsPrepayment, AttachmentEnforcement, DetailRequired, IsHandled); + if IsHandled then + exit; + TempCategory.Init(); TempCategory.Code := Code; TempCategory.Description := Description; @@ -619,7 +638,13 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddSubcategorySeed(var TempSubcategory: Record "Expense Subcategory" temporary; SubcategoryCode: Code[20]; CategoryCode: Code[20]; Description: Text[250]; PostingDescription: Text[100]; Refundable: Boolean; DescriptionMandatory: Boolean) + var + IsHandled: Boolean; begin + OnBeforeAddSubcategorySeed(SubcategoryCode, CategoryCode, Description, PostingDescription, Refundable, DescriptionMandatory, IsHandled); + if IsHandled then + exit; + TempSubcategory.Init(); TempSubcategory."Expense Category Code" := CategoryCode; TempSubcategory.Code := SubcategoryCode; @@ -803,6 +828,8 @@ codeunit 6973 "Create Expense Categories" AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XGERMANYALLTxt, 'EUR', "Expense Justification"::" "); AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUKOTHERTxt, 'GBP', "Expense Justification"::" "); AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUSAOTHERTxt, 'USD', "Expense Justification"::" "); + + OnAfterBuildRuleSeeds(TempRuleHeader); end; /// @@ -823,6 +850,8 @@ codeunit 6973 "Create Expense Categories" AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XGERMANYALLTxt, "Expense Rule Condition Type"::"Daily Rate", 105); AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUKOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 115); AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUSAOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 120); + + OnAfterBuildRuleConditionSeeds(TempRuleCondition); end; /// @@ -904,19 +933,31 @@ codeunit 6973 "Create Expense Categories" end; internal procedure AddRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; CurrencyCode: Code[10]; JustificationRequired: Enum "Expense Justification") + var + IsHandled: Boolean; begin + OnBeforeAddRuleSeed(TempRuleHeader, CategoryCode, ExpenseLocationCode, CurrencyCode, JustificationRequired, IsHandled); + if IsHandled then + exit; + TempRuleHeader.Init(); TempRuleHeader."Expense Category Code" := CategoryCode; TempRuleHeader."Expense Location" := ExpenseLocationCode; TempRuleHeader."Currency Code" := CurrencyCode; TempRuleHeader."Justification Required" := JustificationRequired; + OnBeforeInsertRuleSeed(TempRuleHeader); TempRuleHeader.Insert(); end; internal procedure AddRuleConditionSeed(var TempRuleCondition: Record "Expense Rule Condition" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; ConditionType: Enum "Expense Rule Condition Type"; Value: Decimal) var NextLineNo: Integer; + IsHandled: Boolean; begin + OnBeforeAddRuleConditionSeed(TempRuleCondition, CategoryCode, ExpenseLocationCode, ConditionType, Value, IsHandled); + if IsHandled then + exit; + TempRuleCondition.Reset(); TempRuleCondition.SetRange("Expense Category Code", CategoryCode); TempRuleCondition.SetRange("Expense Location", ExpenseLocationCode); @@ -1252,7 +1293,13 @@ codeunit 6973 "Create Expense Categories" end; internal procedure UpdateEmployeePostingGroup(Code: Code[20]; ExpenseReportPayableAccount: Code[20]; ExpensePayableBankPaidAccount: Code[20]; ExpensePayableCardPaidAccount: Code[20]; ExpenseReportPrepaymentAccount: Code[20]) + var + IsHandled: Boolean; begin + OnBeforeUpdateEmployeePostingGroup(Code, ExpenseReportPayableAccount, ExpensePayableBankPaidAccount, ExpensePayableCardPaidAccount, ExpenseReportPrepaymentAccount, IsHandled); + if IsHandled then + exit; + if not EmployeePostingGroup.Get(Code) then exit; diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al index c457823998d..f9cf33b2c2a 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al @@ -50,7 +50,12 @@ codeunit 6971 "Create Expense GL Account" local procedure CreateGLAccount() var GLAccountIndent: Codeunit "G/L Account-Indent"; + IsHandled: Boolean; begin + OnBeforeCreateGLAccount(IsHandled); + if IsHandled then + exit; + InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpGLAccountAT.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpGLAccountAT.Codeunit.al index e34f38ddbad..a12c8308e38 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpGLAccountAT.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8325 "AT Exp. GL Account" +codeunit 8325 "Create Exp. GL Account AT" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpPostingGrpAT.Codeunit.al similarity index 56% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpPostingGrpAT.Codeunit.al index c32604d5ef7..e61576a8781 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpPostingGrpAT.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8326 "AT Exp. Posting Grp" +codeunit 8326 "Create Exp. Posting Grp AT" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -25,27 +25,27 @@ codeunit 8326 "AT Exp. Posting Grp" local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") var CreateGLAccount: Codeunit "Create G/L Account"; - ATGLAccountNames: Codeunit "AT GL Account Names"; + ExpenseGLAccountNamesAT: Codeunit "Expense GL Account Names AT"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.HospitalityDomesticDeductibleAmountName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.HospitalityDomesticDeductibleAmountName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.KilometerAllowanceName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.KilometerAllowanceName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.OtherName()), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.OtherName()), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); ExpensePerDiemI(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.MealExpensesDomesticName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.MealExpensesDomesticName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); ExpensePerDiemA(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.MealExpensesAbroadName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.MealExpensesAbroadName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.TransportationThirdPartiesName()), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.TransportationThirdPartiesName()), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.TransportationThirdPartiesName()), '', ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.TransportationThirdPartiesName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/UpdateEmpPostingGrpAT.Codeunit.al similarity index 76% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/UpdateEmpPostingGrpAT.Codeunit.al index 02d880a92dd..127e5c7d2e8 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/UpdateEmpPostingGrpAT.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; -codeunit 8327 "AT Upd. Emp. Posting Grp" +codeunit 8327 "Update Emp. Posting Grp AT" { InherentEntitlements = X; InherentPermissions = X; @@ -22,13 +22,13 @@ codeunit 8327 "AT Upd. Emp. Posting Grp" CreateGLAccount: Codeunit "Create G/L Account"; HRGLAccount: Codeunit "Create HR GL Account"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - ATExpGLAccount: Codeunit "AT Exp. GL Account"; - ATGLAccountNames: Codeunit "AT GL Account Names"; + CreateExpGLAccountAT: Codeunit "Create Exp. GL Account AT"; + ExpenseGLAccountNamesAT: Codeunit "Expense GL Account Names AT"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(HRGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), ATExpGLAccount.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(HRGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), CreateExpGLAccountAT.CompanyCreditCardsClearingAccount()); ContosoExpenseAgent.SetOverwriteData(false); end; } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpCategoriesAT.Codeunit.al similarity index 67% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpCategoriesAT.Codeunit.al index f4b508c2b8b..c716f7b2741 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpCategoriesAT.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8328 "AT Exp. Categories" +codeunit 8328 "Create Exp. Categories AT" { InherentEntitlements = X; InherentPermissions = X; @@ -14,10 +14,10 @@ codeunit 8328 "AT Exp. Categories" CreateExpenseGroup: Codeunit "Create Expense Group"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - ATExpPostingGrp: Codeunit "AT Exp. Posting Grp"; + CreateExpPostingGrpAT: Codeunit "Create Exp. Posting Grp AT"; begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiemI(), PerDiemByAssignedPolicyLbl, PerDiemIByAssignedPolicyPostingLbl, ATExpPostingGrp.ExpensePerDiemI(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); - ContosoExpenseAgent.InsertExpenseCategory(PerDiemA(), PerDiemByAssignedPolicyLbl, PerDiemAByAssignedPolicyPostingLbl, ATExpPostingGrp.ExpensePerDiemA(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiemI(), PerDiemByAssignedPolicyLbl, PerDiemIByAssignedPolicyPostingLbl, CreateExpPostingGrpAT.ExpensePerDiemI(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiemA(), PerDiemByAssignedPolicyLbl, PerDiemAByAssignedPolicyPostingLbl, CreateExpPostingGrpAT.ExpensePerDiemA(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleConditionAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleConditionAT.Codeunit.al new file mode 100644 index 00000000000..0ed65438e9a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleConditionAT.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8331 "Create Exp. Rule Condition AT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesAT: Codeunit "Create Exp. Categories AT"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemA(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleHeaderAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleHeaderAT.Codeunit.al new file mode 100644 index 00000000000..1628e30bcff --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpRuleHeaderAT.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8330 "Create Exp. Rule Header AT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesAT: Codeunit "Create Exp. Categories AT"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemA(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpSubCategoriesAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpSubCategoriesAT.Codeunit.al new file mode 100644 index 00000000000..a229835c6f2 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpSubCategoriesAT.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8329 "Create Exp. SubCategories AT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesAT: Codeunit "Create Exp. Categories AT"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesAT.PerDiemA(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesAT.PerDiemI(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/3. Transactions/CreateExpenseAT.Codeunit.al similarity index 80% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/3. Transactions/CreateExpenseAT.Codeunit.al index 99c1b2547a3..c55719a1920 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpense.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/3. Transactions/CreateExpenseAT.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoTool.Helpers; -codeunit 8320 "DE Expense" +codeunit 8332 "Create Expense AT" { InherentEntitlements = X; InherentPermissions = X; @@ -23,7 +23,7 @@ codeunit 8320 "DE Expense" ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpenseLocation: Codeunit "Create Expense Location"; begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DEExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); @@ -33,7 +33,7 @@ codeunit 8320 "DE Expense" var ContosoUtility: Codeunit "Contoso Utilities"; CreateExpenseUser: Codeunit "Create Expense User"; - DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpCategoriesAT: Codeunit "Create Exp. Categories AT"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/4. Historical/CreatePostedExpReportAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/4. Historical/CreatePostedExpReportAT.Codeunit.al new file mode 100644 index 00000000000..b5b92b7fc54 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/4. Historical/CreatePostedExpReportAT.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8335 "Create Posted Exp. Report AT" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccountNamesAT: Codeunit "Expense GL Account Names AT"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SalesRevenuesResourcesExportName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesAT: Codeunit "Create Exp. Categories AT"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesAT.PerDiemI(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesAT.PerDiemA(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al deleted file mode 100644 index 1155ae8f275..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCountryData.Codeunit.al +++ /dev/null @@ -1,64 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8323 "AT Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - ATExpGLAccount: Codeunit "AT Exp. GL Account"; - ATExpPostingGrp: Codeunit "AT Exp. Posting Grp"; - begin - BindSubscription(ATExpGLAccount); - BindSubscription(ATExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"AT Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"AT Exp. Posting Grp"); - - UnbindSubscription(ATExpPostingGrp); - UnbindSubscription(ATExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"AT Exp. Categories"); - Codeunit.Run(Codeunit::"AT Exp. SubCategories"); - Codeunit.Run(Codeunit::"AT Exp. Rule Header"); - Codeunit.Run(Codeunit::"AT Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"AT Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - ATCurrencySwapSub: Codeunit "AT Currency Swap Sub"; - ATPostedExpReport: Codeunit "AT Posted Exp. Report"; - begin - BindSubscription(ATCurrencySwapSub); - BindSubscription(ATPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"AT Posted Exp. Report"); - - UnbindSubscription(ATPostedExpReport); - UnbindSubscription(ATCurrencySwapSub); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al deleted file mode 100644 index 84496f32359..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8331 "AT Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ATExpCategories: Codeunit "AT Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemA(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(ATExpCategories.PerDiemI(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al deleted file mode 100644 index 09dfcbe87d7..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8330 "AT Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - ATExpCategories: Codeunit "AT Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemA(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ATExpCategories.PerDiemI(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al new file mode 100644 index 00000000000..99e401c773a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8323 "Create Expense Country Data AT" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountAT: Codeunit "Create Exp. GL Account AT"; + CreateExpPostingGrpAT: Codeunit "Create Exp. Posting Grp AT"; + begin + BindSubscription(CreateExpGLAccountAT); + BindSubscription(CreateExpPostingGrpAT); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp AT"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp AT"); + + UnbindSubscription(CreateExpPostingGrpAT); + UnbindSubscription(CreateExpGLAccountAT); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories AT"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories AT"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header AT"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition AT"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense AT"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberAT: Codeunit "Exp. Demo Data Subscriber AT"; + CreatePostedExpReportAT: Codeunit "Create Posted Exp. Report AT"; + begin + BindSubscription(ExpDemoDataSubscriberAT); + BindSubscription(CreatePostedExpReportAT); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report AT"); + + UnbindSubscription(CreatePostedExpReportAT); + UnbindSubscription(ExpDemoDataSubscriberAT); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpDemoDataSubscriberAT.Codeunit.al similarity index 95% rename from src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpDemoDataSubscriberAT.Codeunit.al index 2b698862020..f7c0422e771 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCurrencySwapSub.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpDemoDataSubscriberAT.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8287 "ES Currency Swap Sub" +codeunit 8336 "Exp. Demo Data Subscriber AT" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpenseGLAccountNamesAT.Codeunit.al similarity index 97% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpenseGLAccountNamesAT.Codeunit.al index 75baf158068..1687bfbee52 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATGLAccountNames.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpenseGLAccountNamesAT.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8324 "AT GL Account Names" +codeunit 8324 "Expense GL Account Names AT" { Access = Internal; InherentEntitlements = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpGLAccountAU.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpGLAccountAU.Codeunit.al index 3308784413b..4173e491eeb 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpGLAccountAU.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8266 "AU Exp. GL Account" +codeunit 8266 "Create Exp. GL Account AU" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpPostingGrpAU.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpPostingGrpAU.Codeunit.al index fbd87d448d7..0bffe6d8273 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpPostingGrpAU.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8267 "AU Exp. Posting Grp" +codeunit 8267 "Create Exp. Posting Grp AU" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/UpdateEmpPostingGrpAU.Codeunit.al similarity index 97% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/UpdateEmpPostingGrpAU.Codeunit.al index 4e41480d7c6..cff32f1a012 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/UpdateEmpPostingGrpAU.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; -codeunit 8268 "AU Upd. Emp. Posting Grp" +codeunit 8268 "Update Emp. Posting Grp AU" { InherentEntitlements = X; InherentPermissions = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpCategoriesAU.Codeunit.al similarity index 74% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpCategoriesAU.Codeunit.al index 7509f594143..1d05039447e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpCategoriesAU.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8249 "CA Exp. Categories" +codeunit 8269 "Create Exp. Categories AU" { InherentEntitlements = X; InherentPermissions = X; @@ -14,9 +14,9 @@ codeunit 8249 "CA Exp. Categories" CreateExpenseGroup: Codeunit "Create Expense Group"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CAExpPostingGrp: Codeunit "CA Exp. Posting Grp"; + CreateExpPostingGrpAU: Codeunit "Create Exp. Posting Grp AU"; begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CAExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpAU.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleConditionAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleConditionAU.Codeunit.al new file mode 100644 index 00000000000..3dfedd67428 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleConditionAU.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8272 "Create Exp. Rule Condition AU" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleHeaderAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleHeaderAU.Codeunit.al new file mode 100644 index 00000000000..f7175fe5798 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpRuleHeaderAU.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8271 "Create Exp. Rule Header AU" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpSubCategoriesAU.Codeunit.al similarity index 78% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpSubCategoriesAU.Codeunit.al index 3cea8233897..a7629994e10 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpSubCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpSubCategoriesAU.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8250 "CA Exp. SubCategories" +codeunit 8270 "Create Exp. SubCategories AU" { InherentEntitlements = X; InherentPermissions = X; @@ -12,11 +12,11 @@ codeunit 8250 "CA Exp. SubCategories" trigger OnRun() var ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; begin // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CAExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CAExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesAU.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesAU.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/3. Transactions/CreateExpenseAU.Codeunit.al similarity index 80% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/3. Transactions/CreateExpenseAU.Codeunit.al index da9c5ebe688..9f3b595faae 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpense.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/3. Transactions/CreateExpenseAU.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoTool.Helpers; -codeunit 8273 "AU Expense" +codeunit 8273 "Create Expense AU" { InherentEntitlements = X; InherentPermissions = X; @@ -23,7 +23,7 @@ codeunit 8273 "AU Expense" ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpenseLocation: Codeunit "Create Expense Location"; begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), AUExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); @@ -33,7 +33,7 @@ codeunit 8273 "AU Expense" var ContosoUtility: Codeunit "Contoso Utilities"; CreateExpenseUser: Codeunit "Create Expense User"; - AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/4. Historical/CreatePostedExpReportAU.Codeunit.al similarity index 91% rename from src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/AU/4. Historical/CreatePostedExpReportAU.Codeunit.al index ff70818d5db..645d832043e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRPostedExpReport.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/4. Historical/CreatePostedExpReportAU.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; using Microsoft.DemoTool.Helpers; -codeunit 8309 "FR Posted Exp. Report" +codeunit 8274 "Create Posted Exp. Report AU" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -50,12 +50,12 @@ codeunit 8309 "FR Posted Exp. Report" CreateExpenseLocation: Codeunit "Create Expense Location"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpCategories: Codeunit "Create Expense Categories DM"; - FRExpCategories: Codeunit "FR Exp. Categories"; + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; begin ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), FRExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); @@ -89,11 +89,11 @@ codeunit 8309 "FR Posted Exp. Report" ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), FRExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), FRExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesAU.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al deleted file mode 100644 index 6be231090ed..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUCountryData.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8265 "AU Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - AUExpGLAccount: Codeunit "AU Exp. GL Account"; - AUExpPostingGrp: Codeunit "AU Exp. Posting Grp"; - begin - BindSubscription(AUExpGLAccount); - BindSubscription(AUExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"AU Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"AU Exp. Posting Grp"); - - UnbindSubscription(AUExpPostingGrp); - UnbindSubscription(AUExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"AU Exp. Categories"); - Codeunit.Run(Codeunit::"AU Exp. SubCategories"); - Codeunit.Run(Codeunit::"AU Exp. Rule Header"); - Codeunit.Run(Codeunit::"AU Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"AU Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - AUPostedExpReport: Codeunit "AU Posted Exp. Report"; - begin - BindSubscription(AUPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"AU Posted Exp. Report"); - - UnbindSubscription(AUPostedExpReport); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al deleted file mode 100644 index f7e977cc3b1..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8272 "AU Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - AUExpCategories: Codeunit "AU Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(AUExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al deleted file mode 100644 index 1539a091850..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8271 "AU Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - AUExpCategories: Codeunit "AU Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(AUExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/CreateExpenseCountryDataAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/CreateExpenseCountryDataAU.Codeunit.al new file mode 100644 index 00000000000..ca0d071a503 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/CreateExpenseCountryDataAU.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8265 "Create Expense Country Data AU" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountAU: Codeunit "Create Exp. GL Account AU"; + CreateExpPostingGrpAU: Codeunit "Create Exp. Posting Grp AU"; + begin + BindSubscription(CreateExpGLAccountAU); + BindSubscription(CreateExpPostingGrpAU); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp AU"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp AU"); + + UnbindSubscription(CreateExpPostingGrpAU); + UnbindSubscription(CreateExpGLAccountAU); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories AU"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories AU"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header AU"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition AU"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense AU"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportAU: Codeunit "Create Posted Exp. Report AU"; + begin + BindSubscription(CreatePostedExpReportAU); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report AU"); + + UnbindSubscription(CreatePostedExpReportAU); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpGLAccountCA.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpGLAccountCA.Codeunit.al index a2019bf208b..7a8e10537bd 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpGLAccountCA.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8246 "CA Exp. GL Account" +codeunit 8246 "Create Exp. GL Account CA" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpPostingGrpCA.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpPostingGrpCA.Codeunit.al index 09923dee6c9..ccfe241dd47 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpPostingGrpCA.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8247 "CA Exp. Posting Grp" +codeunit 8247 "Create Exp. Posting Grp CA" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/UpdateEmpPostingGrpCA.Codeunit.al similarity index 97% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/UpdateEmpPostingGrpCA.Codeunit.al index 68f4f3b3f3d..7d97d2851bc 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/UpdateEmpPostingGrpCA.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; -codeunit 8248 "CA Upd. Emp. Posting Grp" +codeunit 8248 "Update Emp. Posting Grp CA" { InherentEntitlements = X; InherentPermissions = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpCategoriesCA.Codeunit.al similarity index 74% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpCategoriesCA.Codeunit.al index 0c718c48e85..850315632e1 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpCategoriesCA.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8316 "DE Exp. Categories" +codeunit 8249 "Create Exp. Categories CA" { InherentEntitlements = X; InherentPermissions = X; @@ -14,9 +14,9 @@ codeunit 8316 "DE Exp. Categories" CreateExpenseGroup: Codeunit "Create Expense Group"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - DEExpPostingGrp: Codeunit "DE Exp. Posting Grp"; + CreateExpPostingGrpCA: Codeunit "Create Exp. Posting Grp CA"; begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, DEExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpCA.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleConditionCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleConditionCA.Codeunit.al new file mode 100644 index 00000000000..2385cb01e41 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleConditionCA.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8252 "Create Exp. Rule Condition CA" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesCA: Codeunit "Create Exp. Categories CA"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleHeaderCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleHeaderCA.Codeunit.al new file mode 100644 index 00000000000..29f6ed2e929 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpRuleHeaderCA.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8251 "Create Exp. Rule Header CA" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesCA: Codeunit "Create Exp. Categories CA"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpSubCategoriesCA.Codeunit.al similarity index 78% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpSubCategoriesCA.Codeunit.al index 5217ff5c5a4..e527934fa93 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpSubCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpSubCategoriesCA.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8329 "AT Exp. SubCategories" +codeunit 8250 "Create Exp. SubCategories CA" { InherentEntitlements = X; InherentPermissions = X; @@ -12,11 +12,11 @@ codeunit 8329 "AT Exp. SubCategories" trigger OnRun() var ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpCategoriesCA: Codeunit "Create Exp. Categories CA"; begin // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), ATExpCategories.PerDiemA(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), ATExpCategories.PerDiemI(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesCA.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesCA.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/3. Transactions/CreateExpenseCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/3. Transactions/CreateExpenseCA.Codeunit.al new file mode 100644 index 00000000000..3d21d7768a7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/3. Transactions/CreateExpenseCA.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8253 "Create Expense CA" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesCA: Codeunit "Create Exp. Categories CA"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/4. Historical/CreatePostedExpReportCA.Codeunit.al similarity index 91% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/CA/4. Historical/CreatePostedExpReportCA.Codeunit.al index 11861cb44c8..16f16fe66f1 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUPostedExpReport.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/4. Historical/CreatePostedExpReportCA.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; using Microsoft.DemoTool.Helpers; -codeunit 8274 "AU Posted Exp. Report" +codeunit 8254 "Create Posted Exp. Report CA" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -50,12 +50,12 @@ codeunit 8274 "AU Posted Exp. Report" CreateExpenseLocation: Codeunit "Create Expense Location"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpCategories: Codeunit "Create Expense Categories DM"; - AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpCategoriesCA: Codeunit "Create Exp. Categories CA"; CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; begin ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), AUExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); @@ -89,11 +89,11 @@ codeunit 8274 "AU Posted Exp. Report" ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), AUExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), AUExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCA.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al deleted file mode 100644 index 77bda558d1d..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CACountryData.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8245 "CA Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - CAExpGLAccount: Codeunit "CA Exp. GL Account"; - CAExpPostingGrp: Codeunit "CA Exp. Posting Grp"; - begin - BindSubscription(CAExpGLAccount); - BindSubscription(CAExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"CA Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"CA Exp. Posting Grp"); - - UnbindSubscription(CAExpPostingGrp); - UnbindSubscription(CAExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"CA Exp. Categories"); - Codeunit.Run(Codeunit::"CA Exp. SubCategories"); - Codeunit.Run(Codeunit::"CA Exp. Rule Header"); - Codeunit.Run(Codeunit::"CA Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"CA Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - CAPostedExpReport: Codeunit "CA Posted Exp. Report"; - begin - BindSubscription(CAPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"CA Posted Exp. Report"); - - UnbindSubscription(CAPostedExpReport); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al deleted file mode 100644 index a0148255636..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8252 "CA Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CAExpCategories: Codeunit "CA Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(CAExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al deleted file mode 100644 index 8161f920459..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8251 "CA Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - CAExpCategories: Codeunit "CA Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(CAExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CreateExpenseCountryDataCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CreateExpenseCountryDataCA.Codeunit.al new file mode 100644 index 00000000000..f4853e804ca --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CreateExpenseCountryDataCA.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8245 "Create Expense Country Data CA" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountCA: Codeunit "Create Exp. GL Account CA"; + CreateExpPostingGrpCA: Codeunit "Create Exp. Posting Grp CA"; + begin + BindSubscription(CreateExpGLAccountCA); + BindSubscription(CreateExpPostingGrpCA); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp CA"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp CA"); + + UnbindSubscription(CreateExpPostingGrpCA); + UnbindSubscription(CreateExpGLAccountCA); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories CA"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories CA"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header CA"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition CA"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense CA"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportCA: Codeunit "Create Posted Exp. Report CA"; + begin + BindSubscription(CreatePostedExpReportCA); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report CA"); + + UnbindSubscription(CreatePostedExpReportCA); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpGLAccountDE.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpGLAccountDE.Codeunit.al index add2d151b54..514fb378745 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpGLAccountDE.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8313 "DE Exp. GL Account" +codeunit 8313 "Create Exp. GL Account DE" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpPostingGrpDE.Codeunit.al similarity index 54% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpPostingGrpDE.Codeunit.al index 1d0e86e0dd1..7f23862c43f 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpPostingGrpDE.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8314 "DE Exp. Posting Grp" +codeunit 8314 "Create Exp. Posting Grp DE" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -21,25 +21,25 @@ codeunit 8314 "DE Exp. Posting Grp" [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") var - DEGLAccountNames: Codeunit "DE GL Account Names"; + ExpenseGLAccountNamesDE: Codeunit "Expense GL Account Names DE"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.BusinessEntertainingdeductibleName()), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.BusinessEntertainingdeductibleName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.BoardandlodgingName()), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.BoardandlodgingName()), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.MiscexternalexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.MiscexternalexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); ExpensePerDiem(): - ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.OthertravelexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.RentalvehiclesName()), '', ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SalesInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.RentalvehiclesName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/UpdateEmpPostingGrpDE.Codeunit.al similarity index 73% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/UpdateEmpPostingGrpDE.Codeunit.al index 7d807dc1436..0601ff5d43c 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/UpdateEmpPostingGrpDE.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.HumanResources; -codeunit 8315 "DE Upd. Emp. Posting Grp" +codeunit 8315 "Update Emp. Posting Grp DE" { InherentEntitlements = X; InherentPermissions = X; @@ -19,14 +19,14 @@ codeunit 8315 "DE Upd. Emp. Posting Grp" local procedure UpdateEmployeePostingGroup() var HRGLAccount: Codeunit "Create HR GL Account"; - DEGLAccountNames: Codeunit "DE GL Account Names"; + ExpenseGLAccountNamesDE: Codeunit "Expense GL Account Names DE"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - DEExpGLAccount: Codeunit "DE Exp. GL Account"; + CreateExpGLAccountDE: Codeunit "Create Exp. GL Account DE"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(HRGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.BusinessaccountOperatingDomesticName()), DEExpGLAccount.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(HRGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.BusinessaccountOperatingDomesticName()), CreateExpGLAccountDE.CompanyCreditCardsClearingAccount()); ContosoExpenseAgent.SetOverwriteData(false); end; } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpCategoriesDE.Codeunit.al similarity index 74% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpCategoriesDE.Codeunit.al index 7daebfd0570..cf1e75e4cbc 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpCategoriesDE.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8293 "DK Exp. Categories" +codeunit 8316 "Create Exp. Categories DE" { InherentEntitlements = X; InherentPermissions = X; @@ -14,9 +14,9 @@ codeunit 8293 "DK Exp. Categories" CreateExpenseGroup: Codeunit "Create Expense Group"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - DKExpPostingGrp: Codeunit "DK Exp. Posting Grp"; + CreateExpPostingGrpDE: Codeunit "Create Exp. Posting Grp DE"; begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, DKExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpDE.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleConditionDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleConditionDE.Codeunit.al new file mode 100644 index 00000000000..712bb27c29a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleConditionDE.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8319 "Create Exp. Rule Condition DE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleHeaderDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleHeaderDE.Codeunit.al new file mode 100644 index 00000000000..0d8aeef8b1b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpRuleHeaderDE.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8318 "Create Exp. Rule Header DE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpSubCategoriesDE.Codeunit.al similarity index 78% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpSubCategoriesDE.Codeunit.al index 03d3e292967..fb627a95033 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpSubCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpSubCategoriesDE.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8317 "DE Exp. SubCategories" +codeunit 8317 "Create Exp. SubCategories DE" { InherentEntitlements = X; InherentPermissions = X; @@ -12,11 +12,11 @@ codeunit 8317 "DE Exp. SubCategories" trigger OnRun() var ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; begin // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), DEExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), DEExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesDE.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesDE.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/3. Transactions/CreateExpenseDE.Codeunit.al similarity index 80% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/3. Transactions/CreateExpenseDE.Codeunit.al index 449b8feaf69..363f2b3250a 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATExpense.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/3. Transactions/CreateExpenseDE.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoTool.Helpers; -codeunit 8332 "AT Expense" +codeunit 8320 "Create Expense DE" { InherentEntitlements = X; InherentPermissions = X; @@ -23,7 +23,7 @@ codeunit 8332 "AT Expense" ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpenseLocation: Codeunit "Create Expense Location"; begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ATExpCategories.PerDiemI(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); @@ -33,7 +33,7 @@ codeunit 8332 "AT Expense" var ContosoUtility: Codeunit "Contoso Utilities"; CreateExpenseUser: Codeunit "Create Expense User"; - ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/4. Historical/CreatePostedExpReportDE.Codeunit.al similarity index 90% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/4. Historical/CreatePostedExpReportDE.Codeunit.al index d85e3e23b3b..851b911683e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATPostedExpReport.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/4. Historical/CreatePostedExpReportDE.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; using Microsoft.DemoTool.Helpers; -codeunit 8335 "AT Posted Exp. Report" +codeunit 8321 "Create Posted Exp. Report DE" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -33,10 +33,10 @@ codeunit 8335 "AT Posted Exp. Report" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) var - ATGLAccountNames: Codeunit "AT GL Account Names"; + ExpenseGLAccountNamesDE: Codeunit "Expense GL Account Names DE"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; begin - AccountNo := ExpenseGLAccount.FindGLAccountByName(ATGLAccountNames.SalesRevenuesResourcesExportName()); + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SaleofResourcesName()); end; local procedure CreateExpenseReportToPost() @@ -50,12 +50,12 @@ codeunit 8335 "AT Posted Exp. Report" CreateExpenseLocation: Codeunit "Create Expense Location"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpCategories: Codeunit "Create Expense Categories DM"; - ATExpCategories: Codeunit "AT Exp. Categories"; + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; begin ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), ATExpCategories.PerDiemI(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); @@ -89,11 +89,11 @@ codeunit 8335 "AT Posted Exp. Report" ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ATExpCategories.PerDiemI(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ATExpCategories.PerDiemA(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesDE.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al new file mode 100644 index 00000000000..d30fea8384a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8311 "Create Expense Country Data DE" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountDE: Codeunit "Create Exp. GL Account DE"; + CreateExpPostingGrpDE: Codeunit "Create Exp. Posting Grp DE"; + begin + BindSubscription(CreateExpGLAccountDE); + BindSubscription(CreateExpPostingGrpDE); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp DE"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp DE"); + + UnbindSubscription(CreateExpPostingGrpDE); + UnbindSubscription(CreateExpGLAccountDE); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories DE"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories DE"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header DE"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition DE"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense DE"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberDE: Codeunit "Exp. Demo Data Subscriber DE"; + CreatePostedExpReportDE: Codeunit "Create Posted Exp. Report DE"; + begin + BindSubscription(ExpDemoDataSubscriberDE); + BindSubscription(CreatePostedExpReportDE); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report DE"); + + UnbindSubscription(CreatePostedExpReportDE); + UnbindSubscription(ExpDemoDataSubscriberDE); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al deleted file mode 100644 index cad89122b34..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECountryData.Codeunit.al +++ /dev/null @@ -1,64 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8311 "DE Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - DEExpGLAccount: Codeunit "DE Exp. GL Account"; - DEExpPostingGrp: Codeunit "DE Exp. Posting Grp"; - begin - BindSubscription(DEExpGLAccount); - BindSubscription(DEExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"DE Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"DE Exp. Posting Grp"); - - UnbindSubscription(DEExpPostingGrp); - UnbindSubscription(DEExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"DE Exp. Categories"); - Codeunit.Run(Codeunit::"DE Exp. SubCategories"); - Codeunit.Run(Codeunit::"DE Exp. Rule Header"); - Codeunit.Run(Codeunit::"DE Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"DE Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - DECurrencySwapSub: Codeunit "DE Currency Swap Sub"; - DEPostedExpReport: Codeunit "DE Posted Exp. Report"; - begin - BindSubscription(DECurrencySwapSub); - BindSubscription(DEPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"DE Posted Exp. Report"); - - UnbindSubscription(DEPostedExpReport); - UnbindSubscription(DECurrencySwapSub); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al deleted file mode 100644 index 2468e6693c0..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8319 "DE Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - DEExpCategories: Codeunit "DE Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(DEExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al deleted file mode 100644 index 7af023f38f8..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8318 "DE Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - DEExpCategories: Codeunit "DE Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DEExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpDemoDataSubscriberDE.Codeunit.al similarity index 95% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpDemoDataSubscriberDE.Codeunit.al index 18889b92e61..50f1e7b853b 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ATCurrencySwapSub.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpDemoDataSubscriberDE.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8336 "AT Currency Swap Sub" +codeunit 8322 "Exp. Demo Data Subscriber DE" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpenseGLAccountNamesDE.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpenseGLAccountNamesDE.Codeunit.al index c5badd3457e..875e20a3c88 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEGLAccountNames.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpenseGLAccountNamesDE.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8312 "DE GL Account Names" +codeunit 8312 "Expense GL Account Names DE" { Access = Internal; InherentEntitlements = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpGLAccountDK.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpGLAccountDK.Codeunit.al index a12d64bf42b..cf75529a079 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpGLAccountDK.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8290 "DK Exp. GL Account" +codeunit 8290 "Create Exp. GL Account DK" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpPostingGrpDK.Codeunit.al similarity index 50% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpPostingGrpDK.Codeunit.al index 239a998e5fb..636df9f2a0a 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpPostingGrpDK.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8291 "DK Exp. Posting Grp" +codeunit 8291 "Create Exp. Posting Grp DK" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -21,26 +21,26 @@ codeunit 8291 "DK Exp. Posting Grp" [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") var - DKGLAccountNames: Codeunit "DK GL Account Names"; + ExpenseGLAccountNamesDK: Codeunit "Expense GL Account Names DK"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - DKExpGLAccount: Codeunit "DK Exp. GL Account"; + CreateExpGLAccountDK: Codeunit "Create Exp. GL Account DK"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.EntwinetobaccospiritsName()), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.EntwinetobaccospiritsName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.RestaurantdiningName()), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.RestaurantdiningName()), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.MileagerateName()), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.MileagerateName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, DKExpGLAccount.OtherExpenses(), DKExpGLAccount.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, CreateExpGLAccountDK.OtherExpenses(), CreateExpGLAccountDK.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); ExpensePerDiem(): - ValidateRecordFields(Rec, DKExpGLAccount.TravelAllowancesPerDiem(), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, CreateExpGLAccountDK.TravelAllowancesPerDiem(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.TravelingtradefairsetcName()), DKExpGLAccount.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.TravelingtradefairsetcName()), CreateExpGLAccountDK.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, DKExpGLAccount.RentalCarExpenses(), '', ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.CentdiscrepanciesName())); + ValidateRecordFields(Rec, CreateExpGLAccountDK.RentalCarExpenses(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al similarity index 70% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al index 06a0528020e..929ca38a577 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al @@ -5,7 +5,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.HumanResources; -codeunit 8292 "DK Upd. Emp. Posting Grp" +codeunit 8292 "Update Emp. Posting Grp DK" { InherentEntitlements = X; InherentPermissions = X; @@ -18,13 +18,13 @@ codeunit 8292 "DK Upd. Emp. Posting Grp" local procedure UpdateEmployeePostingGroup() var ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - DKExpGLAccount: Codeunit "DK Exp. GL Account"; - DKGLAccountNames: Codeunit "DK GL Account Names"; + CreateExpGLAccountDK: Codeunit "Create Exp. GL Account DK"; + ExpenseGLAccountNamesDK: Codeunit "Expense GL Account Names DK"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.AccountsPayablePostingName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.BankName()), DKExpGLAccount.CompanyCreditCards()); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.AccountsPayablePostingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.BankName()), CreateExpGLAccountDK.CompanyCreditCards()); ContosoExpenseAgent.SetOverwriteData(false); end; } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpCategoriesDK.Codeunit.al similarity index 74% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpCategoriesDK.Codeunit.al index e70cdbe067d..e7e95138669 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpCategoriesDK.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8269 "AU Exp. Categories" +codeunit 8293 "Create Exp. Categories DK" { InherentEntitlements = X; InherentPermissions = X; @@ -14,9 +14,9 @@ codeunit 8269 "AU Exp. Categories" CreateExpenseGroup: Codeunit "Create Expense Group"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - AUExpPostingGrp: Codeunit "AU Exp. Posting Grp"; + CreateExpPostingGrpDK: Codeunit "Create Exp. Posting Grp DK"; begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, AUExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpDK.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleConditionDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleConditionDK.Codeunit.al new file mode 100644 index 00000000000..f9aee90b49f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleConditionDK.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8296 "Create Exp. Rule Condition DK" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesDK: Codeunit "Create Exp. Categories DK"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleHeaderDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleHeaderDK.Codeunit.al new file mode 100644 index 00000000000..0ed2b293e22 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpRuleHeaderDK.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8295 "Create Exp. Rule Header DK" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesDK: Codeunit "Create Exp. Categories DK"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpSubCategoriesDK.Codeunit.al similarity index 78% rename from src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpSubCategoriesDK.Codeunit.al index a237c36552f..d8d1a6e0afb 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AU/AUExpSubCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpSubCategoriesDK.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8270 "AU Exp. SubCategories" +codeunit 8294 "Create Exp. SubCategories DK" { InherentEntitlements = X; InherentPermissions = X; @@ -12,11 +12,11 @@ codeunit 8270 "AU Exp. SubCategories" trigger OnRun() var ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - AUExpCategories: Codeunit "AU Exp. Categories"; + CreateExpCategoriesDK: Codeunit "Create Exp. Categories DK"; begin // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), AUExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), AUExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesDK.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesDK.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); end; var diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/3. Transactions/CreateExpenseDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/3. Transactions/CreateExpenseDK.Codeunit.al new file mode 100644 index 00000000000..96508c84020 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/3. Transactions/CreateExpenseDK.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8297 "Create Expense DK" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesDK: Codeunit "Create Exp. Categories DK"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/4. Historical/CreatePostedExpReportDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/4. Historical/CreatePostedExpReportDK.Codeunit.al new file mode 100644 index 00000000000..a6ea98b74fb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/4. Historical/CreatePostedExpReportDK.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8298 "Create Posted Exp. Report DK" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccountNamesDK: Codeunit "Expense GL Account Names DK"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.DomesticsalesofgoodsandservicesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesDK: Codeunit "Create Exp. Categories DK"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesDK.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al new file mode 100644 index 00000000000..033c1fe637a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8288 "Create Expense Country Data DK" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountDK: Codeunit "Create Exp. GL Account DK"; + CreateExpPostingGrpDK: Codeunit "Create Exp. Posting Grp DK"; + begin + BindSubscription(CreateExpGLAccountDK); + BindSubscription(CreateExpPostingGrpDK); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp DK"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp DK"); + + UnbindSubscription(CreateExpPostingGrpDK); + UnbindSubscription(CreateExpGLAccountDK); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories DK"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories DK"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header DK"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition DK"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense DK"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberDK: Codeunit "Exp. Demo Data Subscriber DK"; + CreatePostedExpReportDK: Codeunit "Create Posted Exp. Report DK"; + begin + BindSubscription(ExpDemoDataSubscriberDK); + BindSubscription(CreatePostedExpReportDK); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report DK"); + + UnbindSubscription(CreatePostedExpReportDK); + UnbindSubscription(ExpDemoDataSubscriberDK); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al deleted file mode 100644 index c04f734f319..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCountryData.Codeunit.al +++ /dev/null @@ -1,64 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8288 "DK Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - DKExpGLAccount: Codeunit "DK Exp. GL Account"; - DKExpPostingGrp: Codeunit "DK Exp. Posting Grp"; - begin - BindSubscription(DKExpGLAccount); - BindSubscription(DKExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"DK Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"DK Exp. Posting Grp"); - - UnbindSubscription(DKExpPostingGrp); - UnbindSubscription(DKExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"DK Exp. Categories"); - Codeunit.Run(Codeunit::"DK Exp. SubCategories"); - Codeunit.Run(Codeunit::"DK Exp. Rule Header"); - Codeunit.Run(Codeunit::"DK Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"DK Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - DKCurrencySwapSub: Codeunit "DK Currency Swap Sub"; - DKPostedExpReport: Codeunit "DK Posted Exp. Report"; - begin - BindSubscription(DKCurrencySwapSub); - BindSubscription(DKPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"DK Posted Exp. Report"); - - UnbindSubscription(DKPostedExpReport); - UnbindSubscription(DKCurrencySwapSub); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al deleted file mode 100644 index 1307ba6672d..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8296 "DK Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - DKExpCategories: Codeunit "DK Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(DKExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al deleted file mode 100644 index b2497fbfa4d..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8295 "DK Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - DKExpCategories: Codeunit "DK Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(DKExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al deleted file mode 100644 index d4f5e16164a..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpSubCategories.Codeunit.al +++ /dev/null @@ -1,39 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8294 "DK Exp. SubCategories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - DKExpCategories: Codeunit "DK Exp. Categories"; - begin - // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), DKExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), DKExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); - end; - - var - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; - - procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - procedure Intl(): Code[20] - begin - exit(IntlTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al deleted file mode 100644 index 1d7bdc59341..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKExpense.Codeunit.al +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoTool.Helpers; - -codeunit 8297 "DK Expense" -{ - InherentEntitlements = X; - InherentPermissions = X; - Permissions = tabledata "Expense Per Diem" = rim; - - trigger OnRun() - begin - CreateOpenExpense(); - end; - - local procedure CreateOpenExpense() - var - Expense: Record Expense; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DKExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); - UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); - end; - - var - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - DKExpCategories: Codeunit "DK Exp. Categories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al deleted file mode 100644 index 26157d0fd23..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKPostedExpReport.Codeunit.al +++ /dev/null @@ -1,168 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; -using Microsoft.DemoData.HumanResources; -using Microsoft.DemoTool.Helpers; - -codeunit 8298 "DK Posted Exp. Report" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - Permissions = - tabledata "Expense Per Diem" = rim, - tabledata "Expense Report Line" = rim; - - trigger OnRun() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if ExpenseReportHeader.FindLast() then - FromExpenseReportNo := ExpenseReportHeader."No."; - - CreateExpenseReportToPost(); - - PostExpenseReport(); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] - local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) - var - DKGLAccountNames: Codeunit "DK GL Account Names"; - ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - begin - AccountNo := ExpenseGLAccount.FindGLAccountByName(DKGLAccountNames.DomesticsalesofgoodsandservicesName()); - end; - - local procedure CreateExpenseReportToPost() - var - Expense: Record Expense; - ExpenseReportHeader: Record "Expense Report Header"; - CreateEmployee: Codeunit "Create Employee"; - CreateCurrency: Codeunit "Create Currency"; - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpCategories: Codeunit "Create Expense Categories DM"; - DKExpCategories: Codeunit "DK Exp. Categories"; - CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - begin - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), DKExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DKExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DKExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - var - FromExpenseReportNo: Code[20]; - BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; - AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; - MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; - AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; - TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; - ITConferenceLbl: Label 'IT Conference', MaxLength = 100; - ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; - TaxiLbl: Label 'Taxi', MaxLength = 100; - TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; - BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; - BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; - FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; - JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; - RelecloudLbl: Label 'Relecloud', MaxLength = 100; - RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; - AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; - HotelStayLbl: Label 'Hotel stay', MaxLength = 100; - ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; - AccommodationLbl: Label 'Accommodation', MaxLength = 100; - BreakfastLbl: Label 'Breakfast', MaxLength = 100; - HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; - RoomServiceLbl: Label 'Room service', MaxLength = 100; - CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; - VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; - TripToUKLbl: Label 'Trip to UK', MaxLength = 100; - TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; - MileageLbl: Label 'Mileage', MaxLength = 100; - CEOLbl: Label 'CEO', MaxLength = 30; - - local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") - var - ReleaseExpenseDocument: Codeunit "Release Expense Document"; - CreateExpenseReport: Codeunit "Create Expense Report"; - begin - Expense.Get(Expense."No."); - ReleaseExpenseDocument.Run(Expense); - - CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - local procedure PostExpenseReport() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if FromExpenseReportNo <> '' then - ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); - - if ExpenseReportHeader.FindSet() then - repeat - Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); - until ExpenseReportHeader.Next() = 0; - end; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpDemoDataSubscriberDK.Codeunit.al similarity index 95% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpDemoDataSubscriberDK.Codeunit.al index c758e910d02..91f3114d15e 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKCurrencySwapSub.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpDemoDataSubscriberDK.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8299 "DK Currency Swap Sub" +codeunit 8299 "Exp. Demo Data Subscriber DK" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpenseGLAccountNamesDK.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpenseGLAccountNamesDK.Codeunit.al index f318d36cf2b..e1186cfd641 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/DKGLAccountNames.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpenseGLAccountNamesDK.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8289 "DK GL Account Names" +codeunit 8289 "Expense GL Account Names DK" { Access = Internal; InherentEntitlements = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpGLAccountES.Codeunit.al similarity index 90% rename from src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpGLAccountES.Codeunit.al index 2663aacaebb..257df41fafb 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpGLAccountES.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8277 "ES Exp. GL Account" +codeunit 8277 "Create Exp. GL Account ES" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -58,17 +58,17 @@ codeunit 8277 "ES Exp. GL Account" local procedure UpdateIncomeStatementBalanceAccount() begin - UpdateIncomeStmtBalAcc(CompanyCreditCardsClearingAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(ExpensesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(RentalCarExpenses(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(TravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(EntertainmentExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); - UpdateIncomeStmtBalAcc(RoundingExpensesOperatingAccount(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(CompanyCreditCardsClearingAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpensesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.PerDiemTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.MileageTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(RentalCarExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(TravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(EntertainmentExpensesAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); + UpdateIncomeStmtBalAcc(RoundingExpensesOperatingAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.ProfitOrLossName())); end; local procedure UpdateIncomeStmtBalAcc(No: Code[20]; IncomeStmtBalAcc: Code[20]) @@ -98,7 +98,7 @@ codeunit 8277 "ES Exp. GL Account" var ContosoGLAccount: Codeunit "Contoso GL Account"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - ESGLAccountNames: Codeunit "ES GL Account Names"; + ExpenseGLAccountNamesES: Codeunit "Expense GL Account Names ES"; CompanyCreditCardsClearingAccountTok: Label 'Company credit card clearing account', MaxLength = 100; TravelExpensesTok: Label 'Travel expenses', MaxLength = 100; ExpensesPrepaymentsTok: Label 'Expenses Prepayments', MaxLength = 100; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpPostingGrpES.Codeunit.al similarity index 60% rename from src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpPostingGrpES.Codeunit.al index e7fd2ba3e9f..3b6f1164b91 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpPostingGrpES.Codeunit.al @@ -5,7 +5,7 @@ namespace Microsoft.ExpenseAgent; -codeunit 8278 "ES Exp. Posting Grp" +codeunit 8278 "Create Exp. Posting Grp ES" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -23,25 +23,25 @@ codeunit 8278 "ES Exp. Posting Grp" local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") var ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - ESExpGLAccount: Codeunit "ES Exp. GL Account"; - ESGLAccountNames: Codeunit "ES GL Account Names"; + CreateExpGLAccountES: Codeunit "Create Exp. GL Account ES"; + ExpenseGLAccountNamesES: Codeunit "Expense GL Account Names ES"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ESExpGLAccount.EntertainmentExpensesAccount(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, CreateExpGLAccountES.EntertainmentExpensesAccount(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.OtherBusinessExpensesName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.OtherBusinessExpensesName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); ExpensePerDiem(): - ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ESExpGLAccount.TravelExpenses(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, CreateExpGLAccountES.TravelExpenses(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, ESExpGLAccount.RentalCarExpenses(), '', ESExpGLAccount.ExpensesPrepayments(), ESExpGLAccount.RoundingExpensesOperatingAccount(), ESExpGLAccount.RoundingExpensesOperatingAccount()); + ValidateRecordFields(Rec, CreateExpGLAccountES.RentalCarExpenses(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/UpdateEmpPostingGrpES.Codeunit.al similarity index 71% rename from src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/UpdateEmpPostingGrpES.Codeunit.al index 8dddad50362..fbf2f968223 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/UpdateEmpPostingGrpES.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.HumanResources; -codeunit 8279 "ES Upd. Emp. Posting Grp" +codeunit 8279 "Update Emp. Posting Grp ES" { InherentEntitlements = X; InherentPermissions = X; @@ -19,13 +19,13 @@ codeunit 8279 "ES Upd. Emp. Posting Grp" local procedure UpdateEmployeePostingGroup() var ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - ESExpGLAccount: Codeunit "ES Exp. GL Account"; - ESGLAccountNames: Codeunit "ES GL Account Names"; + CreateExpGLAccountES: Codeunit "Create Exp. GL Account ES"; + ExpenseGLAccountNamesES: Codeunit "Expense GL Account Names ES"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.RemunerationAdvancesName()), ESExpGLAccount.ExpensesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.BanksEuroName()), ESExpGLAccount.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.RemunerationAdvancesName()), CreateExpGLAccountES.ExpensesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.BanksEuroName()), CreateExpGLAccountES.CompanyCreditCardsClearingAccount()); ContosoExpenseAgent.SetOverwriteData(false); end; } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpCategoriesES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpCategoriesES.Codeunit.al new file mode 100644 index 00000000000..806d59838c7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpCategoriesES.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8280 "Create Exp. Categories ES" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpES: Codeunit "Create Exp. Posting Grp ES"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpES.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleConditionES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleConditionES.Codeunit.al new file mode 100644 index 00000000000..62b12a0e0a1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleConditionES.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8283 "Create Exp. Rule Condition ES" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesES: Codeunit "Create Exp. Categories ES"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleHeaderES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleHeaderES.Codeunit.al new file mode 100644 index 00000000000..712688b450a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpRuleHeaderES.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8282 "Create Exp. Rule Header ES" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesES: Codeunit "Create Exp. Categories ES"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpSubCategoriesES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpSubCategoriesES.Codeunit.al new file mode 100644 index 00000000000..933adfffca7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/CreateExpSubCategoriesES.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8281 "Create Exp. SubCategories ES" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesES: Codeunit "Create Exp. Categories ES"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesES.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesES.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/UpdateEmployeeES.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/UpdateEmployeeES.Codeunit.al index 5a11120ff7c..c892233c8d2 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESUpdEmployee.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/UpdateEmployeeES.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.HumanResources; using Microsoft.HumanResources.Employee; -codeunit 8286 "ES Upd. Employee" +codeunit 8286 "Update Employee ES" { InherentEntitlements = X; InherentPermissions = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/3. Transactions/CreateExpenseES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/3. Transactions/CreateExpenseES.Codeunit.al new file mode 100644 index 00000000000..1166a7105ca --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/3. Transactions/CreateExpenseES.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8284 "Create Expense ES" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesES: Codeunit "Create Exp. Categories ES"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/4. Historical/CreatePostedExpReportES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/4. Historical/CreatePostedExpReportES.Codeunit.al new file mode 100644 index 00000000000..95db9325f5e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/4. Historical/CreatePostedExpReportES.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8285 "Create Posted Exp. Report ES" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesES: Codeunit "Expense GL Account Names ES"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.InternalResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesES: Codeunit "Create Exp. Categories ES"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesES.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al new file mode 100644 index 00000000000..6e20aa3c652 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al @@ -0,0 +1,70 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8275 "Create Expense Country Data ES" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountES: Codeunit "Create Exp. GL Account ES"; + CreateExpPostingGrpES: Codeunit "Create Exp. Posting Grp ES"; + begin + BindSubscription(CreateExpGLAccountES); + BindSubscription(CreateExpPostingGrpES); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Employee ES"); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp ES"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp ES"); + + UnbindSubscription(CreateExpPostingGrpES); + UnbindSubscription(CreateExpGLAccountES); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories ES"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories ES"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header ES"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition ES"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberES: Codeunit "Exp. Demo Data Subscriber ES"; + begin + BindSubscription(ExpDemoDataSubscriberES); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense ES"); + + UnbindSubscription(ExpDemoDataSubscriberES); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberES: Codeunit "Exp. Demo Data Subscriber ES"; + CreatePostedExpReportES: Codeunit "Create Posted Exp. Report ES"; + begin + BindSubscription(ExpDemoDataSubscriberES); + BindSubscription(CreatePostedExpReportES); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report ES"); + + UnbindSubscription(CreatePostedExpReportES); + UnbindSubscription(ExpDemoDataSubscriberES); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al deleted file mode 100644 index b7bc8b66c76..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESCountryData.Codeunit.al +++ /dev/null @@ -1,70 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8275 "ES Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - ESExpGLAccount: Codeunit "ES Exp. GL Account"; - ESExpPostingGrp: Codeunit "ES Exp. Posting Grp"; - begin - BindSubscription(ESExpGLAccount); - BindSubscription(ESExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"ES Upd. Employee"); - Codeunit.Run(Codeunit::"ES Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"ES Exp. Posting Grp"); - - UnbindSubscription(ESExpPostingGrp); - UnbindSubscription(ESExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"ES Exp. Categories"); - Codeunit.Run(Codeunit::"ES Exp. SubCategories"); - Codeunit.Run(Codeunit::"ES Exp. Rule Header"); - Codeunit.Run(Codeunit::"ES Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - ESCurrencySwapSub: Codeunit "ES Currency Swap Sub"; - begin - BindSubscription(ESCurrencySwapSub); - - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"ES Expense"); - - UnbindSubscription(ESCurrencySwapSub); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - ESCurrencySwapSub: Codeunit "ES Currency Swap Sub"; - ESPostedExpReport: Codeunit "ES Posted Exp. Report"; - begin - BindSubscription(ESCurrencySwapSub); - BindSubscription(ESPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"ES Posted Exp. Report"); - - UnbindSubscription(ESPostedExpReport); - UnbindSubscription(ESCurrencySwapSub); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al deleted file mode 100644 index f1488f5c145..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpCategories.Codeunit.al +++ /dev/null @@ -1,31 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8280 "ES Exp. Categories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateExpenseGroup: Codeunit "Create Expense Group"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - ESExpPostingGrp: Codeunit "ES Exp. Posting Grp"; - begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, ESExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); - end; - - var - PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; - PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; - PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - procedure PerDiem(): Code[20] - begin - exit(PerDiemTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al deleted file mode 100644 index dadd21d2422..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8283 "ES Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ESExpCategories: Codeunit "ES Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(ESExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al deleted file mode 100644 index 66a12401f7b..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8282 "ES Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - ESExpCategories: Codeunit "ES Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(ESExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al deleted file mode 100644 index f474a3fba63..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpSubCategories.Codeunit.al +++ /dev/null @@ -1,39 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8281 "ES Exp. SubCategories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - ESExpCategories: Codeunit "ES Exp. Categories"; - begin - // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), ESExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), ESExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); - end; - - var - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; - - procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - procedure Intl(): Code[20] - begin - exit(IntlTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al deleted file mode 100644 index e6c4d5c4af4..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESExpense.Codeunit.al +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoTool.Helpers; - -codeunit 8284 "ES Expense" -{ - InherentEntitlements = X; - InherentPermissions = X; - Permissions = tabledata "Expense Per Diem" = rim; - - trigger OnRun() - begin - CreateOpenExpense(); - end; - - local procedure CreateOpenExpense() - var - Expense: Record Expense; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ESExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); - UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); - end; - - var - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - ESExpCategories: Codeunit "ES Exp. Categories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al deleted file mode 100644 index b6452ca00d9..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESPostedExpReport.Codeunit.al +++ /dev/null @@ -1,168 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; -using Microsoft.DemoData.HumanResources; -using Microsoft.DemoTool.Helpers; - -codeunit 8285 "ES Posted Exp. Report" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - Permissions = - tabledata "Expense Per Diem" = rim, - tabledata "Expense Report Line" = rim; - - trigger OnRun() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if ExpenseReportHeader.FindLast() then - FromExpenseReportNo := ExpenseReportHeader."No."; - - CreateExpenseReportToPost(); - - PostExpenseReport(); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] - local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) - var - ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - ESGLAccountNames: Codeunit "ES GL Account Names"; - begin - AccountNo := ExpenseGLAccount.FindGLAccountByName(ESGLAccountNames.InternalResourcesName()); - end; - - local procedure CreateExpenseReportToPost() - var - Expense: Record Expense; - ExpenseReportHeader: Record "Expense Report Header"; - CreateEmployee: Codeunit "Create Employee"; - CreateCurrency: Codeunit "Create Currency"; - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpCategories: Codeunit "Create Expense Categories DM"; - ESExpCategories: Codeunit "ES Exp. Categories"; - CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - begin - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), ESExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ESExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), ESExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - var - FromExpenseReportNo: Code[20]; - BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; - AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; - MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; - AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; - TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; - ITConferenceLbl: Label 'IT Conference', MaxLength = 100; - ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; - TaxiLbl: Label 'Taxi', MaxLength = 100; - TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; - BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; - BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; - FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; - JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; - RelecloudLbl: Label 'Relecloud', MaxLength = 100; - RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; - AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; - HotelStayLbl: Label 'Hotel stay', MaxLength = 100; - ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; - AccommodationLbl: Label 'Accommodation', MaxLength = 100; - BreakfastLbl: Label 'Breakfast', MaxLength = 100; - HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; - RoomServiceLbl: Label 'Room service', MaxLength = 100; - CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; - VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; - TripToUKLbl: Label 'Trip to UK', MaxLength = 100; - TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; - MileageLbl: Label 'Mileage', MaxLength = 100; - CEOLbl: Label 'CEO', MaxLength = 30; - - local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") - var - ReleaseExpenseDocument: Codeunit "Release Expense Document"; - CreateExpenseReport: Codeunit "Create Expense Report"; - begin - Expense.Get(Expense."No."); - ReleaseExpenseDocument.Run(Expense); - - CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - local procedure PostExpenseReport() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if FromExpenseReportNo <> '' then - ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); - - if ExpenseReportHeader.FindSet() then - repeat - Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); - until ExpenseReportHeader.Next() = 0; - end; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpDemoDataSubscriberES.Codeunit.al similarity index 95% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpDemoDataSubscriberES.Codeunit.al index 71dc49cbd8b..2818b4c9b49 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DECurrencySwapSub.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpDemoDataSubscriberES.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8322 "DE Currency Swap Sub" +codeunit 8287 "Exp. Demo Data Subscriber ES" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpenseGLAccountNamesES.Codeunit.al similarity index 96% rename from src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpenseGLAccountNamesES.Codeunit.al index f8bfa91f839..230e5fd7366 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ESGLAccountNames.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpenseGLAccountNamesES.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8276 "ES GL Account Names" +codeunit 8276 "Expense GL Account Names ES" { Access = Internal; InherentEntitlements = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 690968c387e..746aa923bbd 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -11,56 +11,56 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" value(0; Default) { Caption = 'Default'; - Implementation = "Expense Agent Country Data" = "W1 Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data W1"; } value(1; US) { Caption = 'US'; - Implementation = "Expense Agent Country Data" = "US Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data US"; } value(2; GB) { Caption = 'GB'; - Implementation = "Expense Agent Country Data" = "GB Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data GB"; } value(3; CA) { Caption = 'CA'; - Implementation = "Expense Agent Country Data" = "CA Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data CA"; } value(4; NZ) { Caption = 'NZ'; - Implementation = "Expense Agent Country Data" = "NZ Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data NZ"; } value(5; AU) { Caption = 'AU'; - Implementation = "Expense Agent Country Data" = "AU Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data AU"; } value(6; ES) { Caption = 'ES'; - Implementation = "Expense Agent Country Data" = "ES Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data ES"; } value(7; DK) { Caption = 'DK'; - Implementation = "Expense Agent Country Data" = "DK Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data DK"; } value(8; FR) { Caption = 'FR'; - Implementation = "Expense Agent Country Data" = "FR Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data FR"; } value(9; DE) { Caption = 'DE'; - Implementation = "Expense Agent Country Data" = "DE Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data DE"; } value(10; AT) { Caption = 'AT'; - Implementation = "Expense Agent Country Data" = "AT Country Data"; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data AT"; } } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpGLAccountFR.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpGLAccountFR.Codeunit.al index 2687affdbd0..254613e9a0f 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpGLAccountFR.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8301 "FR Exp. GL Account" +codeunit 8301 "Create Exp. GL Account FR" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpPostingGrpFR.Codeunit.al similarity index 64% rename from src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpPostingGrpFR.Codeunit.al index ab370d6780f..6602e4dbc29 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpPostingGrpFR.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8302 "FR Exp. Posting Grp" +codeunit 8302 "Create Exp. Posting Grp FR" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -25,24 +25,24 @@ codeunit 8302 "FR Exp. Posting Grp" var CreateGLAccount: Codeunit "Create G/L Account"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - FRExpGLAccount: Codeunit "FR Exp. GL Account"; + CreateExpGLAccountFR: Codeunit "Create Exp. GL Account FR"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EntertainmentandPRName()), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EntertainmentandPRName()), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); ExpensePerDiem(): - ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.TravelName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.TravelName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, FRExpGLAccount.RentalCarExpenses(), '', FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ValidateRecordFields(Rec, CreateExpGLAccountFR.RentalCarExpenses(), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/UpdateEmpPostingGrpFR.Codeunit.al similarity index 78% rename from src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/UpdateEmpPostingGrpFR.Codeunit.al index 9da17fbd6fd..d1b38a2a411 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/UpdateEmpPostingGrpFR.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; -codeunit 8303 "FR Upd. Emp. Posting Grp" +codeunit 8303 "Update Emp. Posting Grp FR" { InherentEntitlements = X; InherentPermissions = X; @@ -21,12 +21,12 @@ codeunit 8303 "FR Upd. Emp. Posting Grp" var CreateGLAccount: Codeunit "Create G/L Account"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - FRExpGLAccount: Codeunit "FR Exp. GL Account"; + CreateExpGLAccountFR: Codeunit "Create Exp. GL Account FR"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), FRExpGLAccount.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), FRExpGLAccount.CompanyCreditCards()); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), CreateExpGLAccountFR.CompanyCreditCards()); ContosoExpenseAgent.SetOverwriteData(false); end; } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpCategoriesFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpCategoriesFR.Codeunit.al new file mode 100644 index 00000000000..91714abbe7e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpCategoriesFR.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8304 "Create Exp. Categories FR" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpFR: Codeunit "Create Exp. Posting Grp FR"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpFR.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleConditionFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleConditionFR.Codeunit.al new file mode 100644 index 00000000000..f956a084d19 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleConditionFR.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8307 "Create Exp. Rule Condition FR" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesFR: Codeunit "Create Exp. Categories FR"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleHeaderFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleHeaderFR.Codeunit.al new file mode 100644 index 00000000000..1bac31ef5f2 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpRuleHeaderFR.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8306 "Create Exp. Rule Header FR" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesFR: Codeunit "Create Exp. Categories FR"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpSubCategoriesFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpSubCategoriesFR.Codeunit.al new file mode 100644 index 00000000000..43be59a3a09 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/2.Master Data/CreateExpSubCategoriesFR.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8305 "Create Exp. SubCategories FR" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesFR: Codeunit "Create Exp. Categories FR"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesFR.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesFR.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/3. Transactions/CreateExpenseFR.Codeunit.al similarity index 80% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/FR/3. Transactions/CreateExpenseFR.Codeunit.al index 5c66e613c53..e2efbdb3fb4 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAExpense.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/3. Transactions/CreateExpenseFR.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoTool.Helpers; -codeunit 8253 "CA Expense" +codeunit 8308 "Create Expense FR" { InherentEntitlements = X; InherentPermissions = X; @@ -23,7 +23,7 @@ codeunit 8253 "CA Expense" ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpenseLocation: Codeunit "Create Expense Location"; begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CAExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); @@ -33,7 +33,7 @@ codeunit 8253 "CA Expense" var ContosoUtility: Codeunit "Contoso Utilities"; CreateExpenseUser: Codeunit "Create Expense User"; - CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpCategoriesFR: Codeunit "Create Exp. Categories FR"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/4. Historical/CreatePostedExpReportFR.Codeunit.al similarity index 91% rename from src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/FR/4. Historical/CreatePostedExpReportFR.Codeunit.al index 661e36af095..6bc02bbc243 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZPostedExpReport.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/4. Historical/CreatePostedExpReportFR.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; using Microsoft.DemoTool.Helpers; -codeunit 8264 "NZ Posted Exp. Report" +codeunit 8309 "Create Posted Exp. Report FR" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -50,12 +50,12 @@ codeunit 8264 "NZ Posted Exp. Report" CreateExpenseLocation: Codeunit "Create Expense Location"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpCategories: Codeunit "Create Expense Categories DM"; - NZExpCategories: Codeunit "NZ Exp. Categories"; + CreateExpCategoriesFR: Codeunit "Create Exp. Categories FR"; CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; begin ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), NZExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); @@ -89,11 +89,11 @@ codeunit 8264 "NZ Posted Exp. Report" ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), NZExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), NZExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesFR.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al new file mode 100644 index 00000000000..8407f2a5e46 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8300 "Create Expense Country Data FR" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountFR: Codeunit "Create Exp. GL Account FR"; + CreateExpPostingGrpFR: Codeunit "Create Exp. Posting Grp FR"; + begin + BindSubscription(CreateExpGLAccountFR); + BindSubscription(CreateExpPostingGrpFR); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp FR"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp FR"); + + UnbindSubscription(CreateExpPostingGrpFR); + UnbindSubscription(CreateExpGLAccountFR); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories FR"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories FR"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header FR"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition FR"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense FR"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberFR: Codeunit "Exp. Demo Data Subscriber FR"; + CreatePostedExpReportFR: Codeunit "Create Posted Exp. Report FR"; + begin + BindSubscription(ExpDemoDataSubscriberFR); + BindSubscription(CreatePostedExpReportFR); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report FR"); + + UnbindSubscription(CreatePostedExpReportFR); + UnbindSubscription(ExpDemoDataSubscriberFR); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/ExpDemoDataSubscriberFR.Codeunit.al similarity index 95% rename from src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/FR/ExpDemoDataSubscriberFR.Codeunit.al index 0b3b6c2b739..7f957243081 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCurrencySwapSub.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/ExpDemoDataSubscriberFR.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8310 "FR Currency Swap Sub" +codeunit 8310 "Exp. Demo Data Subscriber FR" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al deleted file mode 100644 index 5e516821672..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRCountryData.Codeunit.al +++ /dev/null @@ -1,64 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8300 "FR Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - FRExpGLAccount: Codeunit "FR Exp. GL Account"; - FRExpPostingGrp: Codeunit "FR Exp. Posting Grp"; - begin - BindSubscription(FRExpGLAccount); - BindSubscription(FRExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"FR Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"FR Exp. Posting Grp"); - - UnbindSubscription(FRExpPostingGrp); - UnbindSubscription(FRExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"FR Exp. Categories"); - Codeunit.Run(Codeunit::"FR Exp. SubCategories"); - Codeunit.Run(Codeunit::"FR Exp. Rule Header"); - Codeunit.Run(Codeunit::"FR Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"FR Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - FRCurrencySwapSub: Codeunit "FR Currency Swap Sub"; - FRPostedExpReport: Codeunit "FR Posted Exp. Report"; - begin - BindSubscription(FRCurrencySwapSub); - BindSubscription(FRPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"FR Posted Exp. Report"); - - UnbindSubscription(FRPostedExpReport); - UnbindSubscription(FRCurrencySwapSub); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al deleted file mode 100644 index 139298315d8..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpCategories.Codeunit.al +++ /dev/null @@ -1,31 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8304 "FR Exp. Categories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateExpenseGroup: Codeunit "Create Expense Group"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - FRExpPostingGrp: Codeunit "FR Exp. Posting Grp"; - begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, FRExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); - end; - - var - PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; - PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; - PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - procedure PerDiem(): Code[20] - begin - exit(PerDiemTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al deleted file mode 100644 index 151833e0143..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8307 "FR Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - FRExpCategories: Codeunit "FR Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(FRExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al deleted file mode 100644 index 7c3cfd823af..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8306 "FR Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - FRExpCategories: Codeunit "FR Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(FRExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al deleted file mode 100644 index 898fec78585..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpSubCategories.Codeunit.al +++ /dev/null @@ -1,39 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8305 "FR Exp. SubCategories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - FRExpCategories: Codeunit "FR Exp. Categories"; - begin - // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), FRExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), FRExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); - end; - - var - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; - - procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - procedure Intl(): Code[20] - begin - exit(IntlTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al deleted file mode 100644 index 0006405f379..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/FRExpense.Codeunit.al +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoTool.Helpers; - -codeunit 8308 "FR Expense" -{ - InherentEntitlements = X; - InherentPermissions = X; - Permissions = tabledata "Expense Per Diem" = rim; - - trigger OnRun() - begin - CreateOpenExpense(); - end; - - local procedure CreateOpenExpense() - var - Expense: Record Expense; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), FRExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); - UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); - end; - - var - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - FRExpCategories: Codeunit "FR Exp. Categories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpGLAccountGB.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpGLAccountGB.Codeunit.al index 55aa053e6ff..fdc55cc3761 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpGLAccountGB.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8236 "GB Exp. GL Account" +codeunit 8236 "Create Exp. GL Account GB" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpPostingGrpGB.Codeunit.al similarity index 53% rename from src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpPostingGrpGB.Codeunit.al index 9337c030760..dcf224d963d 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpPostingGrpGB.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8237 "GB Exp. Posting Grp" +codeunit 8237 "Create Exp. Posting Grp GB" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -21,25 +21,25 @@ codeunit 8237 "GB Exp. Posting Grp" [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") var - GBGLAccountNames: Codeunit "GB GL Account Names"; + ExpenseGLAccountNamesGB: Codeunit "Expense GL Account Names GB"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.BusinessEntertainingDeductibleName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.BusinessEntertainingDeductibleName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.MiscExternalExpensesName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.MiscExternalExpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); ExpensePerDiem(): - ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherTravelExpensesName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherTravelExpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/UpdateEmpPostingGrpGB.Codeunit.al similarity index 84% rename from src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/UpdateEmpPostingGrpGB.Codeunit.al index 51a9072c619..4a6f1f3a257 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/UpdateEmpPostingGrpGB.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; -codeunit 8238 "GB Upd. Emp. Posting Grp" +codeunit 8238 "Update Emp. Posting Grp GB" { InherentEntitlements = X; InherentPermissions = X; @@ -21,12 +21,12 @@ codeunit 8238 "GB Upd. Emp. Posting Grp" var CreateGLAccount: Codeunit "Create G/L Account"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - GBGLAccountNames: Codeunit "GB GL Account Names"; + ExpenseGLAccountNamesGB: Codeunit "Expense GL Account Names GB"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.CashName()), ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.OtherBankAccountsName()), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.CashName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherBankAccountsName()), ExpenseGLAccount.CompanyCreditCardsAccount()); ContosoExpenseAgent.SetOverwriteData(false); end; } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpCategoriesGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpCategoriesGB.Codeunit.al new file mode 100644 index 00000000000..0f09378b45d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpCategoriesGB.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8239 "Create Exp. Categories GB" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpGB: Codeunit "Create Exp. Posting Grp GB"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpGB.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleConditionGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleConditionGB.Codeunit.al new file mode 100644 index 00000000000..22812ffe401 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleConditionGB.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8242 "Create Exp. Rule Condition GB" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesGB: Codeunit "Create Exp. Categories GB"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleHeaderGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleHeaderGB.Codeunit.al new file mode 100644 index 00000000000..7df56d1bac0 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpRuleHeaderGB.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8241 "Create Exp. Rule Header GB" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesGB: Codeunit "Create Exp. Categories GB"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpSubCategoriesGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpSubCategoriesGB.Codeunit.al new file mode 100644 index 00000000000..2567d675c03 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/2.Master Data/CreateExpSubCategoriesGB.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8240 "Create Exp. SubCategories GB" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesGB: Codeunit "Create Exp. Categories GB"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesGB.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesGB.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/3. Transactions/CreateExpenseGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/3. Transactions/CreateExpenseGB.Codeunit.al new file mode 100644 index 00000000000..6b5a810eccc --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/3. Transactions/CreateExpenseGB.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8243 "Create Expense GB" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesGB: Codeunit "Create Exp. Categories GB"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/4. Historical/CreatePostedExpReportGB.Codeunit.al similarity index 90% rename from src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/GB/4. Historical/CreatePostedExpReportGB.Codeunit.al index 356596ff253..609c0396e84 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/DEPostedExpReport.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/4. Historical/CreatePostedExpReportGB.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; using Microsoft.DemoTool.Helpers; -codeunit 8321 "DE Posted Exp. Report" +codeunit 8244 "Create Posted Exp. Report GB" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -33,10 +33,10 @@ codeunit 8321 "DE Posted Exp. Report" [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) var - DEGLAccountNames: Codeunit "DE GL Account Names"; + ExpenseGLAccountNamesGB: Codeunit "Expense GL Account Names GB"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; begin - AccountNo := ExpenseGLAccount.FindGLAccountByName(DEGLAccountNames.SaleofResourcesName()); + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.SaleofResourcesName()); end; local procedure CreateExpenseReportToPost() @@ -50,12 +50,12 @@ codeunit 8321 "DE Posted Exp. Report" CreateExpenseLocation: Codeunit "Create Expense Location"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpCategories: Codeunit "Create Expense Categories DM"; - DEExpCategories: Codeunit "DE Exp. Categories"; + CreateExpCategoriesGB: Codeunit "Create Exp. Categories GB"; CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; begin ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), DEExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); @@ -89,11 +89,11 @@ codeunit 8321 "DE Posted Exp. Report" ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DEExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), DEExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesGB.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/CreateExpenseCountryDataGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/CreateExpenseCountryDataGB.Codeunit.al new file mode 100644 index 00000000000..36015db6baa --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/CreateExpenseCountryDataGB.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8234 "Create Expense Country Data GB" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountGB: Codeunit "Create Exp. GL Account GB"; + CreateExpPostingGrpGB: Codeunit "Create Exp. Posting Grp GB"; + begin + BindSubscription(CreateExpGLAccountGB); + BindSubscription(CreateExpPostingGrpGB); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp GB"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp GB"); + + UnbindSubscription(CreateExpPostingGrpGB); + UnbindSubscription(CreateExpGLAccountGB); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories GB"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories GB"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header GB"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition GB"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense GB"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportGB: Codeunit "Create Posted Exp. Report GB"; + begin + BindSubscription(CreatePostedExpReportGB); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report GB"); + + UnbindSubscription(CreatePostedExpReportGB); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/ExpenseGLAccountNamesGB.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/GB/ExpenseGLAccountNamesGB.Codeunit.al index c79a028f691..8ad299b8778 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBGLAccountNames.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/ExpenseGLAccountNamesGB.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8235 "GB GL Account Names" +codeunit 8235 "Expense GL Account Names GB" { Access = Internal; InherentEntitlements = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al deleted file mode 100644 index 5fb2ca846cb..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBCountryData.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8234 "GB Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - GBExpGLAccount: Codeunit "GB Exp. GL Account"; - GBExpPostingGrp: Codeunit "GB Exp. Posting Grp"; - begin - BindSubscription(GBExpGLAccount); - BindSubscription(GBExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"GB Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"GB Exp. Posting Grp"); - - UnbindSubscription(GBExpPostingGrp); - UnbindSubscription(GBExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"GB Exp. Categories"); - Codeunit.Run(Codeunit::"GB Exp. SubCategories"); - Codeunit.Run(Codeunit::"GB Exp. Rule Header"); - Codeunit.Run(Codeunit::"GB Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"GB Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - GBPostedExpReport: Codeunit "GB Posted Exp. Report"; - begin - BindSubscription(GBPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"GB Posted Exp. Report"); - - UnbindSubscription(GBPostedExpReport); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al deleted file mode 100644 index f054881cd68..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpCategories.Codeunit.al +++ /dev/null @@ -1,31 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8239 "GB Exp. Categories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateExpenseGroup: Codeunit "Create Expense Group"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - GBExpPostingGrp: Codeunit "GB Exp. Posting Grp"; - begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, GBExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); - end; - - var - PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; - PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; - PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - procedure PerDiem(): Code[20] - begin - exit(PerDiemTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al deleted file mode 100644 index c106f380a33..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8242 "GB Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - GBExpCategories: Codeunit "GB Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(GBExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al deleted file mode 100644 index bf8261c17f3..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8241 "GB Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - GBExpCategories: Codeunit "GB Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(GBExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al deleted file mode 100644 index 46a383cc9b7..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpSubCategories.Codeunit.al +++ /dev/null @@ -1,39 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8240 "GB Exp. SubCategories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - GBExpCategories: Codeunit "GB Exp. Categories"; - begin - // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), GBExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), GBExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); - end; - - var - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; - - procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - procedure Intl(): Code[20] - begin - exit(IntlTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al deleted file mode 100644 index 95bb196c26e..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBExpense.Codeunit.al +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoTool.Helpers; - -codeunit 8243 "GB Expense" -{ - InherentEntitlements = X; - InherentPermissions = X; - Permissions = tabledata "Expense Per Diem" = rim; - - trigger OnRun() - begin - CreateOpenExpense(); - end; - - local procedure CreateOpenExpense() - var - Expense: Record Expense; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), GBExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); - UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); - end; - - var - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - GBExpCategories: Codeunit "GB Exp. Categories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al deleted file mode 100644 index 5a05b6526c0..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/GB/GBPostedExpReport.Codeunit.al +++ /dev/null @@ -1,168 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; -using Microsoft.DemoData.HumanResources; -using Microsoft.DemoTool.Helpers; - -codeunit 8244 "GB Posted Exp. Report" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - Permissions = - tabledata "Expense Per Diem" = rim, - tabledata "Expense Report Line" = rim; - - trigger OnRun() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if ExpenseReportHeader.FindLast() then - FromExpenseReportNo := ExpenseReportHeader."No."; - - CreateExpenseReportToPost(); - - PostExpenseReport(); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] - local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) - var - GBGLAccountNames: Codeunit "GB GL Account Names"; - ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - begin - AccountNo := ExpenseGLAccount.FindGLAccountByName(GBGLAccountNames.SaleofResourcesName()); - end; - - local procedure CreateExpenseReportToPost() - var - Expense: Record Expense; - ExpenseReportHeader: Record "Expense Report Header"; - CreateEmployee: Codeunit "Create Employee"; - CreateCurrency: Codeunit "Create Currency"; - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpCategories: Codeunit "Create Expense Categories DM"; - GBExpCategories: Codeunit "GB Exp. Categories"; - CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - begin - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), GBExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), GBExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), GBExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - var - FromExpenseReportNo: Code[20]; - BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; - AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; - MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; - AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; - TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; - ITConferenceLbl: Label 'IT Conference', MaxLength = 100; - ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; - TaxiLbl: Label 'Taxi', MaxLength = 100; - TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; - BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; - BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; - FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; - JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; - RelecloudLbl: Label 'Relecloud', MaxLength = 100; - RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; - AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; - HotelStayLbl: Label 'Hotel stay', MaxLength = 100; - ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; - AccommodationLbl: Label 'Accommodation', MaxLength = 100; - BreakfastLbl: Label 'Breakfast', MaxLength = 100; - HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; - RoomServiceLbl: Label 'Room service', MaxLength = 100; - CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; - VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; - TripToUKLbl: Label 'Trip to UK', MaxLength = 100; - TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; - MileageLbl: Label 'Mileage', MaxLength = 100; - CEOLbl: Label 'CEO', MaxLength = 30; - - local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") - var - ReleaseExpenseDocument: Codeunit "Release Expense Document"; - CreateExpenseReport: Codeunit "Create Expense Report"; - begin - Expense.Get(Expense."No."); - ReleaseExpenseDocument.Run(Expense); - - CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - local procedure PostExpenseReport() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if FromExpenseReportNo <> '' then - ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); - - if ExpenseReportHeader.FindSet() then - repeat - Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); - until ExpenseReportHeader.Next() = 0; - end; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpGLAccountNZ.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpGLAccountNZ.Codeunit.al index 37b76823dce..80a92445e23 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpGLAccountNZ.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8256 "NZ Exp. GL Account" +codeunit 8256 "Create Exp. GL Account NZ" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpPostingGrpNZ.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpPostingGrpNZ.Codeunit.al index 515904a598b..7a354c5d71c 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpPostingGrpNZ.Codeunit.al @@ -6,7 +6,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; -codeunit 8257 "NZ Exp. Posting Grp" +codeunit 8257 "Create Exp. Posting Grp NZ" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/UpdateEmpPostingGrpNZ.Codeunit.al similarity index 97% rename from src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/UpdateEmpPostingGrpNZ.Codeunit.al index 36b465160c5..cf6662bb29a 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZUpdEmpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/UpdateEmpPostingGrpNZ.Codeunit.al @@ -7,7 +7,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; -codeunit 8258 "NZ Upd. Emp. Posting Grp" +codeunit 8258 "Update Emp. Posting Grp NZ" { InherentEntitlements = X; InherentPermissions = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpCategoriesNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpCategoriesNZ.Codeunit.al new file mode 100644 index 00000000000..fd9dae14451 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpCategoriesNZ.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8259 "Create Exp. Categories NZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpNZ: Codeunit "Create Exp. Posting Grp NZ"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpNZ.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleConditionNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleConditionNZ.Codeunit.al new file mode 100644 index 00000000000..888f7527b2f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleConditionNZ.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8262 "Create Exp. Rule Condition NZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesNZ: Codeunit "Create Exp. Categories NZ"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleHeaderNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleHeaderNZ.Codeunit.al new file mode 100644 index 00000000000..c5a2d44c070 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpRuleHeaderNZ.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8261 "Create Exp. Rule Header NZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesNZ: Codeunit "Create Exp. Categories NZ"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpSubCategoriesNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpSubCategoriesNZ.Codeunit.al new file mode 100644 index 00000000000..17e91fac4ef --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/2.Master Data/CreateExpSubCategoriesNZ.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8260 "Create Exp. SubCategories NZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesNZ: Codeunit "Create Exp. Categories NZ"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesNZ.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesNZ.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/3. Transactions/CreateExpenseNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/3. Transactions/CreateExpenseNZ.Codeunit.al new file mode 100644 index 00000000000..289ce688cf7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/3. Transactions/CreateExpenseNZ.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8263 "Create Expense NZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesNZ: Codeunit "Create Exp. Categories NZ"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/4. Historical/CreatePostedExpReportNZ.Codeunit.al similarity index 91% rename from src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/NZ/4. Historical/CreatePostedExpReportNZ.Codeunit.al index 7ee1e98d313..73faa059e2d 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CA/CAPostedExpReport.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/4. Historical/CreatePostedExpReportNZ.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoData.Finance; using Microsoft.DemoData.HumanResources; using Microsoft.DemoTool.Helpers; -codeunit 8254 "CA Posted Exp. Report" +codeunit 8264 "Create Posted Exp. Report NZ" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -50,12 +50,12 @@ codeunit 8254 "CA Posted Exp. Report" CreateExpenseLocation: Codeunit "Create Expense Location"; ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; CreateExpCategories: Codeunit "Create Expense Categories DM"; - CAExpCategories: Codeunit "CA Exp. Categories"; + CreateExpCategoriesNZ: Codeunit "Create Exp. Categories NZ"; CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; begin ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CAExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); @@ -89,11 +89,11 @@ codeunit 8254 "CA Posted Exp. Report" ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CAExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CAExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNZ.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/CreateExpenseCountryDataNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/CreateExpenseCountryDataNZ.Codeunit.al new file mode 100644 index 00000000000..b0056d650f0 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/CreateExpenseCountryDataNZ.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8255 "Create Expense Country Data NZ" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountNZ: Codeunit "Create Exp. GL Account NZ"; + CreateExpPostingGrpNZ: Codeunit "Create Exp. Posting Grp NZ"; + begin + BindSubscription(CreateExpGLAccountNZ); + BindSubscription(CreateExpPostingGrpNZ); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp NZ"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp NZ"); + + UnbindSubscription(CreateExpPostingGrpNZ); + UnbindSubscription(CreateExpGLAccountNZ); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories NZ"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories NZ"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header NZ"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition NZ"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense NZ"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportNZ: Codeunit "Create Posted Exp. Report NZ"; + begin + BindSubscription(CreatePostedExpReportNZ); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report NZ"); + + UnbindSubscription(CreatePostedExpReportNZ); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al deleted file mode 100644 index 61c4dee22b4..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZCountryData.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8255 "NZ Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - NZExpGLAccount: Codeunit "NZ Exp. GL Account"; - NZExpPostingGrp: Codeunit "NZ Exp. Posting Grp"; - begin - BindSubscription(NZExpGLAccount); - BindSubscription(NZExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"NZ Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"NZ Exp. Posting Grp"); - - UnbindSubscription(NZExpPostingGrp); - UnbindSubscription(NZExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"NZ Exp. Categories"); - Codeunit.Run(Codeunit::"NZ Exp. SubCategories"); - Codeunit.Run(Codeunit::"NZ Exp. Rule Header"); - Codeunit.Run(Codeunit::"NZ Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"NZ Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - NZPostedExpReport: Codeunit "NZ Posted Exp. Report"; - begin - BindSubscription(NZPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"NZ Posted Exp. Report"); - - UnbindSubscription(NZPostedExpReport); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al deleted file mode 100644 index 4b2bf7403cb..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpCategories.Codeunit.al +++ /dev/null @@ -1,31 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8259 "NZ Exp. Categories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateExpenseGroup: Codeunit "Create Expense Group"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - NZExpPostingGrp: Codeunit "NZ Exp. Posting Grp"; - begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, NZExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); - end; - - var - PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; - PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; - PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - procedure PerDiem(): Code[20] - begin - exit(PerDiemTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al deleted file mode 100644 index 7ad4573bc47..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8262 "NZ Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - NZExpCategories: Codeunit "NZ Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(NZExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al deleted file mode 100644 index d683da5442e..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8261 "NZ Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - NZExpCategories: Codeunit "NZ Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(NZExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al deleted file mode 100644 index 110d963af00..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpSubCategories.Codeunit.al +++ /dev/null @@ -1,39 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8260 "NZ Exp. SubCategories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - NZExpCategories: Codeunit "NZ Exp. Categories"; - begin - // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), NZExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), NZExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); - end; - - var - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; - - procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - procedure Intl(): Code[20] - begin - exit(IntlTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al deleted file mode 100644 index adec4da6464..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/NZExpense.Codeunit.al +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoTool.Helpers; - -codeunit 8263 "NZ Expense" -{ - InherentEntitlements = X; - InherentPermissions = X; - Permissions = tabledata "Expense Per Diem" = rim; - - trigger OnRun() - begin - CreateOpenExpense(); - end; - - local procedure CreateOpenExpense() - var - Expense: Record Expense; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), NZExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); - UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); - end; - - var - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - NZExpCategories: Codeunit "NZ Exp. Categories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpGLAccountUS.Codeunit.al similarity index 99% rename from src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpGLAccountUS.Codeunit.al index f97f4886555..5868bac7bfa 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpGLAccountUS.Codeunit.al @@ -8,7 +8,7 @@ using Microsoft.DemoTool.Helpers; using Microsoft.Finance.GeneralLedger.Account; using Microsoft.Foundation.Enums; -codeunit 8224 "US Exp. GL Account" +codeunit 8224 "Create Exp. GL Account US" { SingleInstance = true; EventSubscriberInstance = Manual; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpPostingGrpUS.Codeunit.al similarity index 53% rename from src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpPostingGrpUS.Codeunit.al index 3638e41b226..ef36a8c6185 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpPostingGrp.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpPostingGrpUS.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8225 "US Exp. Posting Grp" +codeunit 8225 "Create Exp. Posting Grp US" { SingleInstance = true; EventSubscriberInstance = Manual; @@ -21,25 +21,25 @@ codeunit 8225 "US Exp. Posting Grp" [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") var - USGLAccountNames: Codeunit "US GL Account Names"; + ExpenseGLAccountNamesUS: Codeunit "Expense GL Account Names US"; ExpenseGLAccount: Codeunit "Create Expense G/L Account"; CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; begin case Rec.Code of CreateExpensePostingGroup.ExpenseEntertainment(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.BusinessEntertainingDeductibleName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.BusinessEntertainingDeductibleName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseMeals(): - ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseMileage(): - ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseOther(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.MiscExternalExpensesName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.MiscExternalExpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); ExpensePerDiem(): - ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseTravel(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherTravelExpensesName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherTravelExpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); CreateExpensePostingGroup.ExpenseRentalCars(): - ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.PayableInvoiceRoundingName())); + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); end; end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/UpdateEmpPostingGrpUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/UpdateEmpPostingGrpUS.Codeunit.al new file mode 100644 index 00000000000..d7669602c10 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/UpdateEmpPostingGrpUS.Codeunit.al @@ -0,0 +1,32 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; + +codeunit 8226 "Update Emp. Posting Grp US" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateGLAccount: Codeunit "Create G/L Account"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesUS: Codeunit "Expense GL Account Names US"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.AccountsPayableDomesticName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.CashName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherBankAccountsName()), ExpenseGLAccount.CompanyCreditCardsAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpCategoriesUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpCategoriesUS.Codeunit.al new file mode 100644 index 00000000000..d1ab832416b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpCategoriesUS.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8227 "Create Exp. Categories US" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpUS: Codeunit "Create Exp. Posting Grp US"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpUS.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleConditionUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleConditionUS.Codeunit.al new file mode 100644 index 00000000000..34d15937dea --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleConditionUS.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8230 "Create Exp. Rule Condition US" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesUS: Codeunit "Create Exp. Categories US"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleHeaderUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleHeaderUS.Codeunit.al new file mode 100644 index 00000000000..c739b222cde --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpRuleHeaderUS.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8229 "Create Exp. Rule Header US" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesUS: Codeunit "Create Exp. Categories US"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpSubCategoriesUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpSubCategoriesUS.Codeunit.al new file mode 100644 index 00000000000..29cfc276ab1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/2.Master Data/CreateExpSubCategoriesUS.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8228 "Create Exp. SubCategories US" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesUS: Codeunit "Create Exp. Categories US"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesUS.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesUS.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/3. Transactions/CreateExpenseUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/3. Transactions/CreateExpenseUS.Codeunit.al new file mode 100644 index 00000000000..62e36a294b3 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/3. Transactions/CreateExpenseUS.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8231 "Create Expense US" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesUS: Codeunit "Create Exp. Categories US"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/4. Historical/CreatePostedExpReportUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/4. Historical/CreatePostedExpReportUS.Codeunit.al new file mode 100644 index 00000000000..2b5d742305a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/4. Historical/CreatePostedExpReportUS.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8232 "Create Posted Exp. Report US" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccountNamesUS: Codeunit "Expense GL Account Names US"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.SaleofResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesUS: Codeunit "Create Exp. Categories US"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesUS.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/CreateExpenseCountryDataUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/CreateExpenseCountryDataUS.Codeunit.al new file mode 100644 index 00000000000..332400a1e50 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/CreateExpenseCountryDataUS.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8223 "Create Expense Country Data US" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountUS: Codeunit "Create Exp. GL Account US"; + CreateExpPostingGrpUS: Codeunit "Create Exp. Posting Grp US"; + begin + BindSubscription(CreateExpGLAccountUS); + BindSubscription(CreateExpPostingGrpUS); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp US"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp US"); + + UnbindSubscription(CreateExpPostingGrpUS); + UnbindSubscription(CreateExpGLAccountUS); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories US"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories US"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header US"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition US"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense US"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportUS: Codeunit "Create Posted Exp. Report US"; + begin + BindSubscription(CreatePostedExpReportUS); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report US"); + + UnbindSubscription(CreatePostedExpReportUS); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/ExpenseGLAccountNamesUS.Codeunit.al similarity index 98% rename from src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/US/ExpenseGLAccountNamesUS.Codeunit.al index f27e4e6c052..f723da58b45 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USGLAccountNames.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/ExpenseGLAccountNamesUS.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8220 "US GL Account Names" +codeunit 8220 "Expense GL Account Names US" { Access = Internal; InherentEntitlements = X; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al deleted file mode 100644 index 5f8dab09554..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USCountryData.Codeunit.al +++ /dev/null @@ -1,61 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8223 "US Country Data" implements "Expense Agent Country Data" -{ - Access = Internal; - InherentEntitlements = X; - InherentPermissions = X; - - procedure CreateSetupData() - var - W1CountryData: Codeunit "W1 Country Data"; - USExpGLAccount: Codeunit "US Exp. GL Account"; - USExpPostingGrp: Codeunit "US Exp. Posting Grp"; - begin - BindSubscription(USExpGLAccount); - BindSubscription(USExpPostingGrp); - - W1CountryData.CreateSetupData(); - Codeunit.Run(Codeunit::"US Upd. Emp. Posting Grp"); - Codeunit.Run(Codeunit::"US Exp. Posting Grp"); - - UnbindSubscription(USExpPostingGrp); - UnbindSubscription(USExpGLAccount); - end; - - procedure CreateMasterData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateMasterData(); - Codeunit.Run(Codeunit::"US Exp. Categories"); - Codeunit.Run(Codeunit::"US Exp. SubCategories"); - Codeunit.Run(Codeunit::"US Exp. Rule Header"); - Codeunit.Run(Codeunit::"US Exp. Rule Condition"); - end; - - procedure CreateTransactionalData() - var - W1CountryData: Codeunit "W1 Country Data"; - begin - W1CountryData.CreateTransactionalData(); - Codeunit.Run(Codeunit::"US Expense"); - end; - - procedure CreateHistoricalData() - var - W1CountryData: Codeunit "W1 Country Data"; - USPostedExpReport: Codeunit "US Posted Exp. Report"; - begin - BindSubscription(USPostedExpReport); - - W1CountryData.CreateHistoricalData(); - Codeunit.Run(Codeunit::"US Posted Exp. Report"); - - UnbindSubscription(USPostedExpReport); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al deleted file mode 100644 index c43bc444861..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpCategories.Codeunit.al +++ /dev/null @@ -1,31 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8227 "US Exp. Categories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateExpenseGroup: Codeunit "Create Expense Group"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - USExpPostingGrp: Codeunit "US Exp. Posting Grp"; - begin - ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, USExpPostingGrp.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); - end; - - var - PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; - PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; - PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - procedure PerDiem(): Code[20] - begin - exit(PerDiemTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al deleted file mode 100644 index fd885936d20..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleCondition.Codeunit.al +++ /dev/null @@ -1,26 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8230 "US Exp. Rule Condition" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - USExpCategories: Codeunit "US Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); - ContosoExpenseAgent.InsertExpenseRuleCondition(USExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al deleted file mode 100644 index 371f4aed2f9..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpRuleHeader.Codeunit.al +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; - -codeunit 8229 "US Exp. Rule Header" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - CreateCurrency: Codeunit "Create Currency"; - USExpCategories: Codeunit "US Exp. Categories"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - begin - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); - ContosoExpenseAgent.InsertExpenseRuleHeader(USExpCategories.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al deleted file mode 100644 index e9d714fe328..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpSubCategories.Codeunit.al +++ /dev/null @@ -1,39 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -codeunit 8228 "US Exp. SubCategories" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - var - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - USExpCategories: Codeunit "US Exp. Categories"; - begin - // PER-DIEM subcategories - ContosoExpenseAgent.InsertExpenseSubcategory(Country(), USExpCategories.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); - ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), USExpCategories.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); - end; - - var - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; - - procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - procedure Intl(): Code[20] - begin - exit(IntlTok); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al deleted file mode 100644 index 01c114bfe84..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USExpense.Codeunit.al +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoTool.Helpers; - -codeunit 8231 "US Expense" -{ - InherentEntitlements = X; - InherentPermissions = X; - Permissions = tabledata "Expense Per Diem" = rim; - - trigger OnRun() - begin - CreateOpenExpense(); - end; - - local procedure CreateOpenExpense() - var - Expense: Record Expense; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - begin - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), USExpCategories.PerDiem(), CreateExpenseLocation.DenmarkAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); - UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); - end; - - var - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - USExpCategories: Codeunit "US Exp. Categories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al deleted file mode 100644 index 0452bed56b2..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USPostedExpReport.Codeunit.al +++ /dev/null @@ -1,168 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; -using Microsoft.DemoData.HumanResources; -using Microsoft.DemoTool.Helpers; - -codeunit 8232 "US Posted Exp. Report" -{ - SingleInstance = true; - EventSubscriberInstance = Manual; - InherentEntitlements = X; - InherentPermissions = X; - Permissions = - tabledata "Expense Per Diem" = rim, - tabledata "Expense Report Line" = rim; - - trigger OnRun() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if ExpenseReportHeader.FindLast() then - FromExpenseReportNo := ExpenseReportHeader."No."; - - CreateExpenseReportToPost(); - - PostExpenseReport(); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] - local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) - var - USGLAccountNames: Codeunit "US GL Account Names"; - ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - begin - AccountNo := ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.SaleofResourcesName()); - end; - - local procedure CreateExpenseReportToPost() - var - Expense: Record Expense; - ExpenseReportHeader: Record "Expense Report Header"; - CreateEmployee: Codeunit "Create Employee"; - CreateCurrency: Codeunit "Create Currency"; - ContosoUtility: Codeunit "Contoso Utilities"; - CreateExpenseUser: Codeunit "Create Expense User"; - CreateExpenseLocation: Codeunit "Create Expense Location"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateExpCategories: Codeunit "Create Expense Categories DM"; - USExpCategories: Codeunit "US Exp. Categories"; - CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; - CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; - begin - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), USExpCategories.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - - ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); - ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); - ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), USExpCategories.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); - UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); - UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), USExpCategories.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); - ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - var - FromExpenseReportNo: Code[20]; - BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; - AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; - MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; - AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; - TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; - ITConferenceLbl: Label 'IT Conference', MaxLength = 100; - ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; - TaxiLbl: Label 'Taxi', MaxLength = 100; - TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; - BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; - BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; - FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; - JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; - RelecloudLbl: Label 'Relecloud', MaxLength = 100; - RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; - AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; - HotelStayLbl: Label 'Hotel stay', MaxLength = 100; - ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; - AccommodationLbl: Label 'Accommodation', MaxLength = 100; - BreakfastLbl: Label 'Breakfast', MaxLength = 100; - HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; - RoomServiceLbl: Label 'Room service', MaxLength = 100; - CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; - VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; - TripToUKLbl: Label 'Trip to UK', MaxLength = 100; - TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; - MileageLbl: Label 'Mileage', MaxLength = 100; - CEOLbl: Label 'CEO', MaxLength = 30; - - local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") - var - ReleaseExpenseDocument: Codeunit "Release Expense Document"; - CreateExpenseReport: Codeunit "Create Expense Report"; - begin - Expense.Get(Expense."No."); - ReleaseExpenseDocument.Run(Expense); - - CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); - end; - - local procedure PostExpenseReport() - var - ExpenseReportHeader: Record "Expense Report Header"; - begin - if FromExpenseReportNo <> '' then - ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); - - if ExpenseReportHeader.FindSet() then - repeat - Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); - until ExpenseReportHeader.Next() = 0; - end; - - local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) - var - ExpensePerDiem: Record "Expense Per Diem"; - begin - ExpensePerDiem.Get(ExpenseNo, LineNo); - - ExpensePerDiem.Validate(Breakfast, Breakfast); - ExpensePerDiem.Validate(Lunch, Lunch); - ExpensePerDiem.Validate(Dinner, Dinner); - ExpensePerDiem.Modify(); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al deleted file mode 100644 index 6c8acc31157..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al +++ /dev/null @@ -1,32 +0,0 @@ -// ------------------------------------------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// ------------------------------------------------------------------------------------------------ -namespace Microsoft.ExpenseAgent; - -using Microsoft.DemoData.Finance; -using Microsoft.DemoData.HumanResources; - -codeunit 8226 "US Upd. Emp. Posting Grp" -{ - InherentEntitlements = X; - InherentPermissions = X; - - trigger OnRun() - begin - UpdateEmployeePostingGroup(); - end; - - local procedure UpdateEmployeePostingGroup() - var - CreateGLAccount: Codeunit "Create G/L Account"; - ExpenseGLAccount: Codeunit "Create Expense G/L Account"; - USGLAccountNames: Codeunit "US GL Account Names"; - ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; - CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; - begin - ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.AccountsPayableDomesticName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.CashName()), ExpenseGLAccount.FindGLAccountByName(USGLAccountNames.OtherBankAccountsName()), ExpenseGLAccount.CompanyCreditCardsAccount()); - ContosoExpenseAgent.SetOverwriteData(false); - end; -} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/W1/CreateExpenseCountryDataW1.Codeunit.al similarity index 95% rename from src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al rename to src/Apps/W1/ExpenseAgent/demo data/Country/W1/CreateExpenseCountryDataW1.Codeunit.al index 597990fe8e2..ac8749079ec 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/W1/W1CountryData.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/W1/CreateExpenseCountryDataW1.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -codeunit 8222 "W1 Country Data" implements "Expense Agent Country Data" +codeunit 8222 "Create Expense Country Data W1" implements "Expense Agent Country Data" { Access = Internal; InherentEntitlements = X; From f50adc53a852a13e4dd158bba0fb6e6801dacb19 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Tue, 11 Aug 2026 14:18:25 +0530 Subject: [PATCH 16/25] Rename resolver and country data variables to match object names --- .../ExpenseAgentContosoModule.Codeunit.al | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al index cf268322849..6968871a5a0 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al @@ -26,38 +26,38 @@ codeunit 8202 "Expense Agent Contoso Module" implements "Contoso Demo Data Modul procedure CreateSetupData() var ExpenseAgentModuleSetup: Record "Expense Agent Module Setup"; - Resolver: Codeunit "Exp. Agent Country Resolver"; - CountryData: Interface "Expense Agent Country Data"; + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: Interface "Expense Agent Country Data"; begin ExpenseAgentModuleSetup.InitRecord(); - CountryData := Resolver.Resolve(); - CountryData.CreateSetupData(); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateSetupData(); end; procedure CreateMasterData() var - Resolver: Codeunit "Exp. Agent Country Resolver"; - CountryData: Interface "Expense Agent Country Data"; + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: Interface "Expense Agent Country Data"; begin - CountryData := Resolver.Resolve(); - CountryData.CreateMasterData(); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateMasterData(); end; procedure CreateTransactionalData() var - Resolver: Codeunit "Exp. Agent Country Resolver"; - CountryData: Interface "Expense Agent Country Data"; + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: Interface "Expense Agent Country Data"; begin - CountryData := Resolver.Resolve(); - CountryData.CreateTransactionalData(); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateTransactionalData(); end; procedure CreateHistoricalData() var - Resolver: Codeunit "Exp. Agent Country Resolver"; - CountryData: Interface "Expense Agent Country Data"; + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: Interface "Expense Agent Country Data"; begin - CountryData := Resolver.Resolve(); - CountryData.CreateHistoricalData(); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateHistoricalData(); end; } \ No newline at end of file From 54192c9de73988dbcf2d1af311db388badfb9b31 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Tue, 11 Aug 2026 14:21:22 +0530 Subject: [PATCH 17/25] Update country resolver and remove porting notes --- .../ExpAgentCountryResolver.Codeunit.al | 8 +- .../demo data/Country/PORTING_NOTES.md | 280 ------------------ 2 files changed, 4 insertions(+), 284 deletions(-) delete mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al index 40ddf0d27d5..46f339e6ac9 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Foundation.Company; +using Microsoft.DemoTool; codeunit 8221 "Exp. Agent Country Resolver" { @@ -19,10 +19,10 @@ codeunit 8221 "Exp. Agent Country Resolver" procedure ResolveCountry() Country: Enum "Expense Agent Country" var - CompanyInformation: Record "Company Information"; + ContosoCoffeeDemoDataSetup: Record "Contoso Coffee Demo Data Setup"; begin - if CompanyInformation.Get() then - case CompanyInformation."Country/Region Code" of + if ContosoCoffeeDemoDataSetup.Get() then + case ContosoCoffeeDemoDataSetup."Country/Region Code" of 'US': exit(Country::US); 'GB': diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md b/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md deleted file mode 100644 index f7a97b6594e..00000000000 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/PORTING_NOTES.md +++ /dev/null @@ -1,280 +0,0 @@ -# Expense Agent — Country Demo Data Consolidation Notes - -This file catalogs the technical workarounds applied while porting the ten -per-country Expense Agent demo-data extensions into the consolidated -`Expense Agent Demo Data` (W1) extension. - -## Rationale - -The consolidated demo data extension must be installable on **any** BC -localization — it can only depend on: - -- `Expense Agent (Preview)` (base app) -- `Contoso Coffee Demo Dataset` (base W1 Contoso Coffee) -- `Expense Agent Demo Data` (itself, framework layer) - -It cannot add hard dependencies on `Contoso Coffee Demo Dataset ()` or on -any country localization pack (which would restrict installability to that -country only). - -The original per-country apps (`ExpenseAgent_/demo data`) freely referenced -`Create GL Accounts` codeunits from `Contoso Coffee Demo Dataset ()` -and, in the ES case, the `Income Stmt. Bal. Acc.` field added by the ES -localization. Neither is available here. - -**All data written on the target locale (numbers, names, categories, -income/balance flags, posting types, etc.) is byte-identical to the original -per-country app output.** The workarounds change *how* a value is looked up, -not *what* value is written. - -## Data preservation - -For every country, the following are copied verbatim from the original -`CreateExpenseGLAccount.Codeunit.al` / `ExpenseEventSubscriber.Codeunit.al`: - -- G/L account numbers (`AddAccountForLocalization(name, number)`) -- G/L account names (`Label` values) -- Income/Balance flag -- G/L Account Category + SubCategory -- Account Type (Posting / Begin-Total / End-Total) -- Begin-Total / End-Total Totaling ranges (CA, NZ) -- General Posting Type -- Direct Posting / Reconciliation / Blocked flags -- Expense Posting Group account mappings (Refundable/Non-refundable/Prepayment/Rounding) -- Employee Posting Group mappings -- Categories / SubCategories / Rule Header / Rule Condition / Expense / - Posted Expense Report data (labels, dates, amounts, vendors, participants) - ---- - -## Judgment calls (per country) - -### Pattern A — Inlined `Contoso Coffee (CC)` name-lookup labels - -**Problem:** original per-country apps look up G/L accounts by name using -`Create GL Account.()` from `Contoso Coffee Demo Dataset ()`. -The consolidated extension cannot depend on the country ContosoCoffee. - -**Workaround:** create a per-country ` GL Account Names` codeunit that -duplicates the `Tok`/`Lbl` string constants verbatim. The base W1 -`Create Expense G/L Account.FindGLAccountByName(...)` resolves the account by -name at runtime, so on a ``-loc install where the ContosoCoffee-`` pack -is installed, the returned account is identical to the original code path. - -**Alternative rejected:** adding `Contoso Coffee Demo Dataset ()` as a -dependency of the consolidated extension → would make the extension only -installable on `` loc. - -#### US -| # | Label | Value | -|---|-------|-------| -| 1 | `BusinessEntertainingDeductibleName` | `Business Entertaining, deductible` | -| 2 | `OtherIncidentalRevenueName` | `Other Incidental Revenue` | -| 3 | `OtherPrepaidExpensesAndAccruedIncomeName` | `Other prepaid expenses and accrued income` | -| 4 | `PayableInvoiceRoundingName` | `Payable Invoice Rounding` | -| 5 | `MiscExternalExpensesName` | `Misc. external expenses` | -| 6 | `OtherTravelExpensesName` | `Other travel expenses` | -| 7 | `RentalVehiclesName` | `Rental vehicles` | -| 8 | `AccountsPayableDomesticName` | `Accounts Payable, Domestic` | -| 9 | `OtherBankAccountsName` | `Other bank accounts ` (trailing space) | -| 10 | `SaleofResourcesName` | `Sale of Resources` | - -- **Before (original US):** `Create US GL Account.OtherIncidentalRevenue()` and siblings — from `src/Apps/US/ContosoCoffeeDemoDatasetUS/app/DemoData/Finance/1.Setup Data/CreateUSGLAccount.Codeunit.al`. -- **After (ported):** [demo data/Country/US/USGLAccountNames.Codeunit.al](demo%20data/Country/US/USGLAccountNames.Codeunit.al) — codeunit 8220. -- **Used by:** [demo data/Country/US/USExpGLAccount.Codeunit.al](demo%20data/Country/US/USExpGLAccount.Codeunit.al), [demo data/Country/US/USExpPostingGrp.Codeunit.al](demo%20data/Country/US/USExpPostingGrp.Codeunit.al), [demo data/Country/US/USUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/US/USUpdEmpPostingGrp.Codeunit.al), [demo data/Country/US/USPostedExpReport.Codeunit.al](demo%20data/Country/US/USPostedExpReport.Codeunit.al). - -#### GB -| # | Label | Value | -|---|-------|-------| -| 1 | `BusinessEntertainingDeductibleName` | `Business Entertaining, deductible` | -| 2 | `OtherIncidentalRevenueName` | `Other Incidental Revenue` | -| 3 | `OtherPrepaidExpensesAndAccruedIncomeName` | `Other prepaid expenses and accrued income` | -| 4 | `PayableInvoiceRoundingName` | `Payable Invoice Rounding` | -| 5 | `MiscExternalExpensesName` | `Misc. external expenses` | -| 6 | `OtherTravelExpensesName` | `Other travel expenses` | -| 7 | `RentalVehiclesName` | `Rental vehicles` | -| 8 | `OtherBankAccountsName` | `Other bank accounts ` (trailing space) | -| 9 | `SaleofResourcesName` | `Sale of Resources` | - -- **Before (original GB):** `Create UK GL Account.()` from `src/Apps/GB/ContosoCoffeeDemoDatasetGB/app/DemoData/Finance/1.Setup Data/CreateUKGLAccount.Codeunit.al` (or equivalent). -- **After (ported):** [demo data/Country/GB/GBGLAccountNames.Codeunit.al](demo%20data/Country/GB/GBGLAccountNames.Codeunit.al) — codeunit 8235. -- **Used by:** [demo data/Country/GB/GBExpGLAccount.Codeunit.al](demo%20data/Country/GB/GBExpGLAccount.Codeunit.al), [demo data/Country/GB/GBExpPostingGrp.Codeunit.al](demo%20data/Country/GB/GBExpPostingGrp.Codeunit.al), [demo data/Country/GB/GBPostedExpReport.Codeunit.al](demo%20data/Country/GB/GBPostedExpReport.Codeunit.al). - -#### CA -Single label inlined directly in [demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L33](demo%20data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L33): - -```al -BankCheckingLbl: Label 'Bank, Checking', MaxLength = 100; -``` - -- **Before (original CA):** `Create CA GL Account.BankCheckingName()` from `src/Apps/CA/ContosoCoffeeDemoDatasetCA/app/DemoData/Finance/1.Setup Data/CreateCAGLAccount.Codeunit.al`. -- **After (ported):** [demo data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L28](demo%20data/Country/CA/CAUpdEmpPostingGrp.Codeunit.al#L28) uses `ExpenseGLAccount.FindGLAccountByName(BankCheckingLbl)`. - -#### ES -| # | Label | Value | -|---|-------|-------| -| 1 | `OtherBusinessExpensesName` | `Other Business Expenses` | -| 2 | `RemunerationAdvancesName` | `Remuneration Advances` | -| 3 | `BanksEuroName` | `Banks Euro` | -| 4 | `InternalResourcesName` | `Internal Resources` | -| 5 | `ProfitOrLossName` | `Profit or Loss` | - -- **Before (original ES):** `Create ES GL Accounts.()` from `src/Apps/ES/ContosoCoffeeDemoDatasetES/app/DemoData/Finance/1.Setup Data/CreateESGLAccounts.Codeunit.al`. -- **After (ported):** [demo data/Country/ES/ESGLAccountNames.Codeunit.al](demo%20data/Country/ES/ESGLAccountNames.Codeunit.al) — codeunit 8276. -- **Used by:** [demo data/Country/ES/ESExpGLAccount.Codeunit.al](demo%20data/Country/ES/ESExpGLAccount.Codeunit.al), [demo data/Country/ES/ESExpPostingGrp.Codeunit.al](demo%20data/Country/ES/ESExpPostingGrp.Codeunit.al), [demo data/Country/ES/ESUpdEmployee.Codeunit.al](demo%20data/Country/ES/ESUpdEmployee.Codeunit.al), [demo data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/ES/ESUpdEmpPostingGrp.Codeunit.al), [demo data/Country/ES/ESPostedExpReport.Codeunit.al](demo%20data/Country/ES/ESPostedExpReport.Codeunit.al). - -#### DK -| # | Label | Value | -|---|-------|-------| -| 1 | `EntwinetobaccospiritsName` | `Ent., Wine / Tobacco / Spirits` | -| 2 | `PrepaymentsAccruedCostsName` | `Prepayments - Accrued Costs` | -| 3 | `CentdiscrepanciesName` | `Cent Discrepancies` | -| 4 | `RestaurantdiningName` | `Restaurant Dining` | -| 5 | `MileagerateName` | `Mileage Rate` | -| 6 | `TravelingtradefairsetcName` | `Traveling, Trade Fairs etc.` | -| 7 | `AccountsPayablePostingName` | `Accounts Payables` | -| 8 | `BankName` | `Bank` | -| 9 | `DomesticsalesofgoodsandservicesName` | `Domestic Sales of Goods and Services` | - -- **Before (original DK):** `Create GL Acc. DK.()` from `src/Apps/DK/ContosoCoffeeDemoDatasetDK/app/DemoData/Finance/1.Setup Data/CreateGLAccDK.Codeunit.al`. -- **After (ported):** [demo data/Country/DK/DKGLAccountNames.Codeunit.al](demo%20data/Country/DK/DKGLAccountNames.Codeunit.al) — codeunit 8289. -- **Used by:** [demo data/Country/DK/DKExpGLAccount.Codeunit.al](demo%20data/Country/DK/DKExpGLAccount.Codeunit.al), [demo data/Country/DK/DKExpPostingGrp.Codeunit.al](demo%20data/Country/DK/DKExpPostingGrp.Codeunit.al), [demo data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/DK/DKUpdEmpPostingGrp.Codeunit.al), [demo data/Country/DK/DKPostedExpReport.Codeunit.al](demo%20data/Country/DK/DKPostedExpReport.Codeunit.al). - -#### NZ, AU -None. Both countries' original apps only reference base W1 Contoso Coffee names (`EmployeesPayableName`, `BankLCYName`, etc.) which are available via `Create G/L Account` in the base `Contoso Coffee Demo Dataset`. - -#### FR -None (no ContosoCoffee-FR name-lookups). FR introduces three FR-unique local G/L accounts (`CompanyCreditCards=512900`, `ExpensePrepaymentAccount=486200`, `RentalCarExpenses=625130`) with local `Tok` labels declared inside [demo data/Country/FR/FRExpGLAccount.Codeunit.al](demo%20data/Country/FR/FRExpGLAccount.Codeunit.al) — same as the original per-country app's own local declarations. - -#### DE -| # | Label | Value | -|---|-------|-------| -| 1 | `BusinessaccountOperatingDomesticName` | `Business account, Operating, Domestic` | -| 2 | `SaleofResourcesName` | `Sale of Resource` | -| 3 | `AssetsintheformofprepaidexpensesName` | `Assets in the form of prepaid expenses` | -| 4 | `SalesInvoiceRoundingName` | `Sales Invoice Rounding` | -| 5 | `BoardandlodgingName` | `Board and lodging` | -| 6 | `MiscexternalexpensesName` | `Misc. external expenses` | -| 7 | `OthertravelexpensesName` | `Other travel expenses` | -| 8 | `RentalvehiclesName` | `Rental vehicles` | -| 9 | `BusinessEntertainingdeductibleName` | `Business Entertaining, deductible` | - -- **Before (original DE):** `Create DE GL Acc.()` from `src/Apps/DE/ContosoCoffeeDemoDatasetDE/app/DemoData/Finance/1.Setup data/CreateDEGLAcc.Codeunit.al`. -- **After (ported):** [demo data/Country/DE/DEGLAccountNames.Codeunit.al](demo%20data/Country/DE/DEGLAccountNames.Codeunit.al) — codeunit 8312. -- **Used by:** [demo data/Country/DE/DEExpPostingGrp.Codeunit.al](demo%20data/Country/DE/DEExpPostingGrp.Codeunit.al), [demo data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/DE/DEUpdEmpPostingGrp.Codeunit.al), [demo data/Country/DE/DEPostedExpReport.Codeunit.al](demo%20data/Country/DE/DEPostedExpReport.Codeunit.al). - -DE also introduces one DE-unique local G/L account (`CompanyCreditCardsClearingAccount=3510`, label `'Company credit card clearing account'`) declared inside [demo data/Country/DE/DEExpGLAccount.Codeunit.al](demo%20data/Country/DE/DEExpGLAccount.Codeunit.al) — same as the original per-country app's own local declaration. - -#### AT -| # | Label | Value | -|---|-------|-------| -| 1 | `SettlementAccountCashBankName` | `Settlement account cash bank` | -| 2 | `SalesRevenuesResourcesExportName` | `Sales revenues resources export` | -| 3 | `TransportationThirdPartiesName` | `Transportation third parties` | -| 4 | `KilometerAllowanceName` | `Kilometer allowance` | -| 5 | `MealExpensesDomesticName` | `Meal expenses domestic` | -| 6 | `MealExpensesAbroadName` | `Meal expenses abroad` | -| 7 | `HospitalityDomesticDeductibleAmountName` | `Hospitality domestic deductible amount` | -| 8 | `OtherName` | `Other` | - -- **Before (original AT):** `Create AT GL Account.()` from `src/Apps/AT/ContosoCoffeeDemoDatasetAT/app/DemoData/Finance/1. Setup Data/CreateATGLAccount.Codeunit.al`. -- **After (ported):** [demo data/Country/AT/ATGLAccountNames.Codeunit.al](demo%20data/Country/AT/ATGLAccountNames.Codeunit.al) — codeunit 8324. -- **Used by:** [demo data/Country/AT/ATExpPostingGrp.Codeunit.al](demo%20data/Country/AT/ATExpPostingGrp.Codeunit.al), [demo data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al](demo%20data/Country/AT/ATUpdEmpPostingGrp.Codeunit.al), [demo data/Country/AT/ATPostedExpReport.Codeunit.al](demo%20data/Country/AT/ATPostedExpReport.Codeunit.al). - -AT also introduces one AT-unique local G/L account (`CompanyCreditCardsClearingAccount=2830`, label `'Company credit card clearing account'`) declared inside [demo data/Country/AT/ATExpGLAccount.Codeunit.al](demo%20data/Country/AT/ATExpGLAccount.Codeunit.al) — same as the original per-country app's own local declaration. - -### Pattern C — AT event subscribers bind/unbind gating - -**Problem:** the original `ExpenseAgent_AT` app declared its -`OnDefineExpenseAccountNo` and `OnBeforeValidateCurrencyCodeInExpense` -subscribers as plain (non-Manual) event subscribers on -[AT Exp. Contoso Localization.Codeunit.al](../../../../AT/ExpenseAgent_AT/demo%20data/Demo%20Data/ATExpContosoLocalization.Codeunit.al) — safe because that app was only ever installed on the AT loc. In the -consolidated extension the same static registration would fire on every -locale, silently rewriting expense account numbers and currency codes for -non-AT companies. - -**Workaround:** move both subscribers into Manual `SingleInstance` codeunits -([demo data/Country/AT/ATPostedExpReport.Codeunit.al](demo%20data/Country/AT/ATPostedExpReport.Codeunit.al) 8335 and [demo data/Country/AT/ATCurrencySwapSub.Codeunit.al](demo%20data/Country/AT/ATCurrencySwapSub.Codeunit.al) 8336) and let the AT orchestrator -[demo data/Country/AT/ATCountryData.Codeunit.al](demo%20data/Country/AT/ATCountryData.Codeunit.al) `BindSubscription` / `UnbindSubscription` them around `CreateHistoricalData`. Same technique used by FR and DE for their currency-swap and historical-account overrides. - -### ID collision — 8333, 8334, 8347, 8348 reserved by System Application - -The demo data extension's `idRanges` in [demo data/app.json](demo%20data/app.json) is `8201-8399`, but four codeunits inside that range are shipped by the base **System Application** and cannot be redefined here: - -| ID | System Application object | -|---|---| -| 8333 | `VS Code Integration Impl.` | -| 8334 | `VS Code Integration` | -| 8347 | `Feature Configuration` | -| 8348 | `Feature Configuration Impl.` | - -AT files that would naturally have received the next sequential IDs 8333/8334 were shifted to **8335 (`AT Posted Exp. Report`)** and **8336 (`AT Currency Swap Sub`)** for that reason. - ---- - -### Pattern B — ES `"Income Stmt. Bal. Acc."` late-bound field write - -**Problem:** the original `ExpenseAgent_ES` app strongly types -`GLAccount.Validate("Income Stmt. Bal. Acc.", )` on 11 G/L accounts. -That field is added to table `G/L Account` by the ES localization pack -(unavailable in W1). Adding a dep on that pack would restrict the whole -consolidated extension to ES loc. - -**Before (original ES):** -`src/Apps/ES/ExpenseAgent_ES/demo data/Demo Data/1.Setup Data/CreateExpenseGLAccountES.Codeunit.al` line 78: -```al -GLAccount.Validate("Income Stmt. Bal. Acc.", IncomeStmtBalAcc); -``` - -**After (ported):** [demo data/Country/ES/ESExpGLAccount.Codeunit.al#L74-L96](demo%20data/Country/ES/ESExpGLAccount.Codeunit.al#L74-L96): -```al -local procedure UpdateIncomeStmtBalAcc(No: Code[20]; IncomeStmtBalAcc: Code[20]) -var - GLAccount: Record "G/L Account"; - RecRef: RecordRef; - FieldRef: FieldRef; - i: Integer; -begin - // "Income Stmt. Bal. Acc." is added by the ES localization to table G/L Account. - // Look it up dynamically via FieldRef so this demo data works without an ES-loc - // compile-time dependency; silently skip when the field is not present. - if not GLAccount.Get(No) then - exit; - - RecRef.GetTable(GLAccount); - for i := 1 to RecRef.FieldCount do begin - FieldRef := RecRef.FieldIndex(i); - if FieldRef.Name = 'Income Stmt. Bal. Acc.' then begin - FieldRef.Validate(IncomeStmtBalAcc); - RecRef.Modify(); - exit; - end; - end; -end; -``` - -**Behavior:** -- On an ES-loc install: the field is present, `FieldRef.Validate` fires, - demo data written is byte-identical to the original. -- On a non-ES install: the loop completes without finding the field, - `UpdateIncomeStmtBalAcc` no-ops. This is safe because on a non-ES install - the country resolver returns something other than `ES` and this codepath - is never reached anyway. - -**Caveat:** field name comparison is against the English identifier -`'Income Stmt. Bal. Acc.'`. If a future BC build renames this field's -`Name` property (unlikely — captions are separate from names), this -lookup would miss and no `Income Stmt. Bal. Acc.` would be written. - ---- - -## Countries with no judgment calls - -Countries where the port is a pure 1:1 rename/renumber with no -technique changes: - -- **NZ** ([demo data/Country/NZ/](demo%20data/Country/NZ/)): base W1 names only. -- **AU** ([demo data/Country/AU/](demo%20data/Country/AU/)): base W1 names only. -- **FR** ([demo data/Country/FR/](demo%20data/Country/FR/)): base W1 names only; three FR-local G/L accounts inlined verbatim from the original per-country app. - -All ten countries ported. From ddbf710f2ab4492b32a86bb09f4d75d989477ce5 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Tue, 11 Aug 2026 14:45:53 +0530 Subject: [PATCH 18/25] Remove country-specific Expense Agent demo data from build config and manifests --- build/groups.json | 170 -------------------- build/projects.json | 100 ------------ build/projects/Apps AT/.AL-Go/settings.json | 1 - build/projects/Apps AU/.AL-Go/settings.json | 1 - build/projects/Apps CA/.AL-Go/settings.json | 1 - build/projects/Apps DE/.AL-Go/settings.json | 1 - build/projects/Apps DK/.AL-Go/settings.json | 1 - build/projects/Apps ES/.AL-Go/settings.json | 1 - build/projects/Apps FR/.AL-Go/settings.json | 1 - build/projects/Apps GB/.AL-Go/settings.json | 1 - build/projects/Apps NZ/.AL-Go/settings.json | 1 - build/projects/Apps US/.AL-Go/settings.json | 1 - src/Apps/W1/ExpenseAgent/app/app.json | 50 ------ src/Apps/W1/ExpenseAgent/demo data/app.json | 53 +----- 14 files changed, 1 insertion(+), 382 deletions(-) diff --git a/build/groups.json b/build/groups.json index a9f4624046c..d633846905f 100644 --- a/build/groups.json +++ b/build/groups.json @@ -8860,176 +8860,6 @@ } ] }, - { - "name": "Expense Agent Demo Data (US)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (GB)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (CA)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (NZ)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (AU)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (ES)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (DK)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (FR)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (DE)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent Demo Data (AT)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, { "name": "OIOUBL", "groups": [ diff --git a/build/projects.json b/build/projects.json index 28918414ec0..7c6017e0419 100644 --- a/build/projects.json +++ b/build/projects.json @@ -5470,106 +5470,6 @@ "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", "owningteam": "\\AI Business Solutions\\Finance" }, - "Expense Agent Demo Data (US)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\US\\ExpenseAgent_US\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "US", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (GB)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\GB\\ExpenseAgent_GB\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "GB", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (AU)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\AU\\ExpenseAgent_AU\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "AU", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (NZ)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\NZ\\ExpenseAgent_NZ\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "NZ", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (CA)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\CA\\ExpenseAgent_CA\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "CA", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (ES)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\ES\\ExpenseAgent_ES\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "ES", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (DK)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\DK\\ExpenseAgent_DK\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "DK", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (FR)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\FR\\ExpenseAgent_FR\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "FR", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (DE)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\DE\\ExpenseAgent_DE\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "DE", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent Demo Data (AT)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\AT\\ExpenseAgent_AT\\demo data", - "skipInstallOnPrem": true, - "hasTranslations": true, - "supportedCountries": "AT", - "runStaticCodeAnalysis": true, - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\minorrelease.ruleset.json", - "owningteam": "\\AI Business Solutions\\Finance" - }, "OIOUBL": { "projectPath": "$env:INETROOT\\App\\Apps\\DK\\OIOUBL\\app", "dvdFolder": "Applications\\OIOUBL\\Source", diff --git a/build/projects/Apps AT/.AL-Go/settings.json b/build/projects/Apps AT/.AL-Go/settings.json index 58ca4e19f7a..f7f8f09d5a2 100644 --- a/build/projects/Apps AT/.AL-Go/settings.json +++ b/build/projects/Apps AT/.AL-Go/settings.json @@ -6,7 +6,6 @@ "../../../src/Apps/AT/ContosoCoffeeDemoDatasetAT/app", "../../../src/Apps/AT/EDocument_AT/demo data", "../../../src/Apps/AT/ExpenseAgent_AT/app", - "../../../src/Apps/AT/ExpenseAgent_AT/demo data", "../../../src/Apps/AT/HybridBCLast_AT/app", "../../../src/Apps/AT/IntrastatAT/app", "../../../src/Apps/DACH/Onprem Permissions DACH/app", diff --git a/build/projects/Apps AU/.AL-Go/settings.json b/build/projects/Apps AU/.AL-Go/settings.json index 3b452e6bd7d..63186f59b97 100644 --- a/build/projects/Apps AU/.AL-Go/settings.json +++ b/build/projects/Apps AU/.AL-Go/settings.json @@ -7,7 +7,6 @@ "../../../src/Apps/AU/ContosoCoffeeDemoDatasetAU/app", "../../../src/Apps/AU/EDocument_AU/demo data", "../../../src/Apps/AU/ExpenseAgent_AU/app", - "../../../src/Apps/AU/ExpenseAgent_AU/demo data", "../../../src/Apps/AU/HybridBCLast_AU/app", "../../../src/Apps/AU/Onprem Permissions AU/app", "../../../src/Apps/W1/AgentDesignExperience/app", diff --git a/build/projects/Apps CA/.AL-Go/settings.json b/build/projects/Apps CA/.AL-Go/settings.json index 07a333aba94..a42c6445995 100644 --- a/build/projects/Apps CA/.AL-Go/settings.json +++ b/build/projects/Apps CA/.AL-Go/settings.json @@ -6,7 +6,6 @@ "../../../src/Apps/CA/ContosoCoffeeDemoDatasetCA/app", "../../../src/Apps/CA/EDocument_CA/demo data", "../../../src/Apps/CA/ExpenseAgent_CA/app", - "../../../src/Apps/CA/ExpenseAgent_CA/demo data", "../../../src/Apps/CA/HybridBCLast_CA/app", "../../../src/Apps/NA/Ceridian/app", "../../../src/Apps/NA/EnvestnetYodleeBankFeeds/app", diff --git a/build/projects/Apps DE/.AL-Go/settings.json b/build/projects/Apps DE/.AL-Go/settings.json index 82f7c5959e5..9d55428fa71 100644 --- a/build/projects/Apps DE/.AL-Go/settings.json +++ b/build/projects/Apps DE/.AL-Go/settings.json @@ -9,7 +9,6 @@ "../../../src/Apps/DE/EDocumentDE/demo data", "../../../src/Apps/DE/Elster/app", "../../../src/Apps/DE/ExpenseAgent_DE/app", - "../../../src/Apps/DE/ExpenseAgent_DE/demo data", "../../../src/Apps/DE/HybridBCLast_DE/app", "../../../src/Apps/DE/IntrastatDE/app", "../../../src/Apps/DE/PEPPOLDE/app", diff --git a/build/projects/Apps DK/.AL-Go/settings.json b/build/projects/Apps DK/.AL-Go/settings.json index 9df8672dc7d..efb1762f1c2 100644 --- a/build/projects/Apps DK/.AL-Go/settings.json +++ b/build/projects/Apps DK/.AL-Go/settings.json @@ -11,7 +11,6 @@ "../../../src/Apps/DK/ElectronicVATDeclarationDK/app", "../../../src/Apps/DK/EnforcedDigitalVouchersDK/app", "../../../src/Apps/DK/ExpenseAgent_DK/app", - "../../../src/Apps/DK/ExpenseAgent_DK/demo data", "../../../src/Apps/DK/FIK/app", "../../../src/Apps/DK/ImportDKPayroll/app", "../../../src/Apps/DK/NemhandelNotification/app", diff --git a/build/projects/Apps ES/.AL-Go/settings.json b/build/projects/Apps ES/.AL-Go/settings.json index 58188f0191a..b3f8e846bd8 100644 --- a/build/projects/Apps ES/.AL-Go/settings.json +++ b/build/projects/Apps ES/.AL-Go/settings.json @@ -8,7 +8,6 @@ "../../../src/Apps/ES/EDocumentFormats/DocumentRegistration/app", "../../../src/Apps/ES/EDocumentFormats/FacturaE/app", "../../../src/Apps/ES/ExpenseAgent_ES/app", - "../../../src/Apps/ES/ExpenseAgent_ES/demo data", "../../../src/Apps/ES/HybridBCLast_ES/app", "../../../src/Apps/ES/IntrastatES/app", "../../../src/Apps/ES/Onprem Permissions ES/app", diff --git a/build/projects/Apps FR/.AL-Go/settings.json b/build/projects/Apps FR/.AL-Go/settings.json index 9d6da0c6daf..406675c9c3d 100644 --- a/build/projects/Apps FR/.AL-Go/settings.json +++ b/build/projects/Apps FR/.AL-Go/settings.json @@ -7,7 +7,6 @@ "../../../src/Apps/FR/EDocument_FR/demo data", "../../../src/Apps/FR/EDocument_FR/EReportingFR/app", "../../../src/Apps/FR/ExpenseAgent_FR/app", - "../../../src/Apps/FR/ExpenseAgent_FR/demo data", "../../../src/Apps/FR/FAReportsFR/app", "../../../src/Apps/FR/FECAuditFile/app", "../../../src/Apps/FR/HybridBCLast_FR/app", diff --git a/build/projects/Apps GB/.AL-Go/settings.json b/build/projects/Apps GB/.AL-Go/settings.json index 9ba159619dd..e19526f7540 100644 --- a/build/projects/Apps GB/.AL-Go/settings.json +++ b/build/projects/Apps GB/.AL-Go/settings.json @@ -6,7 +6,6 @@ "../../../src/Apps/GB/ContosoCoffeeDemoDatasetGB/app", "../../../src/Apps/GB/EDocument_GB/demo data", "../../../src/Apps/GB/ExpenseAgent_GB/app", - "../../../src/Apps/GB/ExpenseAgent_GB/demo data", "../../../src/Apps/GB/GovTalk/app", "../../../src/Apps/GB/GovTalk/demo data", "../../../src/Apps/GB/IdealPostcodes/app", diff --git a/build/projects/Apps NZ/.AL-Go/settings.json b/build/projects/Apps NZ/.AL-Go/settings.json index c7511c9c7bb..5d374ffdb9b 100644 --- a/build/projects/Apps NZ/.AL-Go/settings.json +++ b/build/projects/Apps NZ/.AL-Go/settings.json @@ -7,7 +7,6 @@ "../../../src/Apps/NZ/ContosoCoffeeDemoDatasetNZ/app", "../../../src/Apps/NZ/EDocument_NZ/demo data", "../../../src/Apps/NZ/ExpenseAgent_NZ/app", - "../../../src/Apps/NZ/ExpenseAgent_NZ/demo data", "../../../src/Apps/NZ/HybridBCLast_NZ/app", "../../../src/Apps/W1/AgentDesignExperience/app", "../../../src/Apps/W1/AgentSamples/app", diff --git a/build/projects/Apps US/.AL-Go/settings.json b/build/projects/Apps US/.AL-Go/settings.json index 2314078bb0d..b808dd0ef43 100644 --- a/build/projects/Apps US/.AL-Go/settings.json +++ b/build/projects/Apps US/.AL-Go/settings.json @@ -12,7 +12,6 @@ "../../../src/Apps/US/ContosoCoffeeDemoDatasetUS/app", "../../../src/Apps/US/EDocument_US/demo data", "../../../src/Apps/US/ExpenseAgent_US/app", - "../../../src/Apps/US/ExpenseAgent_US/demo data", "../../../src/Apps/US/HybridBCLast_US/app", "../../../src/Apps/US/HybridGP_US/app", "../../../src/Apps/US/HybridSL_US/app", diff --git a/src/Apps/W1/ExpenseAgent/app/app.json b/src/Apps/W1/ExpenseAgent/app/app.json index fadf16fcbc8..3a2443159a0 100644 --- a/src/Apps/W1/ExpenseAgent/app/app.json +++ b/src/Apps/W1/ExpenseAgent/app/app.json @@ -23,56 +23,6 @@ "name": "Expense Agent Demo Data", "publisher": "Microsoft" }, - { - "id": "2019288b-f106-453d-9f34-be7b3c0726f0", - "name": "Expense Agent Demo Data (US)", - "publisher": "Microsoft" - }, - { - "id": "8f6fdf88-d3fd-4e1b-884f-b40344769cef", - "name": "Expense Agent Demo Data (GB)", - "publisher": "Microsoft" - }, - { - "id": "c6922fb3-8129-41d6-b1e9-049d4f6a665c", - "name": "Expense Agent Demo Data (CA)", - "publisher": "Microsoft" - }, - { - "id": "f8711254-7971-48b9-8691-6583be001d92", - "name": "Expense Agent Demo Data (NZ)", - "publisher": "Microsoft" - }, - { - "id": "cdb01fb9-a487-4ca2-b506-c711aea8621d", - "name": "Expense Agent Demo Data (AU)", - "publisher": "Microsoft" - }, - { - "id": "19abefa5-f413-4fb6-97ca-2d2f08285275", - "name": "Expense Agent Demo Data (ES)", - "publisher": "Microsoft" - }, - { - "id": "02547a44-5300-4fab-abb4-5053335ee983", - "name": "Expense Agent Demo Data (DK)", - "publisher": "Microsoft" - }, - { - "id": "fbeb9e2d-0be8-4ecd-a1e9-4d3304cfb75c", - "name": "Expense Agent Demo Data (FR)", - "publisher": "Microsoft" - }, - { - "id": "0105674e-b902-4e4c-9dc0-6c6341dcea11", - "name": "Expense Agent Demo Data (DE)", - "publisher": "Microsoft" - }, - { - "id": "fd09e630-c536-4a0b-a7b2-88deb847544f", - "name": "Expense Agent Demo Data (AT)", - "publisher": "Microsoft" - }, { "id": "d4f8bc4d-8a7e-4008-b8a3-93721589ce98", "name": "Expense Agent (Preview) (NZ)", diff --git a/src/Apps/W1/ExpenseAgent/demo data/app.json b/src/Apps/W1/ExpenseAgent/demo data/app.json index 31d0ccf937b..1dde3ab17fa 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/app.json +++ b/src/Apps/W1/ExpenseAgent/demo data/app.json @@ -25,58 +25,7 @@ "version": "29.0.0.0" } ], - "internalsVisibleTo": [ - { - "id": "2019288b-f106-453d-9f34-be7b3c0726f0", - "name": "Expense Agent Demo Data (US)", - "publisher": "Microsoft" - }, - { - "id": "8f6fdf88-d3fd-4e1b-884f-b40344769cef", - "name": "Expense Agent Demo Data (GB)", - "publisher": "Microsoft" - }, - { - "id": "c6922fb3-8129-41d6-b1e9-049d4f6a665c", - "name": "Expense Agent Demo Data (CA)", - "publisher": "Microsoft" - }, - { - "id": "f8711254-7971-48b9-8691-6583be001d92", - "name": "Expense Agent Demo Data (NZ)", - "publisher": "Microsoft" - }, - { - "id": "cdb01fb9-a487-4ca2-b506-c711aea8621d", - "name": "Expense Agent Demo Data (AU)", - "publisher": "Microsoft" - }, - { - "id": "19abefa5-f413-4fb6-97ca-2d2f08285275", - "name": "Expense Agent Demo Data (ES)", - "publisher": "Microsoft" - }, - { - "id": "02547a44-5300-4fab-abb4-5053335ee983", - "name": "Expense Agent Demo Data (DK)", - "publisher": "Microsoft" - }, - { - "id": "fbeb9e2d-0be8-4ecd-a1e9-4d3304cfb75c", - "name": "Expense Agent Demo Data (FR)", - "publisher": "Microsoft" - }, - { - "id": "0105674e-b902-4e4c-9dc0-6c6341dcea11", - "name": "Expense Agent Demo Data (DE)", - "publisher": "Microsoft" - }, - { - "id": "fd09e630-c536-4a0b-a7b2-88deb847544f", - "name": "Expense Agent Demo Data (AT)", - "publisher": "Microsoft" - } - ], + "internalsVisibleTo": [], "screenshots": [], "platform": "29.0.0.0", "application": "29.0.0.0", From 7c26d4f663b42da486ba00b37110e836f932fdcd Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Wed, 12 Aug 2026 15:56:17 +0530 Subject: [PATCH 19/25] bb fix --- .../Country/AT/CreateExpenseCountryDataAT.Codeunit.al | 5 +++++ .../Country/DE/CreateExpenseCountryDataDE.Codeunit.al | 5 +++++ .../Country/DK/CreateExpenseCountryDataDK.Codeunit.al | 5 +++++ .../Country/ES/CreateExpenseCountryDataES.Codeunit.al | 2 +- .../Country/FR/CreateExpenseCountryDataFR.Codeunit.al | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al index 99e401c773a..46ef37f18da 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al @@ -41,9 +41,14 @@ codeunit 8323 "Create Expense Country Data AT" implements "Expense Agent Country procedure CreateTransactionalData() var CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberAT: Codeunit "Exp. Demo Data Subscriber AT"; begin + BindSubscription(ExpDemoDataSubscriberAT); + CreateExpenseCountryDataW1.CreateTransactionalData(); Codeunit.Run(Codeunit::"Create Expense AT"); + + UnbindSubscription(ExpDemoDataSubscriberAT); end; procedure CreateHistoricalData() diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al index d30fea8384a..d3d977d1b4f 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al @@ -41,9 +41,14 @@ codeunit 8311 "Create Expense Country Data DE" implements "Expense Agent Country procedure CreateTransactionalData() var CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberDE: Codeunit "Exp. Demo Data Subscriber DE"; begin + BindSubscription(ExpDemoDataSubscriberDE); + CreateExpenseCountryDataW1.CreateTransactionalData(); Codeunit.Run(Codeunit::"Create Expense DE"); + + UnbindSubscription(ExpDemoDataSubscriberDE); end; procedure CreateHistoricalData() diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al index 033c1fe637a..6991225150f 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.Codeunit.al @@ -41,9 +41,14 @@ codeunit 8288 "Create Expense Country Data DK" implements "Expense Agent Country procedure CreateTransactionalData() var CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberDK: Codeunit "Exp. Demo Data Subscriber DK"; begin + BindSubscription(ExpDemoDataSubscriberDK); + CreateExpenseCountryDataW1.CreateTransactionalData(); Codeunit.Run(Codeunit::"Create Expense DK"); + + UnbindSubscription(ExpDemoDataSubscriberDK); end; procedure CreateHistoricalData() diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al index 6e20aa3c652..1f8b4fccfbe 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/CreateExpenseCountryDataES.Codeunit.al @@ -20,7 +20,6 @@ codeunit 8275 "Create Expense Country Data ES" implements "Expense Agent Country BindSubscription(CreateExpPostingGrpES); CreateExpenseCountryDataW1.CreateSetupData(); - Codeunit.Run(Codeunit::"Update Employee ES"); Codeunit.Run(Codeunit::"Update Emp. Posting Grp ES"); Codeunit.Run(Codeunit::"Create Exp. Posting Grp ES"); @@ -33,6 +32,7 @@ codeunit 8275 "Create Expense Country Data ES" implements "Expense Agent Country CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; begin CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Update Employee ES"); Codeunit.Run(Codeunit::"Create Exp. Categories ES"); Codeunit.Run(Codeunit::"Create Exp. SubCategories ES"); Codeunit.Run(Codeunit::"Create Exp. Rule Header ES"); diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al index 8407f2a5e46..f614006d8ed 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al @@ -41,9 +41,14 @@ codeunit 8300 "Create Expense Country Data FR" implements "Expense Agent Country procedure CreateTransactionalData() var CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberFR: Codeunit "Exp. Demo Data Subscriber FR"; begin + BindSubscription(ExpDemoDataSubscriberFR); + CreateExpenseCountryDataW1.CreateTransactionalData(); Codeunit.Run(Codeunit::"Create Expense FR"); + + UnbindSubscription(ExpDemoDataSubscriberFR); end; procedure CreateHistoricalData() From cfceb5b166acdead201b50bebd50fb73761bc054 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Sat, 22 Aug 2026 12:19:00 +0530 Subject: [PATCH 20/25] Add Expense Agent demo data for NL, BE, IT, CH, NO, FI, CZ Per-country demo data (GL accounts, posting/employee groups, categories, subcategories, rules, transactions, historical) for the 7 new countries, and register them in build/projects.json and per-country AL-Go settings. Restrict FindGLAccountByName to Posting accounts to avoid Begin-Total name collisions. Set the CZ Employee Posting Group Payables Account when the localized chart leaves it blank. Ignore the mandatory journal template name check when posting expense reports. --- build/projects.json | 9 +- build/projects/Apps BE/.AL-Go/settings.json | 1 + build/projects/Apps CH/.AL-Go/settings.json | 1 + build/projects/Apps CZ/.AL-Go/settings.json | 1 + build/projects/Apps FI/.AL-Go/settings.json | 1 + build/projects/Apps IT/.AL-Go/settings.json | 1 + build/projects/Apps NL/.AL-Go/settings.json | 1 + build/projects/Apps NO/.AL-Go/settings.json | 1 + .../Codeunits/ExpenseReportPost.Codeunit.al | 2 + .../CreateExpGLAccountBE.Codeunit.al | 160 +++++++++++++++ .../CreateExpPostingGrpBE.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpBE.Codeunit.al | 31 +++ .../CreateExpCategoriesBE.Codeunit.al | 31 +++ .../CreateExpRuleConditionBE.Codeunit.al | 26 +++ .../CreateExpRuleHeaderBE.Codeunit.al | 29 +++ .../CreateExpSubCategoriesBE.Codeunit.al | 39 ++++ .../CreateExpenseBE.Codeunit.al | 51 +++++ .../CreatePostedExpReportBE.Codeunit.al | 168 ++++++++++++++++ .../BE/CreateExpenseCountryDataBE.Codeunit.al | 69 +++++++ .../BE/ExpDemoDataSubscriberBE.Codeunit.al | 24 +++ .../BE/ExpenseGLAccountNamesBE.Codeunit.al | 38 ++++ .../CreateExpGLAccountCH.Codeunit.al | 144 ++++++++++++++ .../CreateExpPostingGrpCH.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpCH.Codeunit.al | 29 +++ .../CreateExpCategoriesCH.Codeunit.al | 31 +++ .../CreateExpRuleConditionCH.Codeunit.al | 26 +++ .../CreateExpRuleHeaderCH.Codeunit.al | 29 +++ .../CreateExpSubCategoriesCH.Codeunit.al | 39 ++++ .../CreateExpenseCH.Codeunit.al | 51 +++++ .../CreatePostedExpReportCH.Codeunit.al | 168 ++++++++++++++++ .../CH/CreateExpenseCountryDataCH.Codeunit.al | 61 ++++++ .../CH/ExpenseGLAccountNamesCH.Codeunit.al | 44 +++++ .../CreateExpGLAccountCZ.Codeunit.al | 147 ++++++++++++++ .../CreateExpPostingGrpCZ.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpCZ.Codeunit.al | 48 +++++ .../CreateExpCategoriesCZ.Codeunit.al | 31 +++ .../CreateExpRuleConditionCZ.Codeunit.al | 26 +++ .../CreateExpRuleHeaderCZ.Codeunit.al | 29 +++ .../CreateExpSubCategoriesCZ.Codeunit.al | 39 ++++ .../CreateExpenseCZ.Codeunit.al | 51 +++++ .../CreatePostedExpReportCZ.Codeunit.al | 168 ++++++++++++++++ .../CZ/CreateExpenseCountryDataCZ.Codeunit.al | 61 ++++++ .../CZ/ExpenseGLAccountNamesCZ.Codeunit.al | 50 +++++ .../ExpAgentCountryResolver.Codeunit.al | 14 ++ .../Country/ExpenseAgentCountry.Enum.al | 35 ++++ .../CreateExpGLAccountFI.Codeunit.al | 184 ++++++++++++++++++ .../CreateExpPostingGrpFI.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpFI.Codeunit.al | 31 +++ .../CreateExpCategoriesFI.Codeunit.al | 31 +++ .../CreateExpRuleConditionFI.Codeunit.al | 26 +++ .../CreateExpRuleHeaderFI.Codeunit.al | 29 +++ .../CreateExpSubCategoriesFI.Codeunit.al | 39 ++++ .../CreateExpenseFI.Codeunit.al | 51 +++++ .../CreatePostedExpReportFI.Codeunit.al | 168 ++++++++++++++++ .../FI/CreateExpenseCountryDataFI.Codeunit.al | 69 +++++++ .../FI/ExpDemoDataSubscriberFI.Codeunit.al | 24 +++ .../FI/ExpenseGLAccountNamesFI.Codeunit.al | 32 +++ .../CreateExpGLAccountIT.Codeunit.al | 133 +++++++++++++ .../CreateExpPostingGrpIT.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpIT.Codeunit.al | 29 +++ .../CreateExpCategoriesIT.Codeunit.al | 31 +++ .../CreateExpRuleConditionIT.Codeunit.al | 26 +++ .../CreateExpRuleHeaderIT.Codeunit.al | 29 +++ .../CreateExpSubCategoriesIT.Codeunit.al | 39 ++++ .../CreateExpenseIT.Codeunit.al | 51 +++++ .../CreatePostedExpReportIT.Codeunit.al | 168 ++++++++++++++++ .../IT/CreateExpenseCountryDataIT.Codeunit.al | 69 +++++++ .../IT/ExpDemoDataSubscriberIT.Codeunit.al | 24 +++ .../IT/ExpenseGLAccountNamesIT.Codeunit.al | 50 +++++ .../CreateExpGLAccountNL.Codeunit.al | 131 +++++++++++++ .../CreateExpPostingGrpNL.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpNL.Codeunit.al | 31 +++ .../CreateExpCategoriesNL.Codeunit.al | 31 +++ .../CreateExpRuleConditionNL.Codeunit.al | 26 +++ .../CreateExpRuleHeaderNL.Codeunit.al | 29 +++ .../CreateExpSubCategoriesNL.Codeunit.al | 39 ++++ .../CreateExpenseNL.Codeunit.al | 51 +++++ .../CreatePostedExpReportNL.Codeunit.al | 168 ++++++++++++++++ .../NL/CreateExpenseCountryDataNL.Codeunit.al | 69 +++++++ .../NL/ExpDemoDataSubscriberNL.Codeunit.al | 24 +++ .../NL/ExpenseGLAccountNamesNL.Codeunit.al | 56 ++++++ .../CreateExpGLAccountNO.Codeunit.al | 118 +++++++++++ .../CreateExpPostingGrpNO.Codeunit.al | 64 ++++++ .../UpdateEmpPostingGrpNO.Codeunit.al | 29 +++ .../CreateExpCategoriesNO.Codeunit.al | 31 +++ .../CreateExpRuleConditionNO.Codeunit.al | 26 +++ .../CreateExpRuleHeaderNO.Codeunit.al | 29 +++ .../CreateExpSubCategoriesNO.Codeunit.al | 39 ++++ .../CreateExpenseNO.Codeunit.al | 51 +++++ .../CreatePostedExpReportNO.Codeunit.al | 168 ++++++++++++++++ .../NO/CreateExpenseCountryDataNO.Codeunit.al | 61 ++++++ .../NO/ExpenseGLAccountNamesNO.Codeunit.al | 50 +++++ .../CreateExpenseGLAccount.Codeunit.al | 1 + src/Apps/W1/ExpenseAgent/demo data/app.json | 4 + 94 files changed, 5047 insertions(+), 1 deletion(-) create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpGLAccountBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpPostingGrpBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/UpdateEmpPostingGrpBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpCategoriesBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleConditionBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleHeaderBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpSubCategoriesBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/3. Transactions/CreateExpenseBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/4. Historical/CreatePostedExpReportBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/CreateExpenseCountryDataBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpDemoDataSubscriberBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpenseGLAccountNamesBE.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpGLAccountCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpPostingGrpCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/UpdateEmpPostingGrpCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpCategoriesCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleConditionCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleHeaderCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpSubCategoriesCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/3. Transactions/CreateExpenseCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/4. Historical/CreatePostedExpReportCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/CreateExpenseCountryDataCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CH/ExpenseGLAccountNamesCH.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpGLAccountCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpPostingGrpCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpCategoriesCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleConditionCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleHeaderCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpSubCategoriesCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/3. Transactions/CreateExpenseCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/4. Historical/CreatePostedExpReportCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/CreateExpenseCountryDataCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/CZ/ExpenseGLAccountNamesCZ.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpGLAccountFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpPostingGrpFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/UpdateEmpPostingGrpFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpCategoriesFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleConditionFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleHeaderFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpSubCategoriesFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/3. Transactions/CreateExpenseFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/4. Historical/CreatePostedExpReportFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/CreateExpenseCountryDataFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpDemoDataSubscriberFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpenseGLAccountNamesFI.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpGLAccountIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpPostingGrpIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/UpdateEmpPostingGrpIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpCategoriesIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleConditionIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleHeaderIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpSubCategoriesIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/3. Transactions/CreateExpenseIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/4. Historical/CreatePostedExpReportIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/CreateExpenseCountryDataIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpDemoDataSubscriberIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpenseGLAccountNamesIT.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpGLAccountNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpPostingGrpNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/UpdateEmpPostingGrpNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpCategoriesNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleConditionNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleHeaderNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpSubCategoriesNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/3. Transactions/CreateExpenseNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/4. Historical/CreatePostedExpReportNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/CreateExpenseCountryDataNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpDemoDataSubscriberNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpenseGLAccountNamesNL.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpGLAccountNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpPostingGrpNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/UpdateEmpPostingGrpNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpCategoriesNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleConditionNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleHeaderNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpSubCategoriesNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/3. Transactions/CreateExpenseNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/4. Historical/CreatePostedExpReportNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/CreateExpenseCountryDataNO.Codeunit.al create mode 100644 src/Apps/W1/ExpenseAgent/demo data/Country/NO/ExpenseGLAccountNamesNO.Codeunit.al diff --git a/build/projects.json b/build/projects.json index f373a331e8b..e9a17fe3b3c 100644 --- a/build/projects.json +++ b/build/projects.json @@ -5440,7 +5440,14 @@ "DK", "FR", "DE", - "AT" + "AT", + "NL", + "BE", + "IT", + "CH", + "NO", + "FI", + "CZ" ], "runStaticCodeAnalysis": true, "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", diff --git a/build/projects/Apps BE/.AL-Go/settings.json b/build/projects/Apps BE/.AL-Go/settings.json index 1ce3bf4a26d..99dfe9961b5 100644 --- a/build/projects/Apps BE/.AL-Go/settings.json +++ b/build/projects/Apps BE/.AL-Go/settings.json @@ -55,6 +55,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/ExpenseWithholdingTax/app", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", diff --git a/build/projects/Apps CH/.AL-Go/settings.json b/build/projects/Apps CH/.AL-Go/settings.json index 00ccab2fbdd..a010a031ec0 100644 --- a/build/projects/Apps CH/.AL-Go/settings.json +++ b/build/projects/Apps CH/.AL-Go/settings.json @@ -53,6 +53,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/ExpenseWithholdingTax/app", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", diff --git a/build/projects/Apps CZ/.AL-Go/settings.json b/build/projects/Apps CZ/.AL-Go/settings.json index 85e7c700242..54320abd2af 100644 --- a/build/projects/Apps CZ/.AL-Go/settings.json +++ b/build/projects/Apps CZ/.AL-Go/settings.json @@ -67,6 +67,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/ExpenseWithholdingTax/app", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", diff --git a/build/projects/Apps FI/.AL-Go/settings.json b/build/projects/Apps FI/.AL-Go/settings.json index b687d7d650d..fe6affb13bf 100644 --- a/build/projects/Apps FI/.AL-Go/settings.json +++ b/build/projects/Apps FI/.AL-Go/settings.json @@ -54,6 +54,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/ExpenseWithholdingTax/app", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", diff --git a/build/projects/Apps IT/.AL-Go/settings.json b/build/projects/Apps IT/.AL-Go/settings.json index 15360a46c24..4787bbe153e 100644 --- a/build/projects/Apps IT/.AL-Go/settings.json +++ b/build/projects/Apps IT/.AL-Go/settings.json @@ -54,6 +54,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", "../../../src/Apps/W1/External File Storage - SFTP Connector/App", diff --git a/build/projects/Apps NL/.AL-Go/settings.json b/build/projects/Apps NL/.AL-Go/settings.json index 5938fcf8b40..d2951fa6893 100644 --- a/build/projects/Apps NL/.AL-Go/settings.json +++ b/build/projects/Apps NL/.AL-Go/settings.json @@ -53,6 +53,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/ExpenseWithholdingTax/app", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", diff --git a/build/projects/Apps NO/.AL-Go/settings.json b/build/projects/Apps NO/.AL-Go/settings.json index 2a8a4ebcd4b..c1b490a2f27 100644 --- a/build/projects/Apps NO/.AL-Go/settings.json +++ b/build/projects/Apps NO/.AL-Go/settings.json @@ -56,6 +56,7 @@ "../../../src/Apps/W1/ExcelReports/App", "../../../src/Apps/W1/ExciseTaxes/app", "../../../src/Apps/W1/ExpenseAgent/app", + "../../../src/Apps/W1/ExpenseAgent/demo data", "../../../src/Apps/W1/ExpenseWithholdingTax/app", "../../../src/Apps/W1/External File Storage - Azure Blob Service Connector/App", "../../../src/Apps/W1/External File Storage - Azure File Service Connector/App", diff --git a/src/Apps/W1/ExpenseAgent/app/src/ExpenseReport/Codeunits/ExpenseReportPost.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/ExpenseReport/Codeunits/ExpenseReportPost.Codeunit.al index af7abe1c8bf..0fabebeab48 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/ExpenseReport/Codeunits/ExpenseReportPost.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/ExpenseReport/Codeunits/ExpenseReportPost.Codeunit.al @@ -82,6 +82,8 @@ codeunit 6987 "Expense Report-Post" SourceCodeSetup.TestField(Expense); ExpenseAgentSetup.GetRecordOnce(); + GenJnlPostLine.SetIgnoreJournalTemplNameMandatoryCheck(); + if (ExpenseAgentSetup."Enable Approval Workflow") or ExpenseAgentSetup."Enable Agent" then begin if not PreviewMode then if ExpenseReportHeader.Status <> ExpenseReportHeader.Status::Approved then diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpGLAccountBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpGLAccountBE.Codeunit.al new file mode 100644 index 00000000000..5b71d82ae84 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpGLAccountBE.Codeunit.al @@ -0,0 +1,160 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8413 "Create Exp. GL Account BE" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategoryMgt.GetPrepaidExpenses(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeTravelAdvances(), EmployeeTravelAdvancesName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(CompanyPaidExpenseClearing(), CompanyPaidExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CorporateCardExpenseClearing(), CorporateCardExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetTravelExpense(), 80); + ContosoGLAccount.InsertGLAccount(BusinessMeals(), BusinessMealsName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MileageAllowance(), MileageAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PerDiemAllowance(), PerDiemAllowanceName(), "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"::Purchase, '', '', true, false, false); + + ContosoGLAccount.InsertGLAccount(OtherEmployeeExpenses(), OtherEmployeeExpensesName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Income, 80); + ContosoGLAccount.InsertGLAccount(NonRefundableEmployeeExpenses(), NonRefundableEmployeeExpensesName(), "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"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseRoundingDifferences(), ExpenseRoundingDifferencesName(), "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"::" ", '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(EmployeeTravelAdvancesName(), '416000'); + ContosoGLAccount.AddAccountForLocalization(CompanyPaidExpenseClearingName(), '457100'); + ContosoGLAccount.AddAccountForLocalization(CorporateCardExpenseClearingName(), '457200'); + ContosoGLAccount.AddAccountForLocalization(BusinessMealsName(), '613910'); + ContosoGLAccount.AddAccountForLocalization(MileageAllowanceName(), '613940'); + ContosoGLAccount.AddAccountForLocalization(PerDiemAllowanceName(), '613950'); + ContosoGLAccount.AddAccountForLocalization(OtherEmployeeExpensesName(), '623100'); + ContosoGLAccount.AddAccountForLocalization(NonRefundableEmployeeExpensesName(), '643100'); + ContosoGLAccount.AddAccountForLocalization(ExpenseRoundingDifferencesName(), '655100'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + EmployeeTravelAdvancesTok: Label 'Employee Travel Advances', MaxLength = 100; + CompanyPaidExpenseClearingTok: Label 'Company Paid Expense Clearing', MaxLength = 100; + CorporateCardExpenseClearingTok: Label 'Corporate Card Expense Clearing', MaxLength = 100; + BusinessMealsTok: Label 'Business Meals', MaxLength = 100; + MileageAllowanceTok: Label 'Mileage Allowance', MaxLength = 100; + PerDiemAllowanceTok: Label 'Per-Diem Allowance', MaxLength = 100; + OtherEmployeeExpensesTok: Label 'Other Employee Expenses', MaxLength = 100; + NonRefundableEmployeeExpensesTok: Label 'Non-Refundable Employee Expenses', MaxLength = 100; + ExpenseRoundingDifferencesTok: Label 'Expense Rounding Differences', MaxLength = 100; + + procedure EmployeeTravelAdvances(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeTravelAdvancesName())); + end; + + procedure EmployeeTravelAdvancesName(): Text[100] + begin + exit(EmployeeTravelAdvancesTok); + end; + + procedure CompanyPaidExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyPaidExpenseClearingName())); + end; + + procedure CompanyPaidExpenseClearingName(): Text[100] + begin + exit(CompanyPaidExpenseClearingTok); + end; + + procedure CorporateCardExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CorporateCardExpenseClearingName())); + end; + + procedure CorporateCardExpenseClearingName(): Text[100] + begin + exit(CorporateCardExpenseClearingTok); + end; + + procedure BusinessMeals(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(BusinessMealsName())); + end; + + procedure BusinessMealsName(): Text[100] + begin + exit(BusinessMealsTok); + end; + + procedure MileageAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MileageAllowanceName())); + end; + + procedure MileageAllowanceName(): Text[100] + begin + exit(MileageAllowanceTok); + end; + + procedure PerDiemAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(PerDiemAllowanceName())); + end; + + procedure PerDiemAllowanceName(): Text[100] + begin + exit(PerDiemAllowanceTok); + end; + + procedure OtherEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(OtherEmployeeExpensesName())); + end; + + procedure OtherEmployeeExpensesName(): Text[100] + begin + exit(OtherEmployeeExpensesTok); + end; + + procedure NonRefundableEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonRefundableEmployeeExpensesName())); + end; + + procedure NonRefundableEmployeeExpensesName(): Text[100] + begin + exit(NonRefundableEmployeeExpensesTok); + end; + + procedure ExpenseRoundingDifferences(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(ExpenseRoundingDifferencesName())); + end; + + procedure ExpenseRoundingDifferencesName(): Text[100] + begin + exit(ExpenseRoundingDifferencesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpPostingGrpBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpPostingGrpBE.Codeunit.al new file mode 100644 index 00000000000..f1c3d0e127e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/CreateExpPostingGrpBE.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8414 "Create Exp. Posting Grp BE" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountBE: Codeunit "Create Exp. GL Account BE"; + ExpenseGLAccountNamesBE: Codeunit "Expense GL Account Names BE"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesBE.EntertainmentAndPRName()), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, CreateExpGLAccountBE.BusinessMeals(), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, CreateExpGLAccountBE.MileageAllowance(), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, CreateExpGLAccountBE.OtherEmployeeExpenses(), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountBE.PerDiemAllowance(), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesBE.TravelName()), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesBE.TravelName()), CreateExpGLAccountBE.NonRefundableEmployeeExpenses(), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.ExpenseRoundingDifferences(), CreateExpGLAccountBE.ExpenseRoundingDifferences()); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/UpdateEmpPostingGrpBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/UpdateEmpPostingGrpBE.Codeunit.al new file mode 100644 index 00000000000..c6d068dee10 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/1.Setup Data/UpdateEmpPostingGrpBE.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8415 "Update Emp. Posting Grp BE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountBE: Codeunit "Create Exp. GL Account BE"; + ExpenseGLAccountNamesBE: Codeunit "Expense GL Account Names BE"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesBE.EmployeesPayableName()), CreateExpGLAccountBE.EmployeeTravelAdvances(), CreateExpGLAccountBE.CompanyPaidExpenseClearing(), CreateExpGLAccountBE.CorporateCardExpenseClearing()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpCategoriesBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpCategoriesBE.Codeunit.al new file mode 100644 index 00000000000..5fce4f6ec1f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpCategoriesBE.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8416 "Create Exp. Categories BE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpBE: Codeunit "Create Exp. Posting Grp BE"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpBE.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleConditionBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleConditionBE.Codeunit.al new file mode 100644 index 00000000000..12a0bf07d23 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleConditionBE.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8419 "Create Exp. Rule Condition BE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesBE: Codeunit "Create Exp. Categories BE"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleHeaderBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleHeaderBE.Codeunit.al new file mode 100644 index 00000000000..934b56c4dd5 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpRuleHeaderBE.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8418 "Create Exp. Rule Header BE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesBE: Codeunit "Create Exp. Categories BE"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpSubCategoriesBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpSubCategoriesBE.Codeunit.al new file mode 100644 index 00000000000..cdd7b216f7e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/2.Master Data/CreateExpSubCategoriesBE.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8417 "Create Exp. SubCategories BE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesBE: Codeunit "Create Exp. Categories BE"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesBE.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesBE.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/3. Transactions/CreateExpenseBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/3. Transactions/CreateExpenseBE.Codeunit.al new file mode 100644 index 00000000000..21efa6f1501 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/3. Transactions/CreateExpenseBE.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8420 "Create Expense BE" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesBE: Codeunit "Create Exp. Categories BE"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/4. Historical/CreatePostedExpReportBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/4. Historical/CreatePostedExpReportBE.Codeunit.al new file mode 100644 index 00000000000..17eaec53ce9 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/4. Historical/CreatePostedExpReportBE.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8421 "Create Posted Exp. Report BE" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccountNamesBE: Codeunit "Expense GL Account Names BE"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesBE.SalesResourcesDomName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesBE: Codeunit "Create Exp. Categories BE"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesBE.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/CreateExpenseCountryDataBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/CreateExpenseCountryDataBE.Codeunit.al new file mode 100644 index 00000000000..429acd73870 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/CreateExpenseCountryDataBE.Codeunit.al @@ -0,0 +1,69 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8412 "Create Expense Country Data BE" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountBE: Codeunit "Create Exp. GL Account BE"; + CreateExpPostingGrpBE: Codeunit "Create Exp. Posting Grp BE"; + begin + BindSubscription(CreateExpGLAccountBE); + BindSubscription(CreateExpPostingGrpBE); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp BE"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp BE"); + + UnbindSubscription(CreateExpPostingGrpBE); + UnbindSubscription(CreateExpGLAccountBE); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories BE"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories BE"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header BE"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition BE"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberBE: Codeunit "Exp. Demo Data Subscriber BE"; + begin + BindSubscription(ExpDemoDataSubscriberBE); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense BE"); + + UnbindSubscription(ExpDemoDataSubscriberBE); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberBE: Codeunit "Exp. Demo Data Subscriber BE"; + CreatePostedExpReportBE: Codeunit "Create Posted Exp. Report BE"; + begin + BindSubscription(ExpDemoDataSubscriberBE); + BindSubscription(CreatePostedExpReportBE); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report BE"); + + UnbindSubscription(CreatePostedExpReportBE); + UnbindSubscription(ExpDemoDataSubscriberBE); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpDemoDataSubscriberBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpDemoDataSubscriberBE.Codeunit.al new file mode 100644 index 00000000000..19a5c5c3e19 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpDemoDataSubscriberBE.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8422 "Exp. Demo Data Subscriber BE" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpenseGLAccountNamesBE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpenseGLAccountNamesBE.Codeunit.al new file mode 100644 index 00000000000..e894b6d9d5d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/BE/ExpenseGLAccountNamesBE.Codeunit.al @@ -0,0 +1,38 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8479 "Expense GL Account Names BE" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + EmployeesPayableTok: Label 'Employees Payable', MaxLength = 100; + TravelTok: Label 'Travel', MaxLength = 100; + EntertainmentAndPRTok: Label 'Entertainment and PR', MaxLength = 100; + SalesResourcesDomTok: Label 'Sales, Resources - Dom.', MaxLength = 100; + + procedure EmployeesPayableName(): Text[100] + begin + exit(EmployeesPayableTok); + end; + + procedure TravelName(): Text[100] + begin + exit(TravelTok); + end; + + procedure EntertainmentAndPRName(): Text[100] + begin + exit(EntertainmentAndPRTok); + end; + + procedure SalesResourcesDomName(): Text[100] + begin + exit(SalesResourcesDomTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpGLAccountCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpGLAccountCH.Codeunit.al new file mode 100644 index 00000000000..26baa0c96ef --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpGLAccountCH.Codeunit.al @@ -0,0 +1,144 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8435 "Create Exp. GL Account CH" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategoryMgt.GetPrepaidExpenses(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeExpenseAdvances(), EmployeeExpenseAdvancesName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeExpenseReimbursementsPayable(), EmployeeExpenseReimbursementsPayableName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CompanyCardExpensesPayable(), CompanyCardExpensesPayableName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CompanyPaidExpenseClearing(), CompanyPaidExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetTravelExpense(), 80); + ContosoGLAccount.InsertGLAccount(MileageAllowance(), MileageAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PerDiemAllowance(), PerDiemAllowanceName(), "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"::Purchase, '', '', true, false, false); + + ContosoGLAccount.InsertGLAccount(EntertainmentExpenses(), EntertainmentExpensesName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MealsAndHospitalityExpenses(), MealsAndHospitalityExpensesName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(EmployeeExpenseAdvancesName(), '1305'); + ContosoGLAccount.AddAccountForLocalization(EmployeeExpenseReimbursementsPayableName(), '2270'); + ContosoGLAccount.AddAccountForLocalization(CompanyCardExpensesPayableName(), '2271'); + ContosoGLAccount.AddAccountForLocalization(CompanyPaidExpenseClearingName(), '2272'); + ContosoGLAccount.AddAccountForLocalization(MileageAllowanceName(), '5821'); + ContosoGLAccount.AddAccountForLocalization(PerDiemAllowanceName(), '5822'); + ContosoGLAccount.AddAccountForLocalization(MealsAndHospitalityExpensesName(), '5841'); + ContosoGLAccount.AddAccountForLocalization(EntertainmentExpensesName(), '5840'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + EmployeeExpenseAdvancesTok: Label 'Employee Expense Advances', MaxLength = 100; + EmployeeExpenseReimbursementsPayableTok: Label 'Employee Expense Reimbursements Payable', MaxLength = 100; + CompanyCardExpensesPayableTok: Label 'Company Card Expenses Payable', MaxLength = 100; + CompanyPaidExpenseClearingTok: Label 'Company-Paid Expense Clearing', MaxLength = 100; + MileageAllowanceTok: Label 'Mileage Allowance', MaxLength = 100; + PerDiemAllowanceTok: Label 'Per Diem Allowance', MaxLength = 100; + EntertainmentExpensesTok: Label 'Entertainment Expenses', MaxLength = 100; + MealsAndHospitalityExpensesTok: Label 'Meals and Hospitality Expenses', MaxLength = 100; + + procedure EmployeeExpenseAdvances(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpenseAdvancesName())); + end; + + procedure EmployeeExpenseAdvancesName(): Text[100] + begin + exit(EmployeeExpenseAdvancesTok); + end; + + procedure EmployeeExpenseReimbursementsPayable(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpenseReimbursementsPayableName())); + end; + + procedure EmployeeExpenseReimbursementsPayableName(): Text[100] + begin + exit(EmployeeExpenseReimbursementsPayableTok); + end; + + procedure CompanyCardExpensesPayable(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCardExpensesPayableName())); + end; + + procedure CompanyCardExpensesPayableName(): Text[100] + begin + exit(CompanyCardExpensesPayableTok); + end; + + procedure CompanyPaidExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyPaidExpenseClearingName())); + end; + + procedure CompanyPaidExpenseClearingName(): Text[100] + begin + exit(CompanyPaidExpenseClearingTok); + end; + + procedure MileageAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MileageAllowanceName())); + end; + + procedure MileageAllowanceName(): Text[100] + begin + exit(MileageAllowanceTok); + end; + + procedure PerDiemAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(PerDiemAllowanceName())); + end; + + procedure PerDiemAllowanceName(): Text[100] + begin + exit(PerDiemAllowanceTok); + end; + + procedure EntertainmentExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EntertainmentExpensesName())); + end; + + procedure EntertainmentExpensesName(): Text[100] + begin + exit(EntertainmentExpensesTok); + end; + + procedure MealsAndHospitalityExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MealsAndHospitalityExpensesName())); + end; + + procedure MealsAndHospitalityExpensesName(): Text[100] + begin + exit(MealsAndHospitalityExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpPostingGrpCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpPostingGrpCH.Codeunit.al new file mode 100644 index 00000000000..834eeb2ba40 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/CreateExpPostingGrpCH.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8436 "Create Exp. Posting Grp CH" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountCH: Codeunit "Create Exp. GL Account CH"; + ExpenseGLAccountNamesCH: Codeunit "Expense GL Account Names CH"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, CreateExpGLAccountCH.EntertainmentExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, CreateExpGLAccountCH.MealsAndHospitalityExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, CreateExpGLAccountCH.MileageAllowance(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.MiscCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountCH.PerDiemAllowance(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.TravelCostsCustomerServiceName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.TravelCostsCustomerServiceName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.OtherPersonnelCostsName()), CreateExpGLAccountCH.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.RoundingDifferencesPurchaseName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/UpdateEmpPostingGrpCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/UpdateEmpPostingGrpCH.Codeunit.al new file mode 100644 index 00000000000..85b3000ef4b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/1.Setup Data/UpdateEmpPostingGrpCH.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8437 "Update Emp. Posting Grp CH" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountCH: Codeunit "Create Exp. GL Account CH"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), CreateExpGLAccountCH.EmployeeExpenseReimbursementsPayable(), CreateExpGLAccountCH.EmployeeExpenseAdvances(), CreateExpGLAccountCH.CompanyPaidExpenseClearing(), CreateExpGLAccountCH.CompanyCardExpensesPayable()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpCategoriesCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpCategoriesCH.Codeunit.al new file mode 100644 index 00000000000..0e7d2278161 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpCategoriesCH.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8438 "Create Exp. Categories CH" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpCH: Codeunit "Create Exp. Posting Grp CH"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpCH.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleConditionCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleConditionCH.Codeunit.al new file mode 100644 index 00000000000..b10d76cc0f7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleConditionCH.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8441 "Create Exp. Rule Condition CH" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesCH: Codeunit "Create Exp. Categories CH"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleHeaderCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleHeaderCH.Codeunit.al new file mode 100644 index 00000000000..fd42991cb27 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpRuleHeaderCH.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8440 "Create Exp. Rule Header CH" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesCH: Codeunit "Create Exp. Categories CH"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpSubCategoriesCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpSubCategoriesCH.Codeunit.al new file mode 100644 index 00000000000..08ae423d272 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/2.Master Data/CreateExpSubCategoriesCH.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8439 "Create Exp. SubCategories CH" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesCH: Codeunit "Create Exp. Categories CH"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesCH.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesCH.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/3. Transactions/CreateExpenseCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/3. Transactions/CreateExpenseCH.Codeunit.al new file mode 100644 index 00000000000..9f018cce239 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/3. Transactions/CreateExpenseCH.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8442 "Create Expense CH" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesCH: Codeunit "Create Exp. Categories CH"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/4. Historical/CreatePostedExpReportCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/4. Historical/CreatePostedExpReportCH.Codeunit.al new file mode 100644 index 00000000000..ccbaa87cb6e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/4. Historical/CreatePostedExpReportCH.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8443 "Create Posted Exp. Report CH" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesCH: Codeunit "Expense GL Account Names CH"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCH.JobSalesAppliedAccountName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesCH: Codeunit "Create Exp. Categories CH"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCH.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/CreateExpenseCountryDataCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/CreateExpenseCountryDataCH.Codeunit.al new file mode 100644 index 00000000000..91b4eb18fd4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/CreateExpenseCountryDataCH.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8434 "Create Expense Country Data CH" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountCH: Codeunit "Create Exp. GL Account CH"; + CreateExpPostingGrpCH: Codeunit "Create Exp. Posting Grp CH"; + begin + BindSubscription(CreateExpGLAccountCH); + BindSubscription(CreateExpPostingGrpCH); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp CH"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp CH"); + + UnbindSubscription(CreateExpPostingGrpCH); + UnbindSubscription(CreateExpGLAccountCH); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories CH"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories CH"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header CH"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition CH"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense CH"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportCH: Codeunit "Create Posted Exp. Report CH"; + begin + BindSubscription(CreatePostedExpReportCH); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report CH"); + + UnbindSubscription(CreatePostedExpReportCH); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CH/ExpenseGLAccountNamesCH.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/ExpenseGLAccountNamesCH.Codeunit.al new file mode 100644 index 00000000000..0a438cf581d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CH/ExpenseGLAccountNamesCH.Codeunit.al @@ -0,0 +1,44 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8481 "Expense GL Account Names CH" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + RoundingDifferencesPurchaseTok: Label 'Rounding Differences Purchase', MaxLength = 100; + OtherPersonnelCostsTok: Label 'Other Personnel Costs', MaxLength = 100; + TravelCostsCustomerServiceTok: Label 'Travel Costs, Customer Service', MaxLength = 100; + MiscCostsTok: Label 'Misc. Costs', MaxLength = 100; + JobSalesAppliedAccountTok: Label 'Job Sales Applied Account', MaxLength = 100; + + procedure RoundingDifferencesPurchaseName(): Text[100] + begin + exit(RoundingDifferencesPurchaseTok); + end; + + procedure OtherPersonnelCostsName(): Text[100] + begin + exit(OtherPersonnelCostsTok); + end; + + procedure TravelCostsCustomerServiceName(): Text[100] + begin + exit(TravelCostsCustomerServiceTok); + end; + + procedure MiscCostsName(): Text[100] + begin + exit(MiscCostsTok); + end; + + procedure JobSalesAppliedAccountName(): Text[100] + begin + exit(JobSalesAppliedAccountTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpGLAccountCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpGLAccountCZ.Codeunit.al new file mode 100644 index 00000000000..8ebd69d4f1a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpGLAccountCZ.Codeunit.al @@ -0,0 +1,147 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8468 "Create Exp. GL Account CZ" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := CopyStr(GLAccountCategoryMgt.GetCash(), 1, MaxStrLen(SubCategory)); + ContosoGLAccount.InsertGLAccount(CompanyCardExpensesPayable(), CompanyCardExpensesPayableName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := CopyStr(GLAccountCategoryMgt.GetPrepaidExpenses(), 1, MaxStrLen(SubCategory)); + ContosoGLAccount.InsertGLAccount(EmployeeExpenseAdvances(), EmployeeExpenseAdvancesName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := TravelExpenseSubcategoryTok; + ContosoGLAccount.InsertGLAccount(MileageAllowance(), MileageAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PerDiemAllowance(), PerDiemAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CarRentalExpenses(), CarRentalExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MealsAndHospitalityExpenses(), MealsAndHospitalityExpensesName(), "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"::Purchase, '', '', true, false, false); + + SubCategory := IncomeSubcategoryTok; + ContosoGLAccount.InsertGLAccount(NonRefundableEmployeeExpenses(), NonRefundableEmployeeExpensesName(), "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"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseRoundingDifferences(), ExpenseRoundingDifferencesName(), "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"::" ", '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCardExpensesPayableName(), '325200'); + ContosoGLAccount.AddAccountForLocalization(EmployeeExpenseAdvancesName(), '335100'); + ContosoGLAccount.AddAccountForLocalization(MileageAllowanceName(), '512200'); + ContosoGLAccount.AddAccountForLocalization(PerDiemAllowanceName(), '512300'); + ContosoGLAccount.AddAccountForLocalization(CarRentalExpensesName(), '512400'); + ContosoGLAccount.AddAccountForLocalization(MealsAndHospitalityExpensesName(), '513200'); + ContosoGLAccount.AddAccountForLocalization(NonRefundableEmployeeExpensesName(), '548200'); + ContosoGLAccount.AddAccountForLocalization(ExpenseRoundingDifferencesName(), '548900'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + TravelExpenseSubcategoryTok: Label 'A.3. Services', MaxLength = 80, Locked = true; + IncomeSubcategoryTok: Label 'III.3. Another Operating Revenues', MaxLength = 80, Locked = true; + CompanyCardExpensesPayableTok: Label 'Company Card Expenses Payable', MaxLength = 100; + EmployeeExpenseAdvancesTok: Label 'Employee Expense Advances', MaxLength = 100; + MileageAllowanceTok: Label 'Mileage Allowance', MaxLength = 100; + PerDiemAllowanceTok: Label 'Per Diem Allowance', MaxLength = 100; + CarRentalExpensesTok: Label 'Car Rental Expenses', MaxLength = 100; + MealsAndHospitalityExpensesTok: Label 'Meals and Hospitality Expenses', MaxLength = 100; + NonRefundableEmployeeExpensesTok: Label 'Non-Refundable Employee Expenses', MaxLength = 100; + ExpenseRoundingDifferencesTok: Label 'Expense Rounding Differences', MaxLength = 100; + + procedure CompanyCardExpensesPayable(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCardExpensesPayableName())); + end; + + procedure CompanyCardExpensesPayableName(): Text[100] + begin + exit(CompanyCardExpensesPayableTok); + end; + + procedure EmployeeExpenseAdvances(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpenseAdvancesName())); + end; + + procedure EmployeeExpenseAdvancesName(): Text[100] + begin + exit(EmployeeExpenseAdvancesTok); + end; + + procedure MileageAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MileageAllowanceName())); + end; + + procedure MileageAllowanceName(): Text[100] + begin + exit(MileageAllowanceTok); + end; + + procedure PerDiemAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(PerDiemAllowanceName())); + end; + + procedure PerDiemAllowanceName(): Text[100] + begin + exit(PerDiemAllowanceTok); + end; + + procedure CarRentalExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CarRentalExpensesName())); + end; + + procedure CarRentalExpensesName(): Text[100] + begin + exit(CarRentalExpensesTok); + end; + + procedure MealsAndHospitalityExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MealsAndHospitalityExpensesName())); + end; + + procedure MealsAndHospitalityExpensesName(): Text[100] + begin + exit(MealsAndHospitalityExpensesTok); + end; + + procedure NonRefundableEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonRefundableEmployeeExpensesName())); + end; + + procedure NonRefundableEmployeeExpensesName(): Text[100] + begin + exit(NonRefundableEmployeeExpensesTok); + end; + + procedure ExpenseRoundingDifferences(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(ExpenseRoundingDifferencesName())); + end; + + procedure ExpenseRoundingDifferencesName(): Text[100] + begin + exit(ExpenseRoundingDifferencesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpPostingGrpCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpPostingGrpCZ.Codeunit.al new file mode 100644 index 00000000000..9e057d391de --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/CreateExpPostingGrpCZ.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8469 "Create Exp. Posting Grp CZ" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountCZ: Codeunit "Create Exp. GL Account CZ"; + ExpenseGLAccountNamesCZ: Codeunit "Expense GL Account Names CZ"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.RepresentationCostsName()), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, CreateExpGLAccountCZ.MealsAndHospitalityExpenses(), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, CreateExpGLAccountCZ.MileageAllowance(), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountCZ.PerDiemAllowance(), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, CreateExpGLAccountCZ.CarRentalExpenses(), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.TravelExpensesName()), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.OtherOperatingExpensesName()), CreateExpGLAccountCZ.NonRefundableEmployeeExpenses(), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.ExpenseRoundingDifferences(), CreateExpGLAccountCZ.ExpenseRoundingDifferences()); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al new file mode 100644 index 00000000000..9fc1a5d9e01 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al @@ -0,0 +1,48 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; +using Microsoft.HumanResources.Employee; + +codeunit 8470 "Update Emp. Posting Grp CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountCZ: Codeunit "Create Exp. GL Account CZ"; + ExpenseGLAccountNamesCZ: Codeunit "Expense GL Account Names CZ"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.PayablesToEmployeesName()), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.CompanyCardExpensesPayable(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.BankAccountKBName())); + ContosoExpenseAgent.SetOverwriteData(false); + + UpdatePayablesAccountInEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.PayablesToEmployeesName())); + end; + + local procedure UpdatePayablesAccountInEmployeePostingGroup(EmployeePostingGroupCode: Code[20]; PayablesAccount: Code[20]) + var + EmployeePostingGroup: Record "Employee Posting Group"; + begin + if not EmployeePostingGroup.Get(EmployeePostingGroupCode) then + exit; + + if EmployeePostingGroup."Payables Account" <> '' then + exit; + + EmployeePostingGroup.Validate("Payables Account", PayablesAccount); + EmployeePostingGroup.Modify(true); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpCategoriesCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpCategoriesCZ.Codeunit.al new file mode 100644 index 00000000000..5e3be55c652 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpCategoriesCZ.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8471 "Create Exp. Categories CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpCZ: Codeunit "Create Exp. Posting Grp CZ"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpCZ.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleConditionCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleConditionCZ.Codeunit.al new file mode 100644 index 00000000000..86cfb724c46 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleConditionCZ.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8474 "Create Exp. Rule Condition CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesCZ: Codeunit "Create Exp. Categories CZ"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleHeaderCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleHeaderCZ.Codeunit.al new file mode 100644 index 00000000000..dee631d5bca --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpRuleHeaderCZ.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8473 "Create Exp. Rule Header CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesCZ: Codeunit "Create Exp. Categories CZ"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpSubCategoriesCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpSubCategoriesCZ.Codeunit.al new file mode 100644 index 00000000000..c46ab185b00 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/2.Master Data/CreateExpSubCategoriesCZ.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8472 "Create Exp. SubCategories CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesCZ: Codeunit "Create Exp. Categories CZ"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesCZ.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesCZ.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/3. Transactions/CreateExpenseCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/3. Transactions/CreateExpenseCZ.Codeunit.al new file mode 100644 index 00000000000..7aef7a6e10c --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/3. Transactions/CreateExpenseCZ.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8475 "Create Expense CZ" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesCZ: Codeunit "Create Exp. Categories CZ"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/4. Historical/CreatePostedExpReportCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/4. Historical/CreatePostedExpReportCZ.Codeunit.al new file mode 100644 index 00000000000..783d8c75811 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/4. Historical/CreatePostedExpReportCZ.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8476 "Create Posted Exp. Report CZ" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesCZ: Codeunit "Expense GL Account Names CZ"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.SalesGoodsDomesticName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesCZ: Codeunit "Create Exp. Categories CZ"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesCZ.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/CreateExpenseCountryDataCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/CreateExpenseCountryDataCZ.Codeunit.al new file mode 100644 index 00000000000..10a8e7a2cac --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/CreateExpenseCountryDataCZ.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8467 "Create Expense Country Data CZ" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountCZ: Codeunit "Create Exp. GL Account CZ"; + CreateExpPostingGrpCZ: Codeunit "Create Exp. Posting Grp CZ"; + begin + BindSubscription(CreateExpGLAccountCZ); + BindSubscription(CreateExpPostingGrpCZ); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp CZ"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp CZ"); + + UnbindSubscription(CreateExpPostingGrpCZ); + UnbindSubscription(CreateExpGLAccountCZ); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories CZ"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories CZ"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header CZ"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition CZ"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense CZ"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportCZ: Codeunit "Create Posted Exp. Report CZ"; + begin + BindSubscription(CreatePostedExpReportCZ); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report CZ"); + + UnbindSubscription(CreatePostedExpReportCZ); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/ExpenseGLAccountNamesCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/ExpenseGLAccountNamesCZ.Codeunit.al new file mode 100644 index 00000000000..77063fd44a8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/ExpenseGLAccountNamesCZ.Codeunit.al @@ -0,0 +1,50 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8484 "Expense GL Account Names CZ" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + BankAccountKBTok: Label 'Bank Account - KB', MaxLength = 100; + PayablesToEmployeesTok: Label 'Payables to employees', MaxLength = 100; + TravelExpensesTok: Label 'Travel expenses', MaxLength = 100; + RepresentationCostsTok: Label 'Representation costs', MaxLength = 100; + OtherOperatingExpensesTok: Label 'Other operating expenses', MaxLength = 100; + SalesGoodsDomesticTok: Label 'Sales goods - domestic', MaxLength = 100; + + procedure BankAccountKBName(): Text[100] + begin + exit(BankAccountKBTok); + end; + + procedure PayablesToEmployeesName(): Text[100] + begin + exit(PayablesToEmployeesTok); + end; + + procedure TravelExpensesName(): Text[100] + begin + exit(TravelExpensesTok); + end; + + procedure RepresentationCostsName(): Text[100] + begin + exit(RepresentationCostsTok); + end; + + procedure OtherOperatingExpensesName(): Text[100] + begin + exit(OtherOperatingExpensesTok); + end; + + procedure SalesGoodsDomesticName(): Text[100] + begin + exit(SalesGoodsDomesticTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al index 46f339e6ac9..74943664145 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al @@ -43,6 +43,20 @@ codeunit 8221 "Exp. Agent Country Resolver" exit(Country::DE); 'AT': exit(Country::AT); + 'NL': + exit(Country::NL); + 'BE': + exit(Country::BE); + 'IT': + exit(Country::IT); + 'CH': + exit(Country::CH); + 'NO': + exit(Country::NO); + 'FI': + exit(Country::FI); + 'CZ': + exit(Country::CZ); end; exit(Country::Default); end; diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al index 746aa923bbd..70e12148bf9 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -63,4 +63,39 @@ enum 8221 "Expense Agent Country" implements "Expense Agent Country Data" Caption = 'AT'; Implementation = "Expense Agent Country Data" = "Create Expense Country Data AT"; } + value(11; NL) + { + Caption = 'NL'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data NL"; + } + value(12; BE) + { + Caption = 'BE'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data BE"; + } + value(13; IT) + { + Caption = 'IT'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data IT"; + } + value(14; CH) + { + Caption = 'CH'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data CH"; + } + value(15; NO) + { + Caption = 'NO'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data NO"; + } + value(16; FI) + { + Caption = 'FI'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data FI"; + } + value(17; CZ) + { + Caption = 'CZ'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data CZ"; + } } diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpGLAccountFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpGLAccountFI.Codeunit.al new file mode 100644 index 00000000000..1dbdb2ddbd5 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpGLAccountFI.Codeunit.al @@ -0,0 +1,184 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8457 "Create Exp. GL Account FI" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(CompanyCardExpenseClearing(), CompanyCardExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CompanyPaidExpenseClearing(), CompanyPaidExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetTravelExpense(), 80); + ContosoGLAccount.InsertGLAccount(BusinessMealExpenses(), BusinessMealExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(MileageAllowance(), MileageAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PerDiemAllowance(), PerDiemAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CarRentalExpenses(), CarRentalExpensesName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherTravelExpenses(), OtherTravelExpensesName(), "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"::Purchase, '', '', true, false, false); + + ContosoGLAccount.InsertGLAccount(EntertainmentExpenses(), EntertainmentExpensesName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherEmployeeExpenses(), OtherEmployeeExpensesName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Income, 80); + ContosoGLAccount.InsertGLAccount(NonRefundableEmployeeExpenses(), NonRefundableEmployeeExpensesName(), "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"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseRoundingDifferences(), ExpenseRoundingDifferencesName(), "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"::" ", '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CompanyCardExpenseClearingName(), '2916'); + ContosoGLAccount.AddAccountForLocalization(CompanyPaidExpenseClearingName(), '2917'); + ContosoGLAccount.AddAccountForLocalization(EntertainmentExpensesName(), '6160'); + ContosoGLAccount.AddAccountForLocalization(BusinessMealExpensesName(), '6161'); + ContosoGLAccount.AddAccountForLocalization(MileageAllowanceName(), '6162'); + ContosoGLAccount.AddAccountForLocalization(PerDiemAllowanceName(), '6163'); + ContosoGLAccount.AddAccountForLocalization(CarRentalExpensesName(), '6164'); + ContosoGLAccount.AddAccountForLocalization(OtherTravelExpensesName(), '6165'); + ContosoGLAccount.AddAccountForLocalization(OtherEmployeeExpensesName(), '6166'); + ContosoGLAccount.AddAccountForLocalization(NonRefundableEmployeeExpensesName(), '6167'); + ContosoGLAccount.AddAccountForLocalization(ExpenseRoundingDifferencesName(), '6168'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + CompanyCardExpenseClearingTok: Label 'Company Card Expense Clearing', MaxLength = 100; + CompanyPaidExpenseClearingTok: Label 'Company-Paid Expense Clearing', MaxLength = 100; + EntertainmentExpensesTok: Label 'Entertainment Expenses', MaxLength = 100; + BusinessMealExpensesTok: Label 'Business Meal Expenses', MaxLength = 100; + MileageAllowanceTok: Label 'Mileage Allowance', MaxLength = 100; + PerDiemAllowanceTok: Label 'Per-Diem Allowance', MaxLength = 100; + CarRentalExpensesTok: Label 'Car Rental Expenses', MaxLength = 100; + OtherTravelExpensesTok: Label 'Other Travel Expenses', MaxLength = 100; + OtherEmployeeExpensesTok: Label 'Other Employee Expenses', MaxLength = 100; + NonRefundableEmployeeExpensesTok: Label 'Non-Refundable Employee Expenses', MaxLength = 100; + ExpenseRoundingDifferencesTok: Label 'Expense Rounding Differences', MaxLength = 100; + + procedure CompanyCardExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyCardExpenseClearingName())); + end; + + procedure CompanyCardExpenseClearingName(): Text[100] + begin + exit(CompanyCardExpenseClearingTok); + end; + + procedure CompanyPaidExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyPaidExpenseClearingName())); + end; + + procedure CompanyPaidExpenseClearingName(): Text[100] + begin + exit(CompanyPaidExpenseClearingTok); + end; + + procedure EntertainmentExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EntertainmentExpensesName())); + end; + + procedure EntertainmentExpensesName(): Text[100] + begin + exit(EntertainmentExpensesTok); + end; + + procedure BusinessMealExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(BusinessMealExpensesName())); + end; + + procedure BusinessMealExpensesName(): Text[100] + begin + exit(BusinessMealExpensesTok); + end; + + procedure MileageAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MileageAllowanceName())); + end; + + procedure MileageAllowanceName(): Text[100] + begin + exit(MileageAllowanceTok); + end; + + procedure PerDiemAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(PerDiemAllowanceName())); + end; + + procedure PerDiemAllowanceName(): Text[100] + begin + exit(PerDiemAllowanceTok); + end; + + procedure CarRentalExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CarRentalExpensesName())); + end; + + procedure CarRentalExpensesName(): Text[100] + begin + exit(CarRentalExpensesTok); + end; + + procedure OtherTravelExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(OtherTravelExpensesName())); + end; + + procedure OtherTravelExpensesName(): Text[100] + begin + exit(OtherTravelExpensesTok); + end; + + procedure OtherEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(OtherEmployeeExpensesName())); + end; + + procedure OtherEmployeeExpensesName(): Text[100] + begin + exit(OtherEmployeeExpensesTok); + end; + + procedure NonRefundableEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonRefundableEmployeeExpensesName())); + end; + + procedure NonRefundableEmployeeExpensesName(): Text[100] + begin + exit(NonRefundableEmployeeExpensesTok); + end; + + procedure ExpenseRoundingDifferences(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(ExpenseRoundingDifferencesName())); + end; + + procedure ExpenseRoundingDifferencesName(): Text[100] + begin + exit(ExpenseRoundingDifferencesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpPostingGrpFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpPostingGrpFI.Codeunit.al new file mode 100644 index 00000000000..2b194751753 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/CreateExpPostingGrpFI.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8458 "Create Exp. Posting Grp FI" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountFI: Codeunit "Create Exp. GL Account FI"; + ExpenseGLAccountNamesFI: Codeunit "Expense GL Account Names FI"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.EntertainmentExpenses(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.BusinessMealExpenses(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.MileageAllowance(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.OtherEmployeeExpenses(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.PerDiemAllowance(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.OtherTravelExpenses(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, CreateExpGLAccountFI.CarRentalExpenses(), CreateExpGLAccountFI.NonRefundableEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.ExpenseRoundingDifferences(), CreateExpGLAccountFI.ExpenseRoundingDifferences()); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/UpdateEmpPostingGrpFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/UpdateEmpPostingGrpFI.Codeunit.al new file mode 100644 index 00000000000..315f9420b8a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/1.Setup Data/UpdateEmpPostingGrpFI.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8459 "Update Emp. Posting Grp FI" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountFI: Codeunit "Create Exp. GL Account FI"; + ExpenseGLAccountNamesFI: Codeunit "Expense GL Account Names FI"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.EmployeesPayableName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.Otherreceivables1Name()), CreateExpGLAccountFI.CompanyPaidExpenseClearing(), CreateExpGLAccountFI.CompanyCardExpenseClearing()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpCategoriesFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpCategoriesFI.Codeunit.al new file mode 100644 index 00000000000..a1746b5d6f1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpCategoriesFI.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8460 "Create Exp. Categories FI" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpFI: Codeunit "Create Exp. Posting Grp FI"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpFI.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleConditionFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleConditionFI.Codeunit.al new file mode 100644 index 00000000000..f91e80f2fa4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleConditionFI.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8463 "Create Exp. Rule Condition FI" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesFI: Codeunit "Create Exp. Categories FI"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleHeaderFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleHeaderFI.Codeunit.al new file mode 100644 index 00000000000..88956093a3f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpRuleHeaderFI.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8462 "Create Exp. Rule Header FI" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesFI: Codeunit "Create Exp. Categories FI"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpSubCategoriesFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpSubCategoriesFI.Codeunit.al new file mode 100644 index 00000000000..41d89751bbb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/2.Master Data/CreateExpSubCategoriesFI.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8461 "Create Exp. SubCategories FI" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesFI: Codeunit "Create Exp. Categories FI"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesFI.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesFI.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/3. Transactions/CreateExpenseFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/3. Transactions/CreateExpenseFI.Codeunit.al new file mode 100644 index 00000000000..dffd0758d5e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/3. Transactions/CreateExpenseFI.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8464 "Create Expense FI" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesFI: Codeunit "Create Exp. Categories FI"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/4. Historical/CreatePostedExpReportFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/4. Historical/CreatePostedExpReportFI.Codeunit.al new file mode 100644 index 00000000000..e61c380ca94 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/4. Historical/CreatePostedExpReportFI.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8465 "Create Posted Exp. Report FI" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesFI: Codeunit "Expense GL Account Names FI"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesFI.SalesofgoodsdomName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesFI: Codeunit "Create Exp. Categories FI"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesFI.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/CreateExpenseCountryDataFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/CreateExpenseCountryDataFI.Codeunit.al new file mode 100644 index 00000000000..da3c8d4eb9a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/CreateExpenseCountryDataFI.Codeunit.al @@ -0,0 +1,69 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8456 "Create Expense Country Data FI" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountFI: Codeunit "Create Exp. GL Account FI"; + CreateExpPostingGrpFI: Codeunit "Create Exp. Posting Grp FI"; + begin + BindSubscription(CreateExpGLAccountFI); + BindSubscription(CreateExpPostingGrpFI); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp FI"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp FI"); + + UnbindSubscription(CreateExpPostingGrpFI); + UnbindSubscription(CreateExpGLAccountFI); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories FI"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories FI"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header FI"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition FI"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberFI: Codeunit "Exp. Demo Data Subscriber FI"; + begin + BindSubscription(ExpDemoDataSubscriberFI); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense FI"); + + UnbindSubscription(ExpDemoDataSubscriberFI); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberFI: Codeunit "Exp. Demo Data Subscriber FI"; + CreatePostedExpReportFI: Codeunit "Create Posted Exp. Report FI"; + begin + BindSubscription(ExpDemoDataSubscriberFI); + BindSubscription(CreatePostedExpReportFI); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report FI"); + + UnbindSubscription(CreatePostedExpReportFI); + UnbindSubscription(ExpDemoDataSubscriberFI); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpDemoDataSubscriberFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpDemoDataSubscriberFI.Codeunit.al new file mode 100644 index 00000000000..977c7cdfd42 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpDemoDataSubscriberFI.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8466 "Exp. Demo Data Subscriber FI" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpenseGLAccountNamesFI.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpenseGLAccountNamesFI.Codeunit.al new file mode 100644 index 00000000000..38a5020518c --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FI/ExpenseGLAccountNamesFI.Codeunit.al @@ -0,0 +1,32 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8483 "Expense GL Account Names FI" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + Otherreceivables1Tok: Label 'Otherreceivables1', MaxLength = 100; + EmployeesPayableTok: Label 'Employees Payable', MaxLength = 100; + SalesofgoodsdomTok: Label 'Salesofgoodsdom', MaxLength = 100; + + procedure Otherreceivables1Name(): Text[100] + begin + exit(Otherreceivables1Tok); + end; + + procedure EmployeesPayableName(): Text[100] + begin + exit(EmployeesPayableTok); + end; + + procedure SalesofgoodsdomName(): Text[100] + begin + exit(SalesofgoodsdomTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpGLAccountIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpGLAccountIT.Codeunit.al new file mode 100644 index 00000000000..b07ce6ac9d5 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpGLAccountIT.Codeunit.al @@ -0,0 +1,133 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8424 "Create Exp. GL Account IT" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategoryMgt.GetPrepaidExpenses(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeAdvancesPrepayments(), EmployeeAdvancesPrepaymentsName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeExpenseReimbursementPayable(), EmployeeExpenseReimbursementPayableName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CorporateCardExpenseClearing(), CorporateCardExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CompanyPaidExpenseClearing(), CompanyPaidExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetTravelExpense(), 80); + ContosoGLAccount.InsertGLAccount(PerDiemAllowance(), PerDiemAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(CarRentalExpenses(), CarRentalExpensesName(), "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"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Income, 80); + ContosoGLAccount.InsertGLAccount(NonDeductibleEmployeeExpenses(), NonDeductibleEmployeeExpensesName(), "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"::" ", '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(EmployeeAdvancesPrepaymentsName(), '2341'); + ContosoGLAccount.AddAccountForLocalization(EmployeeExpenseReimbursementPayableName(), '5851'); + ContosoGLAccount.AddAccountForLocalization(CorporateCardExpenseClearingName(), '5852'); + ContosoGLAccount.AddAccountForLocalization(CompanyPaidExpenseClearingName(), '5853'); + ContosoGLAccount.AddAccountForLocalization(PerDiemAllowanceName(), '8431'); + ContosoGLAccount.AddAccountForLocalization(CarRentalExpensesName(), '8432'); + ContosoGLAccount.AddAccountForLocalization(NonDeductibleEmployeeExpensesName(), '8911'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + EmployeeAdvancesPrepaymentsTok: Label 'Employee Advances and Expense Prepayments', MaxLength = 100; + EmployeeExpenseReimbursementPayableTok: Label 'Employee Expense Reimbursement Payable', MaxLength = 100; + CorporateCardExpenseClearingTok: Label 'Corporate Card Expense Clearing', MaxLength = 100; + CompanyPaidExpenseClearingTok: Label 'Company-Paid Expense Clearing', MaxLength = 100; + PerDiemAllowanceTok: Label 'Per Diem Allowance', MaxLength = 100; + CarRentalExpensesTok: Label 'Car Rental Expenses', MaxLength = 100; + NonDeductibleEmployeeExpensesTok: Label 'Non-Deductible Employee Expenses', MaxLength = 100; + + procedure EmployeeAdvancesPrepayments(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeAdvancesPrepaymentsName())); + end; + + procedure EmployeeAdvancesPrepaymentsName(): Text[100] + begin + exit(EmployeeAdvancesPrepaymentsTok); + end; + + procedure EmployeeExpenseReimbursementPayable(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpenseReimbursementPayableName())); + end; + + procedure EmployeeExpenseReimbursementPayableName(): Text[100] + begin + exit(EmployeeExpenseReimbursementPayableTok); + end; + + procedure CorporateCardExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CorporateCardExpenseClearingName())); + end; + + procedure CorporateCardExpenseClearingName(): Text[100] + begin + exit(CorporateCardExpenseClearingTok); + end; + + procedure CompanyPaidExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CompanyPaidExpenseClearingName())); + end; + + procedure CompanyPaidExpenseClearingName(): Text[100] + begin + exit(CompanyPaidExpenseClearingTok); + end; + + procedure PerDiemAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(PerDiemAllowanceName())); + end; + + procedure PerDiemAllowanceName(): Text[100] + begin + exit(PerDiemAllowanceTok); + end; + + procedure CarRentalExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CarRentalExpensesName())); + end; + + procedure CarRentalExpensesName(): Text[100] + begin + exit(CarRentalExpensesTok); + end; + + procedure NonDeductibleEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonDeductibleEmployeeExpensesName())); + end; + + procedure NonDeductibleEmployeeExpensesName(): Text[100] + begin + exit(NonDeductibleEmployeeExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpPostingGrpIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpPostingGrpIT.Codeunit.al new file mode 100644 index 00000000000..ab55f7fc9b5 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/CreateExpPostingGrpIT.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8425 "Create Exp. Posting Grp IT" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountIT: Codeunit "Create Exp. GL Account IT"; + ExpenseGLAccountNamesIT: Codeunit "Expense GL Account Names IT"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.EntertainmentAndPRName()), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.EntertainmentAndPRName()), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.GasolineAndMotorOilName()), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.MiscellaneousName()), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountIT.PerDiemAllowance(), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.TravelName()), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, CreateExpGLAccountIT.CarRentalExpenses(), CreateExpGLAccountIT.NonDeductibleEmployeeExpenses(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.InvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/UpdateEmpPostingGrpIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/UpdateEmpPostingGrpIT.Codeunit.al new file mode 100644 index 00000000000..49fecfab255 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/1.Setup Data/UpdateEmpPostingGrpIT.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8426 "Update Emp. Posting Grp IT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountIT: Codeunit "Create Exp. GL Account IT"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), CreateExpGLAccountIT.EmployeeExpenseReimbursementPayable(), CreateExpGLAccountIT.EmployeeAdvancesPrepayments(), CreateExpGLAccountIT.CompanyPaidExpenseClearing(), CreateExpGLAccountIT.CorporateCardExpenseClearing()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpCategoriesIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpCategoriesIT.Codeunit.al new file mode 100644 index 00000000000..408e8753967 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpCategoriesIT.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8427 "Create Exp. Categories IT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpIT: Codeunit "Create Exp. Posting Grp IT"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpIT.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleConditionIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleConditionIT.Codeunit.al new file mode 100644 index 00000000000..2cfdc99bdef --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleConditionIT.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8430 "Create Exp. Rule Condition IT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesIT: Codeunit "Create Exp. Categories IT"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleHeaderIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleHeaderIT.Codeunit.al new file mode 100644 index 00000000000..8b65e6e1165 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpRuleHeaderIT.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8429 "Create Exp. Rule Header IT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesIT: Codeunit "Create Exp. Categories IT"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpSubCategoriesIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpSubCategoriesIT.Codeunit.al new file mode 100644 index 00000000000..7846783c6cd --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/2.Master Data/CreateExpSubCategoriesIT.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8428 "Create Exp. SubCategories IT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesIT: Codeunit "Create Exp. Categories IT"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesIT.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesIT.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/3. Transactions/CreateExpenseIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/3. Transactions/CreateExpenseIT.Codeunit.al new file mode 100644 index 00000000000..dbaf3fbed67 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/3. Transactions/CreateExpenseIT.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8431 "Create Expense IT" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesIT: Codeunit "Create Exp. Categories IT"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/4. Historical/CreatePostedExpReportIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/4. Historical/CreatePostedExpReportIT.Codeunit.al new file mode 100644 index 00000000000..5f5bdcbda79 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/4. Historical/CreatePostedExpReportIT.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8432 "Create Posted Exp. Report IT" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesIT: Codeunit "Expense GL Account Names IT"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesIT.SalesOtherJobExpensesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesIT: Codeunit "Create Exp. Categories IT"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesIT.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/CreateExpenseCountryDataIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/CreateExpenseCountryDataIT.Codeunit.al new file mode 100644 index 00000000000..598ba94e26f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/CreateExpenseCountryDataIT.Codeunit.al @@ -0,0 +1,69 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8423 "Create Expense Country Data IT" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountIT: Codeunit "Create Exp. GL Account IT"; + CreateExpPostingGrpIT: Codeunit "Create Exp. Posting Grp IT"; + begin + BindSubscription(CreateExpGLAccountIT); + BindSubscription(CreateExpPostingGrpIT); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp IT"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp IT"); + + UnbindSubscription(CreateExpPostingGrpIT); + UnbindSubscription(CreateExpGLAccountIT); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories IT"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories IT"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header IT"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition IT"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberIT: Codeunit "Exp. Demo Data Subscriber IT"; + begin + BindSubscription(ExpDemoDataSubscriberIT); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense IT"); + + UnbindSubscription(ExpDemoDataSubscriberIT); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberIT: Codeunit "Exp. Demo Data Subscriber IT"; + CreatePostedExpReportIT: Codeunit "Create Posted Exp. Report IT"; + begin + BindSubscription(ExpDemoDataSubscriberIT); + BindSubscription(CreatePostedExpReportIT); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report IT"); + + UnbindSubscription(CreatePostedExpReportIT); + UnbindSubscription(ExpDemoDataSubscriberIT); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpDemoDataSubscriberIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpDemoDataSubscriberIT.Codeunit.al new file mode 100644 index 00000000000..2166da9465f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpDemoDataSubscriberIT.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8433 "Exp. Demo Data Subscriber IT" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpenseGLAccountNamesIT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpenseGLAccountNamesIT.Codeunit.al new file mode 100644 index 00000000000..e58f0677129 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/IT/ExpenseGLAccountNamesIT.Codeunit.al @@ -0,0 +1,50 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8480 "Expense GL Account Names IT" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + EntertainmentAndPRTok: Label 'Entertainment and PR', MaxLength = 100; + TravelTok: Label 'Travel', MaxLength = 100; + GasolineAndMotorOilTok: Label 'Gasoline and Motor Oil', MaxLength = 100; + MiscellaneousTok: Label 'Miscellaneous', MaxLength = 100; + InvoiceRoundingTok: Label 'Invoice Rounding', MaxLength = 100; + SalesOtherJobExpensesTok: Label 'Sales, Other Job Expenses', MaxLength = 100; + + procedure EntertainmentAndPRName(): Text[100] + begin + exit(EntertainmentAndPRTok); + end; + + procedure TravelName(): Text[100] + begin + exit(TravelTok); + end; + + procedure GasolineAndMotorOilName(): Text[100] + begin + exit(GasolineAndMotorOilTok); + end; + + procedure MiscellaneousName(): Text[100] + begin + exit(MiscellaneousTok); + end; + + procedure InvoiceRoundingName(): Text[100] + begin + exit(InvoiceRoundingTok); + end; + + procedure SalesOtherJobExpensesName(): Text[100] + begin + exit(SalesOtherJobExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpGLAccountNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpGLAccountNL.Codeunit.al new file mode 100644 index 00000000000..a70ece0adb1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpGLAccountNL.Codeunit.al @@ -0,0 +1,131 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8402 "Create Exp. GL Account NL" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(CorporateCardExpensePayable(), CorporateCardExpensePayableName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BankPaidExpenseClearing(), BankPaidExpenseClearingName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetTravelExpense(), 80); + ContosoGLAccount.InsertGLAccount(MileageReimbursement(), MileageReimbursementName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(PerDiemAllowance(), PerDiemAllowanceName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(BusinessMealsAndEntertainment(), BusinessMealsAndEntertainmentName(), "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"::Purchase, '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(OtherEmployeeExpenses(), OtherEmployeeExpensesName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Income, 80); + ContosoGLAccount.InsertGLAccount(NonDeductibleEmployeeExpenses(), NonDeductibleEmployeeExpensesName(), "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"::" ", '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(CorporateCardExpensePayableName(), '1521'); + ContosoGLAccount.AddAccountForLocalization(BankPaidExpenseClearingName(), '1522'); + ContosoGLAccount.AddAccountForLocalization(MileageReimbursementName(), '3465'); + ContosoGLAccount.AddAccountForLocalization(PerDiemAllowanceName(), '3466'); + ContosoGLAccount.AddAccountForLocalization(BusinessMealsAndEntertainmentName(), '3564'); + ContosoGLAccount.AddAccountForLocalization(OtherEmployeeExpensesName(), '4291'); + ContosoGLAccount.AddAccountForLocalization(NonDeductibleEmployeeExpensesName(), '4292'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + CorporateCardExpensePayableTok: Label 'Corporate Card Expense Payable', MaxLength = 100; + BankPaidExpenseClearingTok: Label 'Bank-Paid Expense Clearing Account', MaxLength = 100; + MileageReimbursementTok: Label 'Mileage Reimbursement', MaxLength = 100; + PerDiemAllowanceTok: Label 'Per Diem Allowance', MaxLength = 100; + BusinessMealsAndEntertainmentTok: Label 'Business Meals and Entertainment', MaxLength = 100; + OtherEmployeeExpensesTok: Label 'Other Employee Expenses', MaxLength = 100; + NonDeductibleEmployeeExpensesTok: Label 'Non-Deductible Employee Expenses', MaxLength = 100; + + procedure CorporateCardExpensePayable(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(CorporateCardExpensePayableName())); + end; + + procedure CorporateCardExpensePayableName(): Text[100] + begin + exit(CorporateCardExpensePayableTok); + end; + + procedure BankPaidExpenseClearing(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(BankPaidExpenseClearingName())); + end; + + procedure BankPaidExpenseClearingName(): Text[100] + begin + exit(BankPaidExpenseClearingTok); + end; + + procedure MileageReimbursement(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(MileageReimbursementName())); + end; + + procedure MileageReimbursementName(): Text[100] + begin + exit(MileageReimbursementTok); + end; + + procedure PerDiemAllowance(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(PerDiemAllowanceName())); + end; + + procedure PerDiemAllowanceName(): Text[100] + begin + exit(PerDiemAllowanceTok); + end; + + procedure BusinessMealsAndEntertainment(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(BusinessMealsAndEntertainmentName())); + end; + + procedure BusinessMealsAndEntertainmentName(): Text[100] + begin + exit(BusinessMealsAndEntertainmentTok); + end; + + procedure OtherEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(OtherEmployeeExpensesName())); + end; + + procedure OtherEmployeeExpensesName(): Text[100] + begin + exit(OtherEmployeeExpensesTok); + end; + + procedure NonDeductibleEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonDeductibleEmployeeExpensesName())); + end; + + procedure NonDeductibleEmployeeExpensesName(): Text[100] + begin + exit(NonDeductibleEmployeeExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpPostingGrpNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpPostingGrpNL.Codeunit.al new file mode 100644 index 00000000000..06a4cd4a0ee --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/CreateExpPostingGrpNL.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8403 "Create Exp. Posting Grp NL" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountNL: Codeunit "Create Exp. GL Account NL"; + ExpenseGLAccountNamesNL: Codeunit "Expense GL Account Names NL"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, CreateExpGLAccountNL.BusinessMealsAndEntertainment(), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.BoardAndLodgingName()), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, CreateExpGLAccountNL.MileageReimbursement(), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, CreateExpGLAccountNL.OtherEmployeeExpenses(), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountNL.PerDiemAllowance(), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.OtherTravelExpensesName()), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.RentalVehiclesName()), CreateExpGLAccountNL.NonDeductibleEmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.PayableInvoiceRoundingName())); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/UpdateEmpPostingGrpNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/UpdateEmpPostingGrpNL.Codeunit.al new file mode 100644 index 00000000000..13de42c67f7 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/1.Setup Data/UpdateEmpPostingGrpNL.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8404 "Update Emp. Posting Grp NL" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountNL: Codeunit "Create Exp. GL Account NL"; + ExpenseGLAccountNamesNL: Codeunit "Expense GL Account Names NL"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentLiabilitiesToEmployeesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.CurrentReceivableFromEmployeesName()), CreateExpGLAccountNL.BankPaidExpenseClearing(), CreateExpGLAccountNL.CorporateCardExpensePayable()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpCategoriesNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpCategoriesNL.Codeunit.al new file mode 100644 index 00000000000..87af456875e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpCategoriesNL.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8405 "Create Exp. Categories NL" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpNL: Codeunit "Create Exp. Posting Grp NL"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpNL.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleConditionNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleConditionNL.Codeunit.al new file mode 100644 index 00000000000..52a581a4fe0 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleConditionNL.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8408 "Create Exp. Rule Condition NL" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesNL: Codeunit "Create Exp. Categories NL"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleHeaderNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleHeaderNL.Codeunit.al new file mode 100644 index 00000000000..2cfb487d3cb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpRuleHeaderNL.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8407 "Create Exp. Rule Header NL" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesNL: Codeunit "Create Exp. Categories NL"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.USD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpSubCategoriesNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpSubCategoriesNL.Codeunit.al new file mode 100644 index 00000000000..92148797010 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/2.Master Data/CreateExpSubCategoriesNL.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8406 "Create Exp. SubCategories NL" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesNL: Codeunit "Create Exp. Categories NL"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesNL.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesNL.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/3. Transactions/CreateExpenseNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/3. Transactions/CreateExpenseNL.Codeunit.al new file mode 100644 index 00000000000..355d99874b3 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/3. Transactions/CreateExpenseNL.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8409 "Create Expense NL" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesNL: Codeunit "Create Exp. Categories NL"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/4. Historical/CreatePostedExpReportNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/4. Historical/CreatePostedExpReportNL.Codeunit.al new file mode 100644 index 00000000000..b9037f30dab --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/4. Historical/CreatePostedExpReportNL.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8410 "Create Posted Exp. Report NL" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccountNamesNL: Codeunit "Expense GL Account Names NL"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNL.SaleofResourcesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesNL: Codeunit "Create Exp. Categories NL"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNL.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/CreateExpenseCountryDataNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/CreateExpenseCountryDataNL.Codeunit.al new file mode 100644 index 00000000000..0a4e7aed5c4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/CreateExpenseCountryDataNL.Codeunit.al @@ -0,0 +1,69 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8401 "Create Expense Country Data NL" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountNL: Codeunit "Create Exp. GL Account NL"; + CreateExpPostingGrpNL: Codeunit "Create Exp. Posting Grp NL"; + begin + BindSubscription(CreateExpGLAccountNL); + BindSubscription(CreateExpPostingGrpNL); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp NL"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp NL"); + + UnbindSubscription(CreateExpPostingGrpNL); + UnbindSubscription(CreateExpGLAccountNL); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories NL"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories NL"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header NL"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition NL"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberNL: Codeunit "Exp. Demo Data Subscriber NL"; + begin + BindSubscription(ExpDemoDataSubscriberNL); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense NL"); + + UnbindSubscription(ExpDemoDataSubscriberNL); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + ExpDemoDataSubscriberNL: Codeunit "Exp. Demo Data Subscriber NL"; + CreatePostedExpReportNL: Codeunit "Create Posted Exp. Report NL"; + begin + BindSubscription(ExpDemoDataSubscriberNL); + BindSubscription(CreatePostedExpReportNL); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report NL"); + + UnbindSubscription(CreatePostedExpReportNL); + UnbindSubscription(ExpDemoDataSubscriberNL); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpDemoDataSubscriberNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpDemoDataSubscriberNL.Codeunit.al new file mode 100644 index 00000000000..74e2934be36 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpDemoDataSubscriberNL.Codeunit.al @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8411 "Exp. Demo Data Subscriber NL" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)] + local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10]) + var + CreateCurrency: Codeunit "Create Currency"; + begin + if CurrencyCode = CreateCurrency.EUR() then + CurrencyCode := CreateCurrency.USD(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpenseGLAccountNamesNL.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpenseGLAccountNamesNL.Codeunit.al new file mode 100644 index 00000000000..f7d22fcbba8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NL/ExpenseGLAccountNamesNL.Codeunit.al @@ -0,0 +1,56 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8478 "Expense GL Account Names NL" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + CurrentReceivableFromEmployeesTok: Label 'Current Receivable from Employees', MaxLength = 100; + CurrentLiabilitiesToEmployeesTok: Label 'Current Liabilities to Employees', MaxLength = 100; + BoardAndLodgingTok: Label 'Board and lodging', MaxLength = 100; + OtherTravelExpensesTok: Label 'Other travel expenses', MaxLength = 100; + PayableInvoiceRoundingTok: Label 'Payable Invoice Rounding', MaxLength = 100; + SaleofResourcesTok: Label 'Sale of Resources', MaxLength = 100; + RentalVehiclesTok: Label 'Rental vehicles', MaxLength = 100; + + procedure CurrentReceivableFromEmployeesName(): Text[100] + begin + exit(CurrentReceivableFromEmployeesTok); + end; + + procedure CurrentLiabilitiesToEmployeesName(): Text[100] + begin + exit(CurrentLiabilitiesToEmployeesTok); + end; + + procedure BoardAndLodgingName(): Text[100] + begin + exit(BoardAndLodgingTok); + end; + + procedure OtherTravelExpensesName(): Text[100] + begin + exit(OtherTravelExpensesTok); + end; + + procedure PayableInvoiceRoundingName(): Text[100] + begin + exit(PayableInvoiceRoundingTok); + end; + + procedure SaleofResourcesName(): Text[100] + begin + exit(SaleofResourcesTok); + end; + + procedure RentalVehiclesName(): Text[100] + begin + exit(RentalVehiclesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpGLAccountNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpGLAccountNO.Codeunit.al new file mode 100644 index 00000000000..be194ed5dae --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpGLAccountNO.Codeunit.al @@ -0,0 +1,118 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; +using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Enums; + +codeunit 8446 "Create Exp. GL Account NO" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)] + local procedure ModifyGLAccount() + var + GLAccountCategory: Record "G/L Account Category"; + GLAccountCategoryMgt: Codeunit "G/L Account Category Mgt."; + SubCategory: Text[80]; + begin + AddGLAccounts(); + + SubCategory := Format(GLAccountCategoryMgt.GetCash(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeExpensePayableCash(), EmployeeExpensePayableCashName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EmployeeExpensePayableCard(), EmployeeExpensePayableCardName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(EmployeeExpensePayableCompanyPaid(), EmployeeExpensePayableCompanyPaidName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategoryMgt.GetPrepaidExpenses(), 80); + ContosoGLAccount.InsertGLAccount(EmployeeExpensePrepayments(), EmployeeExpensePrepaymentsName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false); + + SubCategory := Format(GLAccountCategory."Account Category"::Income, 80); + ContosoGLAccount.InsertGLAccount(NonRefundableEmployeeExpenses(), NonRefundableEmployeeExpensesName(), "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"::" ", '', '', true, false, false); + ContosoGLAccount.InsertGLAccount(ExpenseRoundingDifferences(), ExpenseRoundingDifferencesName(), "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"::" ", '', '', true, false, false); + end; + + local procedure AddGLAccounts() + begin + ContosoGLAccount.AddAccountForLocalization(EmployeeExpensePayableCashName(), '5960'); + ContosoGLAccount.AddAccountForLocalization(EmployeeExpensePayableCardName(), '5961'); + ContosoGLAccount.AddAccountForLocalization(EmployeeExpensePayableCompanyPaidName(), '5962'); + ContosoGLAccount.AddAccountForLocalization(EmployeeExpensePrepaymentsName(), '5963'); + ContosoGLAccount.AddAccountForLocalization(NonRefundableEmployeeExpensesName(), '5964'); + ContosoGLAccount.AddAccountForLocalization(ExpenseRoundingDifferencesName(), '5965'); + end; + + var + ContosoGLAccount: Codeunit "Contoso GL Account"; + EmployeeExpensePayableCashTok: Label 'Employee Expense Payable - Cash Reimbursement', MaxLength = 100; + EmployeeExpensePayableCardTok: Label 'Employee Expense Payable - Company Card', MaxLength = 100; + EmployeeExpensePayableCompanyPaidTok: Label 'Employee Expense Payable - Company Paid', MaxLength = 100; + EmployeeExpensePrepaymentsTok: Label 'Employee Expense Prepayments', MaxLength = 100; + NonRefundableEmployeeExpensesTok: Label 'Non-Refundable Employee Expenses', MaxLength = 100; + ExpenseRoundingDifferencesTok: Label 'Expense Rounding Differences', MaxLength = 100; + + procedure EmployeeExpensePayableCash(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpensePayableCashName())); + end; + + procedure EmployeeExpensePayableCashName(): Text[100] + begin + exit(EmployeeExpensePayableCashTok); + end; + + procedure EmployeeExpensePayableCard(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpensePayableCardName())); + end; + + procedure EmployeeExpensePayableCardName(): Text[100] + begin + exit(EmployeeExpensePayableCardTok); + end; + + procedure EmployeeExpensePayableCompanyPaid(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpensePayableCompanyPaidName())); + end; + + procedure EmployeeExpensePayableCompanyPaidName(): Text[100] + begin + exit(EmployeeExpensePayableCompanyPaidTok); + end; + + procedure EmployeeExpensePrepayments(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(EmployeeExpensePrepaymentsName())); + end; + + procedure EmployeeExpensePrepaymentsName(): Text[100] + begin + exit(EmployeeExpensePrepaymentsTok); + end; + + procedure NonRefundableEmployeeExpenses(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(NonRefundableEmployeeExpensesName())); + end; + + procedure NonRefundableEmployeeExpensesName(): Text[100] + begin + exit(NonRefundableEmployeeExpensesTok); + end; + + procedure ExpenseRoundingDifferences(): Code[20] + begin + exit(ContosoGLAccount.GetAccountNo(ExpenseRoundingDifferencesName())); + end; + + procedure ExpenseRoundingDifferencesName(): Text[100] + begin + exit(ExpenseRoundingDifferencesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpPostingGrpNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpPostingGrpNO.Codeunit.al new file mode 100644 index 00000000000..2b8b90b1215 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/CreateExpPostingGrpNO.Codeunit.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8447 "Create Exp. Posting Grp NO" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpensePostingGroup(ExpensePerDiem(), ExpensePerDiemLbl); + end; + + [EventSubscriber(ObjectType::Table, Database::"Expense Posting Group", 'OnBeforeInsertEvent', '', false, false)] + local procedure OnInsertRecord(var Rec: Record "Expense Posting Group") + var + CreateExpGLAccountNO: Codeunit "Create Exp. GL Account NO"; + ExpenseGLAccountNamesNO: Codeunit "Expense GL Account Names NO"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + CreateExpensePostingGroup: Codeunit "Create Expense Posting Group"; + begin + case Rec.Code of + CreateExpensePostingGroup.ExpenseEntertainment(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.EntertainmentDeductibleName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.EntertainmentDeductibleName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.CarAllowanceName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.AdministrativeExpensesName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.SubsistenceName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.TravelName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.TravelName()), CreateExpGLAccountNO.NonRefundableEmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.ExpenseRoundingDifferences(), CreateExpGLAccountNO.ExpenseRoundingDifferences()); + end; + end; + + local procedure ValidateRecordFields(var ExpensePostingGroup: Record "Expense Posting Group"; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; ExpenseDebitRoundingAccount: Code[20]; ExpenseCreditRoundingAccount: Code[20]) + begin + ExpensePostingGroup.Validate("Refundable Debit Account", RefundableDebitAccount); + ExpensePostingGroup.Validate("Non-Refundable Debit Account", NonRefundableDebitAccount); + ExpensePostingGroup.Validate("Prepayment Credit Account", PrepaymentCreditAccount); + ExpensePostingGroup.Validate("Debit Rounding Account", ExpenseDebitRoundingAccount); + ExpensePostingGroup.Validate("Credit Rounding Account", ExpenseCreditRoundingAccount); + end; + + var + ExpensePERDIEMTok: Label 'EXPENSE-PERDIEM', MaxLength = 20, Locked = true; + ExpensePerDiemLbl: Label 'Expense - Per Diem', MaxLength = 100; + + procedure ExpensePerDiem(): Code[20] + begin + exit(ExpensePERDIEMTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/UpdateEmpPostingGrpNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/UpdateEmpPostingGrpNO.Codeunit.al new file mode 100644 index 00000000000..79cfa6d0961 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/1.Setup Data/UpdateEmpPostingGrpNO.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.HumanResources; + +codeunit 8448 "Update Emp. Posting Grp NO" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + CreateExpGLAccountNO: Codeunit "Create Exp. GL Account NO"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; + begin + ContosoExpenseAgent.SetOverwriteData(true); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), CreateExpGLAccountNO.EmployeeExpensePayableCash(), CreateExpGLAccountNO.EmployeeExpensePrepayments(), CreateExpGLAccountNO.EmployeeExpensePayableCompanyPaid(), CreateExpGLAccountNO.EmployeeExpensePayableCard()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpCategoriesNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpCategoriesNO.Codeunit.al new file mode 100644 index 00000000000..6d049b0e0af --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpCategoriesNO.Codeunit.al @@ -0,0 +1,31 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8449 "Create Exp. Categories NO" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpNO: Codeunit "Create Exp. Posting Grp NO"; + begin + ContosoExpenseAgent.InsertExpenseCategory(PerDiem(), PerDiemByAssignedPolicyLbl, PerDiemByAssignedPolicyPostingLbl, CreateExpPostingGrpNO.ExpensePerDiem(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem"); + end; + + var + PerDiemTok: Label 'PER-DIEM', MaxLength = 20, Locked = true; + PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; + PerDiemByAssignedPolicyPostingLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + procedure PerDiem(): Code[20] + begin + exit(PerDiemTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleConditionNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleConditionNO.Codeunit.al new file mode 100644 index 00000000000..e3400b15401 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleConditionNO.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8452 "Create Exp. Rule Condition NO" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpCategoriesNO: Codeunit "Create Exp. Categories NO"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 125); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 450); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.Domestic(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 50); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 110); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 105); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.UKOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 115); + ContosoExpenseAgent.InsertExpenseRuleCondition(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.USAOther(), 0D, 10000, Enum::"Expense Rule Condition Type"::"Daily Rate", 120); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleHeaderNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleHeaderNO.Codeunit.al new file mode 100644 index 00000000000..bc8a1560904 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpRuleHeaderNO.Codeunit.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; + +codeunit 8451 "Create Exp. Rule Header NO" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateCurrency: Codeunit "Create Currency"; + CreateExpCategoriesNO: Codeunit "Create Exp. Categories NO"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + begin + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.CanadaAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.CAD(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.DenmarkAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.Domestic(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.FranceAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.GermanyAll(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.EUR(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.UKOther(), 0D, Enum::"Expense Justification"::" ", false, '', CreateCurrency.GBP(), ''); + ContosoExpenseAgent.InsertExpenseRuleHeader(CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.USAOther(), 0D, Enum::"Expense Justification"::" ", false, '', '', ''); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpSubCategoriesNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpSubCategoriesNO.Codeunit.al new file mode 100644 index 00000000000..22c902ee761 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/2.Master Data/CreateExpSubCategoriesNO.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8450 "Create Exp. SubCategories NO" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesNO: Codeunit "Create Exp. Categories NO"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesNO.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesNO.PerDiem(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, false, true, false); + end; + + var + CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; + IntlTok: Label 'INTL', MaxLength = 20, Locked = true; + LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; + InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; + LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; + InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + + procedure Country(): Code[20] + begin + exit(CountryTok); + end; + + procedure Intl(): Code[20] + begin + exit(IntlTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/3. Transactions/CreateExpenseNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/3. Transactions/CreateExpenseNO.Codeunit.al new file mode 100644 index 00000000000..7fe1804d73a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/3. Transactions/CreateExpenseNO.Codeunit.al @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoTool.Helpers; + +codeunit 8453 "Create Expense NO" +{ + InherentEntitlements = X; + InherentPermissions = X; + Permissions = tabledata "Expense Per Diem" = rim; + + trigger OnRun() + begin + CreateOpenExpense(); + end; + + local procedure CreateOpenExpense() + var + Expense: Record Expense; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + begin + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.GermanyAll(), PerDiemByAssignedPolicyLbl, '', ContosoUtility.AdjustDate(19030203D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19030115D), 144000T), CreateDateTime(ContosoUtility.AdjustDate(19030121D), 000500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 10000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 30000, false, true, false); + UpdateExpensePerDiem(Expense."No.", 40000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesNO: Codeunit "Create Exp. Categories NO"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + PerDiemByAssignedPolicyLbl: Label 'Per-diem by assigned policy', MaxLength = 100; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/4. Historical/CreatePostedExpReportNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/4. Historical/CreatePostedExpReportNO.Codeunit.al new file mode 100644 index 00000000000..32834f48a36 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/4. Historical/CreatePostedExpReportNO.Codeunit.al @@ -0,0 +1,168 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +using Microsoft.DemoData.Finance; +using Microsoft.DemoData.HumanResources; +using Microsoft.DemoTool.Helpers; + +codeunit 8454 "Create Posted Exp. Report NO" +{ + SingleInstance = true; + EventSubscriberInstance = Manual; + InherentEntitlements = X; + InherentPermissions = X; + Permissions = + tabledata "Expense Per Diem" = rim, + tabledata "Expense Report Line" = rim; + + trigger OnRun() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if ExpenseReportHeader.FindLast() then + FromExpenseReportNo := ExpenseReportHeader."No."; + + CreateExpenseReportToPost(); + + PostExpenseReport(); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Posted Expense Report", OnDefineExpenseAccountNo, '', false, false)] + local procedure OnDefineExpenseAccountNo(var AccountNo: Code[20]) + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + ExpenseGLAccountNamesNO: Codeunit "Expense GL Account Names NO"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesNO.SalesOtherJobExpensesName()); + end; + + local procedure CreateExpenseReportToPost() + var + Expense: Record Expense; + ExpenseReportHeader: Record "Expense Report Header"; + CreateEmployee: Codeunit "Create Employee"; + CreateCurrency: Codeunit "Create Currency"; + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpenseLocation: Codeunit "Create Expense Location"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategories: Codeunit "Create Expense Categories DM"; + CreateExpCategoriesNO: Codeunit "Create Exp. Categories NO"; + CreateExpenseSubcategories: Codeunit "Create Expense Subcategories"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + begin + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.JO(), ContosoUtility.AdjustDate(19021104D), ContosoUtility.AdjustDate(19021104D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.GermanyAll(), BusinessTripToHamburgLbl, '', ContosoUtility.AdjustDate(19021103D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021024D), 064500T), CreateDateTime(ContosoUtility.AdjustDate(19021027D), 161500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.JO(), CreateExpCategories.Airline(), '', AirlineTicketsLbl, '', ContosoUtility.AdjustDate(19021010D), '', 2042, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'TY6HJO', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + + ExpenseReportHeader := ContosoExpenseAgent.InsertExpenseReportHeader(CreateExpenseUser.EH(), ContosoUtility.AdjustDate(19021204D), ContosoUtility.AdjustDate(19021204D)); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Airline(), '', AirlineTicketsDublinLbl, TravelToConferenceLbl, ContosoUtility.AdjustDate(19021106D), '', 3120, MargieTravelLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'FIUXHJT', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Events(), '', ITConferenceLbl, '', ContosoUtility.AdjustDate(19021107D), CreateCurrency.EUR(), 1990, ProsewareIncLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'G574576HJ656', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021114D), CreateCurrency.EUR(), 45, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '456845856867', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Entertain(), '', BusinessDinnerLbl, BusinessDinnerWithBigPotentialCustomersLbl, ContosoUtility.AdjustDate(19021116D), CreateCurrency.EUR(), 842, FourthCoffeeLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'RT6457560034', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 10000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.ManagingDirector(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 20000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::Employee, CreateEmployee.SalesManager(), '', '', '', '', ''); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 30000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', JesseHomerLbl, RelecloudLbl, '', CEOLbl, 'jesse.homer@contoso.com'); + ContosoExpenseAgent.InsertExpenseParticipant(Expense."No.", 40000, CreateExpCategories.Entertain(), Enum::"Expense Participant Type"::External, '', RobertTownesLbl, AdatumCorporationLbl, '', CEOLbl, 'robert.townes@contoso.com'); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Hotels(), '', HotelStayLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 2150, ContosoSuitesLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', '64675S879CT987990004', '', ''); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 10000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021114D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 20000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021115D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 30000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021115D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 40000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021116D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 50000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021116D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 60000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.RoomService(), RoomServiceLbl, ContosoUtility.AdjustDate(19021116D), 145); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 70000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021117D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 80000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Room(), AccommodationLbl, ContosoUtility.AdjustDate(19021117D), 390); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 90000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Breakfast(), BreakfastLbl, ContosoUtility.AdjustDate(19021118D), 35); + ContosoExpenseAgent.InsertExpenseItemization(Expense."No.", 100000, CreateExpCategories.Hotels(), CreateExpenseSubcategories.Tax(), HotelTaxesLbl, ContosoUtility.AdjustDate(19021118D), 305); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.RentalCars(), '', CarRentalsLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 622.45, VanArsdelLtdLbl, CreateExpensePaymentMethod.Card(), true, false, '', 0DT, 0DT, 0, 0, '', '', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.GroundTransportation(), '', TaxiLbl, '', ContosoUtility.AdjustDate(19021118D), CreateCurrency.EUR(), 71, TailwindTradersLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 0, '', '', '7456875687568', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.UKOther(), TripToUKLbl, '', ContosoUtility.AdjustDate(19021121D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021114D), 053000T), CreateDateTime(ContosoUtility.AdjustDate(19021118D), 220500T), 0, 0, '', '', '', '', ''); + UpdateExpensePerDiem(Expense."No.", 20000, false, false, true); + UpdateExpensePerDiem(Expense."No.", 40000, false, true, false); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategoriesNO.PerDiem(), CreateExpenseLocation.Domestic(), TripToDoverLbl, '', ContosoUtility.AdjustDate(19021204D), '', 0, '', CreateExpensePaymentMethod.Cash(), true, false, '', CreateDateTime(ContosoUtility.AdjustDate(19021127D), 070000T), CreateDateTime(ContosoUtility.AdjustDate(19021129D), 145500T), 0, 0, '', '', '', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + Expense := ContosoExpenseAgent.InsertExpense(CreateExpenseUser.EH(), CreateExpCategories.Mileage(), '', MileageLbl, '', ContosoUtility.AdjustDate(19031101D), '', 0, VanArsdelLtdLbl, CreateExpensePaymentMethod.Cash(), true, false, '', 0DT, 0DT, 0, 249, 'New York', 'Dover', 'H6584769867J9J95789', '', ''); + ReleaseAndAddExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + var + FromExpenseReportNo: Code[20]; + BusinessTripToHamburgLbl: Label 'Business trip to Hamburg, DE', MaxLength = 100; + AirlineTicketsLbl: Label 'Airline tickets NY/FRANKFURT/HAMBURG/FRANKFURT/NY', MaxLength = 100; + MargieTravelLbl: Label 'Margie''s Travel', MaxLength = 100; + AirlineTicketsDublinLbl: Label 'Airline tickets NY/DUBLIN/NY', MaxLength = 100; + TravelToConferenceLbl: Label 'Travel to the conference', MaxLength = 100; + ITConferenceLbl: Label 'IT Conference', MaxLength = 100; + ProsewareIncLbl: Label 'Proseware, Inc.', MaxLength = 100; + TaxiLbl: Label 'Taxi', MaxLength = 100; + TailwindTradersLbl: Label 'Tailwind Traders', MaxLength = 100; + BusinessDinnerLbl: Label 'Business Dinner', MaxLength = 100; + BusinessDinnerWithBigPotentialCustomersLbl: Label 'Business dinner with a big potential customers', MaxLength = 100; + FourthCoffeeLbl: Label 'Fourth Coffee', MaxLength = 100; + JesseHomerLbl: Label 'Jesse Homer', MaxLength = 100; + RelecloudLbl: Label 'Relecloud', MaxLength = 100; + RobertTownesLbl: Label 'Robert Townes', MaxLength = 100; + AdatumCorporationLbl: Label 'Adatum Corporation', MaxLength = 100; + HotelStayLbl: Label 'Hotel stay', MaxLength = 100; + ContosoSuitesLbl: Label 'Contoso Suites', MaxLength = 100; + AccommodationLbl: Label 'Accommodation', MaxLength = 100; + BreakfastLbl: Label 'Breakfast', MaxLength = 100; + HotelTaxesLbl: Label 'Hotel Taxes', MaxLength = 100; + RoomServiceLbl: Label 'Room service', MaxLength = 100; + CarRentalsLbl: Label 'Car Rentals', MaxLength = 100; + VanArsdelLtdLbl: Label 'VanArsdel, Ltd.', MaxLength = 100; + TripToUKLbl: Label 'Trip to UK', MaxLength = 100; + TripToDoverLbl: Label 'Trip to Dover', MaxLength = 100; + MileageLbl: Label 'Mileage', MaxLength = 100; + CEOLbl: Label 'CEO', MaxLength = 30; + + local procedure ReleaseAndAddExpenseToExpenseReport(Expense: Record Expense; ExpenseReportHeader: Record "Expense Report Header") + var + ReleaseExpenseDocument: Codeunit "Release Expense Document"; + CreateExpenseReport: Codeunit "Create Expense Report"; + begin + Expense.Get(Expense."No."); + ReleaseExpenseDocument.Run(Expense); + + CreateExpenseReport.AddSingleExpenseToExpenseReport(Expense, ExpenseReportHeader); + end; + + local procedure PostExpenseReport() + var + ExpenseReportHeader: Record "Expense Report Header"; + begin + if FromExpenseReportNo <> '' then + ExpenseReportHeader.SetFilter("No.", '>%1', FromExpenseReportNo); + + if ExpenseReportHeader.FindSet() then + repeat + Codeunit.Run(Codeunit::"Expense Report-Post", ExpenseReportHeader); + until ExpenseReportHeader.Next() = 0; + end; + + local procedure UpdateExpensePerDiem(ExpenseNo: Code[20]; LineNo: Integer; Breakfast: Boolean; Lunch: Boolean; Dinner: Boolean) + var + ExpensePerDiem: Record "Expense Per Diem"; + begin + ExpensePerDiem.Get(ExpenseNo, LineNo); + + ExpensePerDiem.Validate(Breakfast, Breakfast); + ExpensePerDiem.Validate(Lunch, Lunch); + ExpensePerDiem.Validate(Dinner, Dinner); + ExpensePerDiem.Modify(); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/CreateExpenseCountryDataNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/CreateExpenseCountryDataNO.Codeunit.al new file mode 100644 index 00000000000..99d6fd6382e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/CreateExpenseCountryDataNO.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8445 "Create Expense Country Data NO" implements "Expense Agent Country Data" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + procedure CreateSetupData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreateExpGLAccountNO: Codeunit "Create Exp. GL Account NO"; + CreateExpPostingGrpNO: Codeunit "Create Exp. Posting Grp NO"; + begin + BindSubscription(CreateExpGLAccountNO); + BindSubscription(CreateExpPostingGrpNO); + + CreateExpenseCountryDataW1.CreateSetupData(); + Codeunit.Run(Codeunit::"Update Emp. Posting Grp NO"); + Codeunit.Run(Codeunit::"Create Exp. Posting Grp NO"); + + UnbindSubscription(CreateExpPostingGrpNO); + UnbindSubscription(CreateExpGLAccountNO); + end; + + procedure CreateMasterData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateMasterData(); + Codeunit.Run(Codeunit::"Create Exp. Categories NO"); + Codeunit.Run(Codeunit::"Create Exp. SubCategories NO"); + Codeunit.Run(Codeunit::"Create Exp. Rule Header NO"); + Codeunit.Run(Codeunit::"Create Exp. Rule Condition NO"); + end; + + procedure CreateTransactionalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + begin + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense NO"); + end; + + procedure CreateHistoricalData() + var + CreateExpenseCountryDataW1: Codeunit "Create Expense Country Data W1"; + CreatePostedExpReportNO: Codeunit "Create Posted Exp. Report NO"; + begin + BindSubscription(CreatePostedExpReportNO); + + CreateExpenseCountryDataW1.CreateHistoricalData(); + Codeunit.Run(Codeunit::"Create Posted Exp. Report NO"); + + UnbindSubscription(CreatePostedExpReportNO); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/NO/ExpenseGLAccountNamesNO.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/ExpenseGLAccountNamesNO.Codeunit.al new file mode 100644 index 00000000000..ebc7b40da06 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NO/ExpenseGLAccountNamesNO.Codeunit.al @@ -0,0 +1,50 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.ExpenseAgent; + +codeunit 8482 "Expense GL Account Names NO" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + TravelTok: Label 'Travel', MaxLength = 100; + EntertainmentDeductibleTok: Label 'Entertainment, Deductible', MaxLength = 100; + CarAllowanceTok: Label 'Car Allowance', MaxLength = 100; + AdministrativeExpensesTok: Label 'Administrative Expenses', MaxLength = 100; + SubsistenceTok: Label 'Subsitence', MaxLength = 100; + SalesOtherJobExpensesTok: Label 'Sales, Other Job Expenses', MaxLength = 100; + + procedure TravelName(): Text[100] + begin + exit(TravelTok); + end; + + procedure EntertainmentDeductibleName(): Text[100] + begin + exit(EntertainmentDeductibleTok); + end; + + procedure CarAllowanceName(): Text[100] + begin + exit(CarAllowanceTok); + end; + + procedure AdministrativeExpensesName(): Text[100] + begin + exit(AdministrativeExpensesTok); + end; + + procedure SubsistenceName(): Text[100] + begin + exit(SubsistenceTok); + end; + + procedure SalesOtherJobExpensesName(): Text[100] + begin + exit(SalesOtherJobExpensesTok); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Demo Data/1.Setup Data/CreateExpenseGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/1.Setup Data/CreateExpenseGLAccount.Codeunit.al index cadee37a35e..59a2ace4221 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Demo Data/1.Setup Data/CreateExpenseGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/1.Setup Data/CreateExpenseGLAccount.Codeunit.al @@ -47,6 +47,7 @@ codeunit 8207 "Create Expense G/L Account" GLAccount: Record "G/L Account"; begin GLAccount.SetRange("Name", AccountName); + GLAccount.SetRange("Account Type", GLAccount."Account Type"::Posting); if GLAccount.FindFirst() then exit(GLAccount."No.") else diff --git a/src/Apps/W1/ExpenseAgent/demo data/app.json b/src/Apps/W1/ExpenseAgent/demo data/app.json index 1dde3ab17fa..67dd193d200 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/app.json +++ b/src/Apps/W1/ExpenseAgent/demo data/app.json @@ -33,6 +33,10 @@ { "from": 8201, "to": 8399 + }, + { + "from": 8400, + "to": 8499 } ], "target": "OnPrem", From 6966337ffb763f51f4ad36e8067435194baa3518 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Sat, 22 Aug 2026 14:14:13 +0530 Subject: [PATCH 21/25] Fix AA0139 overflow warnings in demo data InsertExpense Bound Justification, Payment Method Code, Starting Point and Ending Point assignments with CopyStr to the target Expense field lengths (Text[100], Code[10], Text[50]). These pre-existing overflows surfaced as new warnings when the demo data began building for the newly added countries. --- .../Contoso Helpers/ContosoExpenseAgent.Codeunit.al | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al index f1324b15afe..834f090b00d 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al @@ -286,7 +286,7 @@ codeunit 8205 "Contoso Expense Agent" Expense.Validate("Expense Category", ExpenseCategoryCode); Expense.Validate("Expense Location", ExpenseLocationCode); Expense.Validate("Description", Description); - Expense.Validate("Justification", Justification); + Expense.Validate("Justification", CopyStr(Justification, 1, MaxStrLen(Expense.Justification))); Expense.Validate("Expense Date", ExpenseDate); ValidateCurrencyCodeInExpense(Expense, CurrencyCode); @@ -294,7 +294,7 @@ codeunit 8205 "Contoso Expense Agent" if Amount <> 0 then Expense.Validate("Amount", Amount); Expense.Validate("Merchant Name", MerchantName); - Expense.Validate("Payment Method Code", PaymentMethodCode); + Expense.Validate("Payment Method Code", CopyStr(PaymentMethodCode, 1, MaxStrLen(Expense."Payment Method Code"))); Expense.Validate(Refundable, Refundable); Expense.Validate(Billable, Billable); Expense.Validate("Billable to Customer", BillableToCustomer); @@ -303,8 +303,8 @@ codeunit 8205 "Contoso Expense Agent" Expense.Validate("Non-Refundable Amount", NonRefundableAmount); if Mileage <> 0 then Expense.Validate("Mileage", Mileage); - Expense.Validate("Starting Point", StartingPoint); - Expense.Validate("Ending Point", EndingPoint); + Expense.Validate("Starting Point", CopyStr(StartingPoint, 1, MaxStrLen(Expense."Starting Point"))); + Expense.Validate("Ending Point", CopyStr(EndingPoint, 1, MaxStrLen(Expense."Ending Point"))); Expense.Validate("Expense Ext. Doc. No.", ExpenseExtDocNo); Expense.Validate("Job No.", JobNo); Expense.Validate("Job Task No.", JobTaskNo); From 0cd5a2a98c8fcb24bd24b3816a75509de89f4c7c Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Sat, 22 Aug 2026 14:24:51 +0530 Subject: [PATCH 22/25] Narrow InsertExpense parameters to match Expense field lengths Replace the CopyStr bounding with correctly sized parameters (Justification Text[100], Payment Method Code Code[10], Starting/Ending Point Text[50]) to clear the AA0139 overflow warnings surfaced by building the demo data for the new countries. --- .../Contoso Helpers/ContosoExpenseAgent.Codeunit.al | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al index 834f090b00d..d01f93101f2 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Demo Tool/Contoso Helpers/ContosoExpenseAgent.Codeunit.al @@ -278,7 +278,7 @@ codeunit 8205 "Contoso Expense Agent" ExpenseUser.Insert(true); end; - internal procedure InsertExpense(ExpenseUserNo: Code[20]; ExpenseCategoryCode: Code[20]; ExpenseLocationCode: Code[30]; Description: Text[100]; Justification: Text[250]; ExpenseDate: Date; CurrencyCode: Code[10]; Amount: Decimal; MerchantName: Text[100]; PaymentMethodCode: Code[20]; Refundable: Boolean; Billable: Boolean; BillableToCustomer: Code[20]; StartingDateTime: DateTime; EndingDateTime: DateTime; NonRefundableAmount: Decimal; Mileage: Decimal; StartingPoint: Text[100]; EndingPoint: Text[100]; ExpenseExtDocNo: Text[30]; JobNo: Code[20]; JobTaskNo: Code[20]): Record Expense + internal procedure InsertExpense(ExpenseUserNo: Code[20]; ExpenseCategoryCode: Code[20]; ExpenseLocationCode: Code[30]; Description: Text[100]; Justification: Text[100]; ExpenseDate: Date; CurrencyCode: Code[10]; Amount: Decimal; MerchantName: Text[100]; PaymentMethodCode: Code[10]; Refundable: Boolean; Billable: Boolean; BillableToCustomer: Code[20]; StartingDateTime: DateTime; EndingDateTime: DateTime; NonRefundableAmount: Decimal; Mileage: Decimal; StartingPoint: Text[50]; EndingPoint: Text[50]; ExpenseExtDocNo: Text[30]; JobNo: Code[20]; JobTaskNo: Code[20]): Record Expense var Expense: Record Expense; begin @@ -286,7 +286,7 @@ codeunit 8205 "Contoso Expense Agent" Expense.Validate("Expense Category", ExpenseCategoryCode); Expense.Validate("Expense Location", ExpenseLocationCode); Expense.Validate("Description", Description); - Expense.Validate("Justification", CopyStr(Justification, 1, MaxStrLen(Expense.Justification))); + Expense.Validate("Justification", Justification); Expense.Validate("Expense Date", ExpenseDate); ValidateCurrencyCodeInExpense(Expense, CurrencyCode); @@ -294,7 +294,7 @@ codeunit 8205 "Contoso Expense Agent" if Amount <> 0 then Expense.Validate("Amount", Amount); Expense.Validate("Merchant Name", MerchantName); - Expense.Validate("Payment Method Code", CopyStr(PaymentMethodCode, 1, MaxStrLen(Expense."Payment Method Code"))); + Expense.Validate("Payment Method Code", PaymentMethodCode); Expense.Validate(Refundable, Refundable); Expense.Validate(Billable, Billable); Expense.Validate("Billable to Customer", BillableToCustomer); @@ -303,8 +303,8 @@ codeunit 8205 "Contoso Expense Agent" Expense.Validate("Non-Refundable Amount", NonRefundableAmount); if Mileage <> 0 then Expense.Validate("Mileage", Mileage); - Expense.Validate("Starting Point", CopyStr(StartingPoint, 1, MaxStrLen(Expense."Starting Point"))); - Expense.Validate("Ending Point", CopyStr(EndingPoint, 1, MaxStrLen(Expense."Ending Point"))); + Expense.Validate("Starting Point", StartingPoint); + Expense.Validate("Ending Point", EndingPoint); Expense.Validate("Expense Ext. Doc. No.", ExpenseExtDocNo); Expense.Validate("Job No.", JobNo); Expense.Validate("Job Task No.", JobTaskNo); From 6f9a7e594eea0fcaf81f30f9230e1ab36596f968 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Sun, 23 Aug 2026 08:32:11 +0530 Subject: [PATCH 23/25] Fix CZ Employee Posting Group --- .../Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al index 9fc1a5d9e01..ea098a0e96f 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CZ/1.Setup Data/UpdateEmpPostingGrpCZ.Codeunit.al @@ -26,7 +26,7 @@ codeunit 8470 "Update Emp. Posting Grp CZ" CreateEmployeePostingGroup: Codeunit "Create Employee Posting Group"; begin ContosoExpenseAgent.SetOverwriteData(true); - ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.PayablesToEmployeesName()), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), CreateExpGLAccountCZ.CompanyCardExpensesPayable(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.BankAccountKBName())); + ContosoExpenseAgent.UpdateEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.PayablesToEmployeesName()), CreateExpGLAccountCZ.EmployeeExpenseAdvances(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.BankAccountKBName()), CreateExpGLAccountCZ.CompanyCardExpensesPayable()); ContosoExpenseAgent.SetOverwriteData(false); UpdatePayablesAccountInEmployeePostingGroup(CreateEmployeePostingGroup.EmployeeExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.PayablesToEmployeesName())); From acfc0b6103356570ad7f674b1e3ae5d85c3aa4d6 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Sun, 23 Aug 2026 13:42:14 +0530 Subject: [PATCH 24/25] Consolidate 17 country Expense Agent setups into single W1 app Move per-country GL account/category resolution into the W1 Create Expense GL Account codeunit with country-aware name/search/fallback logic; retire per-country Expense Agent apps from build groups/projects/AL-Go settings and app.json internalsVisibleTo. Fix country account mappings surfaced during testing (DK prepayment 26400, DK other 05699, AT bank/card/travel/rounding names, NZ prepayment 2510, FR bank 512100, FR travel 625100, plus new-country fallbacks). --- build/groups.json | 170 -- build/projects.json | 140 -- build/projects/Apps AT/.AL-Go/settings.json | 1 - build/projects/Apps AU/.AL-Go/settings.json | 1 - build/projects/Apps CA/.AL-Go/settings.json | 1 - build/projects/Apps DE/.AL-Go/settings.json | 1 - build/projects/Apps DK/.AL-Go/settings.json | 1 - build/projects/Apps ES/.AL-Go/settings.json | 1 - build/projects/Apps FR/.AL-Go/settings.json | 1 - build/projects/Apps GB/.AL-Go/settings.json | 1 - build/projects/Apps NZ/.AL-Go/settings.json | 1 - build/projects/Apps US/.AL-Go/settings.json | 1 - .../src/ExpenseEventSubscriberAT.Codeunit.al | 415 +---- .../src/ExpenseEventSubscriberAU.Codeunit.al | 261 +-- .../src/ExpenseEventSubscriberCA.Codeunit.al | 299 +--- .../src/ExpenseEventSubscriberDE.Codeunit.al | 282 +--- .../src/ExpenseEventSubscriberDK.Codeunit.al | 275 +--- .../src/ExpenseEventSubscriberES.Codeunit.al | 327 +--- .../src/ExpenseEventSubscriberFR.Codeunit.al | 282 +--- .../src/ExpenseEventSubscriberGB.Codeunit.al | 268 +-- .../src/ExpenseEventSubscriberNZ.Codeunit.al | 292 +--- .../src/ExpenseEventSubscriberUS.Codeunit.al | 268 +-- src/Apps/W1/ExpenseAgent/app/app.json | 50 - .../CreateExpenseCategories.Codeunit.al | 96 +- .../CreateExpenseGLAccount.Codeunit.al | 1456 ++++++++++++++++- 25 files changed, 1549 insertions(+), 3342 deletions(-) diff --git a/build/groups.json b/build/groups.json index 53a6b78d678..4e84d8d9e33 100644 --- a/build/groups.json +++ b/build/groups.json @@ -8662,176 +8662,6 @@ } ] }, - { - "name": "Expense Agent (Preview) (US)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (NZ)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (AT)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (AU)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (CA)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (DE)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (DK)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (ES)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (FR)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, - { - "name": "Expense Agent (Preview) (GB)", - "groups": [ - { - "name": "AllExtensions" - }, - { - "name": "Financials" - }, - { - "name": "FinancialsExtensions" - }, - { - "name": "ContosoDemoData" - } - ] - }, { "name": "Expense Agent Tests", "groups": [ diff --git a/build/projects.json b/build/projects.json index e9a17fe3b3c..83ec58f78f7 100644 --- a/build/projects.json +++ b/build/projects.json @@ -5275,146 +5275,6 @@ "skipInstallOnPrem": true, "owningteam": "\\AI Business Solutions\\Finance" }, - "Expense Agent (Preview) (US)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\US\\ExpenseAgent_US\\app", - "hasTranslations": true, - "supportedCountries": [ - "US" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (NZ)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\NZ\\ExpenseAgent_NZ\\app", - "hasTranslations": true, - "supportedCountries": [ - "NZ" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (AT)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\AT\\ExpenseAgent_AT\\app", - "hasTranslations": true, - "supportedCountries": [ - "AT" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (AU)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\AU\\ExpenseAgent_AU\\app", - "hasTranslations": true, - "supportedCountries": [ - "AU" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (CA)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\CA\\ExpenseAgent_CA\\app", - "hasTranslations": true, - "supportedCountries": [ - "CA" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (DE)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\DE\\ExpenseAgent_DE\\app", - "hasTranslations": true, - "supportedCountries": [ - "DE" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (DK)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\DK\\ExpenseAgent_DK\\app", - "hasTranslations": true, - "supportedCountries": [ - "DK" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (ES)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\ES\\ExpenseAgent_ES\\app", - "hasTranslations": true, - "supportedCountries": [ - "ES" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (FR)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\FR\\ExpenseAgent_FR\\app", - "hasTranslations": true, - "supportedCountries": [ - "FR" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, - "Expense Agent (Preview) (GB)": { - "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\GB\\ExpenseAgent_GB\\app", - "hasTranslations": true, - "supportedCountries": [ - "GB" - ], - "runStaticCodeAnalysis": true, - "installOnEnvironmentUpdate": true, - "logLevel": "warning", - "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", - "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.ruleset.json", - "skipInstallOnPrem": true, - "owningteam": "\\AI Business Solutions\\Finance" - }, "Expense Agent Tests": { "projectPath": "$env:INETROOT\\App\\BCApps\\src\\Apps\\W1\\ExpenseAgent\\test", "supportedCountries": "All", diff --git a/build/projects/Apps AT/.AL-Go/settings.json b/build/projects/Apps AT/.AL-Go/settings.json index 433794c2277..dd817a2ac58 100644 --- a/build/projects/Apps AT/.AL-Go/settings.json +++ b/build/projects/Apps AT/.AL-Go/settings.json @@ -5,7 +5,6 @@ "appFolders": [ "../../../src/Apps/AT/ContosoCoffeeDemoDatasetAT/app", "../../../src/Apps/AT/EDocument_AT/demo data", - "../../../src/Apps/AT/ExpenseAgent_AT/app", "../../../src/Apps/AT/HybridBCLast_AT/app", "../../../src/Apps/AT/IntrastatAT/app", "../../../src/Apps/DACH/Onprem Permissions DACH/app", diff --git a/build/projects/Apps AU/.AL-Go/settings.json b/build/projects/Apps AU/.AL-Go/settings.json index 6a83fc8cfcb..b2262987909 100644 --- a/build/projects/Apps AU/.AL-Go/settings.json +++ b/build/projects/Apps AU/.AL-Go/settings.json @@ -6,7 +6,6 @@ "../../../src/Apps/APAC/EDocumentFormats/PINT A-NZ/app", "../../../src/Apps/AU/ContosoCoffeeDemoDatasetAU/app", "../../../src/Apps/AU/EDocument_AU/demo data", - "../../../src/Apps/AU/ExpenseAgent_AU/app", "../../../src/Apps/AU/HybridBCLast_AU/app", "../../../src/Apps/AU/Onprem Permissions AU/app", "../../../src/Apps/W1/AgentDesignExperience/app", diff --git a/build/projects/Apps CA/.AL-Go/settings.json b/build/projects/Apps CA/.AL-Go/settings.json index 449f3d2813f..184ed3b4d46 100644 --- a/build/projects/Apps CA/.AL-Go/settings.json +++ b/build/projects/Apps CA/.AL-Go/settings.json @@ -5,7 +5,6 @@ "appFolders": [ "../../../src/Apps/CA/ContosoCoffeeDemoDatasetCA/app", "../../../src/Apps/CA/EDocument_CA/demo data", - "../../../src/Apps/CA/ExpenseAgent_CA/app", "../../../src/Apps/CA/HybridBCLast_CA/app", "../../../src/Apps/NA/Ceridian/app", "../../../src/Apps/NA/EnvestnetYodleeBankFeeds/app", diff --git a/build/projects/Apps DE/.AL-Go/settings.json b/build/projects/Apps DE/.AL-Go/settings.json index e52d2b983ae..69d9ef11982 100644 --- a/build/projects/Apps DE/.AL-Go/settings.json +++ b/build/projects/Apps DE/.AL-Go/settings.json @@ -8,7 +8,6 @@ "../../../src/Apps/DE/EDocumentDE/app", "../../../src/Apps/DE/EDocumentDE/demo data", "../../../src/Apps/DE/Elster/app", - "../../../src/Apps/DE/ExpenseAgent_DE/app", "../../../src/Apps/DE/HybridBCLast_DE/app", "../../../src/Apps/DE/IntrastatDE/app", "../../../src/Apps/DE/PEPPOLDE/app", diff --git a/build/projects/Apps DK/.AL-Go/settings.json b/build/projects/Apps DK/.AL-Go/settings.json index 53d077badaf..0705145cc2c 100644 --- a/build/projects/Apps DK/.AL-Go/settings.json +++ b/build/projects/Apps DK/.AL-Go/settings.json @@ -10,7 +10,6 @@ "../../../src/Apps/DK/EDocumentFormatOIOUBL/app", "../../../src/Apps/DK/ElectronicVATDeclarationDK/app", "../../../src/Apps/DK/EnforcedDigitalVouchersDK/app", - "../../../src/Apps/DK/ExpenseAgent_DK/app", "../../../src/Apps/DK/FIK/app", "../../../src/Apps/DK/ImportDKPayroll/app", "../../../src/Apps/DK/NemhandelNotification/app", diff --git a/build/projects/Apps ES/.AL-Go/settings.json b/build/projects/Apps ES/.AL-Go/settings.json index 2b3aa0d7553..e6e92209f6f 100644 --- a/build/projects/Apps ES/.AL-Go/settings.json +++ b/build/projects/Apps ES/.AL-Go/settings.json @@ -7,7 +7,6 @@ "../../../src/Apps/ES/EDocumentES/demo data", "../../../src/Apps/ES/EDocumentFormats/DocumentRegistration/app", "../../../src/Apps/ES/EDocumentFormats/FacturaE/app", - "../../../src/Apps/ES/ExpenseAgent_ES/app", "../../../src/Apps/ES/HybridBCLast_ES/app", "../../../src/Apps/ES/IntrastatES/app", "../../../src/Apps/ES/Onprem Permissions ES/app", diff --git a/build/projects/Apps FR/.AL-Go/settings.json b/build/projects/Apps FR/.AL-Go/settings.json index 18b226a0215..6d0a135bb66 100644 --- a/build/projects/Apps FR/.AL-Go/settings.json +++ b/build/projects/Apps FR/.AL-Go/settings.json @@ -6,7 +6,6 @@ "../../../src/Apps/FR/ContosoCoffeeDemoDatasetFR/app", "../../../src/Apps/FR/EDocument_FR/demo data", "../../../src/Apps/FR/EDocument_FR/EReportingFR/app", - "../../../src/Apps/FR/ExpenseAgent_FR/app", "../../../src/Apps/FR/FAReportsFR/app", "../../../src/Apps/FR/FECAuditFile/app", "../../../src/Apps/FR/HybridBCLast_FR/app", diff --git a/build/projects/Apps GB/.AL-Go/settings.json b/build/projects/Apps GB/.AL-Go/settings.json index c40bb9158f6..ff7b7730102 100644 --- a/build/projects/Apps GB/.AL-Go/settings.json +++ b/build/projects/Apps GB/.AL-Go/settings.json @@ -5,7 +5,6 @@ "appFolders": [ "../../../src/Apps/GB/ContosoCoffeeDemoDatasetGB/app", "../../../src/Apps/GB/EDocument_GB/demo data", - "../../../src/Apps/GB/ExpenseAgent_GB/app", "../../../src/Apps/GB/GovTalk/app", "../../../src/Apps/GB/GovTalk/demo data", "../../../src/Apps/GB/IdealPostcodes/app", diff --git a/build/projects/Apps NZ/.AL-Go/settings.json b/build/projects/Apps NZ/.AL-Go/settings.json index ee9520013f7..8b9e418705a 100644 --- a/build/projects/Apps NZ/.AL-Go/settings.json +++ b/build/projects/Apps NZ/.AL-Go/settings.json @@ -6,7 +6,6 @@ "../../../src/Apps/APAC/EDocumentFormats/PINT A-NZ/app", "../../../src/Apps/NZ/ContosoCoffeeDemoDatasetNZ/app", "../../../src/Apps/NZ/EDocument_NZ/demo data", - "../../../src/Apps/NZ/ExpenseAgent_NZ/app", "../../../src/Apps/NZ/HybridBCLast_NZ/app", "../../../src/Apps/W1/AgentDesignExperience/app", "../../../src/Apps/W1/AgentSamples/app", diff --git a/build/projects/Apps US/.AL-Go/settings.json b/build/projects/Apps US/.AL-Go/settings.json index 95dbfabd1ca..30963fcca58 100644 --- a/build/projects/Apps US/.AL-Go/settings.json +++ b/build/projects/Apps US/.AL-Go/settings.json @@ -11,7 +11,6 @@ "../../../src/Apps/NA/PEPPOLNA/app", "../../../src/Apps/US/ContosoCoffeeDemoDatasetUS/app", "../../../src/Apps/US/EDocument_US/demo data", - "../../../src/Apps/US/ExpenseAgent_US/app", "../../../src/Apps/US/HybridBCLast_US/app", "../../../src/Apps/US/HybridGP_US/app", "../../../src/Apps/US/HybridSL_US/app", diff --git a/src/Apps/AT/ExpenseAgent_AT/app/src/ExpenseEventSubscriberAT.Codeunit.al b/src/Apps/AT/ExpenseAgent_AT/app/src/ExpenseEventSubscriberAT.Codeunit.al index 8a960dc318d..180e536f9cf 100644 --- a/src/Apps/AT/ExpenseAgent_AT/app/src/ExpenseEventSubscriberAT.Codeunit.al +++ b/src/Apps/AT/ExpenseAgent_AT/app/src/ExpenseEventSubscriberAT.Codeunit.al @@ -4,420 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6914 "Expense Event Subscriber AT" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemARefundableDebitAccountNo(), ExpensePerDiemARefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemIRefundableDebitAccountNo(), ExpensePerDiemIRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealNonRefundableDebitAccountNo(), ExpenseMealNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeAddPostingGroupSeed', '', false, false)] - local procedure OnBeforeAddPostingGroupSeed(Code: Code[20]; var IsHandled: Boolean) - begin - if Code = CreateExpenseCategories.GetEXPENSEPERDIEMTxt() then - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnAfterBuildPostingGroupSeeds', '', false, false)] - local procedure OnAfterBuildPostingGroupSeeds(var TempPostingGroup: Record "Expense Posting Group" temporary) - begin - CreateExpenseCategories.AddPostingGroupSeed(TempPostingGroup, ExpensePerDiemI(), ExpensePerDiemInCountryLbl, ExpensePerDiemIRefundableDebitAccountNo()); - CreateExpenseCategories.AddPostingGroupSeed(TempPostingGroup, ExpensePerDiemA(), ExpensePerDiemAbroadLbl, ExpensePerDiemARefundableDebitAccountNo()); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnAfterBuildCategorySeeds', '', false, false)] - local procedure OnAfterBuildCategorySeeds(var TempCategory: Record "Expense Category" temporary) - begin - CreateExpenseCategories.AddCategorySeed(TempCategory, PerDiemI(), PerDiemByAssignedPolicyLbl, PerDiemIByAssignedPolicyPostingLbl, CreateExpenseCategories.GetTRAVELTxt(), ExpensePerDiemI(), CreateExpenseCategories.GetCASHTxt(), true, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::"Per Diem"); - CreateExpenseCategories.AddCategorySeed(TempCategory, PerDiemA(), PerDiemByAssignedPolicyLbl, PerDiemAByAssignedPolicyPostingLbl, CreateExpenseCategories.GetTRAVELTxt(), ExpensePerDiemA(), CreateExpenseCategories.GetCASHTxt(), true, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::"Per Diem"); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnAfterBuildSubcategorySeeds', '', false, false)] - local procedure OnAfterBuildSubcategorySeeds(var TempSubcategory: Record "Expense Subcategory" temporary) - begin - CreateExpenseCategories.AddSubcategorySeed(TempSubcategory, Country(), PerDiemA(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, true, false); - CreateExpenseCategories.AddSubcategorySeed(TempSubcategory, Intl(), PerDiemI(), InternationalPerDiemLbl, InternationalPerDiemPostingLbl, true, false); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnAfterBuildRuleSeeds', '', false, false)] - local procedure OnAfterBuildRuleSeeds(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemI(), CreateExpenseCategories.GetCANADAALLTxt(), 'CAD', "Expense Justification"::" "); - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemI(), CreateExpenseCategories.GetDENMARKALLTxt(), 'USD', "Expense Justification"::" "); - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemA(), CreateExpenseCategories.GetDOMESTICTxt(), 'USD', "Expense Justification"::" "); - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemI(), CreateExpenseCategories.GetFRANCEALLTxt(), 'USD', "Expense Justification"::" "); - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemI(), CreateExpenseCategories.GetGERMANYALLTxt(), 'USD', "Expense Justification"::" "); - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemI(), CreateExpenseCategories.GetUKOTHERTxt(), 'GBP', "Expense Justification"::" "); - CreateExpenseCategories.AddRuleSeed(TempRuleHeader, PerDiemI(), CreateExpenseCategories.GetUSAOTHERTxt(), 'USD', "Expense Justification"::" "); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnAfterBuildRuleConditionSeeds', '', false, false)] - local procedure OnAfterBuildRuleConditionSeeds(var TempRuleCondition: Record "Expense Rule Condition" temporary) - begin - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemI(), CreateExpenseCategories.GetCANADAALLTxt(), "Expense Rule Condition Type"::"Daily Rate", 125); - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemI(), CreateExpenseCategories.GetDENMARKALLTxt(), "Expense Rule Condition Type"::"Daily Rate", 450); - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemA(), CreateExpenseCategories.GetDOMESTICTxt(), "Expense Rule Condition Type"::"Daily Rate", 50); - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemI(), CreateExpenseCategories.GetFRANCEALLTxt(), "Expense Rule Condition Type"::"Daily Rate", 110); - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemI(), CreateExpenseCategories.GetGERMANYALLTxt(), "Expense Rule Condition Type"::"Daily Rate", 105); - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemI(), CreateExpenseCategories.GetUKOTHERTxt(), "Expense Rule Condition Type"::"Daily Rate", 115); - CreateExpenseCategories.AddRuleConditionSeed(TempRuleCondition, PerDiemI(), CreateExpenseCategories.GetUSAOTHERTxt(), "Expense Rule Condition Type"::"Daily Rate", 120); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeAddCategorySeed', '', false, false)] - local procedure OnBeforeAddCategorySeed(Code: Code[20]; var IsHandled: Boolean) - begin - if Code = CreateExpenseCategories.GetPERDIEMTxt() then - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeAddSubcategorySeed', '', false, false)] - local procedure OnBeforeAddSubcategorySeed(CategoryCode: Code[20]; var IsHandled: Boolean) - begin - if CategoryCode = CreateExpenseCategories.GetPERDIEMTxt() then - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeAddRuleSeed', '', false, false)] - local procedure OnBeforeAddRuleSeed(CategoryCode: Code[20]; var IsHandled: Boolean) - begin - if CategoryCode = CreateExpenseCategories.GetPERDIEMTxt() then - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeAddRuleConditionSeed', '', false, false)] - local procedure OnBeforeAddRuleConditionSeed(CategoryCode: Code[20]; var IsHandled: Boolean) - begin - if CategoryCode = CreateExpenseCategories.GetPERDIEMTxt() then - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - ExpensePerDiemI(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemIRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - ExpensePerDiemA(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemARefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseMealNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7740'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7310'); - end; - - local procedure ExpensePerDiemARefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemARefundableLbl, ExpensePerDiemARefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7360'); - end; - - local procedure ExpensePerDiemIRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemIRefundableLbl, ExpensePerDiemIRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7350'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7340'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7691'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7680'); - end; - - local procedure ExpenseMealNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealNonRefundableLbl, ExpenseMealNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7692'); - end; - - local procedure ExpenseOtherNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7745'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2770'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8070'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8070'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('3680'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2770'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2800'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2830'); - end; - - local procedure ExpensePerDiemI(): Code[20] - begin - exit(ExpensePERDIEMITok); - end; - - local procedure ExpensePerDiemA(): Code[20] - begin - exit(ExpensePERDIEMATok); - end; - - local procedure PerDiemI(): Code[20] - begin - exit(PerDiemITok); - end; - - local procedure PerDiemA(): Code[20] - begin - exit(PerDiemATok); - end; - - local procedure Country(): Code[20] - begin - exit(CountryTok); - end; - - local procedure Intl(): Code[20] - begin - exit(IntlTok); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - CreateExpenseCategories: Codeunit "Create Expense Categories"; - ExpenseOtherRefundableLbl: Label 'Other', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Other', MaxLength = 30; - ExpenseMealNonRefundableLbl: Label 'Meal expenses, nondeductible', MaxLength = 100; - ExpenseMealNonRefundableSearchLbl: Label 'Meal expenses, nondeductible', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Misc. external expenses, nondeductible', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'external expenses', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Settlement account cash bank', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Settlement account cash', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Application Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Application Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Transportation third parties', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Transportation third', MaxLength = 30; - ExpensePerDiemARefundableLbl: Label 'Meal expenses abroad', MaxLength = 100; - ExpensePerDiemARefundableSearchLbl: Label 'Meal expenses abroad', MaxLength = 30; - ExpensePerDiemIRefundableLbl: Label 'Meal expenses domestic', MaxLength = 100; - ExpensePerDiemIRefundableSearchLbl: Label 'Meal expenses domestic', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Kilometer allowance', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Kilometer', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Hospitality domestic deductible amount', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Hospitality domestic', MaxLength = 30; - ExpensePayableCashLbl: Label 'Employees Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Settlement account cash bank', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Settlement account cash', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit card clearing account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Bank, LCY', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'Bank', MaxLength = 30; - ExpensePERDIEMITok: Label 'EXPENSE-PERDIEM-I', MaxLength = 20, Locked = true; - ExpensePerDiemInCountryLbl: Label 'Expense - Per Diem in country', MaxLength = 100; - ExpensePERDIEMATok: Label 'EXPENSE-PERDIEM-A', MaxLength = 20, Locked = true; - ExpensePerDiemAbroadLbl: Label 'Expense - Per Diem abroad', MaxLength = 100; - PerDiemITok: Label 'PER-DIEM-I', MaxLength = 20, Locked = true; - PerDiemATok: Label 'PER-DIEM-A', MaxLength = 20, Locked = true; - PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250; - PerDiemIByAssignedPolicyPostingLbl: Label 'Per-diem (international) by assigned policy', MaxLength = 100; - PerDiemAByAssignedPolicyPostingLbl: Label 'Per-diem (local) by assigned policy', MaxLength = 100; - CountryTok: Label 'COUNTRY', MaxLength = 20, Locked = true; - IntlTok: Label 'INTL', MaxLength = 20, Locked = true; - LocalCountryPerDiemLbl: Label 'Daily per-diem allowance based on domestic travel rates, paid instead of individual meal or incidental expense reimbursements.', MaxLength = 250; - InternationalPerDiemLbl: Label 'Daily per-diem allowance for international business travel, based on applicable foreign travel rates.', MaxLength = 250; - LocalCountryPerDiemPostingLbl: Label 'Local country per-diem', MaxLength = 100; - InternationalPerDiemPostingLbl: Label 'International per-diem', MaxLength = 100; + ObsoleteState = Pending; + ObsoleteReason = 'The AT-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/AU/ExpenseAgent_AU/app/src/ExpenseEventSubscriberAU.Codeunit.al b/src/Apps/AU/ExpenseAgent_AU/app/src/ExpenseEventSubscriberAU.Codeunit.al index ac08aeb3f09..899c92c5ff3 100644 --- a/src/Apps/AU/ExpenseAgent_AU/app/src/ExpenseEventSubscriberAU.Codeunit.al +++ b/src/Apps/AU/ExpenseAgent_AU/app/src/ExpenseEventSubscriberAU.Codeunit.al @@ -4,266 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6915 "Expense Event Subscriber AU" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6236'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6249'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6246'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6247'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6248'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6235'); - end; - - local procedure ExpenseNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7240'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1512'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('4756'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('4756'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2378'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1512'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1010'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1025'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Business Entertaining, nondeductible', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Business Entertaining', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Finance Charges to Vendors', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Finance Charges to Vendors', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Employee Prepayments, Expenses', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Entertainment and PR', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Employees Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Employee Prepayments', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Bank, LCY', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The AU-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/CA/ExpenseAgent_CA/app/src/ExpenseEventSubscriberCA.Codeunit.al b/src/Apps/CA/ExpenseAgent_CA/app/src/ExpenseEventSubscriberCA.Codeunit.al index 1930b1ad7a9..827b9db51b9 100644 --- a/src/Apps/CA/ExpenseAgent_CA/app/src/ExpenseEventSubscriberCA.Codeunit.al +++ b/src/Apps/CA/ExpenseAgent_CA/app/src/ExpenseEventSubscriberCA.Codeunit.al @@ -4,304 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6916 "Expense Event Subscriber CA" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountCategory: Record "G/L Account Category"; - GLAccountIndent: Codeunit "G/L Account-Indent"; - SubCategory: Text[80]; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); - CreateExpenseGLAccount.InsertGLAccount(EmployeePrepaymentsAccountNo(), ExpensePrepaymentBeginLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', '', 0, '', Enum::"G/L Account Type"::"Begin-Total", '', '', false, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(EmployeePrepaymentsTotalAccountNo(), ExpensePrepaymentTotalLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', '', 0, EmployeePrepaymentsAccountNo() + '..' + EmployeePrepaymentsTotalAccountNo(), Enum::"G/L Account Type"::"End-Total", '', '', false, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertRuleSeed', '', false, false)] - local procedure OnBeforeInsertRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - if TempRuleHeader."Currency Code" = 'CAD' then - TempRuleHeader."Currency Code" := ''; - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('67430'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('61340'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('61310'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('61320'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('61330'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('61200'); - end; - - local procedure ExpenseNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('71900'); - end; - - local procedure EmployeePrepaymentsAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentBeginLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('13600'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('13610'); - end; - - local procedure EmployeePrepaymentsTotalAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentTotalLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('13690'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('47400'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('47400'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('23850'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('13610'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('11120'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('11160'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Misc. external expenses, nondeductible', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Misc. external', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Finance Charges to Vendors', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Finance Charges to Vendors', MaxLength = 30; - ExpensePrepaymentBeginLbl: Label 'Employee prepayments', MaxLength = 100; - ExpenseOtherPrepaymentLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; - ExpensePrepaymentTotalLbl: Label 'Employee Prepayments, Total', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Employee Prepayments, Expenses', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Entertainment and PR', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Vacation Compensation Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Employee Prepayments', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Bank, Checking', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The CA-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/DE/ExpenseAgent_DE/app/src/ExpenseEventSubscriberDE.Codeunit.al b/src/Apps/DE/ExpenseAgent_DE/app/src/ExpenseEventSubscriberDE.Codeunit.al index 44447703c05..3c5f31e3a79 100644 --- a/src/Apps/DE/ExpenseAgent_DE/app/src/ExpenseEventSubscriberDE.Codeunit.al +++ b/src/Apps/DE/ExpenseAgent_DE/app/src/ExpenseEventSubscriberDE.Codeunit.al @@ -4,287 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6917 "Expense Event Subscriber DE" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealNonRefundableDebitAccountNo(), ExpenseMealNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseMealNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertRuleSeed', '', false, false)] - local procedure OnBeforeInsertRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - if TempRuleHeader."Currency Code" = 'EUR' then - TempRuleHeader."Currency Code" := 'USD'; - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6300'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6650'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6664'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6658'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6660'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6640'); - end; - - local procedure ExpenseMealNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealNonRefundableLbl, ExpenseMealNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6662'); - end; - - local procedure ExpenseOtherNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6650'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1900'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7500'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('7500'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('4150'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1900'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1810'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('3510'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Misc. external expenses', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Misc. external', MaxLength = 30; - ExpenseMealNonRefundableLbl: Label 'Meal expenses, nondeductible', MaxLength = 100; - ExpenseMealNonRefundableSearchLbl: Label 'Meal expenses, nondeductible', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Assets in the form of prepaid expenses', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'prepaid expenses', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Sales Invoice Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Sales Invoice Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Board and lodging', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Business Entertaining, deductible', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Employees Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Assets in the form of prepaid expenses', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'prepaid expenses', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit card clearing account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Business account, Operating, Domestic', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The DE-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/DK/ExpenseAgent_DK/app/src/ExpenseEventSubscriberDK.Codeunit.al b/src/Apps/DK/ExpenseAgent_DK/app/src/ExpenseEventSubscriberDK.Codeunit.al index 17c8688ac60..89a60717860 100644 --- a/src/Apps/DK/ExpenseAgent_DK/app/src/ExpenseEventSubscriberDK.Codeunit.al +++ b/src/Apps/DK/ExpenseAgent_DK/app/src/ExpenseEventSubscriberDK.Codeunit.al @@ -4,280 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6918 "Expense Event Subscriber DK" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealNonRefundableDebitAccountNo(), ExpenseMealNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseMealNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('05699'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03650'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03652'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03180'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03660'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03630'); - end; - - local procedure ExpenseMealNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealNonRefundableLbl, ExpenseMealNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03661'); - end; - - local procedure ExpenseOtherNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('03655'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('26400'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('07570'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('07570'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('25100'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('26400'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('18200'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('18300'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Other expenses', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Other expenses', MaxLength = 30; - ExpenseMealNonRefundableLbl: Label 'Meal expenses, nondeductible', MaxLength = 100; - ExpenseMealNonRefundableSearchLbl: Label 'Meal expenses, nondeductible', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Non-deductible travel expenses', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Non-deductible travel', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Prepayments - Accrued Costs', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Prepayments', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Cent Discrepancies', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Cent Discrepancies', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Traveling, Trade Fairs etc.', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Travel allowances per diem', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'per diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage Rate', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Restaurant Dining', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Restaurant', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Ent., Wine / Tobacco / Spirits', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Accounts Payables', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Prepayments - Accrued Costs', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Prepayments', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Bank', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'Bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The DK-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/ES/ExpenseAgent_ES/app/src/ExpenseEventSubscriberES.Codeunit.al b/src/Apps/ES/ExpenseAgent_ES/app/src/ExpenseEventSubscriberES.Codeunit.al index e7373c0e544..c4cfa891ac4 100644 --- a/src/Apps/ES/ExpenseAgent_ES/app/src/ExpenseEventSubscriberES.Codeunit.al +++ b/src/Apps/ES/ExpenseAgent_ES/app/src/ExpenseEventSubscriberES.Codeunit.al @@ -4,332 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6919 "Expense Event Subscriber ES" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseProfitLossAccountNo(), ExpenseProfitLossLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealNonRefundableDebitAccountNo(), ExpenseMealNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - UpdateIncomeStatementBalanceAccount(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseMealNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertRuleSeed', '', false, false)] - local procedure OnBeforeInsertRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - if TempRuleHeader."Currency Code" = 'EUR' then - TempRuleHeader."Currency Code" := 'USD'; - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6290003'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6291001'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6291002'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6291003'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6292001'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6293001'); - end; - - local procedure ExpenseMealNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealNonRefundableLbl, ExpenseMealNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6292002'); - end; - - local procedure ExpenseOtherNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6299001'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('4800001'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6298001'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('6298001'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('4600001'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('4800001'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('5720001'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('5721001'); - end; - - local procedure ExpenseProfitLossAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpenseProfitLossLbl, ExpenseProfitLossSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('1290001'); - end; - - local procedure UpdateIncomeStatementBalanceAccount() - var - ProfitLossAccountNo: Code[20]; - begin - ProfitLossAccountNo := ExpenseProfitLossAccountNo(); - - UpdateIncomeStmtBalAcc(ExpenseOtherRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseTravelRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpensePerDiemRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseMileageRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseEntertainRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseMealsRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseMealNonRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseOtherNonRefundableDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpensePrepaymentDebitAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseDebitRoundingAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseCreditRoundingAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseReportPayableAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpenseReportPrepaymentAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpensePayableCardPaidAccountNo(), ProfitLossAccountNo); - UpdateIncomeStmtBalAcc(ExpensePayableBankPaidAccountNo(), ProfitLossAccountNo); - end; - - local procedure UpdateIncomeStmtBalAcc(No: Code[20]; IncomeStmtBalAcc: Code[20]) - var - GLAccount: Record "G/L Account"; - begin - if GLAccount.Get(No) then begin - GLAccount.Validate("Income Stmt. Bal. Acc.", IncomeStmtBalAcc); - GLAccount.Modify(); - end; - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Other Business Expenses', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Other Business Expenses', MaxLength = 30; - ExpenseMealNonRefundableLbl: Label 'Meal expenses, nondeductible', MaxLength = 100; - ExpenseMealNonRefundableSearchLbl: Label 'Meal expenses, nondeductible', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Other nondeductible travel expenses', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Other nondeductible travel', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Expenses Prepayments', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Expenses Prepayments', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Rounding Expenses Operating', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Rounding Expenses Operating', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Entertainment expenses', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Remuneration Advances', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Expenses Prepayments', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Expenses Prepayments', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit card clearing account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Banks Euro', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'Bank', MaxLength = 30; - ExpenseProfitLossLbl: Label 'Profit or Loss', MaxLength = 100; - ExpenseProfitLossSearchLbl: Label 'Profit or Loss', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The ES-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/FR/ExpenseAgent_FR/app/src/ExpenseEventSubscriberFR.Codeunit.al b/src/Apps/FR/ExpenseAgent_FR/app/src/ExpenseEventSubscriberFR.Codeunit.al index 442e423a795..c9a0c1eacf5 100644 --- a/src/Apps/FR/ExpenseAgent_FR/app/src/ExpenseEventSubscriberFR.Codeunit.al +++ b/src/Apps/FR/ExpenseAgent_FR/app/src/ExpenseEventSubscriberFR.Codeunit.al @@ -4,287 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6920 "Expense Event Subscriber FR" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealNonRefundableDebitAccountNo(), ExpenseMealNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseMealNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseOtherNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertRuleSeed', '', false, false)] - local procedure OnBeforeInsertRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - if TempRuleHeader."Currency Code" = 'EUR' then - TempRuleHeader."Currency Code" := 'USD'; - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625180'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625100'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625110'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625120'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625200'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625700'); - end; - - local procedure ExpenseMealNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealNonRefundableLbl, ExpenseMealNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625210'); - end; - - local procedure ExpenseOtherNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('625290'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('486200'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('658600'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('658600'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('438300'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('486200'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('512100'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('512900'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Other travel', MaxLength = 30; - ExpenseMealNonRefundableLbl: Label 'Meal expenses, nondeductible', MaxLength = 100; - ExpenseMealNonRefundableSearchLbl: Label 'Meal expenses, nondeductible', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Other nondeductible travel expenses', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Other nondeductible travel', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Expense prepayment account', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Expense prepayment', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Application Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Application Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Travel', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Entertainment and PR', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Employees Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Expense prepayment account', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Expense prepayment', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Bank, LCY', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The FR-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/GB/ExpenseAgent_GB/app/src/ExpenseEventSubscriberGB.Codeunit.al b/src/Apps/GB/ExpenseAgent_GB/app/src/ExpenseEventSubscriberGB.Codeunit.al index 8fdb0f7f1d3..691906a58bb 100644 --- a/src/Apps/GB/ExpenseAgent_GB/app/src/ExpenseEventSubscriberGB.Codeunit.al +++ b/src/Apps/GB/ExpenseAgent_GB/app/src/ExpenseEventSubscriberGB.Codeunit.al @@ -4,273 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6921 "Expense Event Subscriber GB" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertRuleSeed', '', false, false)] - local procedure OnBeforeInsertRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - if TempRuleHeader."Currency Code" = 'GBP' then - TempRuleHeader."Currency Code" := ''; - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('31540'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('30540'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('30550'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('30560'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('30535'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('30820'); - end; - - local procedure ExpenseNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('10390'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('76600'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('31330'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('31330'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('5850'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('78100'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('78400'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('78410'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Misc. external expenses', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Misc. external', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Other Incidental Revenue', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Other Incidental', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Other prepaid expenses and accrued income', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Other prepaid expenses', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Payable Invoice Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Payable Invoice Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Business Entertaining, deductible', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Employees Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Cash', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Cash', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Other bank accounts', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The GB-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/NZ/ExpenseAgent_NZ/app/src/ExpenseEventSubscriberNZ.Codeunit.al b/src/Apps/NZ/ExpenseAgent_NZ/app/src/ExpenseEventSubscriberNZ.Codeunit.al index 9b040e1324c..c2c73d1ae5e 100644 --- a/src/Apps/NZ/ExpenseAgent_NZ/app/src/ExpenseEventSubscriberNZ.Codeunit.al +++ b/src/Apps/NZ/ExpenseAgent_NZ/app/src/ExpenseEventSubscriberNZ.Codeunit.al @@ -4,297 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6977 "Expense Event Subscriber NZ" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountCategory: Record "G/L Account Category"; - GLAccountIndent: Codeunit "G/L Account-Indent"; - SubCategory: Text[80]; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80); - CreateExpenseGLAccount.InsertGLAccount(EmployeePrepaymentsAccountNo(), ExpensePrepaymentBeginLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', '', 0, '', Enum::"G/L Account Type"::"Begin-Total", '', '', false, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(EmployeePrepaymentsTotalAccountNo(), ExpensePrepaymentTotalLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', '', 0, EmployeePrepaymentsAccountNo() + '..' + EmployeePrepaymentsTotalAccountNo(), Enum::"G/L Account Type"::"End-Total", '', '', false, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8660'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8430'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8431'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8432'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8433'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('8420'); - end; - - local procedure ExpenseNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('9240'); - end; - - local procedure EmployeePrepaymentsAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentBeginLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2500'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2510'); - end; - - local procedure EmployeePrepaymentsTotalAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentTotalLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2590'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('9140'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('9140'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('5850'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2510'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2920'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('2950'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Misc. external expenses, nondeductible', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Misc. external', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Finance Charges to Vendors', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Finance Charges to Vendors', MaxLength = 30; - ExpensePrepaymentBeginLbl: Label 'Employee prepayments', MaxLength = 100; - ExpenseOtherPrepaymentLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; - ExpensePrepaymentTotalLbl: Label 'Employee Prepayments, Total', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'Employee Prepayments, Expenses', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Entertainment and PR', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Employees Payable', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Employee Prepayments', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Bank, LCY', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The NZ-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/US/ExpenseAgent_US/app/src/ExpenseEventSubscriberUS.Codeunit.al b/src/Apps/US/ExpenseAgent_US/app/src/ExpenseEventSubscriberUS.Codeunit.al index cf9c0be25b2..840c195522f 100644 --- a/src/Apps/US/ExpenseAgent_US/app/src/ExpenseEventSubscriberUS.Codeunit.al +++ b/src/Apps/US/ExpenseAgent_US/app/src/ExpenseEventSubscriberUS.Codeunit.al @@ -4,273 +4,11 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.ExpenseAgent; -using Microsoft.Finance.GeneralLedger.Account; -using Microsoft.HumanResources.Employee; - codeunit 6913 "Expense Event Subscriber US" { InherentEntitlements = X; InherentPermissions = X; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense GL Account", 'OnBeforeCreateGLAccount', '', false, false)] - local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) - var - GLAccountIndent: Codeunit "G/L Account-Indent"; - begin - CreateExpenseGLAccount.InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - CreateExpenseGLAccount.InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - - GLAccountIndent.Indent(); - IsHandled := true; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertPostingGroupSeed', '', false, false)] - local procedure OnBeforeInsertPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary) - var - CreateExpenseCategories: Codeunit "Create Expense Categories"; - begin - case TempPostingGroup.Code of - CreateExpenseCategories.GetEXPENSETRAVELTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseTravelRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEPERDIEMTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpensePerDiemRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEOTHERTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseOtherRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMILEAGETxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMileageRefundableDebitAccountNo(), '', ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEMEALSTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseMealsRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - CreateExpenseCategories.GetEXPENSEENTERTAINTxt(): - AddExpensePostingGroupAccount(TempPostingGroup, ExpenseEntertainRefundableDebitAccountNo(), ExpenseNonRefundableDebitAccountNo(), ExpensePrepaymentDebitAccountNo(), ExpenseDebitRoundingAccountNo(), ExpenseCreditRoundingAccountNo()); - end; - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeUpdateEmployeePostingGroup', '', false, false)] - local procedure OnBeforeUpdateEmployeePostingGroup(Code: Code[20]; var IsHandled: Boolean) - var - EmployeePostingGroup: Record "Employee Posting Group"; - begin - IsHandled := true; - if not EmployeePostingGroup.Get(Code) then - exit; - - EmployeePostingGroup.Validate("Expense Report Payable Account", ExpenseReportPayableAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Bank Paid Acc.", ExpensePayableBankPaidAccountNo()); - EmployeePostingGroup.Validate("Expense Payable Card Paid Acc.", ExpensePayableCardPaidAccountNo()); - EmployeePostingGroup.Validate("Exp. Report Prepayment Account", ExpenseReportPrepaymentAccountNo()); - EmployeePostingGroup.Modify(true); - end; - - [EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense Categories", 'OnBeforeInsertRuleSeed', '', false, false)] - local procedure OnBeforeInsertRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary) - begin - if TempRuleHeader."Currency Code" = 'USD' then - TempRuleHeader."Currency Code" := ''; - end; - - local procedure AddExpensePostingGroupAccount(var TempPostingGroup: Record "Expense Posting Group" temporary; RefundableDebitAccount: Code[20]; NonRefundableDebitAccount: Code[20]; PrepaymentCreditAccount: Code[20]; DebitRoundingAccount: Code[20]; CreditRoundingAccount: Code[20]) - begin - TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := NonRefundableDebitAccount; - TempPostingGroup."Prepayment Credit Account" := PrepaymentCreditAccount; - TempPostingGroup."Debit Rounding Account" := DebitRoundingAccount; - TempPostingGroup."Credit Rounding Account" := CreditRoundingAccount; - end; - - local procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('68280'); - end; - - local procedure ExpenseTravelRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('62340'); - end; - - local procedure ExpensePerDiemRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('62350'); - end; - - local procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('62360'); - end; - - local procedure ExpenseMealsRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('62370'); - end; - - local procedure ExpenseEntertainRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('63420'); - end; - - local procedure ExpenseNonRefundableDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('40390'); - end; - - local procedure ExpensePrepaymentDebitAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('16600'); - end; - - local procedure ExpenseDebitRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('67300'); - end; - - local procedure ExpenseCreditRoundingAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('67300'); - end; - - local procedure ExpenseReportPayableAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('22100'); - end; - - local procedure ExpenseReportPrepaymentAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('18100'); - end; - - local procedure ExpensePayableBankPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('18400'); - end; - - local procedure ExpensePayableCardPaidAccountNo(): Code[20] - var - ExistingAccNo: Code[20]; - begin - ExistingAccNo := CreateExpenseGLAccount.FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); - if ExistingAccNo <> '' then - exit(ExistingAccNo); - - exit('18600'); - end; - - var - CreateExpenseGLAccount: Codeunit "Create Expense GL Account"; - ExpenseOtherRefundableLbl: Label 'Misc. external expenses, nondeductible', MaxLength = 100; - ExpenseOtherRefundableSearchLbl: Label 'Misc. external', MaxLength = 30; - ExpenseOtherNonRefundableLbl: Label 'Other Incidental Revenue', MaxLength = 100; - ExpenseOtherNonRefundableSearchLbl: Label 'Other Incidental', MaxLength = 30; - ExpenseOtherPrepaymentLbl: Label 'Other prepaid expenses and accrued income', MaxLength = 100; - ExpenseOtherPrepaymentSearchLbl: Label 'prepaid expenses', MaxLength = 30; - ExpenseOtherDebitRoundingLbl: Label 'Payable Invoice Rounding', MaxLength = 100; - ExpenseOtherCreditRoundingLbl: Label 'Payable Invoice Rounding', MaxLength = 100; - ExpenseRoundingSearchLbl: Label 'Rounding', MaxLength = 30; - ExpenseTravelRefundableLbl: Label 'Other travel expenses', MaxLength = 100; - ExpenseTravelRefundableSearchLbl: Label 'Travel', MaxLength = 30; - ExpensePerDiemRefundableLbl: Label 'Per-diem travel expenses', MaxLength = 100; - ExpensePerDiemRefundableSearchLbl: Label 'Per-diem', MaxLength = 30; - ExpenseMileageRefundableLbl: Label 'Mileage travel expenses', MaxLength = 100; - ExpenseMileageRefundableSearchLbl: Label 'Mileage', MaxLength = 30; - ExpenseMealsRefundableLbl: Label 'Meal expenses, deductible', MaxLength = 100; - ExpenseMealsRefundableSearchLbl: Label 'Meals', MaxLength = 30; - ExpenseEntertainRefundableLbl: Label 'Business Entertaining, deductible', MaxLength = 100; - ExpenseEntertainRefundableSearchLbl: Label 'Entertain', MaxLength = 30; - ExpensePayableCashLbl: Label 'Accounts Payable, Domestic', MaxLength = 100; - ExpensePrepaymentLbl: Label 'Cash', MaxLength = 100; - ExpensePrepaymentSearchLbl: Label 'Cash', MaxLength = 30; - ExpensePayableCardPaidLbl: Label 'Company credit cards account', MaxLength = 100; - ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; - ExpensePayableBankPaidLbl: Label 'Other bank accounts', MaxLength = 100; - ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ObsoleteState = Pending; + ObsoleteReason = 'The US-specific expense setup has been merged into the base Expense Agent app.'; + ObsoleteTag = '29.0'; } \ No newline at end of file diff --git a/src/Apps/W1/ExpenseAgent/app/app.json b/src/Apps/W1/ExpenseAgent/app/app.json index 9311c235bb7..3402b1be02e 100644 --- a/src/Apps/W1/ExpenseAgent/app/app.json +++ b/src/Apps/W1/ExpenseAgent/app/app.json @@ -23,56 +23,6 @@ "name": "Expense Agent Demo Data", "publisher": "Microsoft" }, - { - "id": "d4f8bc4d-8a7e-4008-b8a3-93721589ce98", - "name": "Expense Agent (Preview) (NZ)", - "publisher": "Microsoft" - }, - { - "id": "fa126935-93d3-4e4e-a006-4f7406625d2e", - "name": "Expense Agent (Preview) (US)", - "publisher": "Microsoft" - }, - { - "id": "c60a4c19-38b7-4d2b-96bb-edfcea98cf1f", - "name": "Expense Agent (Preview) (AT)", - "publisher": "Microsoft" - }, - { - "id": "646b8424-68af-4eb3-b325-97f695cdb19f", - "name": "Expense Agent (Preview) (AU)", - "publisher": "Microsoft" - }, - { - "id": "9a6af095-afbf-449a-a516-8147c96060da", - "name": "Expense Agent (Preview) (CA)", - "publisher": "Microsoft" - }, - { - "id": "cb71e33d-b543-4d2a-8098-b27b38649687", - "name": "Expense Agent (Preview) (DE)", - "publisher": "Microsoft" - }, - { - "id": "f1c6dae4-c092-429f-845c-00657fa4d293", - "name": "Expense Agent (Preview) (DK)", - "publisher": "Microsoft" - }, - { - "id": "c4b4a30a-16cd-4b0b-9a3f-9962d74d8cb9", - "name": "Expense Agent (Preview) (ES)", - "publisher": "Microsoft" - }, - { - "id": "8b524ccf-12e4-4f6c-9325-71bdb18f7284", - "name": "Expense Agent (Preview) (FR)", - "publisher": "Microsoft" - }, - { - "id": "b299c435-af71-4b42-b15b-f1cdddd1a561", - "name": "Expense Agent (Preview) (GB)", - "publisher": "Microsoft" - }, { "id": "4cb44e6c-9a37-4d4e-b45f-1b3054ddc59a", "name": "Expense Withholding Tax", diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al index 05b2c49c9ff..9113665055a 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseCategories.Codeunit.al @@ -5,6 +5,8 @@ namespace Microsoft.ExpenseAgent; using Microsoft.Finance.Currency; +using Microsoft.Finance.GeneralLedger.Setup; +using Microsoft.Foundation.Company; using Microsoft.HumanResources.Employee; codeunit 6973 "Create Expense Categories" @@ -102,6 +104,11 @@ codeunit 6973 "Create Expense Categories" AddPostingGroupSeed(TempPostingGroup, XEXPENSEMEALSTxt, XExpenseMealsDescTxt, CreateExpenseGLAccount.ExpenseMealsRefundableDebitAccountNo()); AddPostingGroupSeed(TempPostingGroup, XEXPENSEENTERTAINTxt, XExpenseEntertainDescTxt, CreateExpenseGLAccount.ExpenseEntertainRefundableDebitAccountNo()); + if GetCountryCode() = 'AT' then begin + AddPostingGroupSeed(TempPostingGroup, XEXPENSEPERDIEMITxt, XExpensePerDiemInCountryDescTxt, CreateExpenseGLAccount.ExpensePerDiemIRefundableDebitAccountNo()); + AddPostingGroupSeed(TempPostingGroup, XEXPENSEPERDIEMATxt, XExpensePerDiemAbroadDescTxt, CreateExpenseGLAccount.ExpensePerDiemARefundableDebitAccountNo()); + end; + OnAfterBuildPostingGroupSeeds(TempPostingGroup); end; @@ -143,14 +150,27 @@ codeunit 6973 "Create Expense Categories" if IsHandled then exit; + if (GetCountryCode() = 'AT') and (Code = XEXPENSEPERDIEMTxt) then + exit; + TempPostingGroup.Init(); TempPostingGroup.Code := Code; TempPostingGroup.Description := Description; TempPostingGroup."Refundable Debit Account" := RefundableDebitAccount; - TempPostingGroup."Non-Refundable Debit Account" := CreateExpenseGLAccount.ExpenseNonRefundableDebitAccountNo(); + if (Code <> XEXPENSEPERDIEMTxt) and (Code <> XEXPENSEMILEAGETxt) then + TempPostingGroup."Non-Refundable Debit Account" := CreateExpenseGLAccount.ExpenseNonRefundableDebitAccountNo(); TempPostingGroup."Prepayment Credit Account" := CreateExpenseGLAccount.ExpensePrepaymentDebitAccountNo(); TempPostingGroup."Debit Rounding Account" := CreateExpenseGLAccount.ExpenseDebitRoundingAccountNo(); TempPostingGroup."Credit Rounding Account" := CreateExpenseGLAccount.ExpenseCreditRoundingAccountNo(); + if GetCountryCode() = 'AT' then + case Code of + XEXPENSEMEALSTxt: + TempPostingGroup."Non-Refundable Debit Account" := CreateExpenseGLAccount.ExpenseMealNonRefundableDebitAccountNo(); + XEXPENSEENTERTAINTxt, XEXPENSEPERDIEMITxt, XEXPENSEPERDIEMATxt: + TempPostingGroup."Non-Refundable Debit Account" := ''; + end; + if (GetCountryCode() in ['DE', 'DK', 'ES', 'FR']) and (Code = XEXPENSEMEALSTxt) then + TempPostingGroup."Non-Refundable Debit Account" := CreateExpenseGLAccount.ExpenseMealNonRefundableDebitAccountNo(); OnBeforeInsertPostingGroupSeed(TempPostingGroup); TempPostingGroup.Insert(); end; @@ -240,6 +260,11 @@ codeunit 6973 "Create Expense Categories" AddCategorySeed(TempCategory, XTIPSTxt, XTipsDescTxt, XTipsPostingTxt, XFOODBEVERAGETxt, XEXPENSEOTHERTxt, XCASHTxt, false, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::" "); AddCategorySeed(TempCategory, XTOLLSTxt, XTollRoadUsageFeeTxt, XTollsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCASHTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" "); + if GetCountryCode() = 'AT' then begin + AddCategorySeed(TempCategory, XPERDIEMITxt, XPerDiemDescTxt, XPerDiemIByAssignedPolicyPostingTxt, XTRAVELTxt, XEXPENSEPERDIEMITxt, XCASHTxt, true, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::"Per Diem"); + AddCategorySeed(TempCategory, XPERDIEMATxt, XPerDiemDescTxt, XPerDiemAByAssignedPolicyPostingTxt, XTRAVELTxt, XEXPENSEPERDIEMATxt, XCASHTxt, true, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::"Per Diem"); + end; + OnAfterBuildCategorySeeds(TempCategory); end; @@ -356,6 +381,11 @@ codeunit 6973 "Create Expense Categories" // FINES AddSubcategorySeed(TempSubcategory, XFINESTxt, XFINESTxt, XFinesSubDescTxt, XFinesPostingTxt, true, false); + if GetCountryCode() = 'AT' then begin + AddSubcategorySeed(TempSubcategory, XCOUNTRYTxt, XPERDIEMATxt, XCountryPerDiemDescTxt, XSubCountryPerDiemPostingTxt, true, false); + AddSubcategorySeed(TempSubcategory, XINTLTxt, XPERDIEMITxt, XIntlPerDiemDescTxt, XSubIntlPerDiemPostingTxt, true, false); + end; + OnAfterBuildSubcategorySeeds(TempSubcategory); end; @@ -623,6 +653,9 @@ codeunit 6973 "Create Expense Categories" if IsHandled then exit; + if (GetCountryCode() = 'AT') and (Code = XPERDIEMTxt) then + exit; + TempCategory.Init(); TempCategory.Code := Code; TempCategory.Description := Description; @@ -645,6 +678,9 @@ codeunit 6973 "Create Expense Categories" if IsHandled then exit; + if (GetCountryCode() = 'AT') and (CategoryCode = XPERDIEMTxt) then + exit; + TempSubcategory.Init(); TempSubcategory."Expense Category Code" := CategoryCode; TempSubcategory.Code := SubcategoryCode; @@ -829,6 +865,16 @@ codeunit 6973 "Create Expense Categories" AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUKOTHERTxt, 'GBP', "Expense Justification"::" "); AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUSAOTHERTxt, 'USD', "Expense Justification"::" "); + if GetCountryCode() = 'AT' then begin + AddRuleSeed(TempRuleHeader, XPERDIEMITxt, XCANADAALLTxt, 'CAD', "Expense Justification"::" "); + AddRuleSeed(TempRuleHeader, XPERDIEMITxt, XDENMARKALLTxt, 'USD', "Expense Justification"::" "); + AddRuleSeed(TempRuleHeader, XPERDIEMATxt, XDOMESTICTxt, 'USD', "Expense Justification"::" "); + AddRuleSeed(TempRuleHeader, XPERDIEMITxt, XFRANCEALLTxt, 'USD', "Expense Justification"::" "); + AddRuleSeed(TempRuleHeader, XPERDIEMITxt, XGERMANYALLTxt, 'USD', "Expense Justification"::" "); + AddRuleSeed(TempRuleHeader, XPERDIEMITxt, XUKOTHERTxt, 'GBP', "Expense Justification"::" "); + AddRuleSeed(TempRuleHeader, XPERDIEMITxt, XUSAOTHERTxt, 'USD', "Expense Justification"::" "); + end; + OnAfterBuildRuleSeeds(TempRuleHeader); end; @@ -851,6 +897,16 @@ codeunit 6973 "Create Expense Categories" AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUKOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 115); AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUSAOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 120); + if GetCountryCode() = 'AT' then begin + AddRuleConditionSeed(TempRuleCondition, XPERDIEMITxt, XCANADAALLTxt, "Expense Rule Condition Type"::"Daily Rate", 125); + AddRuleConditionSeed(TempRuleCondition, XPERDIEMITxt, XDENMARKALLTxt, "Expense Rule Condition Type"::"Daily Rate", 450); + AddRuleConditionSeed(TempRuleCondition, XPERDIEMATxt, XDOMESTICTxt, "Expense Rule Condition Type"::"Daily Rate", 50); + AddRuleConditionSeed(TempRuleCondition, XPERDIEMITxt, XFRANCEALLTxt, "Expense Rule Condition Type"::"Daily Rate", 110); + AddRuleConditionSeed(TempRuleCondition, XPERDIEMITxt, XGERMANYALLTxt, "Expense Rule Condition Type"::"Daily Rate", 105); + AddRuleConditionSeed(TempRuleCondition, XPERDIEMITxt, XUKOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 115); + AddRuleConditionSeed(TempRuleCondition, XPERDIEMITxt, XUSAOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 120); + end; + OnAfterBuildRuleConditionSeeds(TempRuleCondition); end; @@ -934,12 +990,24 @@ codeunit 6973 "Create Expense Categories" internal procedure AddRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; CurrencyCode: Code[10]; JustificationRequired: Enum "Expense Justification") var + EURCurrency: Record Currency; + GeneralLedgerSetup: Record "General Ledger Setup"; IsHandled: Boolean; begin OnBeforeAddRuleSeed(TempRuleHeader, CategoryCode, ExpenseLocationCode, CurrencyCode, JustificationRequired, IsHandled); if IsHandled then exit; + if (GetCountryCode() = 'AT') and (CategoryCode = XPERDIEMTxt) then + exit; + + if (CurrencyCode = 'EUR') and (not EURCurrency.Get('EUR')) then + CurrencyCode := 'USD'; + + if GeneralLedgerSetup.Get() then + if CurrencyCode = GeneralLedgerSetup."LCY Code" then + CurrencyCode := ''; + TempRuleHeader.Init(); TempRuleHeader."Expense Category Code" := CategoryCode; TempRuleHeader."Expense Location" := ExpenseLocationCode; @@ -958,6 +1026,9 @@ codeunit 6973 "Create Expense Categories" if IsHandled then exit; + if (GetCountryCode() = 'AT') and (CategoryCode = XPERDIEMTxt) then + exit; + TempRuleCondition.Reset(); TempRuleCondition.SetRange("Expense Category Code", CategoryCode); TempRuleCondition.SetRange("Expense Location", ExpenseLocationCode); @@ -985,6 +1056,14 @@ codeunit 6973 "Create Expense Categories" InsertExpenseGroup(XPREPAYMENTTxt, 'Prepayments - Cash Advance'); end; + local procedure GetCountryCode(): Code[10] + var + CompanyInformation: Record "Company Information"; + begin + if CompanyInformation.Get() then + exit(CompanyInformation."Country/Region Code"); + end; + var XAIRLINETxt: Label 'AIRLINE', Locked = true; XAirlineTicketsTxt: Label 'Expenses for commercial air travel, including airline tickets and airfare. Covers flights, passenger names, routes, carriers, booking references, fares, taxes, seat selection, baggage or change fees, and boarding passes.', MaxLength = 250; @@ -1257,8 +1336,17 @@ codeunit 6973 "Create Expense Categories" XUKOTHERTxt: Label 'UK-OTHER', Locked = true; XUSAOTHERTxt: Label 'USA-OTHER', Locked = true; XEMPLEXPTxt: Label 'EMPLEXP', MaxLength = 20; - - internal procedure InsertExpenseCategory(Code: Code[20]; Description: Text[250]; PostingDescription: Text[100]; ExpenseGroupCode: Code[20]; PostingGroupCode: Code[20]; PaymentMethod: Code[20]; IsRefundable: Boolean; IsPrepayment: Boolean; AttachmentEnforcement: Enum "Expense Attachment Enforcement"; DetailRequired: Enum "Expense Detail Needed") + XEXPENSEPERDIEMITxt: Label 'EXPENSE-PERDIEM-I', Locked = true; + XEXPENSEPERDIEMATxt: Label 'EXPENSE-PERDIEM-A', Locked = true; + XPERDIEMITxt: Label 'PER-DIEM-I', Locked = true; + XPERDIEMATxt: Label 'PER-DIEM-A', Locked = true; + XINTLTxt: Label 'INTL', Locked = true; + XExpensePerDiemInCountryDescTxt: Label 'Expense - Per Diem in country', MaxLength = 100; + XExpensePerDiemAbroadDescTxt: Label 'Expense - Per Diem abroad', MaxLength = 100; + XPerDiemIByAssignedPolicyPostingTxt: Label 'Per-diem (international) by assigned policy', MaxLength = 100; + XPerDiemAByAssignedPolicyPostingTxt: Label 'Per-diem (local) by assigned policy', MaxLength = 100; + + internal procedure InsertExpenseCategory(Code: Code[20]; Description: Text[250]; PostingDescription: Text[100]; ExpenseGroupCode: Code[20]; PostingGroupCode: Code[20]; PaymentMethod: Code[10]; IsRefundable: Boolean; IsPrepayment: Boolean; AttachmentEnforcement: Enum "Expense Attachment Enforcement"; DetailRequired: Enum "Expense Detail Needed") begin if ExpenseCategory.Get(Code) then exit; @@ -1310,7 +1398,7 @@ codeunit 6973 "Create Expense Categories" EmployeePostingGroup.Modify(true); end; - local procedure InsertExpenseGroup(Code: Code[20]; Description: Text[100]) + local procedure InsertExpenseGroup(Code: Code[20]; Description: Text[50]) begin if ExpenseGroup.Get(Code) then exit; diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al index f9cf33b2c2a..5a584b92595 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al @@ -5,6 +5,7 @@ namespace Microsoft.ExpenseAgent; using Microsoft.Finance.GeneralLedger.Account; +using Microsoft.Foundation.Company; using Microsoft.Foundation.Enums; codeunit 6971 "Create Expense GL Account" @@ -45,35 +46,213 @@ codeunit 6971 "Create Expense GL Account" ExpensePayableCardPaidSearchLbl: Label 'credit card', MaxLength = 30; ExpensePayableBankPaidLbl: Label 'Other bank accounts', MaxLength = 100; ExpensePayableBankPaidSearchLbl: Label 'bank', MaxLength = 30; + ExpenseCashLbl: Label 'Cash', MaxLength = 100; + ExpenseCashSearchLbl: Label 'Cash', MaxLength = 30; + ExpenseTravelRefundableSearchGBLbl: Label 'Travel', MaxLength = 30; + ExpenseOtherNonRefundableSearchGBLbl: Label 'Other Incidental', MaxLength = 30; + ExpenseOtherPrepaymentSearchGBLbl: Label 'Other prepaid expenses', MaxLength = 30; + ExpensePerDiemARefundableLbl: Label 'Meal expenses abroad', MaxLength = 100; + ExpensePerDiemARefundableSearchLbl: Label 'Meal expenses abroad', MaxLength = 30; + ExpensePerDiemIRefundableLbl: Label 'Meal expenses domestic', MaxLength = 100; + ExpensePerDiemIRefundableSearchLbl: Label 'Meal expenses domestic', MaxLength = 30; + ExpenseMealNonRefundableLbl: Label 'Meal expenses, nondeductible', MaxLength = 100; + ExpenseMealNonRefundableSearchLbl: Label 'Meal expenses, nondeductible', MaxLength = 30; + ExpenseOtherEmployeeExpensesLbl: Label 'Other Employee Expenses', MaxLength = 100; + ExpenseOtherEmployeeExpensesSearchLbl: Label 'Other Employee Expenses', MaxLength = 30; + ExpenseMiscellaneousLbl: Label 'Miscellaneous', MaxLength = 100; + ExpenseMiscellaneousSearchLbl: Label 'Miscellaneous', MaxLength = 30; + ExpenseMiscCostsLbl: Label 'Misc. Costs', MaxLength = 100; + ExpenseMiscCostsSearchLbl: Label 'Misc. Costs', MaxLength = 30; + ExpenseAdministrativeExpensesLbl: Label 'Administrative Expenses', MaxLength = 100; + ExpenseAdministrativeExpensesSearchLbl: Label 'Administrative Expenses', MaxLength = 30; + ExpenseOtherOperatingExpensesLbl: Label 'Other operating expenses', MaxLength = 100; + ExpenseOtherOperatingExpensesSearchLbl: Label 'Other operating expenses', MaxLength = 30; + ExpenseOtherTravelExpensesLbl: Label 'Other Travel Expenses', MaxLength = 100; + ExpenseOtherTravelExpensesSearchLbl: Label 'Other Travel Expenses', MaxLength = 30; + ExpenseTravelLbl: Label 'Travel', MaxLength = 100; + ExpenseTravelSearchLbl: Label 'Travel', MaxLength = 30; + ExpenseTravelCostsCustServiceLbl: Label 'Travel Costs, Customer Service', MaxLength = 100; + ExpenseTravelCostsCustServiceSearchLbl: Label 'Travel Costs, Customer Service', MaxLength = 30; + ExpenseTravelExpensesLbl: Label 'Travel expenses', MaxLength = 100; + ExpenseTravelExpensesSearchLbl: Label 'Travel expenses', MaxLength = 30; + ExpensePerDiemAllowanceLbl: Label 'Per Diem Allowance', MaxLength = 100; + ExpensePerDiemAllowanceSearchLbl: Label 'Per Diem Allowance', MaxLength = 30; + ExpensePerDiemAllowanceHyphenLbl: Label 'Per-Diem Allowance', MaxLength = 100; + ExpensePerDiemAllowanceHyphenSearchLbl: Label 'Per-Diem Allowance', MaxLength = 30; + ExpenseSubsistenceLbl: Label 'Subsitence', MaxLength = 100; + ExpenseSubsistenceSearchLbl: Label 'Subsitence', MaxLength = 30; + ExpenseMileageAllowanceLbl: Label 'Mileage Allowance', MaxLength = 100; + ExpenseMileageAllowanceSearchLbl: Label 'Mileage Allowance', MaxLength = 30; + ExpenseMileageReimbursementLbl: Label 'Mileage Reimbursement', MaxLength = 100; + ExpenseMileageReimbursementSearchLbl: Label 'Mileage Reimbursement', MaxLength = 30; + ExpenseGasolineMotorOilLbl: Label 'Gasoline and Motor Oil', MaxLength = 100; + ExpenseGasolineMotorOilSearchLbl: Label 'Gasoline and Motor Oil', MaxLength = 30; + ExpenseCarAllowanceLbl: Label 'Car Allowance', MaxLength = 100; + ExpenseCarAllowanceSearchLbl: Label 'Car Allowance', MaxLength = 30; + ExpenseMealsHospitalityLbl: Label 'Meals and Hospitality Expenses', MaxLength = 100; + ExpenseMealsHospitalitySearchLbl: Label 'Meals and Hospitality Expenses', MaxLength = 30; + ExpenseBusinessMealsLbl: Label 'Business Meals', MaxLength = 100; + ExpenseBusinessMealsSearchLbl: Label 'Business Meals', MaxLength = 30; + ExpenseBusinessMealExpensesLbl: Label 'Business Meal Expenses', MaxLength = 100; + ExpenseBusinessMealExpensesSearchLbl: Label 'Business Meal Expenses', MaxLength = 30; + ExpenseBoardAndLodgingLbl: Label 'Board and lodging', MaxLength = 100; + ExpenseBoardAndLodgingSearchLbl: Label 'Board and lodging', MaxLength = 30; + ExpenseEntertainmentAndPRLbl: Label 'Entertainment and PR', MaxLength = 100; + ExpenseEntertainmentAndPRSearchLbl: Label 'Entertainment and PR', MaxLength = 30; + ExpenseEntertainmentDeductibleLbl: Label 'Entertainment, Deductible', MaxLength = 100; + ExpenseEntertainmentDeductibleSearchLbl: Label 'Entertainment, Deductible', MaxLength = 30; + ExpenseBusinessMealsEntertainLbl: Label 'Business Meals and Entertainment', MaxLength = 100; + ExpenseBusinessMealsEntertainSearchLbl: Label 'Business Meals and Entertain', MaxLength = 30; + ExpenseEntertainmentExpensesLbl: Label 'Entertainment Expenses', MaxLength = 100; + ExpenseEntertainmentExpensesSearchLbl: Label 'Entertainment Expenses', MaxLength = 30; + ExpenseRepresentationCostsLbl: Label 'Representation costs', MaxLength = 100; + ExpenseRepresentationCostsSearchLbl: Label 'Representation costs', MaxLength = 30; + ExpenseNonRefundableEmpLbl: Label 'Non-Refundable Employee Expenses', MaxLength = 100; + ExpenseNonRefundableEmpSearchLbl: Label 'Non-Refundable Employee', MaxLength = 30; + ExpenseNonDeductibleEmpLbl: Label 'Non-Deductible Employee Expenses', MaxLength = 100; + ExpenseNonDeductibleEmpSearchLbl: Label 'Non-Deductible Employee', MaxLength = 30; + ExpenseOtherPersonnelCostsLbl: Label 'Other Personnel Costs', MaxLength = 100; + ExpenseOtherPersonnelCostsSearchLbl: Label 'Other Personnel Costs', MaxLength = 30; + ExpenseEmpExpenseAdvancesLbl: Label 'Employee Expense Advances', MaxLength = 100; + ExpenseEmpExpenseAdvancesSearchLbl: Label 'Employee Expense Advances', MaxLength = 30; + ExpenseEmpTravelAdvancesLbl: Label 'Employee Travel Advances', MaxLength = 100; + ExpenseEmpTravelAdvancesSearchLbl: Label 'Employee Travel Advances', MaxLength = 30; + ExpenseEmpAdvancesPrepaymentsLbl: Label 'Employee Advances and Expense Prepayments', MaxLength = 100; + ExpenseEmpAdvancesPrepaymentsSearchLbl: Label 'Employee Advances and Expense', MaxLength = 30; + ExpenseEmpExpensePrepaymentsLbl: Label 'Employee Expense Prepayments', MaxLength = 100; + ExpenseEmpExpensePrepaymentsSearchLbl: Label 'Employee Expense Prepayments', MaxLength = 30; + ExpenseCurrentReceivableEmpLbl: Label 'Current Receivable from Employees', MaxLength = 100; + ExpenseCurrentReceivableEmpSearchLbl: Label 'Current Receivable', MaxLength = 30; + ExpenseOtherreceivables1Lbl: Label 'Otherreceivables1', MaxLength = 100; + ExpenseOtherreceivables1SearchLbl: Label 'Otherreceivables1', MaxLength = 30; + ExpensePayablesToEmployeesLbl: Label 'Payables to employees', MaxLength = 100; + ExpenseCurrentLiabilitiesEmpLbl: Label 'Current Liabilities to Employees', MaxLength = 100; + ExpenseEmpExpReimbursementsPayableLbl: Label 'Employee Expense Reimbursements Payable', MaxLength = 100; + ExpenseEmpExpReimbursementPayableLbl: Label 'Employee Expense Reimbursement Payable', MaxLength = 100; + ExpenseEmpExpPayableCashLbl: Label 'Employee Expense Payable - Cash Reimbursement', MaxLength = 100; + ExpenseRoundingDifferencesLbl: Label 'Expense Rounding Differences', MaxLength = 100; + ExpenseRoundingDifferencesSearchLbl: Label 'Expense Rounding Differences', MaxLength = 30; + ExpenseInvoiceRoundingLbl: Label 'Invoice Rounding', MaxLength = 100; + ExpenseInvoiceRoundingSearchLbl: Label 'Invoice Rounding', MaxLength = 30; + ExpenseRoundingDiffPurchaseLbl: Label 'Rounding Differences Purchase', MaxLength = 100; + ExpenseRoundingDiffPurchaseSearchLbl: Label 'Rounding Differences Purchase', MaxLength = 30; + ExpenseCompanyPaidExpClearingLbl: Label 'Company Paid Expense Clearing', MaxLength = 100; + ExpenseCompanyPaidExpClearingSearchLbl: Label 'Company Paid Expense Clearing', MaxLength = 30; + ExpenseCompanyPaidExpClearHyphenLbl: Label 'Company-Paid Expense Clearing', MaxLength = 100; + ExpenseCompanyPaidExpClearHyphenSearchLbl: Label 'Company-Paid Expense Clearing', MaxLength = 30; + ExpenseBankPaidExpClearingLbl: Label 'Bank-Paid Expense Clearing Account', MaxLength = 100; + ExpenseBankPaidExpClearingSearchLbl: Label 'Bank-Paid Expense Clearing', MaxLength = 30; + ExpenseEmpExpPayableCompPaidLbl: Label 'Employee Expense Payable - Company Paid', MaxLength = 100; + ExpenseEmpExpPayableCompPaidSearchLbl: Label 'Payable - Company Paid', MaxLength = 30; + ExpenseBankAccountKBLbl: Label 'Bank Account - KB', MaxLength = 100; + ExpenseBankAccountKBSearchLbl: Label 'Bank Account - KB', MaxLength = 30; + ExpenseCorporateCardExpClearingLbl: Label 'Corporate Card Expense Clearing', MaxLength = 100; + ExpenseCorporateCardExpClearingSearchLbl: Label 'Corporate Card Expense', MaxLength = 30; + ExpenseCompanyCardExpPayableLbl: Label 'Company Card Expenses Payable', MaxLength = 100; + ExpenseCompanyCardExpPayableSearchLbl: Label 'Company Card Expenses Payable', MaxLength = 30; + ExpenseCompanyCardExpClearingLbl: Label 'Company Card Expense Clearing', MaxLength = 100; + ExpenseCompanyCardExpClearingSearchLbl: Label 'Company Card Expense Clearing', MaxLength = 30; + ExpenseCorporateCardExpPayableLbl: Label 'Corporate Card Expense Payable', MaxLength = 100; + ExpenseCorporateCardExpPayableSearchLbl: Label 'Corporate Card Expense Payable', MaxLength = 30; + ExpenseEmpExpPayableCompCardLbl: Label 'Employee Expense Payable - Company Card', MaxLength = 100; + ExpenseEmpExpPayableCompCardSearchLbl: Label 'Payable - Company Card', MaxLength = 30; + ExpenseOtherBusinessExpensesLbl: Label 'Other Business Expenses', MaxLength = 100; + ExpenseOtherBusinessExpensesSearchLbl: Label 'Other Business Expenses', MaxLength = 30; + ExpenseOtherNondeductTravelLbl: Label 'Other nondeductible travel expenses', MaxLength = 100; + ExpenseOtherNondeductTravelSearchLbl: Label 'Other nondeductible travel', MaxLength = 30; + ExpenseExpensesPrepaymentsLbl: Label 'Expenses Prepayments', MaxLength = 100; + ExpenseExpensesPrepaymentsSearchLbl: Label 'Expenses Prepayments', MaxLength = 30; + ExpenseRoundingExpensesOperatingLbl: Label 'Rounding Expenses Operating', MaxLength = 100; + ExpenseRemunerationAdvancesLbl: Label 'Remuneration Advances', MaxLength = 100; + ExpenseBanksEuroLbl: Label 'Banks Euro', MaxLength = 100; + ExpenseProfitLossLbl: Label 'Profit or Loss', MaxLength = 100; + ExpenseProfitLossSearchLbl: Label 'Profit or Loss', MaxLength = 30; + ExpenseOtherExternalCostsLbl: Label 'Other external costs', MaxLength = 100; + ExpenseOtherExternalCostsSearchLbl: Label 'Other external', MaxLength = 30; + ExpenseTravelingTradeFairsLbl: Label 'Traveling, Trade Fairs etc.', MaxLength = 100; + ExpenseTravelAllowancesPerDiemLbl: Label 'Travel allowances per diem', MaxLength = 100; + ExpensePerDiemLowerSearchLbl: Label 'per diem', MaxLength = 30; + ExpenseMileageRateLbl: Label 'Mileage Rate', MaxLength = 100; + ExpenseRestaurantDiningLbl: Label 'Restaurant Dining', MaxLength = 100; + ExpenseRestaurantSearchLbl: Label 'Restaurant', MaxLength = 30; + ExpenseEntWineTobaccoSpiritsLbl: Label 'Ent., Wine / Tobacco / Spirits', MaxLength = 100; + ExpenseNonDeductibleTravelLbl: Label 'Non-deductible travel expenses', MaxLength = 100; + ExpenseNonDeductibleTravelSearchLbl: Label 'Non-deductible travel', MaxLength = 30; + ExpensePrepaymentsAccruedCostsLbl: Label 'Prepayments - Accrued Costs', MaxLength = 100; + ExpensePrepaymentsAccruedSearchLbl: Label 'Accrued Costs', MaxLength = 30; + ExpenseCentDiscrepanciesLbl: Label 'Cent Discrepancies', MaxLength = 100; + ExpenseAccountsPayablesLbl: Label 'Accounts Payables', MaxLength = 100; + ExpenseBankLbl: Label 'Bank', MaxLength = 100; + ExpenseCompanyCreditCardsLbl: Label 'Company credit cards', MaxLength = 100; + ExpenseAssetsPrepaidLbl: Label 'Assets in the form of prepaid expenses', MaxLength = 100; + ExpenseSalesInvoiceRoundingLbl: Label 'Sales Invoice Rounding', MaxLength = 100; + ExpenseBusinessAccountOperatingLbl: Label 'Business account, Operating, Domestic', MaxLength = 100; + ExpenseCompanyCreditCardClearingLbl: Label 'Company credit card clearing account', MaxLength = 100; + ExpenseVacationCompPayableLbl: Label 'Vacation Compensation Payable', MaxLength = 100; + ExpenseBankCheckingLbl: Label 'Bank, Checking', MaxLength = 100; + ExpensePrepaymentBeginLbl: Label 'Employee prepayments', MaxLength = 100; + ExpensePrepaymentTotalLbl: Label 'Employee Prepayments, Total', MaxLength = 100; + ExpenseBusinessEntertainNondeductLbl: Label 'Business Entertaining, nondeductible', MaxLength = 100; + ExpenseBusinessEntertainNondeductSearchLbl: Label 'Business Entertaining', MaxLength = 30; + ExpenseFinanceChargesVendorsLbl: Label 'Finance Charges to Vendors', MaxLength = 100; + ExpenseFinanceChargesVendorsSearchLbl: Label 'Finance Charges to Vendors', MaxLength = 30; + ExpenseEmployeePrepaymentsExpLbl: Label 'Employee Prepayments, Expenses', MaxLength = 100; + ExpenseEmployeePrepaymentsExpSearchLbl: Label 'Employee Prepayments, Expenses', MaxLength = 30; + ExpenseEmployeePrepaymentsSearchLbl: Label 'Employee Prepayments', MaxLength = 30; + ExpenseBankLCYLbl: Label 'Bank, LCY', MaxLength = 100; + ExpenseMiscExternalNondeductibleLbl: Label 'Misc. external expenses, nondeductible', MaxLength = 100; + ExpenseAccountsPayableDomesticLbl: Label 'Accounts Payable, Domestic', MaxLength = 100; + ExpenseTransportThirdPartiesLbl: Label 'Transportation third parties', MaxLength = 100; + ExpenseTransportThirdPartiesSearchLbl: Label 'Transportation third', MaxLength = 30; + ExpenseApplicationRoundingLbl: Label 'Application Rounding', MaxLength = 100; + ExpenseCreditCardClearingSearchLbl: Label 'credit card clearing', MaxLength = 30; local procedure CreateGLAccount() var GLAccountIndent: Codeunit "G/L Account-Indent"; IsHandled: Boolean; + SubCategory: Text[80]; begin OnBeforeCreateGLAccount(IsHandled); if IsHandled then exit; - InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + if GetCountryCode() = 'ES' then + InsertGLAccount(ExpenseProfitLossAccountNo(), ExpenseProfitLossLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Equity, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + if GetCountryCode() = 'AT' then begin + InsertGLAccount(ExpensePerDiemARefundableDebitAccountNo(), ExpensePerDiemARefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpensePerDiemIRefundableDebitAccountNo(), ExpensePerDiemIRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + end else + InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseMileageRefundableDebitAccountNo(), ExpenseMileageRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseEntertainRefundableDebitAccountNo(), ExpenseEntertainRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseMealsRefundableDebitAccountNo(), ExpenseMealsRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + if GetCountryCode() in ['AT', 'DE', 'DK', 'ES', 'FR'] then + InsertGLAccount(ExpenseMealNonRefundableDebitAccountNo(), ExpenseMealNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseOtherNonRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpenseOtherPrepaymentLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseOtherDebitRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseOtherCreditRoundingLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseNonRefundableDebitAccountNo(), ExpenseNonRefundableAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + if GetCountryCode() in ['CA', 'NZ'] then begin + SubCategory := Format(Enum::"G/L Account Category"::Expense, 80); + InsertGLAccount(ExpensePrepaymentBeginAccountNo(), ExpensePrepaymentBeginLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"Begin-Total", '', '', '', 0, '', Enum::"G/L Account Type"::"Begin-Total", '', '', false, false, false); + end; + InsertGLAccount(ExpensePrepaymentDebitAccountNo(), ExpensePrepaymentDebitAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + if GetCountryCode() in ['CA', 'NZ'] then + InsertGLAccount(ExpensePrepaymentTotalAccountNo(), ExpensePrepaymentTotalLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::"End-Total", '', '', '', 0, ExpensePrepaymentBeginAccountNo() + '..' + ExpensePrepaymentTotalAccountNo(), Enum::"G/L Account Type"::"End-Total", '', '', false, false, false); + InsertGLAccount(ExpenseDebitRoundingAccountNo(), ExpenseDebitRoundingAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseCreditRoundingAccountNo(), ExpenseCreditRoundingAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseReportPayableAccountNo(), ExpensePayableCashLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpensePrepaymentLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidLbl, "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseReportPayableAccountNo(), ExpenseReportPayableAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Liabilities, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpenseReportPrepaymentAccountNo(), ExpenseReportPrepaymentAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpensePayableCardPaidAccountNo(), ExpensePayableCardPaidAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); + InsertGLAccount(ExpensePayableBankPaidAccountNo(), ExpensePayableBankPaidAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false); - GLAccountIndent.Indent(); + if GetCountryCode() = 'ES' then + UpdateIncomeStatementBalanceAccount() + else + GLAccountIndent.Indent(); end; internal procedure InsertGLAccount(AccountNo: Code[20]; Name: Text[100]; IncomeOrBalance: Enum "G/L Account Income/Balance"; AccountCategory: Enum "G/L Account Category"; AccountSubCategory: Text[80]; AccountType: Enum "G/L Account Type"; GenBusPostingGroup: Code[20]; GenProdPostingGroup: Code[20]; TaxGroup: Code[20]; NoOfBlankLines: Integer; Totaling: Text[250]; GenPostingType: Enum "General Posting Type"; VATGenPostingGroup: Code[20]; VATProdPostingGroup: Code[20]; DirectPosting: Boolean; ReconciliationAccount: Boolean; NewPage: Boolean) @@ -134,14 +313,94 @@ codeunit 6971 "Create Expense GL Account" GLAccount.Validate("Account Category", Enum::"G/L Account Category"::" "); end; + local procedure UpdateIncomeStatementBalanceAccount() + var + ProfitLossAccountNo: Code[20]; + begin + ProfitLossAccountNo := ExpenseProfitLossAccountNo(); + + UpdateIncomeStmtBalAcc(ExpenseOtherRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseTravelRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpensePerDiemRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseMileageRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseEntertainRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseMealsRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseMealNonRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseNonRefundableDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpensePrepaymentDebitAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseDebitRoundingAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseCreditRoundingAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseReportPayableAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpenseReportPrepaymentAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpensePayableCardPaidAccountNo(), ProfitLossAccountNo); + UpdateIncomeStmtBalAcc(ExpensePayableBankPaidAccountNo(), ProfitLossAccountNo); + end; + + local procedure UpdateIncomeStmtBalAcc(No: Code[20]; IncomeStmtBalAcc: Code[20]) + var + GLAccount: Record "G/L Account"; + GLAccountRecRef: RecordRef; + IncomeStmtBalAccFieldRef: FieldRef; + begin + if not GLAccount.Get(No) then + exit; + + GLAccountRecRef.GetTable(GLAccount); + if not GLAccountRecRef.FieldExist(ESIncomeStmtBalAccFieldNo()) then + exit; + + IncomeStmtBalAccFieldRef := GLAccountRecRef.Field(ESIncomeStmtBalAccFieldNo()); + IncomeStmtBalAccFieldRef.Validate(IncomeStmtBalAcc); + GLAccountRecRef.Modify(); + end; + + local procedure ESIncomeStmtBalAccFieldNo(): Integer + begin + exit(10700); + end; + internal procedure ExpenseOtherRefundableDebitAccountNo(): Code[20] var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableLbl, ExpenseOtherRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherRefundableAccountName(), ExpenseOtherRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'CH': + exit('6780'); + 'CZ': + exit('548100'); + 'IT': + exit('8640'); + 'US': + exit('68280'); + 'AU': + exit('6236'); + 'CA': + exit('67430'); + 'DE': + exit('6300'); + 'DK': + exit('05699'); + 'ES': + exit('6290003'); + 'FR': + exit('625180'); + 'NZ': + exit('8660'); + 'AT': + exit('7740'); + 'BE': + exit('623100'); + 'FI': + exit('6166'); + 'NL': + exit('4291'); + 'NO': + exit('9135'); + end; exit('31540'); end; @@ -149,10 +408,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableLbl, ExpenseTravelRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseTravelRefundableAccountName(), ExpenseTravelRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'BE': + exit('613900'); + 'CH': + exit('6640'); + 'CZ': + exit('512100'); + 'IT': + exit('8430'); + 'NL': + exit('3464'); + 'US': + exit('62340'); + 'AU': + exit('6249'); + 'CA': + exit('61340'); + 'DE': + exit('6650'); + 'DK': + exit('03650'); + 'ES': + exit('6291001'); + 'FR': + exit('625100'); + 'NZ': + exit('8430'); + 'AT': + exit('7310'); + 'FI': + exit('6165'); + 'NO': + exit('8430'); + end; exit('30540'); end; @@ -160,21 +453,130 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableLbl, ExpensePerDiemRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemRefundableAccountName(), ExpensePerDiemRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'US': + exit('62350'); + 'AU': + exit('6246'); + 'CA': + exit('61310'); + 'DE': + exit('6664'); + 'DK': + exit('03652'); + 'ES': + exit('6291002'); + 'FR': + exit('625110'); + 'NZ': + exit('8431'); + 'BE': + exit('613950'); + 'CH': + exit('5822'); + 'CZ': + exit('512300'); + 'FI': + exit('6163'); + 'IT': + exit('8431'); + 'NL': + exit('3466'); + 'NO': + exit('9170'); + end; exit('30550'); end; + internal procedure ExpensePerDiemARefundableDebitAccountNo(): Code[20] + var + ExistingAccNo: Code[20]; + begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemARefundableLbl, ExpensePerDiemARefundableSearchLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + + exit('7360'); + end; + + internal procedure ExpensePerDiemIRefundableDebitAccountNo(): Code[20] + var + ExistingAccNo: Code[20]; + begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePerDiemIRefundableLbl, ExpensePerDiemIRefundableSearchLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + + exit('7350'); + end; + + internal procedure ExpenseMealNonRefundableDebitAccountNo(): Code[20] + var + ExistingAccNo: Code[20]; + begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealNonRefundableLbl, ExpenseMealNonRefundableSearchLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + + case GetCountryCode() of + 'DE': + exit('6662'); + 'DK': + exit('03661'); + 'ES': + exit('6292002'); + 'FR': + exit('625210'); + end; + exit('7692'); + end; + internal procedure ExpenseMileageRefundableDebitAccountNo(): Code[20] var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableLbl, ExpenseMileageRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMileageRefundableAccountName(), ExpenseMileageRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'IT': + exit('8510'); + 'US': + exit('62360'); + 'AU': + exit('6247'); + 'CA': + exit('61320'); + 'DE': + exit('6658'); + 'DK': + exit('03180'); + 'ES': + exit('6291003'); + 'FR': + exit('625120'); + 'NZ': + exit('8432'); + 'AT': + exit('7340'); + 'BE': + exit('613940'); + 'CH': + exit('5821'); + 'CZ': + exit('512200'); + 'FI': + exit('6162'); + 'NL': + exit('3465'); + 'NO': + exit('8910'); + end; exit('30560'); end; @@ -182,10 +584,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableLbl, ExpenseMealsRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseMealsRefundableAccountName(), ExpenseMealsRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'IT': + exit('8420'); + 'NL': + exit('3463'); + 'US': + exit('62370'); + 'AU': + exit('6248'); + 'CA': + exit('61330'); + 'DE': + exit('6660'); + 'DK': + exit('03660'); + 'ES': + exit('6292001'); + 'FR': + exit('625200'); + 'NZ': + exit('8433'); + 'AT': + exit('7691'); + 'BE': + exit('613910'); + 'CH': + exit('5841'); + 'CZ': + exit('513200'); + 'FI': + exit('6161'); + 'NO': + exit('8450'); + end; exit('30535'); end; @@ -193,10 +629,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableLbl, ExpenseEntertainRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseEntertainRefundableAccountName(), ExpenseEntertainRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'BE': + exit('614500'); + 'CZ': + exit('513100'); + 'IT': + exit('8420'); + 'US': + exit('63420'); + 'AU': + exit('6235'); + 'CA': + exit('61200'); + 'DE': + exit('6640'); + 'DK': + exit('03630'); + 'ES': + exit('6293001'); + 'FR': + exit('625700'); + 'NZ': + exit('8420'); + 'AT': + exit('7680'); + 'CH': + exit('5840'); + 'FI': + exit('6160'); + 'NL': + exit('3564'); + 'NO': + exit('8450'); + end; exit('30820'); end; @@ -204,10 +674,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherNonRefundableLbl, ExpenseOtherNonRefundableSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseNonRefundableAccountName(), ExpenseNonRefundableSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'CH': + exit('5830'); + 'US': + exit('40390'); + 'AU': + exit('7240'); + 'CA': + exit('71900'); + 'DE': + exit('6650'); + 'DK': + exit('03655'); + 'ES': + exit('6299001'); + 'FR': + exit('625290'); + 'NZ': + exit('9240'); + 'AT': + exit('7745'); + 'BE': + exit('643100'); + 'CZ': + exit('548200'); + 'FI': + exit('6167'); + 'IT': + exit('8911'); + 'NL': + exit('4292'); + 'NO': + exit('5964'); + end; exit('10390'); end; @@ -215,10 +719,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherPrepaymentLbl, ExpenseOtherPrepaymentSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentDebitAccountName(), ExpensePrepaymentDebitSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'FI': + exit('1720'); + 'NL': + exit('0710'); + 'US': + exit('16600'); + 'AU': + exit('1512'); + 'CA': + exit('13610'); + 'DE': + exit('1900'); + 'DK': + exit('26400'); + 'ES': + exit('4800001'); + 'FR': + exit('486200'); + 'NZ': + exit('2510'); + 'AT': + exit('2770'); + 'BE': + exit('416000'); + 'CH': + exit('1305'); + 'CZ': + exit('335100'); + 'IT': + exit('2341'); + 'NO': + exit('5963'); + end; exit('76600'); end; @@ -226,10 +764,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherDebitRoundingLbl, ExpenseRoundingSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseDebitRoundingAccountName(), ExpenseRoundingSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'CH': + exit('4908'); + 'IT': + exit('9140'); + 'NL': + exit('3930'); + 'US': + exit('67300'); + 'AU': + exit('4756'); + 'CA': + exit('47400'); + 'DE': + exit('7500'); + 'DK': + exit('07570'); + 'ES': + exit('6298001'); + 'FR': + exit('658600'); + 'NZ': + exit('9140'); + 'AT': + exit('8070'); + 'BE': + exit('655100'); + 'CZ': + exit('548900'); + 'FI': + exit('6168'); + 'NO': + exit('5965'); + end; exit('31330'); end; @@ -237,10 +809,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseOtherCreditRoundingLbl, ExpenseRoundingSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpenseCreditRoundingAccountName(), ExpenseRoundingSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'CH': + exit('4908'); + 'IT': + exit('9140'); + 'NL': + exit('3930'); + 'US': + exit('67300'); + 'AU': + exit('4756'); + 'CA': + exit('47400'); + 'DE': + exit('7500'); + 'DK': + exit('07570'); + 'ES': + exit('6298001'); + 'FR': + exit('658600'); + 'NZ': + exit('9140'); + 'AT': + exit('8070'); + 'BE': + exit('655100'); + 'CZ': + exit('548900'); + 'FI': + exit('6168'); + 'NO': + exit('5965'); + end; exit('31330'); end; @@ -248,10 +854,44 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpensePayableCashLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Liabilities, ExpenseReportPayableAccountName()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'BE': + exit('457000'); + 'CZ': + exit('333100'); + 'FI': + exit('2914'); + 'NL': + exit('1520'); + 'US': + exit('22100'); + 'AU': + exit('2378'); + 'CA': + exit('23850'); + 'DE': + exit('4150'); + 'DK': + exit('25100'); + 'ES': + exit('4600001'); + 'FR': + exit('438300'); + 'NZ': + exit('5850'); + 'AT': + exit('3680'); + 'CH': + exit('2270'); + 'IT': + exit('5851'); + 'NO': + exit('5960'); + end; exit('5850'); end; @@ -259,21 +899,691 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePrepaymentLbl, ExpensePrepaymentSearchLbl); + if GetCountryCode() in ['GB', 'US'] then begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpenseCashLbl, ExpenseCashSearchLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + case GetCountryCode() of + 'GB': + exit('78100'); + 'US': + exit('18100'); + end; + end; + + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpenseReportPrepaymentAccountName(), ExpenseReportPrepaymentSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'FI': + exit('1720'); + 'NL': + exit('0710'); + 'AU': + exit('1512'); + 'CA': + exit('13610'); + 'DE': + exit('1900'); + 'DK': + exit('26400'); + 'ES': + exit('4800001'); + 'FR': + exit('486200'); + 'NZ': + exit('2510'); + 'AT': + exit('2770'); + 'BE': + exit('416000'); + 'CH': + exit('1305'); + 'CZ': + exit('335100'); + 'IT': + exit('2341'); + 'NO': + exit('5963'); + end; exit('76600'); end; + local procedure ExpenseReportPrepaymentAccountName(): Text[100] + begin + case GetCountryCode() of + 'GB', 'US': + exit(ExpenseCashLbl); + 'CZ', 'CH': + exit(ExpenseEmpExpenseAdvancesLbl); + 'BE': + exit(ExpenseEmpTravelAdvancesLbl); + 'IT': + exit(ExpenseEmpAdvancesPrepaymentsLbl); + 'NO': + exit(ExpenseEmpExpensePrepaymentsLbl); + 'NL': + exit(ExpenseCurrentReceivableEmpLbl); + 'FI': + exit(ExpenseOtherreceivables1Lbl); + 'AU': + exit(ExpenseEmployeePrepaymentsExpLbl); + 'CA': + exit(ExpenseEmployeePrepaymentsExpLbl); + 'NZ': + exit(ExpenseEmployeePrepaymentsExpLbl); + 'DE': + exit(ExpenseAssetsPrepaidLbl); + 'DK': + exit(ExpensePrepaymentsAccruedCostsLbl); + 'ES': + exit(ExpenseExpensesPrepaymentsLbl); + end; + exit(ExpensePrepaymentLbl); + end; + + local procedure ExpenseReportPrepaymentSearch(): Text[30] + begin + case GetCountryCode() of + 'CZ', 'CH': + exit(ExpenseEmpExpenseAdvancesSearchLbl); + 'BE': + exit(ExpenseEmpTravelAdvancesSearchLbl); + 'IT': + exit(ExpenseEmpAdvancesPrepaymentsSearchLbl); + 'NO': + exit(ExpenseEmpExpensePrepaymentsSearchLbl); + 'NL': + exit(ExpenseCurrentReceivableEmpSearchLbl); + 'FI': + exit(ExpenseOtherreceivables1SearchLbl); + 'AU': + exit(ExpenseEmployeePrepaymentsSearchLbl); + 'CA': + exit(ExpenseEmployeePrepaymentsSearchLbl); + 'NZ': + exit(ExpenseEmployeePrepaymentsSearchLbl); + 'DK': + exit(ExpensePrepaymentsAccruedSearchLbl); + 'ES': + exit(ExpenseExpensesPrepaymentsSearchLbl); + end; + exit(ExpensePrepaymentSearchLbl); + end; + + local procedure ExpenseOtherRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'NL', 'BE', 'FI': + exit(ExpenseOtherEmployeeExpensesLbl); + 'IT': + exit(ExpenseMiscellaneousLbl); + 'CH': + exit(ExpenseMiscCostsLbl); + 'NO': + exit(ExpenseAdministrativeExpensesLbl); + 'CZ': + exit(ExpenseOtherOperatingExpensesLbl); + 'US': + exit(ExpenseMiscExternalNondeductibleLbl); + 'AU': + exit(ExpenseBusinessEntertainNondeductLbl); + 'CA': + exit(ExpenseMiscExternalNondeductibleLbl); + 'DK': + exit(ExpenseOtherExternalCostsLbl); + 'ES': + exit(ExpenseOtherBusinessExpensesLbl); + end; + exit(ExpenseOtherRefundableLbl); + end; + + local procedure ExpenseOtherRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'NL', 'BE', 'FI': + exit(ExpenseOtherEmployeeExpensesSearchLbl); + 'IT': + exit(ExpenseMiscellaneousSearchLbl); + 'CH': + exit(ExpenseMiscCostsSearchLbl); + 'NO': + exit(ExpenseAdministrativeExpensesSearchLbl); + 'CZ': + exit(ExpenseOtherOperatingExpensesSearchLbl); + 'AU': + exit(ExpenseBusinessEntertainNondeductSearchLbl); + 'DK': + exit(ExpenseOtherExternalCostsSearchLbl); + 'ES': + exit(ExpenseOtherBusinessExpensesSearchLbl); + end; + exit(ExpenseOtherRefundableSearchLbl); + end; + + local procedure ExpenseTravelRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'AT': + exit(ExpenseTransportThirdPartiesLbl); + 'BE', 'IT', 'NO', 'FR': + exit(ExpenseTravelLbl); + 'FI': + exit(ExpenseOtherTravelExpensesLbl); + 'CH': + exit(ExpenseTravelCostsCustServiceLbl); + 'CZ': + exit(ExpenseTravelExpensesLbl); + 'DK': + exit(ExpenseTravelingTradeFairsLbl); + 'NZ': + exit(ExpenseTravelLbl); + 'ES': + exit(ExpenseTravelExpensesLbl); + end; + exit(ExpenseTravelRefundableLbl); + end; + + local procedure ExpenseTravelRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'AT': + exit(ExpenseTransportThirdPartiesSearchLbl); + 'GB', 'US': + exit(ExpenseTravelRefundableSearchGBLbl); + 'BE', 'IT', 'NO', 'FR': + exit(ExpenseTravelSearchLbl); + 'FI': + exit(ExpenseOtherTravelExpensesSearchLbl); + 'CH': + exit(ExpenseTravelCostsCustServiceSearchLbl); + 'CZ': + exit(ExpenseTravelExpensesSearchLbl); + 'AU': + exit(ExpenseTravelRefundableSearchGBLbl); + 'CA': + exit(ExpenseTravelRefundableSearchGBLbl); + 'DE': + exit(ExpenseTravelRefundableSearchGBLbl); + 'DK': + exit(ExpenseTravelRefundableSearchGBLbl); + 'ES': + exit(ExpenseTravelRefundableSearchGBLbl); + end; + exit(ExpenseTravelRefundableSearchLbl); + end; + + local procedure ExpensePerDiemRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'CZ', 'NL', 'CH', 'IT': + exit(ExpensePerDiemAllowanceLbl); + 'BE', 'FI': + exit(ExpensePerDiemAllowanceHyphenLbl); + 'NO': + exit(ExpenseSubsistenceLbl); + 'DK': + exit(ExpenseTravelAllowancesPerDiemLbl); + end; + exit(ExpensePerDiemRefundableLbl); + end; + + local procedure ExpensePerDiemRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'CZ', 'NL', 'CH', 'IT': + exit(ExpensePerDiemAllowanceSearchLbl); + 'BE', 'FI': + exit(ExpensePerDiemAllowanceHyphenSearchLbl); + 'NO': + exit(ExpenseSubsistenceSearchLbl); + 'DK': + exit(ExpensePerDiemLowerSearchLbl); + end; + exit(ExpensePerDiemRefundableSearchLbl); + end; + + local procedure ExpenseMileageRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'CZ', 'BE', 'CH', 'FI': + exit(ExpenseMileageAllowanceLbl); + 'NL': + exit(ExpenseMileageReimbursementLbl); + 'IT': + exit(ExpenseGasolineMotorOilLbl); + 'NO': + exit(ExpenseCarAllowanceLbl); + 'DK': + exit(ExpenseMileageRateLbl); + end; + exit(ExpenseMileageRefundableLbl); + end; + + local procedure ExpenseMileageRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'CZ', 'BE', 'CH', 'FI': + exit(ExpenseMileageAllowanceSearchLbl); + 'NL': + exit(ExpenseMileageReimbursementSearchLbl); + 'IT': + exit(ExpenseGasolineMotorOilSearchLbl); + 'NO': + exit(ExpenseCarAllowanceSearchLbl); + end; + exit(ExpenseMileageRefundableSearchLbl); + end; + + local procedure ExpenseMealsRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'CZ', 'CH': + exit(ExpenseMealsHospitalityLbl); + 'BE': + exit(ExpenseBusinessMealsLbl); + 'FI': + exit(ExpenseBusinessMealExpensesLbl); + 'NL': + exit(ExpenseBoardAndLodgingLbl); + 'IT': + exit(ExpenseEntertainmentAndPRLbl); + 'NO': + exit(ExpenseEntertainmentDeductibleLbl); + 'DE': + exit(ExpenseBoardAndLodgingLbl); + 'DK': + exit(ExpenseRestaurantDiningLbl); + end; + exit(ExpenseMealsRefundableLbl); + end; + + local procedure ExpenseMealsRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'CZ', 'CH': + exit(ExpenseMealsHospitalitySearchLbl); + 'BE': + exit(ExpenseBusinessMealsSearchLbl); + 'FI': + exit(ExpenseBusinessMealExpensesSearchLbl); + 'NL': + exit(ExpenseBoardAndLodgingSearchLbl); + 'IT': + exit(ExpenseEntertainmentAndPRSearchLbl); + 'NO': + exit(ExpenseEntertainmentDeductibleSearchLbl); + 'DK': + exit(ExpenseRestaurantSearchLbl); + end; + exit(ExpenseMealsRefundableSearchLbl); + end; + + local procedure ExpenseEntertainRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'NL': + exit(ExpenseBusinessMealsEntertainLbl); + 'CH', 'FI': + exit(ExpenseEntertainmentExpensesLbl); + 'BE', 'IT': + exit(ExpenseEntertainmentAndPRLbl); + 'NO': + exit(ExpenseEntertainmentDeductibleLbl); + 'CZ': + exit(ExpenseRepresentationCostsLbl); + 'AU': + exit(ExpenseEntertainmentAndPRLbl); + 'CA': + exit(ExpenseEntertainmentAndPRLbl); + 'DK': + exit(ExpenseEntWineTobaccoSpiritsLbl); + 'ES': + exit(ExpenseEntertainmentExpensesLbl); + end; + exit(ExpenseEntertainRefundableLbl); + end; + + local procedure ExpenseEntertainRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'NL': + exit(ExpenseBusinessMealsEntertainSearchLbl); + 'CH', 'FI': + exit(ExpenseEntertainmentExpensesSearchLbl); + 'BE', 'IT': + exit(ExpenseEntertainmentAndPRSearchLbl); + 'NO': + exit(ExpenseEntertainmentDeductibleSearchLbl); + 'CZ': + exit(ExpenseRepresentationCostsSearchLbl); + end; + exit(ExpenseEntertainRefundableSearchLbl); + end; + + local procedure ExpenseNonRefundableAccountName(): Text[100] + begin + case GetCountryCode() of + 'BE', 'CZ', 'FI', 'NO': + exit(ExpenseNonRefundableEmpLbl); + 'IT', 'NL': + exit(ExpenseNonDeductibleEmpLbl); + 'CH': + exit(ExpenseOtherPersonnelCostsLbl); + 'AU': + exit(ExpenseFinanceChargesVendorsLbl); + 'CA': + exit(ExpenseFinanceChargesVendorsLbl); + 'DE': + exit(ExpenseTravelRefundableLbl); + 'DK': + exit(ExpenseNonDeductibleTravelLbl); + 'ES': + exit(ExpenseOtherNondeductTravelLbl); + end; + exit(ExpenseOtherNonRefundableLbl); + end; + + local procedure ExpenseNonRefundableSearch(): Text[30] + begin + case GetCountryCode() of + 'GB', 'US': + exit(ExpenseOtherNonRefundableSearchGBLbl); + 'BE', 'CZ', 'FI', 'NO': + exit(ExpenseNonRefundableEmpSearchLbl); + 'IT', 'NL': + exit(ExpenseNonDeductibleEmpSearchLbl); + 'CH': + exit(ExpenseOtherPersonnelCostsSearchLbl); + 'AU': + exit(ExpenseFinanceChargesVendorsSearchLbl); + 'CA': + exit(ExpenseFinanceChargesVendorsSearchLbl); + 'DE': + exit(ExpenseTravelSearchLbl); + 'DK': + exit(ExpenseNonDeductibleTravelSearchLbl); + 'ES': + exit(ExpenseOtherNondeductTravelSearchLbl); + end; + exit(ExpenseOtherNonRefundableSearchLbl); + end; + + local procedure ExpensePrepaymentDebitAccountName(): Text[100] + begin + case GetCountryCode() of + 'CZ', 'CH': + exit(ExpenseEmpExpenseAdvancesLbl); + 'BE': + exit(ExpenseEmpTravelAdvancesLbl); + 'IT': + exit(ExpenseEmpAdvancesPrepaymentsLbl); + 'NO': + exit(ExpenseEmpExpensePrepaymentsLbl); + 'NL': + exit(ExpenseCurrentReceivableEmpLbl); + 'FI': + exit(ExpenseOtherreceivables1Lbl); + 'AU': + exit(ExpenseEmployeePrepaymentsExpLbl); + 'CA': + exit(ExpenseEmployeePrepaymentsExpLbl); + 'DE': + exit(ExpenseAssetsPrepaidLbl); + 'DK': + exit(ExpensePrepaymentsAccruedCostsLbl); + 'ES': + exit(ExpenseExpensesPrepaymentsLbl); + end; + exit(ExpenseOtherPrepaymentLbl); + end; + + local procedure ExpensePrepaymentDebitSearch(): Text[30] + begin + case GetCountryCode() of + 'GB': + exit(ExpenseOtherPrepaymentSearchGBLbl); + 'CZ', 'CH': + exit(ExpenseEmpExpenseAdvancesSearchLbl); + 'BE': + exit(ExpenseEmpTravelAdvancesSearchLbl); + 'IT': + exit(ExpenseEmpAdvancesPrepaymentsSearchLbl); + 'NO': + exit(ExpenseEmpExpensePrepaymentsSearchLbl); + 'NL': + exit(ExpenseCurrentReceivableEmpSearchLbl); + 'FI': + exit(ExpenseOtherreceivables1SearchLbl); + 'AU': + exit(ExpenseEmployeePrepaymentsExpSearchLbl); + 'CA': + exit(ExpenseEmployeePrepaymentsExpSearchLbl); + 'DK': + exit(ExpensePrepaymentsAccruedSearchLbl); + 'ES': + exit(ExpenseExpensesPrepaymentsSearchLbl); + end; + exit(ExpenseOtherPrepaymentSearchLbl); + end; + + local procedure ExpenseDebitRoundingAccountName(): Text[100] + begin + case GetCountryCode() of + 'AT': + exit(ExpenseApplicationRoundingLbl); + 'BE', 'CZ', 'FI', 'NO': + exit(ExpenseRoundingDifferencesLbl); + 'IT': + exit(ExpenseInvoiceRoundingLbl); + 'CH': + exit(ExpenseRoundingDiffPurchaseLbl); + 'AU': + exit(ExpenseInvoiceRoundingLbl); + 'CA': + exit(ExpenseInvoiceRoundingLbl); + 'DE': + exit(ExpenseSalesInvoiceRoundingLbl); + 'DK': + exit(ExpenseCentDiscrepanciesLbl); + 'ES': + exit(ExpenseRoundingExpensesOperatingLbl); + end; + exit(ExpenseOtherDebitRoundingLbl); + end; + + local procedure ExpenseCreditRoundingAccountName(): Text[100] + begin + case GetCountryCode() of + 'AT': + exit(ExpenseApplicationRoundingLbl); + 'BE', 'CZ', 'FI', 'NO': + exit(ExpenseRoundingDifferencesLbl); + 'IT': + exit(ExpenseInvoiceRoundingLbl); + 'CH': + exit(ExpenseRoundingDiffPurchaseLbl); + 'AU': + exit(ExpenseInvoiceRoundingLbl); + 'CA': + exit(ExpenseInvoiceRoundingLbl); + 'DE': + exit(ExpenseSalesInvoiceRoundingLbl); + 'DK': + exit(ExpenseCentDiscrepanciesLbl); + 'ES': + exit(ExpenseRoundingExpensesOperatingLbl); + end; + exit(ExpenseOtherCreditRoundingLbl); + end; + + local procedure ExpenseRoundingSearch(): Text[30] + begin + case GetCountryCode() of + 'BE', 'CZ', 'FI', 'NO': + exit(ExpenseRoundingDifferencesSearchLbl); + 'IT': + exit(ExpenseInvoiceRoundingSearchLbl); + 'CH': + exit(ExpenseRoundingDiffPurchaseSearchLbl); + end; + exit(ExpenseRoundingSearchLbl); + end; + + local procedure ExpenseReportPayableAccountName(): Text[100] + begin + case GetCountryCode() of + 'CH': + exit(ExpenseEmpExpReimbursementsPayableLbl); + 'IT': + exit(ExpenseEmpExpReimbursementPayableLbl); + 'NO': + exit(ExpenseEmpExpPayableCashLbl); + 'CZ': + exit(ExpensePayablesToEmployeesLbl); + 'NL': + exit(ExpenseCurrentLiabilitiesEmpLbl); + 'US': + exit(ExpenseAccountsPayableDomesticLbl); + 'CA': + exit(ExpenseVacationCompPayableLbl); + 'DK': + exit(ExpenseAccountsPayablesLbl); + 'ES': + exit(ExpenseRemunerationAdvancesLbl); + end; + exit(ExpensePayableCashLbl); + end; + + local procedure ExpensePayableBankPaidAccountName(): Text[100] + begin + case GetCountryCode() of + 'BE': + exit(ExpenseCompanyPaidExpClearingLbl); + 'CH', 'FI', 'IT': + exit(ExpenseCompanyPaidExpClearHyphenLbl); + 'NL': + exit(ExpenseBankPaidExpClearingLbl); + 'NO': + exit(ExpenseEmpExpPayableCompPaidLbl); + 'CZ': + exit(ExpenseBankAccountKBLbl); + 'AU', 'AT', 'FR': + exit(ExpenseBankLCYLbl); + 'CA': + exit(ExpenseBankCheckingLbl); + 'DE': + exit(ExpenseBusinessAccountOperatingLbl); + 'DK': + exit(ExpenseBankLbl); + 'ES': + exit(ExpenseBanksEuroLbl); + end; + exit(ExpensePayableBankPaidLbl); + end; + + local procedure ExpensePayableBankPaidSearch(): Text[30] + begin + case GetCountryCode() of + 'BE': + exit(ExpenseCompanyPaidExpClearingSearchLbl); + 'CH', 'FI', 'IT': + exit(ExpenseCompanyPaidExpClearHyphenSearchLbl); + 'NL': + exit(ExpenseBankPaidExpClearingSearchLbl); + 'NO': + exit(ExpenseEmpExpPayableCompPaidSearchLbl); + 'CZ': + exit(ExpenseBankAccountKBSearchLbl); + end; + exit(ExpensePayableBankPaidSearchLbl); + end; + + local procedure ExpensePayableCardPaidAccountName(): Text[100] + begin + case GetCountryCode() of + 'BE', 'IT': + exit(ExpenseCorporateCardExpClearingLbl); + 'CH', 'CZ': + exit(ExpenseCompanyCardExpPayableLbl); + 'FI': + exit(ExpenseCompanyCardExpClearingLbl); + 'NL': + exit(ExpenseCorporateCardExpPayableLbl); + 'NO': + exit(ExpenseEmpExpPayableCompCardLbl); + 'DE', 'AT': + exit(ExpenseCompanyCreditCardClearingLbl); + 'DK': + exit(ExpenseCompanyCreditCardsLbl); + 'ES': + exit(ExpenseCompanyCreditCardClearingLbl); + end; + exit(ExpensePayableCardPaidLbl); + end; + + local procedure ExpensePayableCardPaidSearch(): Text[30] + begin + case GetCountryCode() of + 'AT': + exit(ExpenseCreditCardClearingSearchLbl); + 'BE', 'IT': + exit(ExpenseCorporateCardExpClearingSearchLbl); + 'CH', 'CZ': + exit(ExpenseCompanyCardExpPayableSearchLbl); + 'FI': + exit(ExpenseCompanyCardExpClearingSearchLbl); + 'NL': + exit(ExpenseCorporateCardExpPayableSearchLbl); + 'NO': + exit(ExpenseEmpExpPayableCompCardSearchLbl); + end; + exit(ExpensePayableCardPaidSearchLbl); + end; + internal procedure ExpensePayableBankPaidAccountNo(): Code[20] var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidLbl, ExpensePayableBankPaidSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableBankPaidAccountName(), ExpensePayableBankPaidSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'CZ': + exit('221100'); + 'US': + exit('18400'); + 'AU': + exit('1010'); + 'CA': + exit('11120'); + 'DE': + exit('1810'); + 'DK': + exit('18200'); + 'ES': + exit('5720001'); + 'FR': + exit('512100'); + 'NZ': + exit('2920'); + 'AT': + exit('2800'); + 'BE': + exit('457100'); + 'CH': + exit('2272'); + 'FI': + exit('2917'); + 'IT': + exit('5853'); + 'NL': + exit('1522'); + 'NO': + exit('5962'); + end; exit('78400'); end; @@ -281,13 +1591,92 @@ codeunit 6971 "Create Expense GL Account" var ExistingAccNo: Code[20]; begin - ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidLbl, ExpensePayableCardPaidSearchLbl); + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpensePayableCardPaidAccountName(), ExpensePayableCardPaidSearch()); if ExistingAccNo <> '' then exit(ExistingAccNo); + case GetCountryCode() of + 'GB': + exit('78410'); + 'US': + exit('18600'); + 'AU': + exit('1025'); + 'CA': + exit('11160'); + 'DE': + exit('3510'); + 'DK': + exit('18300'); + 'ES': + exit('5721001'); + 'FR': + exit('512900'); + 'NZ': + exit('2950'); + 'AT': + exit('2830'); + 'BE': + exit('457200'); + 'CH': + exit('2271'); + 'CZ': + exit('325200'); + 'FI': + exit('2916'); + 'IT': + exit('5852'); + 'NL': + exit('1521'); + 'NO': + exit('5961'); + end; exit('78600'); end; + internal procedure ExpenseProfitLossAccountNo(): Code[20] + var + ExistingAccNo: Code[20]; + begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Assets, ExpenseProfitLossLbl, ExpenseProfitLossSearchLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + + exit('1290001'); + end; + + internal procedure ExpensePrepaymentBeginAccountNo(): Code[20] + var + ExistingAccNo: Code[20]; + begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentBeginLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + + case GetCountryCode() of + 'CA': + exit('13600'); + 'NZ': + exit('2500'); + end; + end; + + internal procedure ExpensePrepaymentTotalAccountNo(): Code[20] + var + ExistingAccNo: Code[20]; + begin + ExistingAccNo := FindExistingExpenseAccount("G/L Account Category"::Expense, ExpensePrepaymentTotalLbl); + if ExistingAccNo <> '' then + exit(ExistingAccNo); + + case GetCountryCode() of + 'CA': + exit('13690'); + 'NZ': + exit('2590'); + end; + end; + internal procedure FindExistingExpenseAccount(AccountCategory: Enum "G/L Account Category"; FullDescription: Text; PartialDescription: Text) AccNo: Code[20] begin AccNo := FindExistingExpenseAccount(AccountCategory, FullDescription); @@ -326,6 +1715,15 @@ codeunit 6971 "Create Expense GL Account" exit(''); end; + local procedure GetCountryCode(): Code[10] + var + CompanyInformation: Record "Company Information"; + begin + CompanyInformation.SetLoadFields("Country/Region Code"); + if CompanyInformation.Get() then + exit(CompanyInformation."Country/Region Code"); + end; + [IntegrationEvent(false, false)] local procedure OnBeforeCreateGLAccount(var IsHandled: Boolean) begin From 5a1499b32cabb66642da4e2f656aeab65dbe1668 Mon Sep 17 00:00:00 2001 From: v-rohangarg20 Date: Sun, 23 Aug 2026 22:26:58 +0530 Subject: [PATCH 25/25] Skip G/L account re-indent for blank-country companies CreateGLAccount ran GLAccountIndent.Indent() for any non-ES company, including uninitialized/test companies with no Country/Region Code (e.g. 'My Company'). In a localized container (ES) the localized G/L Account-Indent rejects the W1 default expense accounts (e.g. 10390) with 'Missing group', failing the PreviewPostingOfExpenseReportWhenDemoDataIsExecuted test. Only re-indent when a country code is set. --- .../app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al index 5a584b92595..887ac1e6f19 100644 --- a/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al +++ b/src/Apps/W1/ExpenseAgent/app/src/Setup/Codeunits/CreateExpenseGLAccount.Codeunit.al @@ -252,7 +252,8 @@ codeunit 6971 "Create Expense GL Account" if GetCountryCode() = 'ES' then UpdateIncomeStatementBalanceAccount() else - GLAccountIndent.Indent(); + if GetCountryCode() <> '' then + GLAccountIndent.Indent(); end; internal procedure InsertGLAccount(AccountNo: Code[20]; Name: Text[100]; IncomeOrBalance: Enum "G/L Account Income/Balance"; AccountCategory: Enum "G/L Account Category"; AccountSubCategory: Text[80]; AccountType: Enum "G/L Account Type"; GenBusPostingGroup: Code[20]; GenProdPostingGroup: Code[20]; TaxGroup: Code[20]; NoOfBlankLines: Integer; Totaling: Text[250]; GenPostingType: Enum "General Posting Type"; VATGenPostingGroup: Code[20]; VATProdPostingGroup: Code[20]; DirectPosting: Boolean; ReconciliationAccount: Boolean; NewPage: Boolean)