Skip to content
Open
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
@@ -0,0 +1,5 @@
{
"mandatoryPrefix": "ForNAV",
"name": "Peppol",
"publisher": "Microsoft"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/Apps/W1/EDocumentConnectors/FORNAV/App/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"id": "0addc017-80c4-40ad-bac6-5852f4fc4c55",
"name": "E-Document Connector - FORNAV",
"publisher": "Microsoft",
"brief": "E-Document Connector - FORNAV",
"description": "E-Document Connector - FORNAV",
"version": "27.1.0.0",
"privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
"help": "https://go.microsoft.com/fwlink/?linkid=2204541",
"url": "https://go.microsoft.com/fwlink/?LinkId=724011",
"logo": "ExtensionLogo.png",
"contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2206603",
"screenshots": [],
"resourceExposurePolicy": {
"allowDebugging": true,
"allowDownloadingSource": true,
"includeSourceInSymbolFile": true
},
"dependencies": [
{
"id": "e1d97edc-c239-46b4-8d84-6368bdf67c8b",
"name": "E-Document Core",
"publisher": "Microsoft",
"version": "27.1.0.0"
}
],
"internalsVisibleTo": [
{
"id": "c848de8f-5f8b-4adf-8a7a-8de832b204dd",
"name": "E-Document Connector - FORNAV Tests",
"publisher": "Microsoft"
}
],
"target": "Cloud",
"application": "27.1.0.0",
"platform": "27.0.0.0",
"idRanges": [
{
"from": 6410,
"to": 6426
}
],
"preprocessorSymbols": [],
"features": [
"TranslationFile",
"NoImplicitWith"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.ForNAV;

using Microsoft.EServices.EDocument;
tableextension 6412 "ForNAV EDocument" extends "E-Document"
{
fields
{
field(6410; "ForNAV Edoc. ID"; Text[80]) // Needs to have same length as "ForNAV Incoming Doc".ID
{
Access = Internal;
DataClassification = CustomerContent;
Caption = 'ForNAV Edocument ID';
ToolTip = 'Specifies the ForNAV E-Document ID.';
}
}

internal procedure DocumentLog() Log: Record "E-Document Integration Log";
begin
Log.SetRange(Log."E-Doc. Entry No", Rec."Entry No");
if Rec.Direction = Rec.Direction::Outgoing then begin
Log.SetRange(Method, 'POST');
// Use a dummy label because the URL is mandatory but we don't use it
Log.SetRange("Request URL", 'https://sendfilepostrequest/');
if not Log.FindLast() then
Clear(Log);
end else begin
Log.SetRange(Method, 'GET');
// Use a dummy label because the URL is mandatory but we don't use it
Log.SetRange("Request URL", 'https://gettargetdocumentrequest/');
if not Log.FindLast() then
Clear(Log);
end;
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.ForNAV;

using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Integration;
tableextension 6411 "ForNAV E-Document Service" extends "E-Document Service"
{
internal procedure ForNAVIsServiceIntegration(): Boolean
begin
exit("Service Integration V2" = ForNAVServiceIntegration());
end;

internal procedure ForNAVServiceIntegration(): Enum "Service Integration"
begin
exit("Service Integration V2"::FORNAV);
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.ForNAV;

using System.Threading;
using Microsoft.EServices.EDocument;


/// <summary>
/// Processes the FORNAV Incoming Documents
/// </summary>
codeunit 6410 "ForNAV App. Resp. Handler"
{
Permissions =
tabledata "E-Document Service Status" = RIMD;
Access = internal;
TableNo = "Job Queue Entry";

local procedure UpdateServiceStatus(EDocument: Record "E-Document"; EDocumentService: Record "E-Document Service"; EDocumentStatus: Enum "E-Document Service Status")
var
EDocumentServiceStatus: Record "E-Document Service Status";
begin
if EDocumentServiceStatus.Get(EDocument."Entry No", EDocumentService.Code) then begin
EDocumentServiceStatus.Validate(Status, EDocumentStatus);
EDocumentServiceStatus.Modify()
end else begin
EDocumentServiceStatus.Validate("E-Document Entry No", EDocument."Entry No");
EDocumentServiceStatus.Validate("E-Document Service Code", EDocumentService.Code);
EDocumentServiceStatus.Validate(Status, EDocumentStatus);
EDocumentServiceStatus.Insert();
end;
end;

procedure ProcessApplicationResponse(DocumentType: Enum "E-Document Type"; DocNo: Text; Status: Enum "E-Document Service Status"): Boolean
var
EDocument: Record "E-Document";
EDocumentService: Record "E-Document Service";
Setup: Record "ForNAV Peppol Setup";
EDocLogHelper: Codeunit "E-Document Log Helper";
begin
if not Setup.GetEDocumentService(EDocumentService) then
exit(false);

EDocument.SetRange("Document No.", DocNo);
EDocument.SetRange("Document Type", DocumentType);
EDocument.SetRange(Direction, "E-Document Direction"::Outgoing);
if EDocument.FindFirst() then begin
EDocLogHelper.InsertLog(EDocument, EDocumentService, Status);
UpdateServiceStatus(EDocument, EDocumentService, Status);
exit(true);
end;
end;

trigger OnRun()
var
ForNAVIncomingEDocument: Record "ForNAV Incoming E-Document";
begin
ForNAVIncomingEDocument.Get(Rec."Record ID to Process");
if ForNAVIncomingEDocument.DocType = ForNAVIncomingEDocument.DocType::ApplicationResponse then
if ForNAVIncomingEDocument.EDocumentType <> "E-Document Type"::None then
if ProcessApplicationResponse(ForNAVIncomingEDocument.EDocumentType, ForNAVIncomingEDocument.DocNo, ForNAVIncomingEDocument.Status = ForNAVIncomingEDocument.Status::Approved ? "E-Document Service Status"::Approved : "E-Document Service Status"::Rejected) then begin
ForNAVIncomingEDocument.Status := ForNAVIncomingEDocument.Status::Processed;
ForNAVIncomingEDocument.Modify();
end;
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.ForNAV;
enum 6410 "ForNAV Incoming E-Doc Status"
{
Access = Internal;

value(0; Unknown)
{
Caption = 'Unknown';
}
value(1; Approved)
{
Caption = 'Approved';
}
value(2; Rejected)
{
Caption = 'Rejected';
}
value(3; Received)
{
Caption = 'Received';
}
value(4; Send)
{
Caption = 'Send';
}
value(5; Processed)
{
Caption = 'Processed';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.ForNAV;

using System.Threading;
using Microsoft.EServices.EDocument;

page 6417 "ForNAV Incoming E-Docs Api"
{
PageType = API;
APIPublisher = 'microsoft';
EntityName = 'eDocConnectorForNav';
EntitySetName = 'eDocConnectorsForNav';
APIGroup = 'peppol';
APIVersion = 'v1.0';
SourceTable = "ForNAV Incoming E-Document";
DelayedInsert = true;
Caption = 'ForNavPeppolE-Doc';
InsertAllowed = true;
DeleteAllowed = false;
ModifyAllowed = false;
Extensible = false;
Permissions = TableData "Job Queue Entry" = rimd,
TableData "Job Queue Log Entry" = RIMD,
TableData "Job Queue Category" = rimd;
layout
{
area(Content)
{
repeater(GroupName)
{
field(iD; Rec.ID)
{
ApplicationArea = All;
}
field(docNo; Rec.DocNo)
{
ApplicationArea = All;

}
field(docType; Rec.DocType)
{
ApplicationArea = All;

}
field(docCode; Rec.DocCode)
{
ApplicationArea = All;
}
field(doc; Document)
{
ApplicationArea = All;
}
field(message; Message)
{
ApplicationArea = All;
}
field(status; Rec.Status)
{
ApplicationArea = All;
}
field(eDocumentType; Rec.EDocumentType)
{
ApplicationArea = All;
}
field(schemeID; Rec.SchemeID)
{
ApplicationArea = All;
}
field(endpointID; Rec.EndpointID)
{
ApplicationArea = All;
}
}
}
}

var
Document, Message : BigText;

[TryFunction]
local procedure CreateJob(JobQueueCodeunit: Integer; RecId: RecordId)
var
Setup: Record "ForNAV Peppol Setup";
QueueEntry: Record "Job Queue Entry";
begin
QueueEntry.ID := CreateGuid();
QueueEntry."Record ID to Process" := RecId;
QueueEntry."Object ID to Run" := JobQueueCodeunit;
QueueEntry."Object Type to Run" := QueueEntry."Object Type to Run"::Codeunit;
QueueEntry."Job Queue Category Code" := Setup.GetForNAVCode();
QueueEntry.Description := 'Used by ForNAV to process incoming e-documents';
QueueEntry.Status := QueueEntry.Status::"On Hold";
QueueEntry.Insert();
end;

local procedure SetErrorMessage(var NewMessage: BigText)
var
Error: ErrorInfo;
begin
Clear(NewMessage);
NewMessage.AddText('Error\n');
NewMessage.AddText(GetLastErrorText() + '\n');
NewMessage.AddText(GetLastErrorCallStack() + '\n');
foreach Error in GetCollectedErrors() do
NewMessage.AddText(Error.Message + '\n');
end;

trigger OnInsertRecord(BelowxRec: Boolean): Boolean
var
EDocumentService: Record "E-Document Service";
Setup: Record "ForNAV Peppol Setup";
BlankRecordId: RecordId;
DocumentOutStream, MessageOutStream : OutStream;
begin
case Rec.DocType of
Rec.DocType::Evidence:
if not CreateJob(Codeunit::"E-Document Get Response", BlankRecordId) then
SetErrorMessage(Message);
Rec.DocType::ApplicationResponse:
if not CreateJob(Codeunit::"ForNAV App. Resp. Handler", Rec.RecordId()) then
SetErrorMessage(Message);
Rec.DocType::Invoice, Rec.DocType::CreditNote:
begin
if not Setup.GetEDocumentService(EDocumentService) then
exit(false);

if not CreateJob(6147, EDocumentService.RecordId()) then // Codeunit 6147 "E-Document Import Job"
SetErrorMessage(Message);
end;
end;

Rec.Doc.CreateOutStream(DocumentOutStream, TextEncoding::UTF8);
Document.Write(DocumentOutStream);
Rec.Message.CreateOutStream(MessageOutStream, TextEncoding::UTF8);
Message.Write(MessageOutStream);
exit(true);
end;

trigger OnFindRecord(Which: Text): Boolean
begin
exit(false);
end;
}
Loading