From 10be50a53091ce99f380385dd98dd6a09173a713 Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Wed, 11 Dec 2024 15:14:07 +0100 Subject: [PATCH 01/15] Add attachment pages in EDocument and EDocuments pages --- Apps/W1/EDocument/app/src/Document/EDocument.Page.al | 10 ++++++++++ Apps/W1/EDocument/app/src/Document/EDocuments.Page.al | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al index d975f9088..abd73486e 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al @@ -6,6 +6,7 @@ namespace Microsoft.eServices.EDocument; using System.Telemetry; using System.Utilities; +using Microsoft.Foundation.Attachment; using Microsoft.eServices.EDocument.Integration.Send; using Microsoft.eServices.EDocument.Integration.Receive; using Microsoft.Bank.Reconciliation; @@ -185,6 +186,15 @@ page 6121 "E-Document" } #endif } + area(FactBoxes) + { + part(DocumentAttachment; "Doc. Attachment List Factbox") + { + Caption = 'Documents'; + UpdatePropagation = Both; + SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); + } + } } actions { diff --git a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al index f54f4880a..30eb44f5e 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al @@ -3,6 +3,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ namespace Microsoft.eServices.EDocument; +using Microsoft.Foundation.Attachment; page 6122 "E-Documents" { @@ -55,6 +56,15 @@ page 6122 "E-Documents" } } } + area(FactBoxes) + { + part(DocumentListFactBox; "Doc. Attachment List Factbox") + { + Caption = 'Documents'; + UpdatePropagation = Both; + SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); + } + } } actions { From 3e81f6a4a07661656640280db87833876e3fc627 Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Wed, 11 Dec 2024 15:16:15 +0100 Subject: [PATCH 02/15] add EDocument app workspace --- .../EDocument/edocument_workspace.code-workspace | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Apps/W1/EDocument/edocument_workspace.code-workspace diff --git a/Apps/W1/EDocument/edocument_workspace.code-workspace b/Apps/W1/EDocument/edocument_workspace.code-workspace new file mode 100644 index 000000000..f10f2a03c --- /dev/null +++ b/Apps/W1/EDocument/edocument_workspace.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "name": "app", + "path": "app" + }, + { + "name": "test", + "path": "test" + }, + { + "name": "demo data", + "path": "demo data" + } + ] +} \ No newline at end of file From f4c11e284549a39e0b356ae69c618198edd0bdc0 Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Thu, 12 Dec 2024 11:10:12 +0100 Subject: [PATCH 03/15] add code analyzers settings to code workspace --- Apps/W1/EDocument/edocument_workspace.code-workspace | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Apps/W1/EDocument/edocument_workspace.code-workspace b/Apps/W1/EDocument/edocument_workspace.code-workspace index f10f2a03c..35fb4f1ea 100644 --- a/Apps/W1/EDocument/edocument_workspace.code-workspace +++ b/Apps/W1/EDocument/edocument_workspace.code-workspace @@ -1,4 +1,12 @@ { + "settings": { + "al.enableCodeAnalysis": true, + "al.codeAnalyzers": [ + "${CodeCop}", + "${UICop}", + "${AppSourceCop}" + ] + }, "folders": [ { "name": "app", From 638f123c22655934a706940742162fd1da6fa52c Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Fri, 27 Dec 2024 12:05:11 +0100 Subject: [PATCH 04/15] add missing factboxes --- .../app/src/Document/EDocument.Page.al | 18 +++++++++++++++--- .../app/src/Document/EDocuments.Page.al | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al index abd73486e..cd4eae920 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al @@ -186,13 +186,25 @@ page 6121 "E-Document" } #endif } - area(FactBoxes) + area(factboxes) { - part(DocumentAttachment; "Doc. Attachment List Factbox") +#if not CLEAN25 + part("Attached Documents"; "Document Attachment Factbox") + { + ObsoleteTag = '25.0'; + ObsoleteState = Pending; + ObsoleteReason = 'The "Document Attachment FactBox" has been replaced by "Doc. Attachment List Factbox", which supports multiple files upload.'; + ApplicationArea = All; + Caption = 'Attachments'; + SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); + } +#endif + part("Attached Documents List"; "Doc. Attachment List Factbox") { Caption = 'Documents'; UpdatePropagation = Both; - SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); + SubPageLink = "E-Document Entry No." = field("Entry No"), + "E-Document Attachment" = const(true); } } } diff --git a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al index 30eb44f5e..f90aa7550 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al @@ -56,13 +56,26 @@ page 6122 "E-Documents" } } } - area(FactBoxes) + area(factboxes) { +#if not CLEAN25 + part("Attached Documents"; "Document Attachment Factbox") + { + ObsoleteTag = '25.0'; + ObsoleteState = Pending; + ObsoleteReason = 'The "Document Attachment FactBox" has been replaced by "Doc. Attachment List Factbox", which supports multiple files upload.'; + ApplicationArea = All; + Caption = 'Attachments'; + SubPageLink = "E-Document Entry No." = field("Entry No"), + "E-Document Attachment" = const(true); + } +#endif part(DocumentListFactBox; "Doc. Attachment List Factbox") { Caption = 'Documents'; UpdatePropagation = Both; - SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); + SubPageLink = "E-Document Entry No." = field("Entry No"), + "E-Document Attachment" = const(true); } } } From 15803c44de243a85dc133f9ffdf657098dd58d39 Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Fri, 27 Dec 2024 17:17:20 +0100 Subject: [PATCH 05/15] add tests --- .../src/Receive/EDocReceiveTest.Codeunit.al | 179 +++++++++++++++++- 1 file changed, 177 insertions(+), 2 deletions(-) diff --git a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al index 98a2793f6..5d5ba10d7 100644 --- a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al @@ -107,6 +107,7 @@ codeunit 139628 "E-Doc. Receive Test" end; [Test] + [HandlerFunctions('ConfirmHandler')] procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment() var EDocService: Record "E-Document Service"; @@ -185,10 +186,10 @@ codeunit 139628 "E-Doc. Receive Test" EDocumentPage.OpenView(); EDocumentPage.Last(); - Assert.AreEqual(Format(Enum::"E-Document Service Status"::"Imported Document Created"), EDocumentPage.EdocoumentServiceStatus.Status.Value(), 'Wrong service status for processed document'); + // Assert.AreEqual(Format(Enum::"E-Document Service Status"::"Imported Document Created"), EDocumentPage.EdocoumentServiceStatus.Status.Value(), 'Wrong service status for processed document'); // [THEN] E-Document Errors and Warnings has correct status - Assert.AreEqual('', EDocumentPage.ErrorMessagesPart."Message Type".Value(), 'Wrong error message type.'); + // Assert.AreEqual('', EDocumentPage.ErrorMessagesPart."Message Type".Value(), 'Wrong error message type.'); Assert.AreEqual('', EDocumentPage.ErrorMessagesPart.Description.Value(), 'Wrong message in error.'); // Get the purchase invoice from page @@ -1342,6 +1343,46 @@ codeunit 139628 "E-Doc. Receive Test" PurchaseHeader.Delete(true); end; + [Test] + [HandlerFunctions('SelectPOHandlerCancel,ConfirmHandler')] + procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment_WithoutLinkedOrder() + var + EDocService: Record "E-Document Service"; + EDocument: Record "E-Document"; + Item: Record Item; + DocumentAttachment: Record "Document Attachment"; + VATPostingSetup: Record "VAT Posting Setup"; + DocumentVendor: Record Vendor; + EDocumentPage: TestPage "E-Document"; + begin + // [FEATURE] [E-Document] [Receive] + // [SCENARIO] Receive single e-document with two attachments without linking to purchase order + Initialize(); + BindSubscription(EDocImplState); + + // [GIVEN] e-Document service to receive one single purchase order + CreateEDocServiceToReceivePurchaseOrder(EDocService); + // [GIVEN] Vendor with VAT Posting Setup + CreateVendorWithVatPostingSetup(DocumentVendor, VATPostingSetup); + // [GIVEN] Item with item reference + CreateItemWithReference(Item, VATPostingSetup); + // [GIVEN] Incoming PEPPOL file + CreateIncomingPEPPOL(DocumentVendor); + // [GIVEN] Purchase order created for vendor + CreatePurchaseOrder(Item, DocumentVendor); + + // [WHEN] Running Receive + InvokeReceive(EDocService); + + // [THEN] Purchase invoice is created with corresponfing values + EDocument.FindLast(); + + // [THEN] Attachments are moved to Purchase Header + DocumentAttachment.SetRange("E-Document Entry No.", EDocument."Entry No"); + DocumentAttachment.SetRange("E-Document Attachment", true); + Assert.RecordCount(DocumentAttachment, 2); + end; + [ModalPageHandler] procedure SelectPOHandler(var POList: TestPage "Purchase Order List") var @@ -1437,6 +1478,95 @@ codeunit 139628 "E-Doc. Receive Test" Assert.AreEqual(PurchHeader."Amount Including VAT", Abs(GenJnlLine.Amount), ''); end; + local procedure CreateVendorWithVatPostingSetup(var DocumentVendor: Record Vendor; var VATPostingSetup: Record "VAT Posting Setup") + begin + LibraryPurchase.CreateVendorWithVATRegNo(DocumentVendor); + LibraryERM.CreateVATPostingSetupWithAccounts(VATPostingSetup, Enum::"Tax Calculation Type"::"Normal VAT", 1); + DocumentVendor."VAT Bus. Posting Group" := VATPostingSetup."VAT Bus. Posting Group"; + DocumentVendor."VAT Registration No." := 'GB123456789'; + DocumentVendor."Receive E-Document To" := Enum::"E-Document Type"::"Purchase Order"; + DocumentVendor.Modify(false); + end; + + local procedure CreateItemWithReference(var Item: Record Item; var VATPostingSetup: Record "VAT Posting Setup") + var + ItemReference: Record "Item Reference"; + begin + Item.FindFirst(); + Item."VAT Prod. Posting Group" := VATPostingSetup."VAT Prod. Posting Group"; + Item.Modify(false); + ItemReference.DeleteAll(false); + ItemReference."Item No." := Item."No."; + ItemReference."Reference No." := '1000'; + ItemReference.Insert(false); + end; + + local procedure CreateIncomingPEPPOL(var DocumentVendor: Record Vendor) + var + TempXMLBuffer: Record "XML Buffer" temporary; + TempBlob: Codeunit "Temp Blob"; + Document: Text; + XMLInstream: InStream; + begin + TempXMLBuffer.LoadFromText(EDocReceiveFiles.GetDocument1()); + TempXMLBuffer.Reset(); + TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element); + TempXMLBuffer.SetRange(Path, '/Invoice/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID'); + TempXMLBuffer.FindFirst(); + TempXMLBuffer.Value := DocumentVendor."VAT Registration No."; + TempXMLBuffer.Modify(); + + TempXMLBuffer.Reset(); + TempXMLBuffer.FindFirst(); + TempXMLBuffer.Save(TempBlob); + + TempBlob.CreateInStream(XMLInstream, TextEncoding::UTF8); + XMLInstream.Read(Document); + + LibraryVariableStorage.Clear(); + LibraryVariableStorage.Enqueue(Document); + LibraryVariableStorage.Enqueue(1); + EDocImplState.SetVariableStorage(LibraryVariableStorage); + end; + + local procedure CreatePurchaseOrder(var Item: Record Item; var DocumentVendor: Record Vendor) + begin + LibraryPurchase.CreatePurchHeader(PurchaseHeader, PurchaseHeader."Document Type"::Order, DocumentVendor."No."); + LibraryPurchase.CreatePurchaseLine(PurchaseLine, PurchaseHeader, PurchaseLine.Type::Item, Item."No.", 10); + PurchaseLine.Validate("Direct Unit Cost", 100); + PurchaseLine.Modify(true); + end; + + local procedure InvokeReceive(var EDocService: Record "E-Document Service") + var + EDocServicePage: TestPage "E-Document Service"; + begin + EDocServicePage.OpenView(); + EDocServicePage.Filter.SetFilter(Code, EDocService.Code); + EDocServicePage.Receive.Invoke(); + end; + + local procedure CreateEDocServiceToReceivePurchaseOrder(var EDocService: Record "E-Document Service") + begin + LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"Service Integration"::"Mock"); + SetDefaultEDocServiceValues(EDocService); + end; + + local procedure SetDefaultEDocServiceValues(var EDocService: Record "E-Document Service") + begin + EDocService."Document Format" := "E-Document Format"::"PEPPOL BIS 3.0"; + EDocService."Lookup Account Mapping" := false; + EDocService."Lookup Item GTIN" := false; + EDocService."Lookup Item Reference" := false; + EDocService."Resolve Unit Of Measure" := false; + EDocService."Validate Line Discount" := false; + EDocService."Verify Totals" := false; + EDocService."Use Batch Processing" := false; + EDocService."Validate Receiving Company" := false; + EDocService.Modify(false); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"E-Document Create Purch. Doc.", 'OnBeforeProcessHeaderFieldsAssignment', '', false, false)] local procedure OnBeforeProcessHeaderFieldsAssignment(var DocumentHeader: RecordRef; var PurchaseField: Record Field); begin @@ -2762,6 +2892,51 @@ codeunit 139628 "E-Doc. Receive Test" PurchaseHeader.Delete(true); end; + [Test] + [HandlerFunctions('SelectPOHandlerCancel,ConfirmHandler')] + procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment_WithoutLinkedOrder26() + var + EDocService: Record "E-Document Service"; + EDocument: Record "E-Document"; + Item: Record Item; + DocumentAttachment: Record "Document Attachment"; + VATPostingSetup: Record "VAT Posting Setup"; + DocumentVendor: Record Vendor; + EDocumentPage: TestPage "E-Document"; + begin + // [FEATURE] [E-Document] [Receive] + // [SCENARIO] Receive single e-document with two attachments without linking to purchase order + Initialize(); + BindSubscription(EDocImplState); + + // [GIVEN] e-Document service to receive one single purchase order + CreateEDocServiceToReceivePurchaseOrder26(EDocService); + // [GIVEN] Vendor with VAT Posting Setup + CreateVendorWithVatPostingSetup(DocumentVendor, VATPostingSetup); + // [GIVEN] Item with item reference + CreateItemWithReference(Item, VATPostingSetup); + // [GIVEN] Incoming PEPPOL file + CreateIncomingPEPPOL(DocumentVendor); + // [GIVEN] Purchase order created for vendor + CreatePurchaseOrder(Item, DocumentVendor); + + // [WHEN] Running Receive + InvokeReceive(EDocService); + + // [THEN] Purchase invoice is created with corresponfing values + EDocument.FindLast(); + + // [THEN] Attachments are moved to Purchase Header + DocumentAttachment.SetRange("E-Document Entry No.", EDocument."Entry No"); + DocumentAttachment.SetRange("E-Document Attachment", true); + Assert.RecordCount(DocumentAttachment, 2); + end; + + local procedure CreateEDocServiceToReceivePurchaseOrder26(var EDocService: Record "E-Document Service") + begin + LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"E-Document Integration"::Mock); + SetDefaultEDocServiceValues(EDocService); + end; #endif #pragma warning restore AS0018 From 7053de94770bdd68e2f52322483c6d183fafc30e Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Mon, 30 Dec 2024 10:22:25 +0100 Subject: [PATCH 06/15] restore code --- Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al | 3 --- 1 file changed, 3 deletions(-) diff --git a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al index 5d5ba10d7..37893f1a1 100644 --- a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al @@ -107,7 +107,6 @@ codeunit 139628 "E-Doc. Receive Test" end; [Test] - [HandlerFunctions('ConfirmHandler')] procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment() var EDocService: Record "E-Document Service"; @@ -186,10 +185,8 @@ codeunit 139628 "E-Doc. Receive Test" EDocumentPage.OpenView(); EDocumentPage.Last(); - // Assert.AreEqual(Format(Enum::"E-Document Service Status"::"Imported Document Created"), EDocumentPage.EdocoumentServiceStatus.Status.Value(), 'Wrong service status for processed document'); // [THEN] E-Document Errors and Warnings has correct status - // Assert.AreEqual('', EDocumentPage.ErrorMessagesPart."Message Type".Value(), 'Wrong error message type.'); Assert.AreEqual('', EDocumentPage.ErrorMessagesPart.Description.Value(), 'Wrong message in error.'); // Get the purchase invoice from page From 4ecbc5631fe4fa4c4a95a4af84cfede2ab2c7c37 Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Tue, 31 Dec 2024 15:02:31 +0200 Subject: [PATCH 07/15] Subscribed to OnAfterGetRefTable to see attachments in E-Documents pages --- .../EDocAttachmentProcessor.Codeunit.al | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al b/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al index b1e6db847..a595457ce 100644 --- a/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al @@ -126,6 +126,21 @@ codeunit 6169 "E-Doc. Attachment Processor" end; end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Document Attachment Mgmt", OnAfterGetRefTable, '', false, false)] + local procedure OnAfterGetRefTableForEDocs(var RecRef: RecordRef; DocumentAttachment: Record "Document Attachment") + var + EDocument: Record "E-Document"; + begin + case DocumentAttachment."Table ID" of + Database::"E-Document": + begin + RecRef.Open(Database::"E-Document"); + if EDocument.Get(DocumentAttachment."No.") then + RecRef.GetTable(EDocument); + end; + end; + end; + var MissingEDocumentTypeErr: Label 'E-Document type %1 is not supported for attachments', Comment = '%1 - E-Document document type'; From 86809fc9b76e707397f423527f73eb04bd841e4d Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Tue, 31 Dec 2024 15:24:56 +0200 Subject: [PATCH 08/15] Removed ApplicationArea --- Apps/W1/EDocument/app/src/Document/EDocument.Page.al | 1 - Apps/W1/EDocument/app/src/Document/EDocuments.Page.al | 1 - 2 files changed, 2 deletions(-) diff --git a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al index cd4eae920..7518cf719 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al @@ -194,7 +194,6 @@ page 6121 "E-Document" ObsoleteTag = '25.0'; ObsoleteState = Pending; ObsoleteReason = 'The "Document Attachment FactBox" has been replaced by "Doc. Attachment List Factbox", which supports multiple files upload.'; - ApplicationArea = All; Caption = 'Attachments'; SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); } diff --git a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al index f90aa7550..6e4d74bf5 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al @@ -64,7 +64,6 @@ page 6122 "E-Documents" ObsoleteTag = '25.0'; ObsoleteState = Pending; ObsoleteReason = 'The "Document Attachment FactBox" has been replaced by "Doc. Attachment List Factbox", which supports multiple files upload.'; - ApplicationArea = All; Caption = 'Attachments'; SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); From 48424a9b777c94e79d8e7bb746fdd34a3b34283b Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Thu, 2 Jan 2025 14:51:12 +0200 Subject: [PATCH 09/15] Restore changes --- Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al index 37893f1a1..d13637651 100644 --- a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al @@ -185,8 +185,10 @@ codeunit 139628 "E-Doc. Receive Test" EDocumentPage.OpenView(); EDocumentPage.Last(); + Assert.AreEqual(Format(Enum::"E-Document Service Status"::"Imported Document Created"), EDocumentPage.EdocoumentServiceStatus.Status.Value(), 'Wrong service status for processed document'); // [THEN] E-Document Errors and Warnings has correct status + Assert.AreEqual('', EDocumentPage.ErrorMessagesPart."Message Type".Value(), 'Wrong error message type.'); Assert.AreEqual('', EDocumentPage.ErrorMessagesPart.Description.Value(), 'Wrong message in error.'); // Get the purchase invoice from page From 3664f300da306e03a9038b20a02685e7a300ac41 Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Fri, 3 Jan 2025 09:22:06 +0200 Subject: [PATCH 10/15] Removed test --- .../src/Receive/EDocReceiveTest.Codeunit.al | 48 +------------------ 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al index d13637651..d99226d2a 100644 --- a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al @@ -1342,46 +1342,6 @@ codeunit 139628 "E-Doc. Receive Test" PurchaseHeader.Delete(true); end; - [Test] - [HandlerFunctions('SelectPOHandlerCancel,ConfirmHandler')] - procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment_WithoutLinkedOrder() - var - EDocService: Record "E-Document Service"; - EDocument: Record "E-Document"; - Item: Record Item; - DocumentAttachment: Record "Document Attachment"; - VATPostingSetup: Record "VAT Posting Setup"; - DocumentVendor: Record Vendor; - EDocumentPage: TestPage "E-Document"; - begin - // [FEATURE] [E-Document] [Receive] - // [SCENARIO] Receive single e-document with two attachments without linking to purchase order - Initialize(); - BindSubscription(EDocImplState); - - // [GIVEN] e-Document service to receive one single purchase order - CreateEDocServiceToReceivePurchaseOrder(EDocService); - // [GIVEN] Vendor with VAT Posting Setup - CreateVendorWithVatPostingSetup(DocumentVendor, VATPostingSetup); - // [GIVEN] Item with item reference - CreateItemWithReference(Item, VATPostingSetup); - // [GIVEN] Incoming PEPPOL file - CreateIncomingPEPPOL(DocumentVendor); - // [GIVEN] Purchase order created for vendor - CreatePurchaseOrder(Item, DocumentVendor); - - // [WHEN] Running Receive - InvokeReceive(EDocService); - - // [THEN] Purchase invoice is created with corresponfing values - EDocument.FindLast(); - - // [THEN] Attachments are moved to Purchase Header - DocumentAttachment.SetRange("E-Document Entry No.", EDocument."Entry No"); - DocumentAttachment.SetRange("E-Document Attachment", true); - Assert.RecordCount(DocumentAttachment, 2); - end; - [ModalPageHandler] procedure SelectPOHandler(var POList: TestPage "Purchase Order List") var @@ -1545,12 +1505,6 @@ codeunit 139628 "E-Doc. Receive Test" EDocServicePage.Receive.Invoke(); end; - local procedure CreateEDocServiceToReceivePurchaseOrder(var EDocService: Record "E-Document Service") - begin - LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"Service Integration"::"Mock"); - SetDefaultEDocServiceValues(EDocService); - end; - local procedure SetDefaultEDocServiceValues(var EDocService: Record "E-Document Service") begin EDocService."Document Format" := "E-Document Format"::"PEPPOL BIS 3.0"; @@ -2933,7 +2887,7 @@ codeunit 139628 "E-Doc. Receive Test" local procedure CreateEDocServiceToReceivePurchaseOrder26(var EDocService: Record "E-Document Service") begin - LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"E-Document Integration"::Mock); + LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"Service Integration"::Mock); SetDefaultEDocServiceValues(EDocService); end; From 15d206cfbf04ceeb62a3fe8e8e12b0fa36e4d20e Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Fri, 3 Jan 2025 12:31:47 +0200 Subject: [PATCH 11/15] Removed Document Attachment Factbox --- Apps/W1/EDocument/app/src/Document/EDocument.Page.al | 10 ---------- Apps/W1/EDocument/app/src/Document/EDocuments.Page.al | 11 ----------- 2 files changed, 21 deletions(-) diff --git a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al index 7518cf719..8ce4f57ff 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al @@ -188,16 +188,6 @@ page 6121 "E-Document" } area(factboxes) { -#if not CLEAN25 - part("Attached Documents"; "Document Attachment Factbox") - { - ObsoleteTag = '25.0'; - ObsoleteState = Pending; - ObsoleteReason = 'The "Document Attachment FactBox" has been replaced by "Doc. Attachment List Factbox", which supports multiple files upload.'; - Caption = 'Attachments'; - SubPageLink = "E-Document Entry No." = field("Entry No"), "E-Document Attachment" = const(true); - } -#endif part("Attached Documents List"; "Doc. Attachment List Factbox") { Caption = 'Documents'; diff --git a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al index 6e4d74bf5..c512fcdd3 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocuments.Page.al @@ -58,17 +58,6 @@ page 6122 "E-Documents" } area(factboxes) { -#if not CLEAN25 - part("Attached Documents"; "Document Attachment Factbox") - { - ObsoleteTag = '25.0'; - ObsoleteState = Pending; - ObsoleteReason = 'The "Document Attachment FactBox" has been replaced by "Doc. Attachment List Factbox", which supports multiple files upload.'; - Caption = 'Attachments'; - SubPageLink = "E-Document Entry No." = field("Entry No"), - "E-Document Attachment" = const(true); - } -#endif part(DocumentListFactBox; "Doc. Attachment List Factbox") { Caption = 'Documents'; From 3a92dc320cb2674e01cbc7e513814c511b29f3a3 Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Fri, 3 Jan 2025 14:00:42 +0200 Subject: [PATCH 12/15] Test fixes --- .../src/Receive/EDocReceiveTest.Codeunit.al | 93 +++++++++---------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al index d99226d2a..0fad2d128 100644 --- a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al @@ -1342,6 +1342,45 @@ codeunit 139628 "E-Doc. Receive Test" PurchaseHeader.Delete(true); end; + [Test] + [HandlerFunctions('SelectPOHandlerCancel,ConfirmHandler')] + procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment_WithoutLinkedOrder() + var + EDocService: Record "E-Document Service"; + EDocument: Record "E-Document"; + Item: Record Item; + DocumentAttachment: Record "Document Attachment"; + VATPostingSetup: Record "VAT Posting Setup"; + DocumentVendor: Record Vendor; + begin + // [FEATURE] [E-Document] [Receive] + // [SCENARIO] Receive single e-document with two attachments without linking to purchase order + Initialize(); + BindSubscription(EDocImplState); + + // [GIVEN] e-Document service to receive one single purchase order + CreateEDocServiceToReceivePurchaseOrder(EDocService); + // [GIVEN] Vendor with VAT Posting Setup + CreateVendorWithVatPostingSetup(DocumentVendor, VATPostingSetup); + // [GIVEN] Item with item reference + CreateItemWithReference(Item, VATPostingSetup); + // [GIVEN] Incoming PEPPOL file + CreateIncomingPEPPOL(DocumentVendor); + // [GIVEN] Purchase order created for vendor + CreatePurchaseOrder(Item, DocumentVendor); + + // [WHEN] Running Receive + InvokeReceive(EDocService); + + // [THEN] Attachments are imported and linked with e-Document + EDocument.FindLast(); + DocumentAttachment.SetRange("No.", Format(EDocument."Entry No")); + DocumentAttachment.SetRange("Table ID", Database::"E-Document"); + DocumentAttachment.SetRange("E-Document Entry No.", EDocument."Entry No"); + DocumentAttachment.SetRange("E-Document Attachment", true); + Assert.RecordCount(DocumentAttachment, 2); + end; + [ModalPageHandler] procedure SelectPOHandler(var POList: TestPage "Purchase Order List") var @@ -1437,12 +1476,17 @@ codeunit 139628 "E-Doc. Receive Test" Assert.AreEqual(PurchHeader."Amount Including VAT", Abs(GenJnlLine.Amount), ''); end; + local procedure CreateEDocServiceToReceivePurchaseOrder(var EDocService: Record "E-Document Service") + begin + LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"Service Integration"::Mock); + SetDefaultEDocServiceValues(EDocService); + end; + local procedure CreateVendorWithVatPostingSetup(var DocumentVendor: Record Vendor; var VATPostingSetup: Record "VAT Posting Setup") begin LibraryPurchase.CreateVendorWithVATRegNo(DocumentVendor); LibraryERM.CreateVATPostingSetupWithAccounts(VATPostingSetup, Enum::"Tax Calculation Type"::"Normal VAT", 1); DocumentVendor."VAT Bus. Posting Group" := VATPostingSetup."VAT Bus. Posting Group"; - DocumentVendor."VAT Registration No." := 'GB123456789'; DocumentVendor."Receive E-Document To" := Enum::"E-Document Type"::"Purchase Order"; DocumentVendor.Modify(false); end; @@ -1519,7 +1563,6 @@ codeunit 139628 "E-Doc. Receive Test" EDocService.Modify(false); end; - [EventSubscriber(ObjectType::Codeunit, Codeunit::"E-Document Create Purch. Doc.", 'OnBeforeProcessHeaderFieldsAssignment', '', false, false)] local procedure OnBeforeProcessHeaderFieldsAssignment(var DocumentHeader: RecordRef; var PurchaseField: Record Field); begin @@ -2845,52 +2888,6 @@ codeunit 139628 "E-Doc. Receive Test" PurchaseHeader.Delete(true); end; - [Test] - [HandlerFunctions('SelectPOHandlerCancel,ConfirmHandler')] - procedure ReceiveSinglePurchaseInvoice_PEPPOL_WithAttachment_WithoutLinkedOrder26() - var - EDocService: Record "E-Document Service"; - EDocument: Record "E-Document"; - Item: Record Item; - DocumentAttachment: Record "Document Attachment"; - VATPostingSetup: Record "VAT Posting Setup"; - DocumentVendor: Record Vendor; - EDocumentPage: TestPage "E-Document"; - begin - // [FEATURE] [E-Document] [Receive] - // [SCENARIO] Receive single e-document with two attachments without linking to purchase order - Initialize(); - BindSubscription(EDocImplState); - - // [GIVEN] e-Document service to receive one single purchase order - CreateEDocServiceToReceivePurchaseOrder26(EDocService); - // [GIVEN] Vendor with VAT Posting Setup - CreateVendorWithVatPostingSetup(DocumentVendor, VATPostingSetup); - // [GIVEN] Item with item reference - CreateItemWithReference(Item, VATPostingSetup); - // [GIVEN] Incoming PEPPOL file - CreateIncomingPEPPOL(DocumentVendor); - // [GIVEN] Purchase order created for vendor - CreatePurchaseOrder(Item, DocumentVendor); - - // [WHEN] Running Receive - InvokeReceive(EDocService); - - // [THEN] Purchase invoice is created with corresponfing values - EDocument.FindLast(); - - // [THEN] Attachments are moved to Purchase Header - DocumentAttachment.SetRange("E-Document Entry No.", EDocument."Entry No"); - DocumentAttachment.SetRange("E-Document Attachment", true); - Assert.RecordCount(DocumentAttachment, 2); - end; - - local procedure CreateEDocServiceToReceivePurchaseOrder26(var EDocService: Record "E-Document Service") - begin - LibraryEDoc.CreateTestReceiveServiceForEDoc(EDocService, Enum::"Service Integration"::Mock); - SetDefaultEDocServiceValues(EDocService); - end; - #endif #pragma warning restore AS0018 From 4c49da40e9d5dd462f5d684e0b4303fa41c0acb6 Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Fri, 3 Jan 2025 14:19:54 +0200 Subject: [PATCH 13/15] Reverted empty line deletion --- Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al | 1 + 1 file changed, 1 insertion(+) diff --git a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al index 0fad2d128..f1678b62b 100644 --- a/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al +++ b/Apps/W1/EDocument/test/src/Receive/EDocReceiveTest.Codeunit.al @@ -2888,6 +2888,7 @@ codeunit 139628 "E-Doc. Receive Test" PurchaseHeader.Delete(true); end; + #endif #pragma warning restore AS0018 From 9db9c15f93e8250303465962a6fc48e5de0b9ab6 Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Fri, 3 Jan 2025 14:55:30 +0200 Subject: [PATCH 14/15] Removed workspace --- .../edocument_workspace.code-workspace | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 Apps/W1/EDocument/edocument_workspace.code-workspace diff --git a/Apps/W1/EDocument/edocument_workspace.code-workspace b/Apps/W1/EDocument/edocument_workspace.code-workspace deleted file mode 100644 index 35fb4f1ea..000000000 --- a/Apps/W1/EDocument/edocument_workspace.code-workspace +++ /dev/null @@ -1,24 +0,0 @@ -{ - "settings": { - "al.enableCodeAnalysis": true, - "al.codeAnalyzers": [ - "${CodeCop}", - "${UICop}", - "${AppSourceCop}" - ] - }, - "folders": [ - { - "name": "app", - "path": "app" - }, - { - "name": "test", - "path": "test" - }, - { - "name": "demo data", - "path": "demo data" - } - ] -} \ No newline at end of file From 8a4f232a879431994b2ffe7453b1883821e27704 Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Wed, 8 Jan 2025 12:35:25 +0100 Subject: [PATCH 15/15] fix issue with opening details for attachments from E-Document level --- .../EDocAttachmentProcessor.Codeunit.al | 15 +++++++++++++++ .../EDocDocumentAttachmentDetails.PageExt.al | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Apps/W1/EDocument/app/src/Processing/EDocDocumentAttachmentDetails.PageExt.al diff --git a/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al b/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al index a595457ce..64364397a 100644 --- a/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Processing/EDocAttachmentProcessor.Codeunit.al @@ -141,6 +141,21 @@ codeunit 6169 "E-Doc. Attachment Processor" end; end; + [EventSubscriber(ObjectType::Page, Page::"Doc. Attachment List FactBox", OnBeforeDocumentAttachmentDetailsRunModal, '', false, false)] + local procedure FilterEDocumentAttachmentsOnBeforeDocumentAttachmentDetailsRunModal(var DocumentAttachment: Record "Document Attachment"; var DocumentAttachmentDetails: Page "Document Attachment Details") + var + EDocumentEntryNo: Integer; + EDocumentEntryNoText: Text; + begin + DocumentAttachment.FilterGroup(4); + EDocumentEntryNoText := DocumentAttachment.GetFilter("E-Document Entry No."); + if EDocumentEntryNoText <> '' then begin + Evaluate(EDocumentEntryNo, EDocumentEntryNoText); + DocumentAttachmentDetails.FilterForEDocuments(EDocumentEntryNo); + end; + DocumentAttachment.FilterGroup(0); + end; + var MissingEDocumentTypeErr: Label 'E-Document type %1 is not supported for attachments', Comment = '%1 - E-Document document type'; diff --git a/Apps/W1/EDocument/app/src/Processing/EDocDocumentAttachmentDetails.PageExt.al b/Apps/W1/EDocument/app/src/Processing/EDocDocumentAttachmentDetails.PageExt.al new file mode 100644 index 000000000..dd1c95de8 --- /dev/null +++ b/Apps/W1/EDocument/app/src/Processing/EDocDocumentAttachmentDetails.PageExt.al @@ -0,0 +1,11 @@ +namespace Microsoft.eServices.EDocument; +using Microsoft.Foundation.Attachment; + +pageextension 6102 EDocDocumentAttachmentDetails extends "Document Attachment Details" +{ + internal procedure FilterForEDocuments(EDocumentEntryNo: Integer) + begin + Rec.SetRange("E-Document Attachment", true); + Rec.SetRange("E-Document Entry No.", EDocumentEntryNo); + end; +}