Skip to content
Merged
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 @@ -14,7 +14,10 @@ permissionset 7452 "ExciseTaxes - Edit"

Permissions =
tabledata "Excise Tax Type" = IMD,
#if not CLEAN30
tabledata "Excise Tax Item/FA Rate" = IMD,
#endif
tabledata "Excise Tax Rate" = IMD,
tabledata "Item Excise Tax" = IMD,
tabledata "Excise Tax Entry Permission" = IMD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ permissionset 7450 "ExciseTaxes - Objects"

Permissions =
table "Excise Tax Type" = X,
#if not CLEAN30
table "Excise Tax Item/FA Rate" = X,
#endif
table "Excise Tax Rate" = X,
table "Item Excise Tax" = X,
table "Excise Tax Entry Permission" = X,
page "Excise Tax Types" = X,
page "Excise Tax Type Card" = X,
#if not CLEAN30
page "Excise Tax Item/FA Rates" = X,
#endif
page "Excise Tax Rates" = X,
page "Item Excise Taxes" = X,
page "Item Excise Tax API" = X,
page "Excise Tax Entry Permissions" = X,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ permissionset 7451 "ExciseTaxes - Read"

Permissions =
tabledata "Excise Tax Type" = R,
#if not CLEAN30
tabledata "Excise Tax Item/FA Rate" = R,
#endif
tabledata "Excise Tax Rate" = R,
Comment thread
v-rohangarg20 marked this conversation as resolved.
tabledata "Item Excise Tax" = R,
tabledata "Excise Tax Entry Permission" = R;
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ codeunit 7412 "Excise Tax Calculation"
ExciseJnlLine.Validate("Country/Region Code", ItemLedgerEntry."Country/Region Code");
ExciseJnlLine.Validate("Source Type", ExciseJnlLine."Source Type"::Item);
ExciseJnlLine.Validate("Source No.", ItemLedgerEntry."Item No.");
ExciseJnlLine.Validate("Item Category Code", ItemLedgerEntry."Item Category Code");
Comment thread
v-rohangarg20 marked this conversation as resolved.
ExciseJnlLine.Validate("Source Qty.", Abs(ItemLedgerEntry.Quantity));
OnAfterUpdateExciseJournalLineFromItemLedgerEntry(ExciseJnlLine, ItemLedgerEntry);
if RequiresTaxableAmount(ExciseJnlLine) then
ExciseJnlLine.Validate("Excise Taxable Amount", GetTaxableAmountFromItemLedgerEntry(ItemLedgerEntry));
ExciseJnlLine."Item Ledger Entry No." := ItemLedgerEntry."Entry No.";
end;

Expand Down Expand Up @@ -316,9 +320,43 @@ codeunit 7412 "Excise Tax Calculation"
ExciseJnlLine.Validate("Source Type", ExciseJnlLine."Source Type"::"Fixed Asset");
ExciseJnlLine.Validate("Source No.", FALedgerEntry."FA No.");
ExciseJnlLine.Validate("Source Qty.", 1);
if RequiresTaxableAmount(ExciseJnlLine) then
ExciseJnlLine.Validate("Excise Taxable Amount", Abs(FALedgerEntry.Amount));
ExciseJnlLine."FA Ledger Entry No." := FALedgerEntry."Entry No.";
end;

local procedure RequiresTaxableAmount(ExciseJnlLine: Record "Sust. Excise Jnl. Line"): Boolean
begin
exit(ExciseJnlLine."Excise Calculation Type" in ["Excise Calculation Type"::"Ad valorem", "Excise Calculation Type"::Hybrid]);
end;

// The taxable value of an item ledger entry is taken from its value entries: the invoiced sales or purchase
// amount when the entry has one, otherwise the inventory cost.
local procedure GetTaxableAmountFromItemLedgerEntry(var ItemLedgerEntry: Record "Item Ledger Entry"): Decimal
begin
case ItemLedgerEntry."Entry Type" of
Comment thread
v-rohangarg20 marked this conversation as resolved.
ItemLedgerEntry."Entry Type"::Sale:
begin
ItemLedgerEntry.CalcFields("Sales Amount (Actual)");
Comment thread
v-rohangarg20 marked this conversation as resolved.
if ItemLedgerEntry."Sales Amount (Actual)" <> 0 then
exit(Abs(ItemLedgerEntry."Sales Amount (Actual)"));
end;
ItemLedgerEntry."Entry Type"::Purchase:
begin
ItemLedgerEntry.CalcFields("Purchase Amount (Actual)");
if ItemLedgerEntry."Purchase Amount (Actual)" <> 0 then
exit(Abs(ItemLedgerEntry."Purchase Amount (Actual)"));
end;
end;

