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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions src/Apps/W1/ExpenseTaxIntegration/app/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"id": "4cb44e6c-9a37-4d4e-b45f-1b3054ddc59a",
"name": "Expense Tax Integration",
"publisher": "Microsoft",
"version": "29.0.0.0",
"brief": "Expense Tax Integration",
"description": "Expense Tax Integration",
"privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=724013",
"help": "https://go.microsoft.com/fwlink/?linkid=2139719",
"contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2139719",
"url": "https://go.microsoft.com/fwlink/?linkid=724011",
"logo": "./ExtensionLogo.png",
"dependencies": [
{
"id": "66efe10c-8033-403b-a86d-77c0887178ba",
"name": "Expense Agent (Preview)",
"publisher": "Microsoft",
"version": "$(app_minimumVersion)"
},
{
"id": "c31ee575-3fc7-4388-98ee-d75aa2fc5f87",
"name": "Withholding Tax",
"publisher": "Microsoft",
"version": "$(app_minimumVersion)"
}
],
"screenshots": [],
"platform": "29.0.0.0",
"application": "29.0.0.0",
"idRanges": [
{
"from": 7055,
"to": 7059
}
],
"features": [
"TranslationFile"
],
"resourceExposurePolicy": {
"allowDebugging": true,
"allowDownloadingSource": true,
"includeSourceInSymbolFile": true
},
"target": "Cloud"
}
Original file line number Diff line number Diff line change
@@ -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.WithholdingTax;

using Microsoft.ExpenseAgent;

pageextension 7055 "WHT Expense Categories" extends "Expense Category Card"
{
layout
{
addlast("General")
{
group(WHT)
{
Caption = 'Withholding Tax';
ShowCaption = true;

field("Withholding Selection Mode"; Rec."Withholding Selection Mode")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies whether the expense category uses a single tax or a tax group for withholding tax calculation.';
}
field("Wthldg. Tax Prod. Post. Group"; Rec."Wthldg. Tax Prod. Post. Group")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the withholding tax product posting group for the expense category.';
}
field("Withholding Group Code"; Rec."Withholding Group Code")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the withholding tax group code for the expense category.';
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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.ExpenseTaxIntegration;

using Microsoft.ExpenseAgent;
using Microsoft.WithholdingTax;

tableextension 7055 "WHT Expense Category Ext" extends "Expense Category"
{
fields
{
field(7055; "Withholding Selection Mode"; Enum "Withholding Selection Mode")
{
Caption = 'Withholding Selection Mode';
DataClassification = CustomerContent;
}
field(7056; "Wthldg. Tax Prod. Post. Group"; Code[20])
{
Caption = 'Withholding Tax Prod. Post. Group';
TableRelation = "Wthldg. Tax Prod. Post. Group";
DataClassification = CustomerContent;
}
field(7057; "Withholding Group Code"; Code[20])
{
Caption = 'Withholding Group Code';
TableRelation = "Withholding Tax Group";
DataClassification = CustomerContent;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseTaxIntegration;

using Microsoft.ExpenseAgent;
using Microsoft.Finance.GeneralLedger.Journal;
using Microsoft.Finance.GeneralLedger.Setup;
using Microsoft.WithholdingTax;

codeunit 7056 "WHT Expense Category Mgt."
{
var
NoPostingSetupErr: Label 'Withholding Tax Posting Setup does not exist for Business Posting Group %1, Product Posting Group %2.', Comment = '%1 = Bus. Post. Group, %2 = Prod. Post. Group';

[EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", OnAfterValidateEvent, 'Expense Category', false, false)]
local procedure OnAfterExpenseCategoryValidateEmployee(var Rec: Record "Gen. Journal Line")
var
ExpenseCategory: Record "Expense Category";
begin
if CheckWithholdingTaxDisabled() then
exit;

if ExpenseCategory.Get(Rec."Expense Category") then
Rec."Wthldg. Tax Prod. Post. Group" := ExpenseCategory."Wthldg. Tax Prod. Post. Group"
else
Rec."Wthldg. Tax Prod. Post. Group" := '';
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"WHT Employee Calculation", OnBeforeCheckCalcEmployeeWHT, '', false, false)]
local procedure OnBeforeCheckCalcEmployeeWHT(GenJnlLine: Record "Gen. Journal Line")
var
WithholdingTaxPostingSetup: Record "Withholding Tax Posting Setup";
begin
if not WithholdingTaxPostingSetup.Get(GenJnlLine."Wthldg. Tax Bus. Post. Group", GenJnlLine."Wthldg. Tax Prod. Post. Group") and IsExpenseCategorySingleTax(GenJnlLine) then
Error(NoPostingSetupErr, GenJnlLine."Wthldg. Tax Bus. Post. Group", GenJnlLine."Wthldg. Tax Prod. Post. Group");
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"WHT Employee Calculation", OnBeforeInsertThresholdAccumulator, '', false, false)]
local procedure OnBeforeInsertThresholdAccumulator(var ThresholdAccumulator: Record "WHT Threshold Accumulator"; PostingSetup: Record "Withholding Tax Posting Setup")
begin
ThresholdAccumulator."Expense Category Code" := PostingSetup."Threshold Category Code";
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"WHT Employee Calculation", OnBeforeReverseThresholdAccumulator, '', false, false)]
local procedure OnBeforeReverseThresholdAccumulator(var ThresholdAccumulator: Record "WHT Threshold Accumulator"; PostingSetup: Record "Withholding Tax Posting Setup")
begin
ThresholdAccumulator."Expense Category Code" := PostingSetup."Threshold Category Code";
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"WHT Employee Calculation", OnBeforeUpdateThresholdAccumulator, '', false, false)]
local procedure OnBeforeUpdateThresholdAccumulator(var ThresholdAccumulator: Record "WHT Threshold Accumulator"; PostingSetup: Record "Withholding Tax Posting Setup")
begin
ThresholdAccumulator."Expense Category Code" := PostingSetup."Threshold Category Code";
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"WHT Employee Calculation", OnBeforeResolveWHTGroupComponents, '', false, false)]
local procedure OnBeforeResolveWHTGroupComponents(GenJnlLine: Record "Gen. Journal Line"; var WHTGroupCode: Code[20]; var Result: Boolean)
var
WHTGroup: Record "Withholding Tax Group";
ExpenseCategory: Record "Expense Category";
begin
if ExpenseCategory.Get(GenJnlLine."Expense Category") then
if WHTGroup.Get(ExpenseCategory."Withholding Group Code") then begin
WHTGroupCode := WHTGroup.Code;
Result := true;
end else
Result := false;
end;

