diff --git a/build/groups.json b/build/groups.json index d7068859379..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": [ @@ -8866,176 +8696,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 d7472024984..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", @@ -5440,113 +5300,20 @@ "DK", "FR", "DE", - "AT" + "AT", + "NL", + "BE", + "IT", + "CH", + "NO", + "FI", + "CZ" ], "runStaticCodeAnalysis": true, "ruleSetPath": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\base.ruleset.json", "ruleSetPathMinorRelease": "$env:INETROOT\\App\\BCApps\\src\\rulesets\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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\\baseminorrelease.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 b69d18b72c5..dd817a2ac58 100644 --- a/build/projects/Apps AT/.AL-Go/settings.json +++ b/build/projects/Apps AT/.AL-Go/settings.json @@ -5,8 +5,6 @@ "appFolders": [ "../../../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 4c40dcab674..b2262987909 100644 --- a/build/projects/Apps AU/.AL-Go/settings.json +++ b/build/projects/Apps AU/.AL-Go/settings.json @@ -6,8 +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/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 BE/.AL-Go/settings.json b/build/projects/Apps BE/.AL-Go/settings.json index 89662f984c8..3baa5fb02a5 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 CA/.AL-Go/settings.json b/build/projects/Apps CA/.AL-Go/settings.json index 0287f7eb28d..184ed3b4d46 100644 --- a/build/projects/Apps CA/.AL-Go/settings.json +++ b/build/projects/Apps CA/.AL-Go/settings.json @@ -5,8 +5,6 @@ "appFolders": [ "../../../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 CH/.AL-Go/settings.json b/build/projects/Apps CH/.AL-Go/settings.json index d54f29639ec..45799c72d4d 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 b098a779a23..82b24564220 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 DE/.AL-Go/settings.json b/build/projects/Apps DE/.AL-Go/settings.json index e8f8c6f9f8a..69d9ef11982 100644 --- a/build/projects/Apps DE/.AL-Go/settings.json +++ b/build/projects/Apps DE/.AL-Go/settings.json @@ -8,8 +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/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 f021ea8849f..0705145cc2c 100644 --- a/build/projects/Apps DK/.AL-Go/settings.json +++ b/build/projects/Apps DK/.AL-Go/settings.json @@ -10,8 +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/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 b41e7d9371e..e6e92209f6f 100644 --- a/build/projects/Apps ES/.AL-Go/settings.json +++ b/build/projects/Apps ES/.AL-Go/settings.json @@ -7,8 +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/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 FI/.AL-Go/settings.json b/build/projects/Apps FI/.AL-Go/settings.json index 10377e5fd8e..0b3b782ee75 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 FR/.AL-Go/settings.json b/build/projects/Apps FR/.AL-Go/settings.json index 95acbe7a893..6d0a135bb66 100644 --- a/build/projects/Apps FR/.AL-Go/settings.json +++ b/build/projects/Apps FR/.AL-Go/settings.json @@ -6,8 +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/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 a939bdd47ff..ff7b7730102 100644 --- a/build/projects/Apps GB/.AL-Go/settings.json +++ b/build/projects/Apps GB/.AL-Go/settings.json @@ -5,8 +5,6 @@ "appFolders": [ "../../../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 IT/.AL-Go/settings.json b/build/projects/Apps IT/.AL-Go/settings.json index 3c62798dd4e..1dbeb56c68a 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 f7dcb5d5a33..f9cefc1a632 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 f0f93aa13fe..dc908a58806 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/build/projects/Apps NZ/.AL-Go/settings.json b/build/projects/Apps NZ/.AL-Go/settings.json index 25e28df1089..8b9e418705a 100644 --- a/build/projects/Apps NZ/.AL-Go/settings.json +++ b/build/projects/Apps NZ/.AL-Go/settings.json @@ -6,8 +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/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 951e960dd02..30963fcca58 100644 --- a/build/projects/Apps US/.AL-Go/settings.json +++ b/build/projects/Apps US/.AL-Go/settings.json @@ -11,8 +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/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/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 c2e2a766622..3402b1be02e 100644 --- a/src/Apps/W1/ExpenseAgent/app/app.json +++ b/src/Apps/W1/ExpenseAgent/app/app.json @@ -23,106 +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)", - "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/ExpenseReport/Codeunits/ExpenseReportPost.Codeunit.al b/src/Apps/W1/ExpenseAgent/app/src/ExpenseReport/Codeunits/ExpenseReportPost.Codeunit.al index e7dda1c4368..f1647d29411 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 @@ -84,6 +84,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/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..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 @@ -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,214 @@ 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 + 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) @@ -134,14 +314,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 +409,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 +454,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 +585,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 +630,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 +675,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 +720,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 +765,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 +810,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 +855,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 +900,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 +1592,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 +1716,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 diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpGLAccountAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpGLAccountAT.Codeunit.al new file mode 100644 index 00000000000..a12c8308e38 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpGLAccountAT.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 "Create Exp. GL Account AT" +{ + 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/1.Setup Data/CreateExpPostingGrpAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpPostingGrpAT.Codeunit.al new file mode 100644 index 00000000000..e61576a8781 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/CreateExpPostingGrpAT.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 "Create Exp. Posting Grp AT" +{ + 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"; + 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(ExpenseGLAccountNamesAT.HospitalityDomesticDeductibleAmountName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.KilometerAllowanceName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + 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(ExpenseGLAccountNamesAT.MealExpensesDomesticName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ExpensePerDiemA(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.MealExpensesAbroadName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + 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(ExpenseGLAccountNamesAT.TransportationThirdPartiesName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesAT.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/1.Setup Data/UpdateEmpPostingGrpAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/UpdateEmpPostingGrpAT.Codeunit.al new file mode 100644 index 00000000000..127e5c7d2e8 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/1.Setup Data/UpdateEmpPostingGrpAT.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 "Update Emp. Posting Grp AT" +{ + 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"; + 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(ExpenseGLAccountNamesAT.SettlementAccountCashBankName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.BankLcyName()), CreateExpGLAccountAT.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpCategoriesAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpCategoriesAT.Codeunit.al new file mode 100644 index 00000000000..c716f7b2741 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/2.Master Data/CreateExpCategoriesAT.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 "Create Exp. Categories AT" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpAT: Codeunit "Create Exp. Posting Grp AT"; + begin + 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 + 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/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/AT/3. Transactions/CreateExpenseAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/3. Transactions/CreateExpenseAT.Codeunit.al new file mode 100644 index 00000000000..c55719a1920 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/3. Transactions/CreateExpenseAT.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 "Create Expense AT" +{ + 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(), 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); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesAT: Codeunit "Create Exp. Categories AT"; + 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/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/CreateExpenseCountryDataAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.Codeunit.al new file mode 100644 index 00000000000..46ef37f18da --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/CreateExpenseCountryDataAT.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 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"; + ExpDemoDataSubscriberAT: Codeunit "Exp. Demo Data Subscriber AT"; + begin + BindSubscription(ExpDemoDataSubscriberAT); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense AT"); + + UnbindSubscription(ExpDemoDataSubscriberAT); + 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/AT/ExpDemoDataSubscriberAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpDemoDataSubscriberAT.Codeunit.al new file mode 100644 index 00000000000..f7c0422e771 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpDemoDataSubscriberAT.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 "Exp. Demo Data Subscriber AT" +{ + 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/ExpenseGLAccountNamesAT.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpenseGLAccountNamesAT.Codeunit.al new file mode 100644 index 00000000000..1687bfbee52 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AT/ExpenseGLAccountNamesAT.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 "Expense GL Account Names AT" +{ + 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/AU/1.Setup Data/CreateExpGLAccountAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpGLAccountAU.Codeunit.al new file mode 100644 index 00000000000..4173e491eeb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpGLAccountAU.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 "Create Exp. GL Account AU" +{ + 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/1.Setup Data/CreateExpPostingGrpAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpPostingGrpAU.Codeunit.al new file mode 100644 index 00000000000..0bffe6d8273 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/CreateExpPostingGrpAU.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 "Create Exp. Posting Grp AU" +{ + 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/1.Setup Data/UpdateEmpPostingGrpAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/UpdateEmpPostingGrpAU.Codeunit.al new file mode 100644 index 00000000000..cff32f1a012 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/1.Setup Data/UpdateEmpPostingGrpAU.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 "Update Emp. Posting Grp AU" +{ + 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/AU/2.Master Data/CreateExpCategoriesAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpCategoriesAU.Codeunit.al new file mode 100644 index 00000000000..1d05039447e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpCategoriesAU.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 "Create Exp. Categories AU" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpAU: Codeunit "Create Exp. Posting Grp AU"; + begin + 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 + 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/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/AU/2.Master Data/CreateExpSubCategoriesAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpSubCategoriesAU.Codeunit.al new file mode 100644 index 00000000000..a7629994e10 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/2.Master Data/CreateExpSubCategoriesAU.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 "Create Exp. SubCategories AU" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesAU.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesAU.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/3. Transactions/CreateExpenseAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/3. Transactions/CreateExpenseAU.Codeunit.al new file mode 100644 index 00000000000..9f3b595faae --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/3. Transactions/CreateExpenseAU.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 "Create Expense AU" +{ + 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(), 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); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesAU: Codeunit "Create Exp. Categories AU"; + 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/4. Historical/CreatePostedExpReportAU.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/4. Historical/CreatePostedExpReportAU.Codeunit.al new file mode 100644 index 00000000000..645d832043e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/AU/4. Historical/CreatePostedExpReportAU.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 "Create Posted Exp. Report AU" +{ + 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"; + 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(), 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); + + 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(), 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(), 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); + 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/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/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/CA/1.Setup Data/CreateExpGLAccountCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpGLAccountCA.Codeunit.al new file mode 100644 index 00000000000..7a8e10537bd --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpGLAccountCA.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 "Create Exp. GL Account CA" +{ + 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/1.Setup Data/CreateExpPostingGrpCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpPostingGrpCA.Codeunit.al new file mode 100644 index 00000000000..ccfe241dd47 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/CreateExpPostingGrpCA.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 "Create Exp. Posting Grp CA" +{ + 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/1.Setup Data/UpdateEmpPostingGrpCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/UpdateEmpPostingGrpCA.Codeunit.al new file mode 100644 index 00000000000..7d97d2851bc --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/1.Setup Data/UpdateEmpPostingGrpCA.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 "Update Emp. Posting Grp CA" +{ + 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/CA/2.Master Data/CreateExpCategoriesCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpCategoriesCA.Codeunit.al new file mode 100644 index 00000000000..850315632e1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpCategoriesCA.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 "Create Exp. Categories CA" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpCA: Codeunit "Create Exp. Posting Grp CA"; + begin + 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 + 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/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/CA/2.Master Data/CreateExpSubCategoriesCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpSubCategoriesCA.Codeunit.al new file mode 100644 index 00000000000..e527934fa93 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/2.Master Data/CreateExpSubCategoriesCA.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 "Create Exp. SubCategories CA" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesCA: Codeunit "Create Exp. Categories CA"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesCA.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesCA.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/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/CA/4. Historical/CreatePostedExpReportCA.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/4. Historical/CreatePostedExpReportCA.Codeunit.al new file mode 100644 index 00000000000..16f16fe66f1 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/CA/4. Historical/CreatePostedExpReportCA.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 "Create Posted Exp. Report CA" +{ + 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"; + 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(), 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); + + 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(), 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(), 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); + 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/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/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..ea098a0e96f --- /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(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesCZ.BankAccountKBName()), CreateExpGLAccountCZ.CompanyCardExpensesPayable()); + 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/DE/1.Setup Data/CreateExpGLAccountDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpGLAccountDE.Codeunit.al new file mode 100644 index 00000000000..514fb378745 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpGLAccountDE.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 "Create Exp. GL Account DE" +{ + 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/1.Setup Data/CreateExpPostingGrpDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpPostingGrpDE.Codeunit.al new file mode 100644 index 00000000000..7f23862c43f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/CreateExpPostingGrpDE.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 "Create Exp. Posting Grp DE" +{ + 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 + 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(ExpenseGLAccountNamesDE.BusinessEntertainingdeductibleName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + 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(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + 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(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + 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(ExpenseGLAccountNamesDE.RentalvehiclesName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.SalesInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.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/1.Setup Data/UpdateEmpPostingGrpDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/UpdateEmpPostingGrpDE.Codeunit.al new file mode 100644 index 00000000000..0601ff5d43c --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/1.Setup Data/UpdateEmpPostingGrpDE.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 "Update Emp. Posting Grp DE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + HRGLAccount: Codeunit "Create HR GL Account"; + ExpenseGLAccountNamesDE: Codeunit "Expense GL Account Names DE"; + ExpenseGLAccount: Codeunit "Create Expense G/L 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(ExpenseGLAccountNamesDE.AssetsintheformofprepaidexpensesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.BusinessaccountOperatingDomesticName()), CreateExpGLAccountDE.CompanyCreditCardsClearingAccount()); + ContosoExpenseAgent.SetOverwriteData(false); + end; +} diff --git a/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpCategoriesDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpCategoriesDE.Codeunit.al new file mode 100644 index 00000000000..cf1e75e4cbc --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpCategoriesDE.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 "Create Exp. Categories DE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpDE: Codeunit "Create Exp. Posting Grp DE"; + begin + 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 + 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/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/2.Master Data/CreateExpSubCategoriesDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpSubCategoriesDE.Codeunit.al new file mode 100644 index 00000000000..fb627a95033 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/2.Master Data/CreateExpSubCategoriesDE.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 "Create Exp. SubCategories DE" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesDE.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesDE.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/3. Transactions/CreateExpenseDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/3. Transactions/CreateExpenseDE.Codeunit.al new file mode 100644 index 00000000000..363f2b3250a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/3. Transactions/CreateExpenseDE.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 "Create Expense DE" +{ + 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(), 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); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesDE: Codeunit "Create Exp. Categories DE"; + 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/4. Historical/CreatePostedExpReportDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/4. Historical/CreatePostedExpReportDE.Codeunit.al new file mode 100644 index 00000000000..851b911683e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/4. Historical/CreatePostedExpReportDE.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 "Create Posted Exp. Report DE" +{ + 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 + ExpenseGLAccountNamesDE: Codeunit "Expense GL Account Names DE"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDE.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"; + 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(), 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); + + 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(), 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(), 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); + 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/CreateExpenseCountryDataDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.Codeunit.al new file mode 100644 index 00000000000..d3d977d1b4f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/CreateExpenseCountryDataDE.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 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"; + ExpDemoDataSubscriberDE: Codeunit "Exp. Demo Data Subscriber DE"; + begin + BindSubscription(ExpDemoDataSubscriberDE); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense DE"); + + UnbindSubscription(ExpDemoDataSubscriberDE); + 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/ExpDemoDataSubscriberDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpDemoDataSubscriberDE.Codeunit.al new file mode 100644 index 00000000000..50f1e7b853b --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpDemoDataSubscriberDE.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 "Exp. Demo Data Subscriber DE" +{ + 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/ExpenseGLAccountNamesDE.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpenseGLAccountNamesDE.Codeunit.al new file mode 100644 index 00000000000..875e20a3c88 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DE/ExpenseGLAccountNamesDE.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 "Expense GL Account Names DE" +{ + 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/DK/1.Setup Data/CreateExpGLAccountDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpGLAccountDK.Codeunit.al new file mode 100644 index 00000000000..cf75529a079 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpGLAccountDK.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 "Create Exp. GL Account DK" +{ + 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/1.Setup Data/CreateExpPostingGrpDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpPostingGrpDK.Codeunit.al new file mode 100644 index 00000000000..636df9f2a0a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/CreateExpPostingGrpDK.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 "Create Exp. Posting Grp DK" +{ + 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 + ExpenseGLAccountNamesDK: Codeunit "Expense GL Account Names DK"; + ExpenseGLAccount: Codeunit "Create Expense G/L 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(ExpenseGLAccountNamesDK.EntwinetobaccospiritsName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseMeals(): + 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(ExpenseGLAccountNamesDK.MileagerateName()), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, CreateExpGLAccountDK.OtherExpenses(), CreateExpGLAccountDK.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, CreateExpGLAccountDK.TravelAllowancesPerDiem(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.TravelingtradefairsetcName()), CreateExpGLAccountDK.NonDeductibleTravelExpenses(), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, CreateExpGLAccountDK.RentalCarExpenses(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.PrepaymentsAccruedCostsName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.CentdiscrepanciesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesDK.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/1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al new file mode 100644 index 00000000000..929ca38a577 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/1.Setup Data/UpdateEmpPostingGrpDK.Codeunit.al @@ -0,0 +1,30 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (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 "Update Emp. Posting Grp DK" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + 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(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/DK/2.Master Data/CreateExpCategoriesDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpCategoriesDK.Codeunit.al new file mode 100644 index 00000000000..e7e95138669 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpCategoriesDK.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 "Create Exp. Categories DK" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + CreateExpenseGroup: Codeunit "Create Expense Group"; + CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method"; + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpPostingGrpDK: Codeunit "Create Exp. Posting Grp DK"; + begin + 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 + 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/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/DK/2.Master Data/CreateExpSubCategoriesDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpSubCategoriesDK.Codeunit.al new file mode 100644 index 00000000000..d8d1a6e0afb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/2.Master Data/CreateExpSubCategoriesDK.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 "Create Exp. SubCategories DK" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + var + ContosoExpenseAgent: Codeunit "Contoso Expense Agent"; + CreateExpCategoriesDK: Codeunit "Create Exp. Categories DK"; + begin + // PER-DIEM subcategories + ContosoExpenseAgent.InsertExpenseSubcategory(Country(), CreateExpCategoriesDK.PerDiem(), LocalCountryPerDiemLbl, LocalCountryPerDiemPostingLbl, false, true, false); + ContosoExpenseAgent.InsertExpenseSubcategory(Intl(), CreateExpCategoriesDK.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/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..6991225150f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/CreateExpenseCountryDataDK.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 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"; + ExpDemoDataSubscriberDK: Codeunit "Exp. Demo Data Subscriber DK"; + begin + BindSubscription(ExpDemoDataSubscriberDK); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense DK"); + + UnbindSubscription(ExpDemoDataSubscriberDK); + 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/ExpDemoDataSubscriberDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpDemoDataSubscriberDK.Codeunit.al new file mode 100644 index 00000000000..91f3114d15e --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpDemoDataSubscriberDK.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 "Exp. Demo Data Subscriber DK" +{ + 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/ExpenseGLAccountNamesDK.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpenseGLAccountNamesDK.Codeunit.al new file mode 100644 index 00000000000..e1186cfd641 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/DK/ExpenseGLAccountNamesDK.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 "Expense GL Account Names DK" +{ + 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/ES/1.Setup Data/CreateExpGLAccountES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpGLAccountES.Codeunit.al new file mode 100644 index 00000000000..257df41fafb --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpGLAccountES.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 "Create Exp. GL Account ES" +{ + 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(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]) + 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"; + 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; + 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/1.Setup Data/CreateExpPostingGrpES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpPostingGrpES.Codeunit.al new file mode 100644 index 00000000000..3b6f1164b91 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/CreateExpPostingGrpES.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 "Create Exp. Posting Grp ES" +{ + 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"; + 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, CreateExpGLAccountES.EntertainmentExpensesAccount(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesES.OtherBusinessExpensesName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, CreateExpGLAccountES.TravelExpenses(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.RoundingExpensesOperatingAccount()); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, CreateExpGLAccountES.RentalCarExpenses(), '', CreateExpGLAccountES.ExpensesPrepayments(), CreateExpGLAccountES.RoundingExpensesOperatingAccount(), CreateExpGLAccountES.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/1.Setup Data/UpdateEmpPostingGrpES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/UpdateEmpPostingGrpES.Codeunit.al new file mode 100644 index 00000000000..fbf2f968223 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/1.Setup Data/UpdateEmpPostingGrpES.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 "Update Emp. Posting Grp ES" +{ + InherentEntitlements = X; + InherentPermissions = X; + + trigger OnRun() + begin + UpdateEmployeePostingGroup(); + end; + + local procedure UpdateEmployeePostingGroup() + var + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + 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(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/2.Master Data/UpdateEmployeeES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/UpdateEmployeeES.Codeunit.al new file mode 100644 index 00000000000..c892233c8d2 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/2.Master Data/UpdateEmployeeES.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 "Update Employee ES" +{ + 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/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..1f8b4fccfbe --- /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 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::"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"); + 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/ExpDemoDataSubscriberES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpDemoDataSubscriberES.Codeunit.al new file mode 100644 index 00000000000..2818b4c9b49 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpDemoDataSubscriberES.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 "Exp. Demo Data Subscriber ES" +{ + 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/ExpenseGLAccountNamesES.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpenseGLAccountNamesES.Codeunit.al new file mode 100644 index 00000000000..230e5fd7366 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ES/ExpenseGLAccountNamesES.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 "Expense GL Account Names ES" +{ + 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/ExpAgentCountryResolver.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.Codeunit.al new file mode 100644 index 00000000000..74943664145 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpAgentCountryResolver.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; + +using Microsoft.DemoTool; + +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 + ContosoCoffeeDemoDataSetup: Record "Contoso Coffee Demo Data Setup"; + begin + if ContosoCoffeeDemoDataSetup.Get() then + case ContosoCoffeeDemoDataSetup."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); + '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 new file mode 100644 index 00000000000..70e12148bf9 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/ExpenseAgentCountry.Enum.al @@ -0,0 +1,101 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (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" = "Create Expense Country Data W1"; + } + value(1; US) + { + Caption = 'US'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data US"; + } + value(2; GB) + { + Caption = 'GB'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data GB"; + } + value(3; CA) + { + Caption = 'CA'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data CA"; + } + value(4; NZ) + { + Caption = 'NZ'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data NZ"; + } + value(5; AU) + { + Caption = 'AU'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data AU"; + } + value(6; ES) + { + Caption = 'ES'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data ES"; + } + value(7; DK) + { + Caption = 'DK'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data DK"; + } + value(8; FR) + { + Caption = 'FR'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data FR"; + } + value(9; DE) + { + Caption = 'DE'; + Implementation = "Expense Agent Country Data" = "Create Expense Country Data DE"; + } + value(10; AT) + { + 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/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/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/FR/1.Setup Data/CreateExpGLAccountFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpGLAccountFR.Codeunit.al new file mode 100644 index 00000000000..254613e9a0f --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpGLAccountFR.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 "Create Exp. GL Account FR" +{ + 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/1.Setup Data/CreateExpPostingGrpFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpPostingGrpFR.Codeunit.al new file mode 100644 index 00000000000..6602e4dbc29 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/CreateExpPostingGrpFR.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 "Create Exp. Posting Grp FR" +{ + 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"; + 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()), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMeals(): + ValidateRecordFields(Rec, ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccount(), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + ValidateRecordFields(Rec, ExpenseGLAccount.OtherTravelExpensesAccount(), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + ExpensePerDiem(): + ValidateRecordFields(Rec, ExpenseGLAccount.PerDiemTravelExpensesAccount(), '', CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + ValidateRecordFields(Rec, ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.TravelName()), ExpenseGLAccount.OtherNondeductibleTravelExpensesAccount(), CreateExpGLAccountFR.ExpensePrepaymentAccount(), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName()), ExpenseGLAccount.FindGLAccountByName(CreateGLAccount.ApplicationRoundingName())); + CreateExpensePostingGroup.ExpenseRentalCars(): + ValidateRecordFields(Rec, CreateExpGLAccountFR.RentalCarExpenses(), '', CreateExpGLAccountFR.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/1.Setup Data/UpdateEmpPostingGrpFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/UpdateEmpPostingGrpFR.Codeunit.al new file mode 100644 index 00000000000..d1b38a2a411 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/1.Setup Data/UpdateEmpPostingGrpFR.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 "Update Emp. Posting Grp FR" +{ + 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"; + 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()), 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/FR/3. Transactions/CreateExpenseFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/3. Transactions/CreateExpenseFR.Codeunit.al new file mode 100644 index 00000000000..e2efbdb3fb4 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/3. Transactions/CreateExpenseFR.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 "Create Expense FR" +{ + 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(), 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); + UpdateExpensePerDiem(Expense."No.", 60000, false, true, true); + end; + + var + ContosoUtility: Codeunit "Contoso Utilities"; + CreateExpenseUser: Codeunit "Create Expense User"; + CreateExpCategoriesFR: Codeunit "Create Exp. Categories FR"; + 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/4. Historical/CreatePostedExpReportFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/4. Historical/CreatePostedExpReportFR.Codeunit.al new file mode 100644 index 00000000000..6bc02bbc243 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/4. Historical/CreatePostedExpReportFR.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 "Create Posted Exp. Report FR" +{ + 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"; + 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(), 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); + + 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(), 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(), 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); + 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/CreateExpenseCountryDataFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.Codeunit.al new file mode 100644 index 00000000000..f614006d8ed --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/CreateExpenseCountryDataFR.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 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"; + ExpDemoDataSubscriberFR: Codeunit "Exp. Demo Data Subscriber FR"; + begin + BindSubscription(ExpDemoDataSubscriberFR); + + CreateExpenseCountryDataW1.CreateTransactionalData(); + Codeunit.Run(Codeunit::"Create Expense FR"); + + UnbindSubscription(ExpDemoDataSubscriberFR); + 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/ExpDemoDataSubscriberFR.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/ExpDemoDataSubscriberFR.Codeunit.al new file mode 100644 index 00000000000..7f957243081 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/FR/ExpDemoDataSubscriberFR.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 "Exp. Demo Data Subscriber FR" +{ + 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/GB/1.Setup Data/CreateExpGLAccountGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpGLAccountGB.Codeunit.al new file mode 100644 index 00000000000..fdc55cc3761 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpGLAccountGB.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 "Create Exp. GL Account GB" +{ + 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/1.Setup Data/CreateExpPostingGrpGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpPostingGrpGB.Codeunit.al new file mode 100644 index 00000000000..dcf224d963d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/CreateExpPostingGrpGB.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 "Create Exp. Posting Grp GB" +{ + 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 + 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(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(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + 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(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + 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(ExpenseGLAccountNamesGB.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.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/1.Setup Data/UpdateEmpPostingGrpGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/UpdateEmpPostingGrpGB.Codeunit.al new file mode 100644 index 00000000000..4a6f1f3a257 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/1.Setup Data/UpdateEmpPostingGrpGB.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 "Update Emp. Posting Grp GB" +{ + 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"; + 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(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/GB/4. Historical/CreatePostedExpReportGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/4. Historical/CreatePostedExpReportGB.Codeunit.al new file mode 100644 index 00000000000..609c0396e84 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/4. Historical/CreatePostedExpReportGB.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 "Create Posted Exp. Report GB" +{ + 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 + ExpenseGLAccountNamesGB: Codeunit "Expense GL Account Names GB"; + ExpenseGLAccount: Codeunit "Create Expense G/L Account"; + begin + AccountNo := ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesGB.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"; + 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(), 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); + + 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(), 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(), 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); + 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/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/ExpenseGLAccountNamesGB.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/ExpenseGLAccountNamesGB.Codeunit.al new file mode 100644 index 00000000000..8ad299b8778 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/GB/ExpenseGLAccountNamesGB.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 "Expense GL Account Names GB" +{ + 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/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/Country/NZ/1.Setup Data/CreateExpGLAccountNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpGLAccountNZ.Codeunit.al new file mode 100644 index 00000000000..80a92445e23 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpGLAccountNZ.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 "Create Exp. GL Account NZ" +{ + 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/1.Setup Data/CreateExpPostingGrpNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpPostingGrpNZ.Codeunit.al new file mode 100644 index 00000000000..7a354c5d71c --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/CreateExpPostingGrpNZ.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 "Create Exp. Posting Grp NZ" +{ + 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/1.Setup Data/UpdateEmpPostingGrpNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/UpdateEmpPostingGrpNZ.Codeunit.al new file mode 100644 index 00000000000..cf6662bb29a --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/1.Setup Data/UpdateEmpPostingGrpNZ.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 "Update Emp. Posting Grp NZ" +{ + 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/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/NZ/4. Historical/CreatePostedExpReportNZ.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/4. Historical/CreatePostedExpReportNZ.Codeunit.al new file mode 100644 index 00000000000..73faa059e2d --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/NZ/4. Historical/CreatePostedExpReportNZ.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 "Create Posted Exp. Report NZ" +{ + 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"; + 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(), 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); + + 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(), 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(), 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); + 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/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/US/1.Setup Data/CreateExpGLAccountUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpGLAccountUS.Codeunit.al new file mode 100644 index 00000000000..5868bac7bfa --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpGLAccountUS.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 "Create Exp. GL Account US" +{ + 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/1.Setup Data/CreateExpPostingGrpUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpPostingGrpUS.Codeunit.al new file mode 100644 index 00000000000..ef36a8c6185 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/1.Setup Data/CreateExpPostingGrpUS.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 "Create Exp. Posting Grp US" +{ + 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 + 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(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(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseMileage(): + ValidateRecordFields(Rec, ExpenseGLAccount.MileageTravelExpensesAccount(), '', ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseOther(): + 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(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName())); + CreateExpensePostingGroup.ExpenseTravel(): + 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(ExpenseGLAccountNamesUS.RentalVehiclesName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherIncidentalRevenueName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.OtherPrepaidExpensesAndAccruedIncomeName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.PayableInvoiceRoundingName()), ExpenseGLAccount.FindGLAccountByName(ExpenseGLAccountNamesUS.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/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/ExpenseGLAccountNamesUS.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/US/ExpenseGLAccountNamesUS.Codeunit.al new file mode 100644 index 00000000000..f723da58b45 --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/US/ExpenseGLAccountNamesUS.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 "Expense GL Account Names US" +{ + 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/W1/CreateExpenseCountryDataW1.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Country/W1/CreateExpenseCountryDataW1.Codeunit.al new file mode 100644 index 00000000000..ac8749079ec --- /dev/null +++ b/src/Apps/W1/ExpenseAgent/demo data/Country/W1/CreateExpenseCountryDataW1.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 "Create Expense Country Data W1" 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/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/Demo Data/ExpenseAgentContosoModule.Codeunit.al b/src/Apps/W1/ExpenseAgent/demo data/Demo Data/ExpenseAgentContosoModule.Codeunit.al index 77da9374d0f..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,35 +26,38 @@ codeunit 8202 "Expense Agent Contoso Module" implements "Contoso Demo Data Modul procedure CreateSetupData() var ExpenseAgentModuleSetup: Record "Expense Agent Module Setup"; + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: 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"); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateSetupData(); end; procedure CreateMasterData() + var + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: 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"); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateMasterData(); end; procedure CreateTransactionalData() + var + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: Interface "Expense Agent Country Data"; begin - Codeunit.Run(Codeunit::"Create Expense"); - Codeunit.Run(Codeunit::"Create Exp. Report"); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateTransactionalData(); end; procedure CreateHistoricalData() + var + ExpAgentCountryResolver: Codeunit "Exp. Agent Country Resolver"; + ExpenseAgentCountryData: Interface "Expense Agent Country Data"; begin - Codeunit.Run(Codeunit::"Create Posted Expense Report"); + ExpenseAgentCountryData := ExpAgentCountryResolver.Resolve(); + ExpenseAgentCountryData.CreateHistoricalData(); end; } \ No newline at end of file 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..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 diff --git a/src/Apps/W1/ExpenseAgent/demo data/app.json b/src/Apps/W1/ExpenseAgent/demo data/app.json index 6567deda989..67dd193d200 100644 --- a/src/Apps/W1/ExpenseAgent/demo data/app.json +++ b/src/Apps/W1/ExpenseAgent/demo data/app.json @@ -25,65 +25,18 @@ "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", "idRanges": [ { "from": 8201, - "to": 8222 + "to": 8399 + }, + { + "from": 8400, + "to": 8499 } ], "target": "OnPrem",