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 @@ -15,5 +15,6 @@ permissionset 7452 "ExciseTaxes - Edit"
Permissions =
tabledata "Excise Tax Type" = IMD,
tabledata "Excise Tax Item/FA 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 @@ -13,10 +13,14 @@ permissionset 7450 "ExciseTaxes - Objects"
Permissions =
table "Excise Tax Type" = X,
table "Excise Tax Item/FA Rate" = X,
table "Item Excise Tax" = X,
table "Excise Tax Entry Permission" = X,
page "Excise Tax Types" = X,
page "Excise Tax Type Card" = X,
page "Excise Tax Item/FA Rates" = X,
page "Item Excise Taxes" = X,
page "Item Excise Tax API" = X,
page "Excise Tax Entry Permissions" = X,
report "Create Excise Tax Jnl. Entries" = X;
report "Create Excise Tax Jnl. Entries" = X,
codeunit "Excise Tax Upgrade" = X;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ permissionset 7451 "ExciseTaxes - Read"
Permissions =
tabledata "Excise Tax Type" = R,
tabledata "Excise Tax Item/FA Rate" = R,
tabledata "Item Excise Tax" = R,
tabledata "Excise Tax Entry Permission" = R;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace Microsoft.ExciseTaxes;
using Microsoft.FixedAssets.FixedAsset;
using Microsoft.FixedAssets.Ledger;
using Microsoft.Foundation.NoSeries;
using Microsoft.Inventory.Item;
using Microsoft.Inventory.Ledger;
using Microsoft.Purchases.History;
using Microsoft.Sustainability.ExciseTax;
Expand All @@ -27,8 +26,11 @@ codeunit 7412 "Excise Tax Calculation"
if ExciseTaxesTransactionLog."Item Ledger Entry No." = 0 then
exit;

ItemLedgerEntry.SetLoadFields("Excise Tax Posted");
ItemLedgerEntry.SetLoadFields("Excise Tax Posted", "Item No.", "Entry Type");
ItemLedgerEntry.Get(ExciseTaxesTransactionLog."Item Ledger Entry No.");
if not AllExciseTaxesPostedForItemLedgerEntry(ItemLedgerEntry, ExciseTaxesTransactionLog."Excise Tax Type") then
exit;

ItemLedgerEntry."Excise Tax Posted" := true;
ItemLedgerEntry.Modify();
end;
Expand Down Expand Up @@ -58,17 +60,16 @@ codeunit 7412 "Excise Tax Calculation"

internal procedure CreateExciseJournalLineForItem(TaxTypeCode: Code[20]; StartingDate: Date; EndingDate: Date; ItemFilter: Text[250]; PostingDate: Date)
var
Item: Record Item;
Comment thread
v-rohangarg20 marked this conversation as resolved.
ItemExciseTax: Record "Item Excise Tax";
begin
Item.SetLoadFields("Excise Tax Type");
Item.SetRange("Excise Tax Type", TaxTypeCode);
ItemExciseTax.SetRange("Excise Tax Type Code", TaxTypeCode);
if ItemFilter <> '' then
Item.SetFilter("No.", ItemFilter);
ItemExciseTax.SetFilter("Item No.", ItemFilter);

if Item.FindSet() then
if ItemExciseTax.FindSet() then
repeat
ProcessEntryTypesForSource(Item."No.", "Sust. Excise Jnl. Source Type"::Item, Item."Excise Tax Type", StartingDate, EndingDate, PostingDate);
until Item.Next() = 0;
ProcessEntryTypesForSource(ItemExciseTax."Item No.", "Sust. Excise Jnl. Source Type"::Item, TaxTypeCode, StartingDate, EndingDate, PostingDate);
until ItemExciseTax.Next() = 0;
end;

