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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ codeunit 6973 "Create Expense Categories"
AddPostingGroupSeed(TempPostingGroup, XEXPENSEMILEAGETxt, XExpenseMileageDescTxt, CreateExpenseGLAccount.ExpenseMileageRefundableDebitAccountNo());
AddPostingGroupSeed(TempPostingGroup, XEXPENSEMEALSTxt, XExpenseMealsDescTxt, CreateExpenseGLAccount.ExpenseMealsRefundableDebitAccountNo());
AddPostingGroupSeed(TempPostingGroup, XEXPENSEENTERTAINTxt, XExpenseEntertainDescTxt, CreateExpenseGLAccount.ExpenseEntertainRefundableDebitAccountNo());

OnAfterBuildPostingGroupSeeds(TempPostingGroup);
end;

/// <summary>
Expand Down Expand Up @@ -136,13 +134,7 @@ codeunit 6973 "Create Expense Categories"
end;

internal procedure AddPostingGroupSeed(var TempPostingGroup: Record "Expense Posting Group" temporary; Code: Code[20]; Description: Text[100]; RefundableDebitAccount: Code[20])
var
IsHandled: Boolean;
begin
OnBeforeAddPostingGroupSeed(Code, Description, RefundableDebitAccount, IsHandled);
if IsHandled then
exit;

TempPostingGroup.Init();
TempPostingGroup.Code := Code;
TempPostingGroup.Description := Description;
Expand All @@ -151,7 +143,6 @@ codeunit 6973 "Create Expense Categories"
TempPostingGroup."Prepayment Credit Account" := CreateExpenseGLAccount.ExpensePrepaymentDebitAccountNo();
TempPostingGroup."Debit Rounding Account" := CreateExpenseGLAccount.ExpenseDebitRoundingAccountNo();
TempPostingGroup."Credit Rounding Account" := CreateExpenseGLAccount.ExpenseCreditRoundingAccountNo();
OnBeforeInsertPostingGroupSeed(TempPostingGroup);
TempPostingGroup.Insert();
end;

Expand Down Expand Up @@ -239,8 +230,6 @@ codeunit 6973 "Create Expense Categories"
AddCategorySeed(TempCategory, XSUBSCRIPTIONTxt, XProfessionalSubscriptionsTxt, XSubscriptionsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCARDTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" ");
AddCategorySeed(TempCategory, XTIPSTxt, XTipsDescTxt, XTipsPostingTxt, XFOODBEVERAGETxt, XEXPENSEOTHERTxt, XCASHTxt, false, false, "Expense Attachment Enforcement"::" ", "Expense Detail Needed"::" ");
AddCategorySeed(TempCategory, XTOLLSTxt, XTollRoadUsageFeeTxt, XTollsPostingTxt, XDAYEXPENSETxt, XEXPENSEOTHERTxt, XCASHTxt, true, false, "Expense Attachment Enforcement"::Warning, "Expense Detail Needed"::" ");

OnAfterBuildCategorySeeds(TempCategory);
end;

/// <summary>
Expand Down Expand Up @@ -355,8 +344,6 @@ codeunit 6973 "Create Expense Categories"

// FINES
AddSubcategorySeed(TempSubcategory, XFINESTxt, XFINESTxt, XFinesSubDescTxt, XFinesPostingTxt, true, false);

OnAfterBuildSubcategorySeeds(TempSubcategory);
end;

internal procedure GetTRAVELTxt(): Code[20]
Expand Down Expand Up @@ -616,13 +603,7 @@ codeunit 6973 "Create Expense Categories"
end;

internal procedure AddCategorySeed(var TempCategory: Record "Expense Category" temporary; Code: Code[20]; Description: Text[250]; PostingDescription: Text[100]; ExpenseGroupCode: Code[20]; PostingGroupCode: Code[20]; PaymentMethod: Code[10]; IsRefundable: Boolean; IsPrepayment: Boolean; AttachmentEnforcement: Enum "Expense Attachment Enforcement"; DetailRequired: Enum "Expense Detail Needed")
var
IsHandled: Boolean;
begin
OnBeforeAddCategorySeed(Code, Description, PostingDescription, ExpenseGroupCode, PostingGroupCode, PaymentMethod, IsRefundable, IsPrepayment, AttachmentEnforcement, DetailRequired, IsHandled);
if IsHandled then
exit;