ItemLedgerEntry.CalcFields("Cost Amount (Actual)");
if ItemLedgerEntry."Cost Amount (Actual)" <> 0 then
exit(Abs(ItemLedgerEntry."Cost Amount (Actual)"));

ItemLedgerEntry.CalcFields("Cost Amount (Expected)");
exit(Abs(ItemLedgerEntry."Cost Amount (Expected)"));
end;

local procedure UpdateExciseJournalFromPurchaseInvoice(var SustExciseJournalLine: Record "Sust. Excise Jnl. Line"; DocumentNo: Code[20])
var
PurchaseInvoiceHeader: Record "Purch. Inv. Header";
Expand Down Expand Up @@ -447,6 +485,11 @@ codeunit 7412 "Excise Tax Calculation"
begin
end;

[IntegrationEvent(false, false)]
Comment thread
v-rohangarg20 marked this conversation as resolved.
local procedure OnAfterUpdateExciseJournalLineFromItemLedgerEntry(var ExciseJournalLine: Record "Sust. Excise Jnl. Line"; ItemLedgerEntry: Record "Item Ledger Entry")
begin
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeInsertExciseJournalLineForFixedAsset(var ExciseJournalLine: Record "Sust. Excise Jnl. Line"; FALedgerEntry: Record "FA Ledger Entry")
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Microsoft.ExciseTaxes;

using Microsoft.FixedAssets.FixedAsset;
using Microsoft.Inventory.Item;
using Microsoft.Inventory.Ledger;
using Microsoft.Sustainability.ExciseTax;

codeunit 7413 "Excise Tax Trans Subscriber"
Expand All @@ -20,6 +21,10 @@ codeunit 7413 "Excise Tax Trans Subscriber"

SustExciseTaxesTransactionLog."Excise Tax Type" := SustainabilityExciseJnlLine."Excise Tax Type";
SustExciseTaxesTransactionLog."Excise Duty" := SustainabilityExciseJnlLine."Excise Duty";
SustExciseTaxesTransactionLog."Excise Calculation Type" := SustainabilityExciseJnlLine."Excise Calculation Type";
SustExciseTaxesTransactionLog."Excise Duty %" := SustainabilityExciseJnlLine."Excise Duty %";
SustExciseTaxesTransactionLog."Excise Taxable Amount" := SustainabilityExciseJnlLine."Excise Taxable Amount";
SustExciseTaxesTransactionLog."Item Category Code" := SustainabilityExciseJnlLine."Item Category Code";
SustExciseTaxesTransactionLog."Tax Amount" := SustainabilityExciseJnlLine."Tax Amount";
SustExciseTaxesTransactionLog."Quantity for Excise Tax" := SustainabilityExciseJnlLine."Quantity for Excise Tax";
SustExciseTaxesTransactionLog."Excise Unit of Measure Code" := SustainabilityExciseJnlLine."Excise Unit of Measure Code";
Expand Down Expand Up @@ -79,7 +84,8 @@ codeunit 7413 "Excise Tax Trans Subscriber"
ExciseJournalLine.Validate("Excise Unit of Measure Code", ItemExciseTax."Excise Unit of Measure Code");
ExciseJournalLine.Validate("Quantity for Excise Tax", ItemExciseTax."Quantity for Excise Tax");
end;
ExciseJournalLine.Validate("Excise Duty", GetExciseDutyForSource(ExciseJournalLine."Excise Tax Type", ExciseJournalLine."Source Type", ExciseJournalLine."Source No.", ExciseJournalLine."Posting Date"));
ExciseJournalLine.Validate("Item Category Code", Item."Item Category Code");
ApplyExciseRate(ExciseJournalLine, Item."Item Category Code");
end;

