From 3e81f6a4a07661656640280db87833876e3fc627 Mon Sep 17 00:00:00 2001 From: Piotr Michalak Date: Wed, 11 Dec 2024 15:16:15 +0100 Subject: [PATCH 1/4] 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 0000000000..f10f2a03cc --- /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 2/4] 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 f10f2a03cc..35fb4f1ea3 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 aca48dfa4d7a7c581fee6d2bac9def62c53f5c69 Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Wed, 22 Jan 2025 17:52:39 +0200 Subject: [PATCH 3/4] E-Invoice Preview FastTab structure --- .../app/src/Document/EDocument.Page.al | 10 +++- .../src/InvoicePreview/EInvoiceLine.Table.al | 53 +++++++++++++++++++ .../src/InvoicePreview/EInvoiceLines.Page.al | 43 +++++++++++++++ .../app/src/Processing/EDocImport.Codeunit.al | 37 +++++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLine.Table.al create mode 100644 Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLines.Page.al diff --git a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al index d975f90883..a2af7dfa97 100644 --- a/Apps/W1/EDocument/app/src/Document/EDocument.Page.al +++ b/Apps/W1/EDocument/app/src/Document/EDocument.Page.al @@ -152,6 +152,13 @@ page 6121 "E-Document" ToolTip = 'Specifies the receiving company address.'; } } + part(EInvoicePreview; "E-Invoice Lines") + { + Caption = 'E-Invoice Lines'; + SubPageLink = "E-Document Entry No." = field("Entry No"); + ShowFilter = false; + Visible = IsIncomingDoc and ShowPreview; + } part(EdocoumentServiceStatus; "E-Document Service Status") { Caption = 'Service Status'; @@ -493,6 +500,7 @@ page 6121 "E-Document" begin IsProcessed := Rec.Status = Rec.Status::Processed; IsIncomingDoc := Rec.Direction = Rec.Direction::Incoming; + ShowPreview := (Rec."Document Type" = Rec."Document Type"::"Purchase Invoice") or (Rec."Document Type" = Rec."Document Type"::"Purchase Credit Memo"); RecordLinkTxt := EDocumentHelper.GetRecordLinkText(Rec); HasErrorsOrWarnings := (EDocumentErrorHelper.ErrorMessageCount(Rec) + EDocumentErrorHelper.WarningMessageCount(Rec)) > 0; @@ -597,7 +605,7 @@ page 6121 "E-Document" EDocumentHelper: Codeunit "E-Document Processing"; ErrorsAndWarningsNotification: Notification; RecordLinkTxt, StyleStatusTxt : Text; - ShowRelink, ShowMapToOrder, HasErrorsOrWarnings, HasErrors, IsIncomingDoc, IsProcessed, CopilotVisible : Boolean; + ShowRelink, ShowMapToOrder, HasErrorsOrWarnings, HasErrors, IsIncomingDoc, IsProcessed, CopilotVisible, ShowPreview : Boolean; EDocHasErrorOrWarningMsg: Label 'Errors or warnings found for E-Document. Please review below in "Error Messages" section.'; DocNotCreatedMsg: Label 'Failed to create new %1 from E-Document. Please review errors below.', Comment = '%1 - E-Document Document Type'; diff --git a/Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLine.Table.al b/Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLine.Table.al new file mode 100644 index 0000000000..23ec53c754 --- /dev/null +++ b/Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLine.Table.al @@ -0,0 +1,53 @@ +table 6100 "E-Invoice Line" +{ + DataClassification = CustomerContent; + + fields + { + field(1; "E-Document Entry No."; Integer) + { + TableRelation = "E-Document"; + Caption = 'E-Document Entry No'; + } + field(2; "Line No."; Integer) + { + Caption = 'Line No.'; + } + field(3; "No."; Code[20]) + { + Caption = 'No.'; + } + field(4; Description; Text[100]) + { + Caption = 'Description'; + } + field(5; "Unit of Measure Code"; Text[50]) + { + Caption = 'Unit of Measure Code'; + } + field(6; Quantity; Decimal) + { + Caption = 'Quantity'; + DecimalPlaces = 0 : 5; + } + field(7; "Direct Unit Cost"; Decimal) + { + Caption = 'Direct Unit Cost'; + } + field(8; "Line Discount %"; Decimal) + { + Caption = 'Line Discount %'; + DecimalPlaces = 0 : 5; + MaxValue = 100; + MinValue = 0; + } + } + + keys + { + key(Key1; "E-Document Entry No.", "Line No.") + { + Clustered = true; + } + } +} \ No newline at end of file diff --git a/Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLines.Page.al b/Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLines.Page.al new file mode 100644 index 0000000000..8735718a6e --- /dev/null +++ b/Apps/W1/EDocument/app/src/InvoicePreview/EInvoiceLines.Page.al @@ -0,0 +1,43 @@ +page 6100 "E-Invoice Lines" +{ + PageType = ListPart; + ApplicationArea = Basic, Suite; + Editable = false; + InsertAllowed = false; + DeleteAllowed = false; + SourceTable = "E-Invoice Line"; + + layout + { + area(Content) + { + repeater(EInvoiceLines) + { + field("No."; Rec."No.") + { + ToolTip = 'Specifies what is being purchased.'; + } + field(Description; Rec.Description) + { + ToolTip = 'Describes what is being purchased.'; + } + field("Unit of Measure Code"; Rec."Unit of Measure Code") + { + ToolTip = 'Specifies how each unit of the item or resource is measured, such as in pieces or hours.'; + } + field(Quantity; Rec.Quantity) + { + ToolTip = 'Specifies the quantity of what you''re buying. The number is based on the unit chosen in the Unit of Measure Code field.'; + } + field("Direct Unit Cost"; Rec."Direct Unit Cost") + { + ToolTip = 'Specifies the price of one unit of what you are buying.'; + } + field("Line Discount %"; Rec."Line Discount %") + { + ToolTip = 'Specifies the discount percentage that is granted for the item on the line.'; + } + } + } + } +} \ No newline at end of file diff --git a/Apps/W1/EDocument/app/src/Processing/EDocImport.Codeunit.al b/Apps/W1/EDocument/app/src/Processing/EDocImport.Codeunit.al index 0591dfdb3b..263cb361dc 100644 --- a/Apps/W1/EDocument/app/src/Processing/EDocImport.Codeunit.al +++ b/Apps/W1/EDocument/app/src/Processing/EDocImport.Codeunit.al @@ -536,9 +536,46 @@ codeunit 6140 "E-Doc. Import" SourceDocumentHeader.Copy(SourceDocumentHeaderMapped, true); SourceDocumentLine.Copy(SourceDocumentLineMapped, true); + CreateEInvoiceLinesPreview(EDocument, SourceDocumentLine); + OnAfterPrepareReceivedDoc(EDocument, TempBlob, SourceDocumentHeader, SourceDocumentLine, TempEDocMapping); end; + local procedure CreateEInvoiceLinesPreview(EDocument: Record "E-Document"; SourceDocumentLine: RecordRef) + var + EDocumentImportHelper: Codeunit "E-Document Import Helper"; + EInvoiceLine: Record "E-Invoice Line"; + PurchaseLine: Record "Purchase Line"; + LineAmount: Decimal; + LineDiscountAmount: Decimal; + begin + EInvoiceLine.SetRange("E-Document Entry No.", EDocument."Entry No"); + if not EInvoiceLine.IsEmpty() then + EInvoiceLine.DeleteAll(true); + + if (EDocument."Document Type" <> EDocument."Document Type"::"Purchase Invoice") and (EDocument."Document Type" <> EDocument."Document Type"::"Purchase Credit Memo") then + exit; + + if SourceDocumentLine.FindSet() then + repeat + EInvoiceLine.Init(); + EInvoiceLine."E-Document Entry No." := EDocument."Entry No"; + EInvoiceLine."Line No." := SourceDocumentLine.Field(PurchaseLine.FieldNo("Line No.")).Value(); // (line number from e-invoice file if exist, if not just ordered lines) + EInvoiceLine."No." := SourceDocumentLine.Field(PurchaseLine.FieldNo("No.")).Value(); + EInvoiceLine."Description" := SourceDocumentLine.Field(PurchaseLine.FieldNo("Description")).Value(); + EInvoiceLine."Unit of Measure Code" := SourceDocumentLine.Field(PurchaseLine.FieldNo("Unit of Measure Code")).Value(); + EInvoiceLine."Quantity" := SourceDocumentLine.Field(PurchaseLine.FieldNo("Quantity")).Value(); + EInvoiceLine."Direct Unit Cost" := SourceDocumentLine.Field(PurchaseLine.FieldNo("Direct Unit Cost")).Value(); + + LineAmount := SourceDocumentLine.Field(PurchaseLine.FieldNo(Amount)).Value(); + LineDiscountAmount := SourceDocumentLine.Field(PurchaseLine.FieldNo("Line Discount Amount")).Value(); + if LineDiscountAmount <> 0 then + EInvoiceLine."Line Discount %" := 100 * (LineDiscountAmount / (LineAmount + LineDiscountAmount)); + + EInvoiceLine.Insert(true); + until SourceDocumentLine.Next() = 0; + end; + local procedure CreateDocument(var EDocument: Record "E-Document"; var TempDocumentHeader: RecordRef; var TempDocumentLine: RecordRef; var DocumentHeader: RecordRef; PurchaseDocumentType: Enum "Purchase Document Type") var EDocumentCreatePurchase: Codeunit "E-Document Create Purch. Doc."; From ed154583bc47c28c2dcbceda02447fa65ed13a2c Mon Sep 17 00:00:00 2001 From: Grasiele Matuleviciute Date: Wed, 22 Jan 2025 17:57:15 +0200 Subject: [PATCH 4/4] Temp --- Apps/W1/EDocument/edocument_workspace.code-workspace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Apps/W1/EDocument/edocument_workspace.code-workspace b/Apps/W1/EDocument/edocument_workspace.code-workspace index 35fb4f1ea3..6bef87d954 100644 --- a/Apps/W1/EDocument/edocument_workspace.code-workspace +++ b/Apps/W1/EDocument/edocument_workspace.code-workspace @@ -3,8 +3,8 @@ "al.enableCodeAnalysis": true, "al.codeAnalyzers": [ "${CodeCop}", - "${UICop}", - "${AppSourceCop}" + "${UICop}" + //"${AppSourceCop}" ] }, "folders": [