Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
79657ea
new doc with issue and concerns
ventselartur Mar 29, 2026
3baca49
save plans
ventselartur Mar 30, 2026
98fae1a
update plans
ventselartur Mar 30, 2026
31a7c57
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur Apr 3, 2026
b8fb566
fix: normalize ADI tax data to VAT percentage in E-Document Purchase …
ventselartur Apr 3, 2026
34b2207
feat: add [BC] VAT Prod. Posting Group field to E-Document Purchase Line
ventselartur Apr 3, 2026
47c64e8
feat: add VAT Prod. Posting Group column to E-Document draft subform
ventselartur Apr 3, 2026
dbb35b7
feat: add VAT Rate Mismatch notification type and handlers
ventselartur Apr 3, 2026
e0dd7f7
feat: resolve VAT Prod. Posting Group from extracted VAT rate during …
ventselartur Apr 3, 2026
4bfea7d
feat: apply resolved VAT Prod. Posting Group when creating purchase i…
ventselartur Apr 3, 2026
5d4b175
test: add integration tests for VAT Posting Group resolution during P…
ventselartur Apr 3, 2026
f6c8e55
style: sort using statements alphabetically in PreparePurchaseEDocDraft
ventselartur Apr 3, 2026
91447d6
docs: add design spec for VAT rate mismatch inline warning field
ventselartur Apr 3, 2026
a89ec5c
docs: update OnValidate logic to compare VAT % from setup against ext…
ventselartur Apr 3, 2026
b634ab3
docs: use exact VAT % comparison and handle zero-rate lines in OnVali…
ventselartur Apr 3, 2026
8a0a6d7
docs: add OnLookup trigger to open VAT Posting Setup filtered by vendor
ventselartur Apr 3, 2026
05edca8
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur Apr 7, 2026
ac58f63
docs: filter VAT matching to Normal VAT and Reverse Charge VAT only
ventselartur Apr 7, 2026
31784c7
docs: add 7 new test cases for VAT calculation type filtering and OnV…
ventselartur Apr 7, 2026
72373db
docs: add implementation plan for VAT rate mismatch inline warning field
ventselartur Apr 7, 2026
0c0ed31
feat: add VAT Rate Mismatch field and OnValidate/OnLookup to VAT Prod…
ventselartur Apr 7, 2026
1bb68d8
refactor: set VAT Rate Mismatch flag instead of notification in Prepa…
ventselartur Apr 7, 2026
9e9d974
feat: add inline VAT warning column to draft subform page
ventselartur Apr 7, 2026
b745f53
refactor: remove VAT Rate Mismatch notification infrastructure
ventselartur Apr 7, 2026
307a1de
test: update VAT resolution tests to assert mismatch flag instead of …
ventselartur Apr 7, 2026
b0e91be
test: add tests for VAT Calculation Type filtering in Prepare Draft
ventselartur Apr 7, 2026
da77a1c
test: add OnValidate mismatch re-evaluation tests
ventselartur Apr 7, 2026
4f497cd
add minor changes
ventselartur Apr 7, 2026
886c294
refactor: move VAT tests to dedicated E-Doc Purch. VAT Tests codeunit
ventselartur Apr 7, 2026
bb35470
remove PayablesAgentVATIssue.md
ventselartur Apr 7, 2026
074152d
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur Apr 7, 2026
eb04ce2
remove docs
ventselartur Apr 14, 2026
f3f27b9
add total line to the draft
ventselartur Apr 14, 2026
e9360b6
merge from master with manual resolve
ventselartur Apr 14, 2026
8f1d64e
resolve conflicts
ventselartur Apr 14, 2026
bc5d54d
fix EDocPurchVATTests.Codeunit.al
ventselartur Apr 14, 2026
7c5f77e
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur Apr 20, 2026
ad40024
make total line amount not editable
ventselartur Apr 21, 2026
5a34323
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur May 7, 2026
3caf30f
[E-Document] Substitute Standard Purchase Order with Omit Last Line a…
ventselartur May 8, 2026
c96a46d
feat(edoc): add LogVATRateMismatch on E-Document Purchase Line
ventselartur May 8, 2026
0604d4f
feat(edoc): log VAT mismatch from line OnValidate
ventselartur May 8, 2026
fb6df3a
feat(edoc): log VAT mismatch from ResolveVATProductPostingGroups
ventselartur May 8, 2026
1d41664
swamp company and vendor fields in EDocStandardPurchaseOrder.Report.al
ventselartur May 11, 2026
ddfcd2a
update for LogVATRateMismatch
ventselartur May 11, 2026
35cdfac
align EDocStandardPurchaseOrder.Report.al
ventselartur May 11, 2026
fc4e7aa
update
ventselartur May 11, 2026
39a9379
VAT amount diff
ventselartur May 11, 2026
20f51b0
update the page
ventselartur May 11, 2026
2e8171c
revert header to line inconsistency. part 1
ventselartur May 15, 2026
eee3358
remove remaining referenes to the header to lines inconsistency
ventselartur May 15, 2026
a826a76
merge from main
ventselartur May 18, 2026
224dba0
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur May 19, 2026
0582b39
replace direct validation of VAT Product Posting group to the one wit…
ventselartur May 19, 2026
98e9df4
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
ventselartur May 19, 2026
2cc30fd
removeing unnecessary things
ventselartur May 19, 2026
9db4a01
add resolve VAT product posting group option
ventselartur May 19, 2026
8e9474d
add new options
ventselartur May 20, 2026
73a0312
remove unnecessary changes
ventselartur May 20, 2026
36d5570
remove more changes
ventselartur May 20, 2026
13c97d3
refactoring
ventselartur May 20, 2026
63562f7
Remove personal .claude symlinks
ventselartur May 20, 2026
84dab51
add change to EDocumentUpgrade.Codeunit.al
ventselartur May 20, 2026
fc69473
code review
ventselartur May 21, 2026
6e09338
code review
ventselartur May 22, 2026
2b2feee
replace VAT diff field with a variable on the page
ventselartur May 22, 2026
b243550
merge with confilict resolution
ventselartur May 22, 2026
a7c501a
fix test codeunit id to avoid conflict
ventselartur May 22, 2026
2e01735
code review
ventselartur May 22, 2026
d37d81c
add telemetry tag
ventselartur May 22, 2026
b9392a3
update id in the app.json
ventselartur May 22, 2026
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 @@ -26,6 +26,16 @@ pageextension 6162 "E-Doc. Purch. Payables Setup" extends "Purchases & Payables
ApplicationArea = All;
ToolTip = 'Specifies how the posting date is set on purchase invoices created from e-documents. Work Date uses the current work date. Document Date uses the document date from the e-document.';
}
field("Apply VAT Diff. For Purch EDoc"; Rec."Apply VAT Diff. For Purch EDoc")
{
ApplicationArea = All;
ToolTip = 'Specifies whether VAT difference should be applied when matching incoming E-Document line with Purchase Order line';
}
field("Resolve VAT Group Purch EDoc"; Rec."Resolve VAT Group Purch EDoc")
{
ApplicationArea = All;
ToolTip = 'Specifies whether to resolve VAT Product Group for purchase lines created from e-documents based on the VAT rate and the vendor''s VAT posting setup. If disabled, the VAT Product Group will not be identified based on the purchase e-document.';
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,17 @@ tableextension 6162 "E-Doc. Purch. Payables Setup" extends "Purchases & Payables
Caption = 'E-Document Default Posting Date';
DataClassification = CustomerContent;
}
field(6103; "Apply VAT Diff. For Purch EDoc"; Boolean)
{
Caption = 'Apply VAT Diff. For Purch. E-Doc.';
DataClassification = CustomerContent;
InitValue = true;
}
field(6104; "Resolve VAT Group Purch EDoc"; Boolean)
Comment thread
ventselartur marked this conversation as resolved.
{
Caption = 'Resolve VAT Product Group for Purch. E-Doc.';
DataClassification = CustomerContent;
InitValue = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ codeunit 6117 "E-Doc. Create Purchase Invoice" implements IEDocumentFinishDraft,
EDocLineByReceipt.Close();
PurchaseHeader.Modify();
PurchCalcDiscByType.ApplyInvDiscBasedOnAmt(EDocumentPurchaseHeader."Total Discount", PurchaseHeader);
EDocPurchaseDocumentHelper.ApplyVATDifferenceToLines(PurchaseHeader, EDocumentPurchaseHeader);
exit(PurchaseHeader);
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace Microsoft.eServices.EDocument.Processing.Import;
using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Processing;
using Microsoft.eServices.EDocument.Processing.Import.Purchase;
using Microsoft.Finance.Currency;
using Microsoft.Finance.Dimension;
using Microsoft.Finance.VAT.Setup;
using Microsoft.Foundation.Attachment;
using Microsoft.Purchases.Document;
using Microsoft.Purchases.Posting;
Expand Down Expand Up @@ -40,6 +42,9 @@ codeunit 6402 "E-Doc. Purch. Doc. Helper"
PurchaseLine."Variant Code" := EDocumentPurchaseLine."[BC] Variant Code";
PurchaseLine.Type := EDocumentPurchaseLine."[BC] Purchase Line Type";
ValidateFieldWithContext(PurchaseLine, PurchaseLine.FieldNo("No."), EDocumentPurchaseLine."[BC] Purchase Type No.");
if EDocumentPurchaseLine."[BC] VAT Prod. Posting Group" <> '' then
ValidateFieldWithContext(
PurchaseLine, PurchaseLine.FieldNo("VAT Prod. Posting Group"), EDocumentPurchaseLine."[BC] VAT Prod. Posting Group");
if (PurchaseLine.Type = PurchaseLine.Type::"G/L Account") and HasTotalDiscount then
ValidateFieldWithContext(PurchaseLine, PurchaseLine.FieldNo("Allow Invoice Disc."), true);
PurchaseLine.Description := EDocumentPurchaseLine.Description;
Expand Down Expand Up @@ -154,6 +159,45 @@ codeunit 6402 "E-Doc. Purch. Doc. Helper"
EDocImpSessionTelemetry.SetBool('Totals Validation', TryValidateDocumentTotals(PurchaseHeader));
end;

procedure ApplyVATDifferenceToLines(PurchaseHeader: Record "Purchase Header"; EDocumentPurchaseHeader: Record "E-Document Purchase Header")
var
PurchaseLine: Record "Purchase Line";
Currency: Record Currency;
LineAmount: Decimal;
TotalLineAmount, VATDiffRemainder, VATDiffForLine : Decimal;
AppliedVATAmountDiff: Decimal;
begin
AppliedVATAmountDiff := EDocumentPurchaseHeader.GetAppliedVATAmountDiff();
if AppliedVATAmountDiff = 0 then
exit;

if PurchaseHeader."Currency Code" = '' then
Currency.InitRoundingPrecision()
else
Currency.Get(PurchaseHeader."Currency Code");

TotalLineAmount := ComputeTotalLineAmount(EDocumentPurchaseHeader."E-Document Entry No.", Currency."Amount Rounding Precision");
if TotalLineAmount = 0 then
exit;

PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type");
PurchaseLine.SetRange("Document No.", PurchaseHeader."No.");
PurchaseLine.SetFilter(Type, '<>%1', PurchaseLine.Type::" ");
if not PurchaseLine.FindSet() then
Comment thread
ventselartur marked this conversation as resolved.
exit;

VATDiffRemainder := 0;
repeat
LineAmount := PurchaseLine."Line Amount" - PurchaseLine."Inv. Discount Amount";
if LineAmount <> 0 then begin
VATDiffForLine := VATDiffRemainder + AppliedVATAmountDiff * LineAmount / TotalLineAmount;
PurchaseLine.Validate("VAT Difference", Round(VATDiffForLine, Currency."Amount Rounding Precision"));
VATDiffRemainder := VATDiffForLine - PurchaseLine."VAT Difference";
PurchaseLine.Modify(true);
end;
until PurchaseLine.Next() = 0;
end;

procedure RevertCreatedDocument(EDocument: Record "E-Document")
var
PurchaseHeader: Record "Purchase Header";
Expand Down Expand Up @@ -181,4 +225,27 @@ codeunit 6402 "E-Doc. Purch. Doc. Helper"
exit;
PurchaseHeader.Validate("Posting Date", EDocumentPurchaseHeader."Document Date");
end;

procedure SetNormalReverseChargeFilter(var VATPostingSetup: Record "VAT Posting Setup"; VATBusPostingGroup: Code[20])
Comment thread
ventselartur marked this conversation as resolved.
begin
VATPostingSetup.SetRange("VAT Bus. Posting Group", VATBusPostingGroup);
VATPostingSetup.SetFilter("VAT Calculation Type", '%1|%2',
VATPostingSetup."VAT Calculation Type"::"Normal VAT",
VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT");
end;

local procedure ComputeTotalLineAmount(EDocEntryNo: Integer; AmountRoundingPrecision: Decimal): Decimal
var
EDocPurchLine: Record "E-Document Purchase Line";
TotalLineAmount: Decimal;
begin
EDocPurchLine.SetRange("E-Document Entry No.", EDocEntryNo);
if EDocPurchLine.FindSet() then
repeat
TotalLineAmount += Round(
EDocPurchLine.Quantity * EDocPurchLine."Unit Price" - EDocPurchLine."Total Discount",
AmountRoundingPrecision);
until EDocPurchLine.Next() = 0;
exit(TotalLineAmount);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Processing.AI;
using Microsoft.eServices.EDocument.Processing.Import.Purchase;
using Microsoft.eServices.EDocument.Processing.Interfaces;
using Microsoft.Finance.GeneralLedger.Setup;
using Microsoft.Finance.VAT.Setup;
using Microsoft.Foundation.UOM;
using Microsoft.Purchases.Document;
using Microsoft.Purchases.Setup;
using Microsoft.Purchases.Vendor;
using System.Log;

Expand All @@ -31,11 +34,15 @@ codeunit 6406 "EDoc Prepare Purch. Draft"
Vendor: Record Vendor;
PurchaseOrder: Record "Purchase Header";
EDocVendorAssignmentHistory: Record "E-Doc. Vendor Assign. History";

EDocPurchaseHistMapping: Codeunit "E-Doc. Purchase Hist. Mapping";
EDocActivityLogSession: Codeunit "E-Doc. Activity Log Session";
IUnitOfMeasureProvider: Interface IUnitOfMeasureProvider;
IPurchaseLineProvider: Interface IPurchaseLineProvider;
IPurchaseOrderProvider: Interface IPurchaseOrderProvider;
LineAmount: Decimal;
LineVATAmount: Decimal;
TotalLineVATAmount: Decimal;
begin
IUnitOfMeasureProvider := EDocImportParameters."Processing Customizations";
IPurchaseLineProvider := EDocImportParameters."Processing Customizations";
Expand Down Expand Up @@ -72,16 +79,26 @@ codeunit 6406 "EDoc Prepare Purch. Draft"
EDocumentPurchaseLine.Modify();
until EDocumentPurchaseLine.Next() = 0;

// Resolve VAT Product Posting Groups from extracted VAT rates
ResolveVATProductPostingGroups(EDocument."Entry No", EDocumentPurchaseHeader);

CopilotLineMatching(EDocument."Entry No");
end;

Clear(EDocumentPurchaseLine);
EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocument."Entry No");
TotalLineVATAmount := 0;
if EDocumentPurchaseLine.FindSet() then
repeat
LineAmount := Round(EDocumentPurchaseLine.Quantity * EDocumentPurchaseLine."Unit Price" - EDocumentPurchaseLine."Total Discount");
Comment thread
ventselartur marked this conversation as resolved.
LineVATAmount := Round(LineAmount * EDocumentPurchaseLine."VAT Rate" / 100);
Comment thread
ventselartur marked this conversation as resolved.
TotalLineVATAmount += LineVATAmount;
EDocImpSessionTelemetry.SetLine(EDocumentPurchaseLine.SystemId);
until EDocumentPurchaseLine.Next() = 0;

ComputeAndApplyVATAmountDifference(EDocumentPurchaseHeader, TotalLineVATAmount);
EDocumentPurchaseHeader.Modify();

LogAllActivitySessionChanges(EDocActivityLogSession);

if EDocActivityLogSession.EndSession() then;
Expand Down Expand Up @@ -138,6 +155,72 @@ codeunit 6406 "EDoc Prepare Purch. Draft"
ActivityLog.Log();
end;

local procedure ResolveVATProductPostingGroups(EDocumentEntryNo: Integer; EDocumentPurchaseHeader: Record "E-Document Purchase Header")
var
PurchasesPayablesSetup: Record "Purchases & Payables Setup";
EDocumentPurchaseLine: Record "E-Document Purchase Line";
Vendor: Record Vendor;
VATRate: Decimal;
LineBase: Decimal;
LineCount: Integer;
begin
if not PurchasesPayablesSetup.Get() then
exit;
if not PurchasesPayablesSetup."Resolve VAT Group Purch EDoc" then
exit;
Vendor := EDocumentPurchaseHeader.GetBCVendor();
if Vendor."No." = '' then
exit;
if Vendor."VAT Bus. Posting Group" = '' then
exit;

EDocumentPurchaseLine.SetRange("E-Document Entry No.", EDocumentEntryNo);
LineCount := EDocumentPurchaseLine.Count();
if LineCount = 0 then
exit;

if EDocumentPurchaseLine.FindSet() then
Comment thread
ventselartur marked this conversation as resolved.
repeat
VATRate := EDocumentPurchaseLine."VAT Rate";

// Single-line fallback: compute from header Total VAT
if (VATRate = 0) and (LineCount = 1) and (EDocumentPurchaseHeader."Total VAT" > 0) then begin
LineBase := EDocumentPurchaseLine.Quantity * EDocumentPurchaseLine."Unit Price" - EDocumentPurchaseLine."Total Discount";
if LineBase = 0 then
Comment thread
ventselartur marked this conversation as resolved.
LineBase := EDocumentPurchaseHeader."Sub Total";
if LineBase > 0 then
VATRate := Round((EDocumentPurchaseHeader."Total VAT" / LineBase) * 100, 0.01);
end;

if VATRate > 0 then begin
EDocumentPurchaseLine."[BC] VAT Prod. Posting Group" :=
FindVATProductPostingGroup(Vendor."VAT Bus. Posting Group", VATRate);
EDocumentPurchaseLine.Modify();
if EDocumentPurchaseLine."[BC] VAT Prod. Posting Group" = '' then
EDocumentPurchaseLine.LogVATRateMismatch(Vendor."VAT Bus. Posting Group", VATRate)
else
EDocumentPurchaseLine.LogVATRateResolved(Vendor."VAT Bus. Posting Group", VATRate);
end;
until EDocumentPurchaseLine.Next() = 0;
end;

local procedure FindVATProductPostingGroup(VATBusPostingGroup: Code[20]; VATRate: Decimal): Code[20]
var
VATPostingSetup: Record "VAT Posting Setup";
EDocPurchDocHelper: Codeunit "E-Doc. Purch. Doc. Helper";
CustomDimensions: Dictionary of [Text, Text];
VATPostingGroupNotFoundLbl: Label 'VAT Product Posting Group not found for VAT Rate %1.', Comment = '%1 = VAT rate', Locked = true;
begin
EDocPurchDocHelper.SetNormalReverseChargeFilter(VATPostingSetup, VATBusPostingGroup);
VATPostingSetup.SetRange("VAT %", VATRate);
if VATPostingSetup.Count() = 1 then begin
Comment thread
ventselartur marked this conversation as resolved.
VATPostingSetup.FindFirst();
exit(VATPostingSetup."VAT Prod. Posting Group");
end;
Session.LogMessage('0000TXZ', StrSubstNo(VATPostingGroupNotFoundLbl, VATRate), Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, CustomDimensions);
exit('');
Comment thread
ventselartur marked this conversation as resolved.
end;

local procedure CopilotLineMatching(EDocumentEntryNo: Integer)
var
EDocumentPurchaseLine: Record "E-Document Purchase Line";
Expand Down Expand Up @@ -172,4 +255,64 @@ codeunit 6406 "EDoc Prepare Purch. Draft"
if Codeunit.Run(Codeunit::"E-Doc. Deferral Matching", EDocumentPurchaseLine) then;
end;
end;

local procedure ComputeAndApplyVATAmountDifference(EDocumentPurchaseHeader: Record "E-Document Purchase Header"; TotalLineVATAmount: Decimal)
Comment thread
ventselartur marked this conversation as resolved.
var
PurchasesPayablesSetup: Record "Purchases & Payables Setup";
GeneralLedgerSetup: Record "General Ledger Setup";
ActivityLog: Codeunit "Activity Log Builder";
VATAmountDiff: Decimal;
Reasoning: Text[250];
VATDiffAppliedLbl: Label 'Applied VAT amount difference of %1 to reconcile document Total VAT %2 with computed Total Line VAT Amount %3.', Comment = '%1 = VAT difference, %2 = Total VAT, %3 = Total Line VAT Amount';
VATDiffSkippedSetupLbl: Label 'VAT amount difference of %1 was not applied because Apply VAT Diff. For Purch. E-Doc. is disabled in Purchases & Payables Setup.', Comment = '%1 = VAT difference';
VATDiffSkippedAllowLbl: Label 'VAT amount difference of %1 was not applied because Allow VAT Difference is disabled in Purchases & Payables Setup.', Comment = '%1 = VAT difference';
VATDiffSkippedMaxLbl: Label 'VAT amount difference of %1 was not applied because it exceeds the Max. VAT Difference Allowed of %2 in General Ledger Setup.', Comment = '%1 = VAT difference, %2 = Max. VAT Difference Allowed';
begin
if (EDocumentPurchaseHeader."Total VAT" = 0) or (TotalLineVATAmount = EDocumentPurchaseHeader."Total VAT") then
exit;

VATAmountDiff := EDocumentPurchaseHeader."Total VAT" - TotalLineVATAmount;

if not PurchasesPayablesSetup.Get() then
exit;

if not PurchasesPayablesSetup."Apply VAT Diff. For Purch EDoc" then begin
Reasoning := CopyStr(StrSubstNo(VATDiffSkippedSetupLbl, VATAmountDiff), 1, MaxStrLen(Reasoning));
ActivityLog
.Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Total VAT"), EDocumentPurchaseHeader.SystemId)
.SetExplanation(Reasoning)
.SetType(Enum::"Activity Log Type"::"AL")
.Log();
exit;
end;

if not PurchasesPayablesSetup."Allow VAT Difference" then begin
Reasoning := CopyStr(StrSubstNo(VATDiffSkippedAllowLbl, VATAmountDiff), 1, MaxStrLen(Reasoning));
ActivityLog
.Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Total VAT"), EDocumentPurchaseHeader.SystemId)
.SetExplanation(Reasoning)
.SetType(Enum::"Activity Log Type"::"AL")
.Log();
exit;
end;

if not GeneralLedgerSetup.Get() then
exit;
if Abs(VATAmountDiff) > GeneralLedgerSetup."Max. VAT Difference Allowed" then begin
Reasoning := CopyStr(StrSubstNo(VATDiffSkippedMaxLbl, VATAmountDiff, GeneralLedgerSetup."Max. VAT Difference Allowed"), 1, MaxStrLen(Reasoning));
ActivityLog
.Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Total VAT"), EDocumentPurchaseHeader.SystemId)
.SetExplanation(Reasoning)
.SetType(Enum::"Activity Log Type"::"AL")
.Log();
exit;
end;

Reasoning := CopyStr(StrSubstNo(VATDiffAppliedLbl, VATAmountDiff, EDocumentPurchaseHeader."Total VAT", TotalLineVATAmount), 1, MaxStrLen(Reasoning));
Comment thread
ventselartur marked this conversation as resolved.
ActivityLog
.Init(Database::"E-Document Purchase Header", EDocumentPurchaseHeader.FieldNo("Total VAT"), EDocumentPurchaseHeader.SystemId)
.SetExplanation(Reasoning)
.SetType(Enum::"Activity Log Type"::"AL")
.Log();
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Microsoft.Finance.Dimension;
using Microsoft.Inventory.Item.Catalog;
using Microsoft.Purchases.Document;
using Microsoft.Purchases.History;
using Microsoft.Purchases.Setup;

page 6183 "E-Doc. Purchase Draft Subform"
{
Expand Down Expand Up @@ -71,6 +72,12 @@ page 6183 "E-Doc. Purchase Draft Subform"
Lookup = true;
ShowMandatory = true;
}
field("VAT Prod. Posting Group"; Rec."[BC] VAT Prod. Posting Group")
Comment thread
ventselartur marked this conversation as resolved.
{
ApplicationArea = All;
Lookup = true;
Visible = VATProdPostGroupIsVisible;
}
field("Item Reference No."; Rec."[BC] Item Reference No.")
{
ApplicationArea = All;
Expand Down Expand Up @@ -333,7 +340,7 @@ page 6183 "E-Doc. Purchase Draft Subform"
EDocPOMatching: Codeunit "E-Doc. PO Matching";
AdditionalColumns, OrderMatchedCaption, MatchWarningsCaption, MatchWarningsStyleExpr : Text;
LineAmount: Decimal;
DimVisible1, DimVisible2, HasAdditionalColumns, IsEDocumentMatchedToAnyPOLine, IsLineMatchedToOrderLine, IsLineMatchedToReceiptLine, HasEDocumentOrderMatchWarnings : Boolean;
DimVisible1, DimVisible2, HasAdditionalColumns, IsEDocumentMatchedToAnyPOLine, IsLineMatchedToOrderLine, IsLineMatchedToReceiptLine, HasEDocumentOrderMatchWarnings, VATProdPostGroupIsVisible : Boolean;
HistoryCantBeRetrievedErr: Label 'The purchase invoice that matched historically with this line can''t be opened.';

trigger OnOpenPage()
Expand All @@ -350,6 +357,7 @@ page 6183 "E-Doc. Purchase Draft Subform"
trigger OnAfterGetCurrRecord()
begin
UpdatePOMatching();
SetVATProductPostingGroupVisibility();
Comment thread
ventselartur marked this conversation as resolved.
end;

trigger OnAfterGetRecord()
Expand All @@ -362,6 +370,7 @@ page 6183 "E-Doc. Purchase Draft Subform"
IsLineMatchedToReceiptLine := EDocPOMatching.IsEDocumentLineMatchedToAnyReceiptLine(EDocumentPurchaseLine);
OrderMatchedCaption := IsLineMatchedToOrderLine ? GetSummaryOfMatchedOrders() : '';
UpdateMatchWarnings();
SetVATProductPostingGroupVisibility();
Comment thread
ventselartur marked this conversation as resolved.
end;

internal procedure SetEDocumentPurchaseHeader(EDocPurchHeader: Record "E-Document Purchase Header")
Expand All @@ -381,6 +390,14 @@ page 6183 "E-Doc. Purchase Draft Subform"
DimVisible1, DimVisible2, DimOther, DimOther, DimOther, DimOther, DimOther, DimOther);
end;

local procedure SetVATProductPostingGroupVisibility()
var
PurchSetup: Record "Purchases & Payables Setup";
begin
PurchSetup.Get();
Comment thread
ventselartur marked this conversation as resolved.
VATProdPostGroupIsVisible := PurchSetup."Resolve VAT Group Purch EDoc";
end;

local procedure UpdateCalculatedAmounts(UpdateParentRecord: Boolean)
var
TotalEDocPurchaseLine: Record "E-Document Purchase Line";
Expand Down Expand Up @@ -564,5 +581,4 @@ page 6183 "E-Doc. Purchase Draft Subform"
if WarningDetails.Length() > 0 then
Message(WarningDetails.ToText());
end;

}
Loading
Loading