[EventSubscriber(ObjectType::Table, Database::"Sust. Excise Jnl. Line", OnAfterCopyFromFixedAsset, '', false, false)]
Expand All @@ -93,17 +99,55 @@ codeunit 7413 "Excise Tax Trans Subscriber"
ExciseJournalLine.TestField("Excise Tax Type");
ExciseJournalLine.Validate("Excise Unit of Measure Code", FixedAsset."Excise Unit of Measure Code");
ExciseJournalLine.Validate("Quantity for Excise Tax", FixedAsset."Quantity for Excise Tax");
ExciseJournalLine.Validate("Excise Duty", GetExciseDutyForSource(ExciseJournalLine."Excise Tax Type", ExciseJournalLine."Source Type", ExciseJournalLine."Source No.", ExciseJournalLine."Posting Date"));
ApplyExciseRate(ExciseJournalLine, '');
end;

local procedure GetExciseDutyForSource(TaxTypeCode: Code[20]; SourceType: Enum "Sust. Excise Jnl. Source Type"; SourceNo: Code[20]; EffectiveDate: Date): Decimal
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Excise Tax Calculation", OnAfterUpdateExciseJournalLineFromItemLedgerEntry, '', false, false)]
local procedure OnAfterUpdateExciseJournalLineFromItemLedgerEntry(var ExciseJournalLine: Record "Sust. Excise Jnl. Line"; ItemLedgerEntry: Record "Item Ledger Entry")
begin
ApplyExciseRate(ExciseJournalLine, ItemLedgerEntry."Item Category Code");
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sust. Excise Jnl.-Check", OnAfterCheckSustainabilityExciseJournalLine, '', false, false)]
local procedure OnAfterCheckSustainabilityExciseJournalLine(SustainabilityExciseJnlLine: Record "Sust. Excise Jnl. Line")
var
ExciseTaxItemFARate: Record "Excise Tax Item/FA Rate";
ExciseDuty: Decimal;
ExciseTaxCalculation: Codeunit "Excise Tax Calculation";
begin
if not ExciseTaxCalculation.IsExciseTaxEntry(SustainabilityExciseJnlLine) then
exit;

case SustainabilityExciseJnlLine."Excise Calculation Type" of
Comment thread
v-rohangarg20 marked this conversation as resolved.
"Excise Calculation Type"::"Ad valorem":
TestAdValoremFields(SustainabilityExciseJnlLine);
"Excise Calculation Type"::Hybrid:
begin
SustainabilityExciseJnlLine.TestField("Excise Duty", ErrorInfo.Create());
SustainabilityExciseJnlLine.TestField("Quantity for Excise Tax", ErrorInfo.Create());
TestAdValoremFields(SustainabilityExciseJnlLine);
end;
end;
end;

local procedure TestAdValoremFields(SustainabilityExciseJnlLine: Record "Sust. Excise Jnl. Line")
begin
SustainabilityExciseJnlLine.TestField("Excise Duty %", ErrorInfo.Create());
SustainabilityExciseJnlLine.TestField("Excise Taxable Amount", ErrorInfo.Create());
end;

local procedure ApplyExciseRate(var ExciseJournalLine: Record "Sust. Excise Jnl. Line"; ItemCategoryCode: Code[20])
var
ExciseTaxRate: Record "Excise Tax Rate";
ExciseSourceType: Enum "Excise Source Type";
begin
ExciseSourceType := ExciseTaxItemFARate.ConvertSustSourceTypeToExciseSourceType(SourceType);
if ExciseTaxItemFARate.GetEffectiveExciseDuty(TaxTypeCode, ExciseSourceType, SourceNo, EffectiveDate, ExciseDuty) then
exit(ExciseDuty);
ExciseSourceType := ExciseTaxRate.ConvertSustSourceTypeToExciseSourceType(ExciseJournalLine."Source Type");
if not ExciseTaxRate.GetEffectiveExciseRate(ExciseJournalLine."Excise Tax Type", ExciseSourceType, ExciseJournalLine."Source No.", ItemCategoryCode, ExciseJournalLine."Posting Date") then
Clear(ExciseTaxRate);

ExciseJournalLine.Validate("Excise Calculation Type", ExciseTaxRate."Excise Calculation Type");
ExciseJournalLine.Validate("Excise Duty %", ExciseTaxRate."Excise Duty %");
ExciseJournalLine.Validate("Excise Duty", ExciseTaxRate."Excise Duty");