local procedure IsExpenseCategorySingleTax(GenJnlline: Record "Gen. Journal Line"): Boolean
var
ExpenseCategory: Record "Expense Category";
begin
if GenJnlline."Expense Category" = '' then
exit(true);

if ExpenseCategory.Get(GenJnlline."Expense Category") then
if (ExpenseCategory."Withholding Selection Mode" = ExpenseCategory."Withholding Selection Mode"::"Tax Group") and (ExpenseCategory."Withholding Group Code" <> '') then
exit(false);

exit(true);
end;

local procedure CheckWithholdingTaxDisabled(): Boolean
var
GeneralLedgerSetup: Record "General Ledger Setup";
begin
GeneralLedgerSetup.Get();
if not GeneralLedgerSetup."Enable Withholding Tax" then
exit(true);

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

using Microsoft.WithholdingTax;

pageextension 7056 "WHT Tax Posting Setup" extends "Withholding Tax Posting Setup"
{
layout
{
addlast(GroupName)
{
field("Threshold Category Code"; Rec."Threshold Category Code")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the threshold category code used to accumulate withholding tax threshold amounts for the expense category.';
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseTaxIntegration;

using Microsoft.ExpenseAgent;
using Microsoft.WithholdingTax;

tableextension 7056 "WHT Tax Posting Setup Ext" extends "Withholding Tax Posting Setup"
{
fields
{
field(7055; "Threshold Category Code"; Code[20])
{
Caption = 'Threshold Category Code';
TableRelation = "Expense Category";
DataClassification = CustomerContent;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseTaxIntegration;

using Microsoft.ExpenseAgent;
using Microsoft.WithholdingTax;

tableextension 7057 "WHT Threshold Accumulator Ext" extends "WHT Threshold Accumulator"
{
fields
{
field(7055; "Expense Category Code"; Code[20])
{
Caption = 'Expense Category Code';
TableRelation = "Expense Category";
DataClassification = CustomerContent;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.ExpenseTaxIntegration;

enum 7055 "Withholding Selection Mode"
{
Extensible = true;
Caption = 'Withholding Selection Mode';

value(0; "Single Tax")
{
Caption = 'Single Tax';
}
value(1; "Tax Group")
{
Caption = 'Tax Group';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.WithholdingTax;

using Microsoft.HumanResources.Payables;

tableextension 6810 "WHT Empl. Ledger Entry Ext" extends "Employee Ledger Entry"
{
fields
{
field(6784; "WHT Amount"; Decimal)
{
Caption = 'WHT Amount';
AutoFormatType = 1;
Editable = false;
DataClassification = CustomerContent;
}
field(6785; "WHT Base Amount"; Decimal)
{
Caption = 'WHT Base Amount';
AutoFormatType = 1;
Editable = false;
DataClassification = CustomerContent;
}
}
}
Loading