TempCategory.Init();
TempCategory.Code := Code;
TempCategory.Description := Description;
Expand All @@ -638,13 +619,7 @@ codeunit 6973 "Create Expense Categories"
end;

internal procedure AddSubcategorySeed(var TempSubcategory: Record "Expense Subcategory" temporary; SubcategoryCode: Code[20]; CategoryCode: Code[20]; Description: Text[250]; PostingDescription: Text[100]; Refundable: Boolean; DescriptionMandatory: Boolean)
var
IsHandled: Boolean;
begin
OnBeforeAddSubcategorySeed(SubcategoryCode, CategoryCode, Description, PostingDescription, Refundable, DescriptionMandatory, IsHandled);
if IsHandled then
exit;

TempSubcategory.Init();
TempSubcategory."Expense Category Code" := CategoryCode;
TempSubcategory.Code := SubcategoryCode;
Expand Down Expand Up @@ -828,8 +803,6 @@ codeunit 6973 "Create Expense Categories"
AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XGERMANYALLTxt, 'EUR', "Expense Justification"::" ");
AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUKOTHERTxt, 'GBP', "Expense Justification"::" ");
AddRuleSeed(TempRuleHeader, XPERDIEMTxt, XUSAOTHERTxt, 'USD', "Expense Justification"::" ");

OnAfterBuildRuleSeeds(TempRuleHeader);
end;

/// <summary>
Expand All @@ -850,8 +823,6 @@ codeunit 6973 "Create Expense Categories"
AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XGERMANYALLTxt, "Expense Rule Condition Type"::"Daily Rate", 105);
AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUKOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 115);
AddRuleConditionSeed(TempRuleCondition, XPERDIEMTxt, XUSAOTHERTxt, "Expense Rule Condition Type"::"Daily Rate", 120);

OnAfterBuildRuleConditionSeeds(TempRuleCondition);
end;

/// <summary>
Expand Down Expand Up @@ -933,31 +904,19 @@ codeunit 6973 "Create Expense Categories"
end;

internal procedure AddRuleSeed(var TempRuleHeader: Record "Expense Rule Header" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; CurrencyCode: Code[10]; JustificationRequired: Enum "Expense Justification")
var
IsHandled: Boolean;
begin
OnBeforeAddRuleSeed(TempRuleHeader, CategoryCode, ExpenseLocationCode, CurrencyCode, JustificationRequired, IsHandled);
if IsHandled then
exit;

TempRuleHeader.Init();
TempRuleHeader."Expense Category Code" := CategoryCode;
TempRuleHeader."Expense Location" := ExpenseLocationCode;
TempRuleHeader."Currency Code" := CurrencyCode;
TempRuleHeader."Justification Required" := JustificationRequired;
OnBeforeInsertRuleSeed(TempRuleHeader);
TempRuleHeader.Insert();
end;

internal procedure AddRuleConditionSeed(var TempRuleCondition: Record "Expense Rule Condition" temporary; CategoryCode: Code[20]; ExpenseLocationCode: Code[20]; ConditionType: Enum "Expense Rule Condition Type"; Value: Decimal)
var
NextLineNo: Integer;
IsHandled: Boolean;
begin
OnBeforeAddRuleConditionSeed(TempRuleCondition, CategoryCode, ExpenseLocationCode, ConditionType, Value, IsHandled);
if IsHandled then
exit;

TempRuleCondition.Reset();
TempRuleCondition.SetRange("Expense Category Code", CategoryCode);
TempRuleCondition.SetRange("Expense Location", ExpenseLocationCode);
Expand Down Expand Up @@ -1293,13 +1252,7 @@ codeunit 6973 "Create Expense Categories"
end;

internal procedure UpdateEmployeePostingGroup(Code: Code[20]; ExpenseReportPayableAccount: Code[20]; ExpensePayableBankPaidAccount: Code[20]; ExpensePayableCardPaidAccount: Code[20]; ExpenseReportPrepaymentAccount: Code[20])
var
IsHandled: Boolean;
begin
OnBeforeUpdateEmployeePostingGroup(Code, ExpenseReportPayableAccount, ExpensePayableBankPaidAccount, ExpensePayableCardPaidAccount, ExpenseReportPrepaymentAccount, IsHandled);
if IsHandled then
exit;