if ExciseJournalLine."Excise Calculation Type" = ExciseJournalLine."Excise Calculation Type"::"Specific per Unit" then
ExciseJournalLine.Validate("Excise Taxable Amount", 0);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,42 @@ codeunit 7414 "Excise Tax Upgrade"
var
UpgradeTag: Codeunit "Upgrade Tag";
begin
if UpgradeTag.HasUpgradeTag(GetMultipleExciseTaxesPerItemUpgradeTag()) then
exit;
if not UpgradeTag.HasUpgradeTag(GetMultipleExciseTaxesPerItemUpgradeTag()) then begin
MigrateItemExciseTaxSetup();
UpgradeTag.SetUpgradeTag(GetMultipleExciseTaxesPerItemUpgradeTag());
end;

MigrateItemExciseTaxSetup();
#if not CLEANSCHEMA33
if not UpgradeTag.HasUpgradeTag(GetExciseTaxRateTableUpgradeTag()) then begin
MigrateExciseTaxRates();
UpgradeTag.SetUpgradeTag(GetExciseTaxRateTableUpgradeTag());
end;
#endif
end;

UpgradeTag.SetUpgradeTag(GetMultipleExciseTaxesPerItemUpgradeTag());
#if not CLEANSCHEMA33
local procedure MigrateExciseTaxRates()
var
ExciseTaxItemFARate: Record "Excise Tax Item/FA Rate";
ExciseTaxRate: Record "Excise Tax Rate";
begin
#pragma warning disable AL0432
if not ExciseTaxItemFARate.FindSet() then
exit;

repeat
if not ExciseTaxRate.Get(ExciseTaxItemFARate."Excise Tax Type Code", ExciseTaxItemFARate."Source Type", ExciseTaxItemFARate."Source No.", '', ExciseTaxItemFARate."Effective From Date") then begin
Comment thread
v-rohangarg20 marked this conversation as resolved.
ExciseTaxRate.Init();
ExciseTaxRate.TransferFields(ExciseTaxItemFARate);
ExciseTaxRate."Item Category Code" := '';
ExciseTaxRate."Excise Calculation Type" := ExciseTaxRate."Excise Calculation Type"::"Specific per Unit";
ExciseTaxRate."Excise Duty %" := 0;
ExciseTaxRate.Insert();
end;
until ExciseTaxItemFARate.Next() = 0;
#pragma warning restore AL0432
end;
#endif

local procedure MigrateItemExciseTaxSetup()
var
Expand Down Expand Up @@ -65,10 +94,20 @@ codeunit 7414 "Excise Tax Upgrade"
local procedure RegisterPerCompanyUpgradeTags(var PerCompanyUpgradeTags: List of [Code[250]])
begin
PerCompanyUpgradeTags.Add(GetMultipleExciseTaxesPerItemUpgradeTag());
#if not CLEANSCHEMA33
PerCompanyUpgradeTags.Add(GetExciseTaxRateTableUpgradeTag());
#endif
end;

local procedure GetMultipleExciseTaxesPerItemUpgradeTag(): Code[250]
begin
exit('MS-626127-MultipleExciseTaxesPerItem-20260727');
end;

#if not CLEANSCHEMA33
local procedure GetExciseTaxRateTableUpgradeTag(): Code[250]
begin
exit('MS-626305-ExciseTaxRate-20260902');
end;
#endif
}
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.ExciseTaxes;

enum 7415 "Excise Calculation Type"
{
Caption = 'Excise Calculation Type';
Extensible = true;

value(0; "Specific per Unit")
{
Caption = 'Specific - per unit';
}
value(1; "Ad valorem")
{
Caption = 'Ad valorem';
}
value(2; Hybrid)
{
Caption = 'Hybrid';
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if not CLEAN30
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Expand All @@ -12,6 +13,9 @@ page 7412 "Excise Tax Item/FA Rates"
DataCaptionExpression = GetCaption();
Caption = 'Excise Duty Rates';
DelayedInsert = true;
ObsoleteState = Pending;
ObsoleteReason = 'Replaced by the Excise Tax Rates page, which shows item category and calculation type based rates.';
ObsoleteTag = '30.0';

layout
{
Expand Down Expand Up @@ -53,4 +57,5 @@ page 7412 "Excise Tax Item/FA Rates"
begin
exit(StrSubstNo(EntryPermissionsCaptionLbl, Rec.TableCaption, Rec."Excise Tax Type Code"));
end;
}
}
#endif
Loading
Loading