internal procedure CreateExciseJournalLineForFixedAsset(TaxTypeCode: Code[20]; StartingDate: Date; EndingDate: Date; FixedAssetFilter: Text[250]; PostingDate: Date)
Expand Down Expand Up @@ -149,10 +150,12 @@ codeunit 7412 "Excise Tax Calculation"
SetFilterOnILEEntryType(EntryType, ItemLedgerEntry);
if ItemLedgerEntry.FindSet() then
repeat
if not ExciseJournalLineExist(ItemLedgerEntry) then begin
if not ExciseJournalLineExist(ItemLedgerEntry, TaxType) and not ExciseTaxPostedInTransLog(ItemLedgerEntry, TaxType) then begin
Comment thread
v-rohangarg20 marked this conversation as resolved.
InitializeExciseJournalLine(ExciseJnlLine, ExciseJournalBatch, PostingDate, LineNo);
UpdateExciseJournalLineFromItemLedgerEntry(ExciseJnlLine, ItemLedgerEntry, TaxType, EntryType);
OnBeforeInsertExciseJournalLineForItem(ExciseJnlLine, ItemLedgerEntry);
ExciseJnlLine.Insert(true);
OnAfterInsertExciseJournalLineForItem(ExciseJnlLine, ItemLedgerEntry);
LineNo += 10000;
end;
until ItemLedgerEntry.Next() = 0;
Expand All @@ -178,7 +181,9 @@ codeunit 7412 "Excise Tax Calculation"
if not ExciseJournalLineExist(FALedgerEntry) then begin
InitializeExciseJournalLine(ExciseJnlLine, ExciseJournalBatch, PostingDate, LineNo);
UpdateExciseJournalLineFromFALedgerEntry(ExciseJnlLine, FALedgerEntry, TaxType, EntryType);
OnBeforeInsertExciseJournalLineForFixedAsset(ExciseJnlLine, FALedgerEntry);
ExciseJnlLine.Insert(true);
OnAfterInsertExciseJournalLineForFixedAsset(ExciseJnlLine, FALedgerEntry);
LineNo += 10000;
end;
until FALedgerEntry.Next() = 0;
Expand Down Expand Up @@ -340,12 +345,13 @@ codeunit 7412 "Excise Tax Calculation"
SustExciseJournalLine.Validate("Country/Region Code", PurchaseCrMemoHeader."Buy-from Country/Region Code");
end;

local procedure ExciseJournalLineExist(ItemLedgerEntry: Record "Item Ledger Entry"): Boolean
local procedure ExciseJournalLineExist(ItemLedgerEntry: Record "Item Ledger Entry"; TaxType: Code[20]): Boolean
var
ExciseJournalLine: Record "Sust. Excise Jnl. Line";
begin
ExciseJournalLine.SetLoadFields("Item Ledger Entry No.");
ExciseJournalLine.SetRange("Item Ledger Entry No.", ItemLedgerEntry."Entry No.");
ExciseJournalLine.SetRange("Excise Tax Type", TaxType);
if not ExciseJournalLine.IsEmpty() then
exit(true);
end;
Expand All @@ -359,4 +365,95 @@ codeunit 7412 "Excise Tax Calculation"
if not ExciseJournalLine.IsEmpty() then
exit(true);
end;

local procedure ExciseTaxPostedInTransLog(ItemLedgerEntry: Record "Item Ledger Entry"; TaxType: Code[20]): Boolean
var
ExciseTaxesTransactionLog: Record "Sust. Excise Taxes Trans. Log";
begin
ExciseTaxesTransactionLog.SetRange("Item Ledger Entry No.", ItemLedgerEntry."Entry No.");
ExciseTaxesTransactionLog.SetRange("Excise Tax Type", TaxType);
exit(not ExciseTaxesTransactionLog.IsEmpty());
end;

local procedure ExciseTaxTypeEnabled(TaxTypeCode: Code[20]): Boolean
var
ExciseTaxType: Record "Excise Tax Type";
begin
ExciseTaxType.SetLoadFields(Enabled);
if ExciseTaxType.Get(TaxTypeCode) then
exit(ExciseTaxType.Enabled);
end;

local procedure AllExciseTaxesPostedForItemLedgerEntry(ItemLedgerEntry: Record "Item Ledger Entry"; CurrentTaxType: Code[20]): Boolean
var
ItemExciseTax: Record "Item Excise Tax";
ExciseTaxEntryPermission: Record "Excise Tax Entry Permission";
ExciseEntryType: Enum "Excise Entry Type";
HasApplicableTaxType: Boolean;
begin
if not GetExciseEntryTypeFromItemLedgerEntry(ItemLedgerEntry, ExciseEntryType) then
exit(false);

ItemExciseTax.SetLoadFields("Excise Tax Type Code");
ItemExciseTax.SetRange("Item No.", ItemLedgerEntry."Item No.");
if ItemExciseTax.FindSet() then
Comment thread
v-rohangarg20 marked this conversation as resolved.
repeat
// Only enabled tax types allowed for this entry's type ever produce a line for it, so the
// flag can be set once all of those are posted; disabled or not-allowed types must not block it.
if ExciseTaxTypeEnabled(ItemExciseTax."Excise Tax Type Code") and
ExciseTaxEntryPermission.IsEntryTypeAllowed(ItemExciseTax."Excise Tax Type Code", ExciseEntryType)
then begin
HasApplicableTaxType := true;
// Treat the tax type currently being posted as posted: it triggered this check and its
// transaction log entry may not be committed yet, so skip the redundant lookup for it.
if (ItemExciseTax."Excise Tax Type Code" <> CurrentTaxType) and
not ExciseTaxPostedInTransLog(ItemLedgerEntry, ItemExciseTax."Excise Tax Type Code")
then
exit(false);
end;
until ItemExciseTax.Next() = 0;