if not EmployeePostingGroup.Get(Code) then
exit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ codeunit 6971 "Create Expense GL Account"
local procedure CreateGLAccount()
var
GLAccountIndent: Codeunit "G/L Account-Indent";
IsHandled: Boolean;
begin
OnBeforeCreateGLAccount(IsHandled);
if IsHandled then
exit;

InsertGLAccount(ExpenseOtherRefundableDebitAccountNo(), ExpenseOtherRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false);
InsertGLAccount(ExpenseTravelRefundableDebitAccountNo(), ExpenseTravelRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false);
InsertGLAccount(ExpensePerDiemRefundableDebitAccountNo(), ExpensePerDiemRefundableLbl, "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, '', Enum::"G/L Account Type"::Posting, '', '', '', 1, '', Enum::"G/L Account Type"::Posting, '', '', true, false, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseAgent;

codeunit 8323 "AT Country Data" implements "Expense Agent Country Data"
{
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;

procedure CreateSetupData()
var
W1CountryData: Codeunit "W1 Country Data";
ATExpGLAccount: Codeunit "AT Exp. GL Account";
ATExpPostingGrp: Codeunit "AT Exp. Posting Grp";
begin
BindSubscription(ATExpGLAccount);
BindSubscription(ATExpPostingGrp);

W1CountryData.CreateSetupData();
Codeunit.Run(Codeunit::"AT Upd. Emp. Posting Grp");
Codeunit.Run(Codeunit::"AT Exp. Posting Grp");

UnbindSubscription(ATExpPostingGrp);
UnbindSubscription(ATExpGLAccount);
end;

procedure CreateMasterData()
var
W1CountryData: Codeunit "W1 Country Data";
begin
W1CountryData.CreateMasterData();
Codeunit.Run(Codeunit::"AT Exp. Categories");
Codeunit.Run(Codeunit::"AT Exp. SubCategories");
Codeunit.Run(Codeunit::"AT Exp. Rule Header");
Codeunit.Run(Codeunit::"AT Exp. Rule Condition");
end;

procedure CreateTransactionalData()
var
W1CountryData: Codeunit "W1 Country Data";
begin
W1CountryData.CreateTransactionalData();
Codeunit.Run(Codeunit::"AT Expense");
end;

procedure CreateHistoricalData()
var
W1CountryData: Codeunit "W1 Country Data";
ATCurrencySwapSub: Codeunit "AT Currency Swap Sub";
ATPostedExpReport: Codeunit "AT Posted Exp. Report";
begin
BindSubscription(ATCurrencySwapSub);
BindSubscription(ATPostedExpReport);

W1CountryData.CreateHistoricalData();
Codeunit.Run(Codeunit::"AT Posted Exp. Report");

UnbindSubscription(ATPostedExpReport);
UnbindSubscription(ATCurrencySwapSub);
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseAgent;

using Microsoft.DemoData.Finance;

codeunit 8336 "AT Currency Swap Sub"
{
SingleInstance = true;
EventSubscriberInstance = Manual;
InherentEntitlements = X;
InherentPermissions = X;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Contoso Expense Agent", OnBeforeValidateCurrencyCodeInExpense, '', false, false)]
local procedure OnBeforeValidateCurrencyCodeInExpense(var CurrencyCode: Code[10])
var
CreateCurrency: Codeunit "Create Currency";
begin
if CurrencyCode = CreateCurrency.EUR() then
CurrencyCode := CreateCurrency.USD();
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseAgent;

codeunit 8328 "AT Exp. Categories"
{
InherentEntitlements = X;
InherentPermissions = X;

trigger OnRun()
var
CreateExpenseGroup: Codeunit "Create Expense Group";
CreateExpensePaymentMethod: Codeunit "Create Expense Payment Method";
ContosoExpenseAgent: Codeunit "Contoso Expense Agent";
ATExpPostingGrp: Codeunit "AT Exp. Posting Grp";
begin
ContosoExpenseAgent.InsertExpenseCategory(PerDiemI(), PerDiemByAssignedPolicyLbl, PerDiemIByAssignedPolicyPostingLbl, ATExpPostingGrp.ExpensePerDiemI(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem");
ContosoExpenseAgent.InsertExpenseCategory(PerDiemA(), PerDiemByAssignedPolicyLbl, PerDiemAByAssignedPolicyPostingLbl, ATExpPostingGrp.ExpensePerDiemA(), Enum::"Expense Attachment Enforcement"::" ", CreateExpensePaymentMethod.Cash(), false, false, CreateExpenseGroup.Travel(), true, Enum::"Expense Reimbursement Type"::"Employee Paid", Enum::"Expense Detail Needed"::"Per Diem");
end;

var
PerDiemITok: Label 'PER-DIEM-I', MaxLength = 20, Locked = true;
PerDiemATok: Label 'PER-DIEM-A', MaxLength = 20, Locked = true;
PerDiemByAssignedPolicyLbl: Label 'Expenses for per-diem or daily allowance paid for business trips, typically based on travel itinerary or other proof of travel (e.g., booking or agenda), rather than individual expense receipts.', MaxLength = 250;
PerDiemIByAssignedPolicyPostingLbl: Label 'Per-diem (international) by assigned policy', MaxLength = 100;
PerDiemAByAssignedPolicyPostingLbl: Label 'Per-diem (local) by assigned policy', MaxLength = 100;

procedure PerDiemI(): Code[20]
begin
exit(PerDiemITok);
end;

procedure PerDiemA(): Code[20]
begin
exit(PerDiemATok);
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseAgent;

using Microsoft.DemoTool.Helpers;
using Microsoft.Finance.GeneralLedger.Account;
using Microsoft.Foundation.Enums;

codeunit 8325 "AT Exp. GL Account"
{
SingleInstance = true;
EventSubscriberInstance = Manual;
InherentEntitlements = X;
InherentPermissions = X;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Create Expense G/L Account", 'OnAfterAddGLAccountsForLocalization', '', false, false)]
local procedure ModifyGLAccount()
var
GLAccountCategory: Record "G/L Account Category";
SubCategory: Text[80];
begin
AddGLAccounts();

SubCategory := Format(GLAccountCategory."Account Category"::Assets, 80);
ContosoGLAccount.InsertGLAccount(CompanyCreditCardsClearingAccount(), CompanyCreditCardsClearingAccountName(), "G/L Account Income/Balance"::"Balance Sheet", Enum::"G/L Account Category"::Assets, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::" ", '', '', true, false, false);

SubCategory := Format(GLAccountCategory."Account Category"::Expense, 80);
ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesDeductibleAccount(), ExpenseGLAccount.MealExpensesDeductibleAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false);
ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MealExpensesNondeductibleAccount(), ExpenseGLAccount.MealExpensesNondeductibleAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false);
ContosoGLAccount.InsertGLAccount(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccount(), ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), "G/L Account Income/Balance"::"Income Statement", Enum::"G/L Account Category"::Expense, SubCategory, Enum::"G/L Account Type"::Posting, '', '', '', 0, '', Enum::"General Posting Type"::Purchase, '', '', true, false, false);
end;

local procedure AddGLAccounts()
begin
ContosoGLAccount.AddAccountForLocalization(CompanyCreditCardsClearingAccountName(), '2830');
ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesDeductibleAccountName(), '7691');
ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MealExpensesNondeductibleAccountName(), '7692');
ContosoGLAccount.AddAccountForLocalization(ExpenseGLAccount.MiscExternalExpensesNondeductibleAccountName(), '7745');
end;

var
ContosoGLAccount: Codeunit "Contoso GL Account";
ExpenseGLAccount: Codeunit "Create Expense G/L Account";
CompanyCreditCardsClearingAccountTok: Label 'Company credit card clearing account', MaxLength = 100;

procedure CompanyCreditCardsClearingAccount(): Code[20]
begin
exit(ContosoGLAccount.GetAccountNo(CompanyCreditCardsClearingAccountName()));
end;

procedure CompanyCreditCardsClearingAccountName(): Text[100]
begin
exit(CompanyCreditCardsClearingAccountTok);
end;
}
Loading
Loading