diff --git a/src/Apps/W1/EDocument/App/.resources/Prompts/EDocHistoricalMatching-SystemPrompt.md b/src/Apps/W1/EDocument/App/.resources/Prompts/EDocHistoricalMatching-SystemPrompt.md index 8f718079a8..42c4a17366 100644 --- a/src/Apps/W1/EDocument/App/.resources/Prompts/EDocHistoricalMatching-SystemPrompt.md +++ b/src/Apps/W1/EDocument/App/.resources/Prompts/EDocHistoricalMatching-SystemPrompt.md @@ -29,24 +29,14 @@ Any output you generate, such as reasoning text, MUST be in the following output - Lower confidence for cross-category matches even if descriptions contain similar terms -### Reasoning: +### Reasoning: **Reasoning Text Instruction Template (Human-Readable Historical Match)** - -When generating reasoning text, write as if explaining to the user why the system recognized this as the same item or account based on historical purchases. -Keep it short (under 250 characters), human, and natural. +When generating reasoning text, write as if explaining to the user why the system recognized this as the item or account based on historical purchases. **General Template** - -> “Matched to [item/account name] because [main reason: same/similar description, code, or pattern], purchased from [vendor name] on [date or time reference, e.g. ‘2 weeks ago’].” - +> "Matches a previous purchase of [item/account name] from [vendor] recorded on [date or time reference]. [main reason: same/similar description, code, or pattern] indicates same type of purchase." If vendor is not present, omit it naturally: - -> “Matched to [item/account name] because [main reason], last purchased [time reference].” - -If account match (not item): - -> “Matched to account [account name] used for [main reason/context] from [vendor name] [time reference].” - +> "Matches a previous purchase of [item/account name] recorded on [date or time reference]. [main reason: same/similar description, code, or pattern] indicates same type of purchase." Return a match **only when** appropriate by calling "match_lines_historical" function. \ No newline at end of file diff --git a/src/Apps/W1/EDocument/App/src/Processing/Import/FinishDraft/EDocCreatePurchaseInvoice.Codeunit.al b/src/Apps/W1/EDocument/App/src/Processing/Import/FinishDraft/EDocCreatePurchaseInvoice.Codeunit.al index cef186eb24..04cbfd6696 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/Import/FinishDraft/EDocCreatePurchaseInvoice.Codeunit.al +++ b/src/Apps/W1/EDocument/App/src/Processing/Import/FinishDraft/EDocCreatePurchaseInvoice.Codeunit.al @@ -120,6 +120,7 @@ codeunit 6117 "E-Doc. Create Purchase Invoice" implements IEDocumentFinishDraft, PurchaseHeader.SetRange("Buy-from Vendor No.", EDocumentPurchaseHeader."[BC] Vendor No."); // Setting the filter, so that the insert trigger assigns the right vendor to the purchase header PurchaseHeader."Document Type" := "Purchase Document Type"::Invoice; PurchaseHeader."Pay-to Vendor No." := EDocumentPurchaseHeader."[BC] Vendor No."; + PurchaseHeader."Posting Description" := EDocumentPurchaseHeader."Posting Description"; VendorInvoiceNo := CopyStr(EDocumentPurchaseHeader."Sales Invoice No.", 1, MaxStrLen(PurchaseHeader."Vendor Invoice No.")); VendorLedgerEntry.SetLoadFields("Entry No."); diff --git a/src/Apps/W1/EDocument/App/src/Processing/Import/PrepareDraft/EDocProviders.Codeunit.al b/src/Apps/W1/EDocument/App/src/Processing/Import/PrepareDraft/EDocProviders.Codeunit.al index b8f9032377..a1a719a812 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/Import/PrepareDraft/EDocProviders.Codeunit.al +++ b/src/Apps/W1/EDocument/App/src/Processing/Import/PrepareDraft/EDocProviders.Codeunit.al @@ -113,7 +113,7 @@ codeunit 6124 "E-Doc. Providers" implements IPurchaseLineProvider, IUnitOfMeasur EDocumentPurchaseLine.Validate("[BC] Item Reference No.", ItemReference."Reference No."); EDocImpSessionTelemetry.SetLineBool(EDocumentPurchaseLine.SystemId, 'Item Reference ', true); - SetActivityLog(EDocumentPurchaseLine.SystemId, EDocumentPurchaseLine.FieldNo("[BC] Item Reference No."), StrSubstNo(ItemReferenceReasonMsg, VendorNo), ItemReference, Page::"Item References", StrSubstNo(ItemReferenceSourceMsg, ItemReference."Reference No."), ActivityLog); + SetActivityLog(EDocumentPurchaseLine.SystemId, EDocumentPurchaseLine.FieldNo("[BC] Purchase Type No."), StrSubstNo(ItemReferenceReasonMsg, VendorNo), ItemReference, Page::"Item References", StrSubstNo(ItemReferenceSourceMsg, ItemReference."Reference No."), ActivityLog); EDocActivityLogSession.Set(EDocActivityLogSession.ItemRefTok(), ActivityLog); exit; end; diff --git a/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocPurchaseDraftSubform.Page.al b/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocPurchaseDraftSubform.Page.al index 3b770f226a..bd8d9f7504 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocPurchaseDraftSubform.Page.al +++ b/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocPurchaseDraftSubform.Page.al @@ -7,6 +7,7 @@ namespace Microsoft.eServices.EDocument.Processing.Import.Purchase; using Microsoft.eServices.EDocument; using Microsoft.eServices.EDocument.Processing.Import; using Microsoft.Finance.Dimension; +using Microsoft.Inventory.Item.Catalog; using Microsoft.Purchases.Document; using Microsoft.Purchases.History; @@ -69,6 +70,7 @@ page 6183 "E-Doc. Purchase Draft Subform" { ApplicationArea = All; Lookup = true; + Visible = false; } field("Unit Of Measure"; Rec."[BC] Unit of Measure") { @@ -294,6 +296,25 @@ page 6183 "E-Doc. Purchase Draft Subform" Rec.LookupDimensions(); end; } + action(LookupItemReferences) + { + ApplicationArea = All; + Caption = 'Item References'; + ToolTip = 'View item references for the vendor associated with this e-document.'; + Image = Change; + + trigger OnAction() + var + ItemReference: Record "Item Reference"; + ItemReferencePage: Page "Item Reference Entries"; + begin + EDocumentPurchaseHeader.TestField("[BC] Vendor No."); + ItemReference.SetRange("Reference Type", ItemReference."Reference Type"::Vendor); + ItemReference.SetRange("Reference Type No.", EDocumentPurchaseHeader."[BC] Vendor No."); + ItemReferencePage.SetTableView(ItemReference); + ItemReferencePage.Run(); + end; + } } } } diff --git a/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseDraft.Page.al b/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseDraft.Page.al index 60832a5017..2c8a594cb2 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseDraft.Page.al +++ b/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseDraft.Page.al @@ -36,7 +36,7 @@ page 6181 "E-Document Purchase Draft" field(Record; RecordLinkTxt) { - Caption = 'Finalized Document'; + Caption = 'Purchase Document'; Editable = false; Importance = Promoted; ToolTip = 'Specifies the record, document, journal line, or ledger entry, that is linked to the electronic document.'; @@ -120,6 +120,19 @@ page 6181 "E-Document Purchase Draft" CurrPage.Update(); end; } + field("Posting Description"; EDocumentPurchaseHeader."Posting Description") + { + Importance = Promoted; + Caption = 'Posting Description'; + ToolTip = 'Specifies the extracted posting description for the document.'; + Editable = true; + + trigger OnValidate() + begin + EDocumentPurchaseHeader.Modify(); + CurrPage.Update(); + end; + } field("Document Date"; EDocumentPurchaseHeader."Document Date") { Caption = 'Document Date'; @@ -418,6 +431,7 @@ page 6181 "E-Document Purchase Draft" Caption = 'Process'; actionref(Promoted_CreateDocument; CreateDocument) { + Visible = false; } actionref(Promoted_AnalyseDocument; AnalyzeDocument) { diff --git a/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseHeader.Table.al b/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseHeader.Table.al index 9b3c15e4c4..4735a1a3d6 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseHeader.Table.al +++ b/src/Apps/W1/EDocument/App/src/Processing/Import/Purchase/EDocumentPurchaseHeader.Table.al @@ -219,6 +219,11 @@ table 6100 "E-Document Purchase Header" Caption = 'Vendor Contact Name'; DataClassification = CustomerContent; } + field(38; "Posting Description"; Text[100]) + { + Caption = 'Posting Description'; + DataClassification = CustomerContent; + } #endregion Purchase fields #region Business Central Data - Validated fields [101-200]