exit(HasApplicableTaxType);
end;

local procedure GetExciseEntryTypeFromItemLedgerEntry(ItemLedgerEntry: Record "Item Ledger Entry"; var ExciseEntryType: Enum "Excise Entry Type"): Boolean
begin
case ItemLedgerEntry."Entry Type" of
ItemLedgerEntry."Entry Type"::Purchase:
ExciseEntryType := ExciseEntryType::Purchase;
ItemLedgerEntry."Entry Type"::Sale:
ExciseEntryType := ExciseEntryType::Sale;
ItemLedgerEntry."Entry Type"::"Positive Adjmt.":
ExciseEntryType := ExciseEntryType::"Positive Adjmt.";
ItemLedgerEntry."Entry Type"::"Negative Adjmt.":
ExciseEntryType := ExciseEntryType::"Negative Adjmt.";
ItemLedgerEntry."Entry Type"::Output:
ExciseEntryType := ExciseEntryType::Output;
ItemLedgerEntry."Entry Type"::"Assembly Output":
ExciseEntryType := ExciseEntryType::"Assembly Output";
else
exit(false);
end;
exit(true);
end;

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

[IntegrationEvent(false, false)]
local procedure OnAfterInsertExciseJournalLineForItem(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
end;

[IntegrationEvent(false, false)]
local procedure OnAfterInsertExciseJournalLineForFixedAsset(var ExciseJournalLine: Record "Sust. Excise Jnl. Line"; FALedgerEntry: Record "FA Ledger Entry")
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@ codeunit 7413 "Excise Tax Trans Subscriber"
SustExciseTaxesTransactionLog."Excise Unit of Measure Code" := SustainabilityExciseJnlLine."Excise Unit of Measure Code";
SustExciseTaxesTransactionLog."Excise Entry Type" := SustainabilityExciseJnlLine."Excise Entry Type";
SustExciseTaxesTransactionLog."FA Ledger Entry No." := SustainabilityExciseJnlLine."FA Ledger Entry No.";
ExciseTaxCalculation.UpdateItemLedgerEntryExciseTaxInfo(SustExciseTaxesTransactionLog);
ExciseTaxCalculation.UpdateFALedgerEntryExciseTaxInfo(SustExciseTaxesTransactionLog);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sustainability Excise Post Mgt", OnAfterInsertExciseTaxesTransactionLog, '', false, false)]
local procedure OnAfterInsertExciseTaxesTransactionLog(var SustExciseTaxesTransactionLog: Record "Sust. Excise Taxes Trans. Log"; SustainabilityExciseJnlLine: Record "Sust. Excise Jnl. Line")
var
ExciseTaxCalculation: Codeunit "Excise Tax Calculation";
begin
if not ExciseTaxCalculation.IsExciseTaxEntry(SustainabilityExciseJnlLine) then
exit;

ExciseTaxCalculation.UpdateItemLedgerEntryExciseTaxInfo(SustExciseTaxesTransactionLog);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sust. Excise Jnl.-Check", OnBeforeTestEmissionAmount, '', false, false)]
local procedure OnBeforeTestEmissionAmount(SustainabilityExciseJnlLine: Record "Sust. Excise Jnl. Line"; var IsHandled: Boolean)
var
Expand Down Expand Up @@ -59,13 +69,16 @@ codeunit 7413 "Excise Tax Trans Subscriber"
[EventSubscriber(ObjectType::Table, Database::"Sust. Excise Jnl. Line", OnAfterCopyFromItem, '', false, false)]
local procedure OnAfterCopyFromItem(var ExciseJournalLine: Record "Sust. Excise Jnl. Line"; Item: Record Item)
var
ItemExciseTax: Record "Item Excise Tax";
ExciseTaxCalculation: Codeunit "Excise Tax Calculation";
begin
if not ExciseTaxCalculation.IsExciseTaxEntry(ExciseJournalLine) then
exit;

ExciseJournalLine.Validate("Excise Unit of Measure Code", Item."Excise Unit of Measure Code");
ExciseJournalLine.Validate("Quantity for Excise Tax", Item."Quantity for Excise Tax");
if ItemExciseTax.Get(Item."No.", ExciseJournalLine."Excise Tax Type") then begin
Comment thread
v-rohangarg20 marked this conversation as resolved.
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"));
end;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.ExciseTaxes;

using Microsoft.Inventory.Item;
using System.Upgrade;

codeunit 7414 "Excise Tax Upgrade"
{
Subtype = Upgrade;
InherentEntitlements = X;
InherentPermissions = X;

trigger OnUpgradePerCompany()
var
UpgradeTag: Codeunit "Upgrade Tag";
begin
if UpgradeTag.HasUpgradeTag(GetMultipleExciseTaxesPerItemUpgradeTag()) then
exit;

MigrateItemExciseTaxSetup();

UpgradeTag.SetUpgradeTag(GetMultipleExciseTaxesPerItemUpgradeTag());
end;

local procedure MigrateItemExciseTaxSetup()
var
Item: Record Item;
ItemExciseTax: Record "Item Excise Tax";
begin
#pragma warning disable AL0432
Comment thread
v-rohangarg20 marked this conversation as resolved.
Item.SetLoadFields("Excise Tax Type", "Quantity for Excise Tax", "Excise Unit of Measure Code");
Item.SetFilter("Excise Tax Type", '<>%1', '');
if Item.FindSet() then
repeat
if not ItemExciseTax.Get(Item."No.", Item."Excise Tax Type") then
CreateItemExciseTaxFromItem(Item);
until Item.Next() = 0;
#pragma warning restore AL0432
end;

local procedure CreateItemExciseTaxFromItem(Item: Record Item)
var
ItemExciseTax: Record "Item Excise Tax";
ExciseTaxType: Record "Excise Tax Type";
begin
#pragma warning disable AL0432
ItemExciseTax.Init();
ItemExciseTax."Item No." := Item."No.";
ItemExciseTax."Excise Tax Type Code" := Item."Excise Tax Type";

ExciseTaxType.SetLoadFields(Description);
if ExciseTaxType.Get(Item."Excise Tax Type") then
ItemExciseTax."Excise Tax Type Description" := ExciseTaxType.Description;

ItemExciseTax."Quantity for Excise Tax" := Item."Quantity for Excise Tax";
ItemExciseTax."Excise Unit of Measure Code" := Item."Excise Unit of Measure Code";
ItemExciseTax.Insert();
#pragma warning restore AL0432
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", OnGetPerCompanyUpgradeTags, '', false, false)]
Comment thread
v-rohangarg20 marked this conversation as resolved.
local procedure RegisterPerCompanyUpgradeTags(var PerCompanyUpgradeTags: List of [Code[250]])
begin
PerCompanyUpgradeTags.Add(GetMultipleExciseTaxesPerItemUpgradeTag());
end;

local procedure GetMultipleExciseTaxesPerItemUpgradeTag(): Code[250]
begin
exit('MS-626127-MultipleExciseTaxesPerItem-20260727');
end;
}
56 changes: 56 additions & 0 deletions src/Apps/W1/ExciseTaxes/app/src/page/ItemExciseTaxAPI.Page.al
Original file line number Diff line number Diff line change
@@ -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.ExciseTaxes;

page 7417 "Item Excise Tax API"
{
PageType = API;
Caption = 'Item Excise Tax';
APIPublisher = 'microsoft';
APIGroup = 'exciseTaxes';
APIVersion = 'v1.0';
EntityName = 'itemExciseTax';
EntitySetName = 'itemExciseTaxes';
SourceTable = "Item Excise Tax";
ODataKeyFields = SystemId;
DelayedInsert = true;
DeleteAllowed = false;

layout
{
area(Content)
{
repeater(Group)
{
field(id; Rec.SystemId)
{
Caption = 'Id';
Editable = false;
}
field(itemNo; Rec."Item No.")
{
Caption = 'Item No.';
}
field(exciseTaxType; Rec."Excise Tax Type Code")
{
Caption = 'Excise Tax Type';
}
field(quantityExciseTax; Rec."Quantity for Excise Tax")
{
Caption = 'Quantity Excise Tax';
}
field(exciseTaxUom; Rec."Excise Unit of Measure Code")
{
Caption = 'Excise Tax UOM';
}
field(lastModifiedDateTime; Rec.SystemModifiedAt)
{
Caption = 'Last Modified Date Time';
Editable = false;
}
}
}
}
}
Loading
Loading