Skip to content

Commit

Permalink
"Uptake latest master of E-Doc Core. Remove dependency on E-Documents…
Browse files Browse the repository at this point in the history
… Connector with External Endpoints
  • Loading branch information
magnushar committed Dec 1, 2024
1 parent 1112145 commit e337674
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schemeids": "0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0147 0151 0170 0183 0184 0188 0190 0191 0192 0193 0194 0195 0196 0198 0199 0200 0201 0202 0203 0204 0205 0208 0209 0210 0211 0212 0213 0215 0216 0217 0218 0219 0220 0221 0225 0230 9901 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959 AN AQ AS AU EM" }
13 changes: 5 additions & 8 deletions Apps/W1/EDocumentConnectors/Tietoevry/app/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
"id": "e1d97edc-c239-46b4-8d84-6368bdf67c8b",
"name": "E-Document Core",
"publisher": "Microsoft",
"version": "26.0.27172.0"
},
{
"id": "d852a468-263e-49e5-bfda-f09e33342b89",
"name": "E-Documents Connector with External Endpoints",
"publisher": "Microsoft",
"version": "26.0.27172.0"
"version": "26.0.0.0"
}
],
"internalsVisibleTo": [
Expand Down Expand Up @@ -51,5 +45,8 @@
"target": "OnPrem",
"features": [
"TranslationFile"
]
],
"resourceFolders": [
".resources"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.Tietoevry;

using Microsoft.EServices.EDocumentConnector;

table 6392 "Connection Setup"
{
fields
Expand Down Expand Up @@ -71,7 +69,7 @@ table 6392 "Connection Setup"
Rec.FieldError(Rec."Company Id");
end;
}
field(13; "Send Mode"; Enum "E-Doc. Ext. Send Mode")
field(13; "Send Mode"; Enum "Send Mode")
{
Caption = 'Send Mode';
DataClassification = EndUserIdentifiableInformation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ tableextension 6390 "E-Document" extends "E-Document"
{
fields
{
field(6390; "Bill-to/Pay-to Id"; Text[100])
field(6390; "Tietoevry Document Id"; Text[50])
{
DataClassification = CustomerContent;
DataClassification = SystemMetadata;
}
field(6391; "Message Id"; Text[50])
{
Expand All @@ -26,9 +26,5 @@ tableextension 6390 "E-Document" extends "E-Document"
{
DataClassification = CustomerContent;
}
field(6394; "Receiving Company Id"; Text[100])
{
DataClassification = CustomerContent;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ namespace Microsoft.EServices.EDocumentConnector.Tietoevry;
using Microsoft.eServices.EDocument;
using Microsoft.Sales.Document;
using Microsoft.Sales.History;
using Microsoft.eServices.EDocument.IO.Peppol;

Check failure on line 10 in Apps/W1/EDocumentConnectors/Tietoevry/app/src/Formats/EDocumentImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build 1st Party Apps (W1) (Translated) / 1st Party Apps (W1) (Translated)

AL0792 Unused using directive 'using Microsoft.eServices.EDocument.IO.Peppol;'.
using Microsoft.Service.History;
using Microsoft.Sales.Peppol;
using System.IO;
using Microsoft.eServices.EDocument.Service.Participant;
using Microsoft.Purchases.Document;
using System.Utilities;

Check failure on line 16 in Apps/W1/EDocumentConnectors/Tietoevry/app/src/Formats/EDocumentImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build 1st Party Apps (W1) (Translated) / 1st Party Apps (W1) (Translated)

AL0792 Unused using directive 'using System.Utilities;'.

codeunit 6391 "Tietoevry E-Document" implements "E-Document"
{



procedure Check(var SourceDocumentHeader: RecordRef; EDocumentService: Record "E-Document Service"; EDocumentProcessingPhase: enum Microsoft.eServices.EDocument."E-Document Processing Phase")
var
SalesHeader: Record "Sales Header";
Expand Down Expand Up @@ -74,8 +79,6 @@ codeunit 6391 "Tietoevry E-Document" implements "E-Document"
end;

EDocument.Find();
ServiceParticipant.Get(EDocumentService.Code, ServiceParticipant."Participant Type"::Customer, EDocument."Bill-to/Pay-to No.");
EDocument."Bill-to/Pay-to Id" := ServiceParticipant."Participant Identifier";

TempBlob.CreateInStream(DocInStream);
TempXMLBuffer.LoadFromStream(DocInStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,52 @@ using Microsoft.Sales.Peppol;
using Microsoft.Sales.Document;
using Microsoft.eServices.EDocument;
using Microsoft.eServices.EDocument.Service.Participant;
using System.IO;
using Microsoft.eServices.EDocument.IO.Peppol;
using System.Utilities;

codeunit 6398 "Format Events"
{

SingleInstance = true;
EventSubscriberInstance = StaticAutomatic;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"EDoc PEPPOL BIS 3.0", OnAfterCreatePEPPOLXMLDocument, '', false, false)]
local procedure OnAfterCreatePEPPOLXMLDocument(EDocumentService: Record "E-Document Service"; var EDocument: Record "E-Document"; var SourceDocumentHeader: RecordRef; var SourceDocumentLines: RecordRef; var TempBlob: Codeunit "Temp Blob");
var
TempXMLBuffer: Record "XML Buffer" temporary;
DocInStream: InStream;
MessageDocumentId: Text;
begin
if EDocumentService."Service Integration V2" <> EDocumentService."Service Integration V2"::Tietoevry then
exit;

TempBlob.CreateInStream(DocInStream);
TempXMLBuffer.LoadFromStream(DocInStream);
TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element);
TempXMLBuffer.SetRange(Name, 'ProfileID');
if TempXMLBuffer.FindFirst() then
EDocument."Message Profile Id" := TempXMLBuffer.Value;

TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Attribute);
TempXMLBuffer.SetRange(Name, 'xmlns');
if TempXMLBuffer.FindFirst() then
MessageDocumentId := TempXMLBuffer.Value;

TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element);
TempXMLBuffer.SetRange(Name);
if TempXMLBuffer.FindFirst() then
MessageDocumentId += '::' + TempXMLBuffer.Name;

TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element);
TempXMLBuffer.SetRange(Name, 'CustomizationID');
if TempXMLBuffer.FindFirst() then
MessageDocumentId += '##' + TempXMLBuffer.Value + '::2.1';

EDocument."Message Document Id" := MessageDocumentId;
EDocument.Modify();
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"PEPPOL Management", OnAfterGetAccountingSupplierPartyInfoByFormat, '', false, false)]
local procedure "PEPPOL Management_OnAfterGetAccountingSupplierPartyInfoByFormat"(var SupplierEndpointID: Text; var SupplierSchemeID: Text; var SupplierName: Text; IsBISBilling: Boolean)
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ codeunit 6392 "Integration Impl." implements IDocumentSender, IDocumentResponseH
end;

[EventSubscriber(ObjectType::Page, Page::"E-Document Service", OnBeforeOpenServiceIntegrationSetupPage, '', false, false)]
local procedure OnBeforeOpenServiceIntegrationSetupPage(EDocumentService: Record "E-Document Service"; var SetupPage: Integer)
local procedure OnBeforeOpenServiceIntegrationSetupPage(EDocumentService: Record "E-Document Service"; var IsServiceIntegrationSetupRun: Boolean)
var
ConnectionSetupCard: Page "Connection Setup Card";
begin
if EDocumentService."Service Integration V2" = EDocumentService."Service Integration V2"::Tietoevry then
SetupPage := Page::"Connection Setup Card";
if EDocumentService."Service Integration V2" <> EDocumentService."Service Integration V2"::Tietoevry then
exit;

ConnectionSetupCard.RunModal();
IsServiceIntegrationSetupRun := true;
end;

var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.Tietoevry;

using Microsoft.EServices.EDocumentConnector;
using System.Security.AccessControl;

permissionsetextension 6394 "Tietoevry EDoc. Connector - Edit" extends "EDocConnector - Edit"
permissionsetextension 6394 "Tietoevry EDoc. Connector - Edit" extends "D365 BASIC"
{
IncludedPermissionSets = "Tietoevry Edit";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.EServices.EDocumentConnector.Tietoevry;
using Microsoft.EServices.EDocumentConnector;

permissionsetextension 6392 "Tietoevry EDoc. Connector - Read" extends "EDocConnector - Read"
using System.Security.AccessControl;

permissionsetextension 6392 "Tietoevry EDoc. Connector - Read" extends "D365 READ"
{
IncludedPermissionSets = "Tietoevry Read";
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ codeunit 6399 Processing
InStream.Read(RequestContent);

Request.Init();
Request.Authenticate().CreateSubmitDocumentRequest(EDocument, RequestContent);
Request.Authenticate().CreateSubmitDocumentRequest(EDocument, EDocumentService, RequestContent);
ResponseContent := HttpExecutor.ExecuteHttpRequest(Request);
SendContext.Http().SetHttpRequestMessage(Request.GetRequest());
SendContext.Http().SetHttpResponseMessage(HttpExecutor.GetResponse());

EDocument.Get(EDocument."Entry No");
EDocument."Document Id" := this.ParseDocumentId(ResponseContent);
EDocument."Tietoevry Document Id" := this.ParseDocumentId(ResponseContent);
EDocument.Modify(true);
end;

Expand All @@ -56,10 +56,10 @@ codeunit 6399 Processing
HttpExecutor: Codeunit "Http Executor";
ResponseContent: Text;
begin
EDocument.TestField("Document Id");
EDocument.TestField("Tietoevry Document Id");

Request.Init();
Request.Authenticate().CreateGetDocumentStatusRequest(EDocument."Document Id");
Request.Authenticate().CreateGetDocumentStatusRequest(EDocument."Tietoevry Document Id");
ResponseContent := HttpExecutor.ExecuteHttpRequest(Request);
SendContext.Http().SetHttpRequestMessage(Request.GetRequest());
SendContext.Http().SetHttpResponseMessage(HttpExecutor.GetResponse());
Expand Down Expand Up @@ -119,7 +119,7 @@ codeunit 6399 Processing
exit;
end;

EDocument."Document Id" := CopyStr(DocumentId, 1, MaxStrLen(EDocument."Document Id"));
EDocument."Tietoevry Document Id" := CopyStr(DocumentId, 1, MaxStrLen(EDocument."Tietoevry Document Id"));
EDocument.Modify();

Request.Init();
Expand All @@ -142,7 +142,7 @@ codeunit 6399 Processing
ResponseContent: Text;
begin
Request.Init();
Request.Authenticate().CreateAcknowledgeRequest(EDocument."Document Id");
Request.Authenticate().CreateAcknowledgeRequest(EDocument."Tietoevry Document Id");
ResponseContent := HttpExecutor.ExecuteHttpRequest(Request);
ReceiveContext.Http().SetHttpRequestMessage(Request.GetRequest());
ReceiveContext.Http().SetHttpResponseMessage(HttpExecutor.GetResponse());
Expand Down Expand Up @@ -173,7 +173,7 @@ codeunit 6399 Processing
var
EDocument: Record "E-Document";
begin
EDocument.SetRange("Document Id", DocumentId);
EDocument.SetRange("Tietoevry Document Id", DocumentId);
exit(not EDocument.IsEmpty());
end;

Expand All @@ -191,10 +191,10 @@ codeunit 6399 Processing
ResponseJson.Get('id', ValueJson);

DocumentId := ValueJson.AsValue().AsText();
if StrLen(DocumentId) > MaxStrLen(EDocument."Document Id") then
if StrLen(DocumentId) > MaxStrLen(EDocument."Tietoevry Document Id") then
Error(this.TietoevryIdLongerErr);

exit(CopyStr(DocumentId, 1, MaxStrLen(EDocument."Document Id")));
exit(CopyStr(DocumentId, 1, MaxStrLen(EDocument."Tietoevry Document Id")));
end;

/// <summary>
Expand All @@ -207,7 +207,7 @@ codeunit 6399 Processing
begin
ResponseJson.ReadFrom(ResponseMsg);
ResponseJson.Get('id', ValueJson);
if EDocument."Document Id" <> ValueJson.AsValue().AsText() then
if EDocument."Tietoevry Document Id" <> ValueJson.AsValue().AsText() then
Error(this.IncorrectDocumentIdInResponseErr);

ResponseJson.Get('status', ValueJson);
Expand Down Expand Up @@ -255,9 +255,16 @@ codeunit 6399 Processing
ValidSchemeIdList: List of [Text];
SplitSeparator: Text;
SchemeId: Text;
ResInStream: InStream;
JsonObject: JsonObject;
JsonToken: JsonToken;
begin
SplitSeparator := ' ';
ValidSchemeId := ValidSchemeIdTxt;
NavApp.GetResource(ResourceSchemeIdPath, ResInStream, TextEncoding::UTF8);
ResInStream.ReadText(ValidSchemeId);
JsonObject.ReadFrom(ValidSchemeId);
JsonObject.Get('schemeids', JsonToken);
ValidSchemeId := JsonToken.AsValue().AsText();
ValidSchemeIdList := ValidSchemeId.Split(SplitSeparator);

foreach SchemeId in ValidSchemeIdList do
Expand All @@ -273,8 +280,6 @@ codeunit 6399 Processing
TietoevryProcessingDocFailedErr: Label 'An error has been identified in the submitted document.';
TietoevryIdLongerErr: Label 'Tietoevry returned id longer than supported by framework.';
TietoevryTok: Label 'E-Document - Tietoevry', Locked = true;
#pragma warning disable AA0240
ValidSchemeIdTxt: Label '0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0147 0151 0170 0183 0184 0188 0190 0191 0192 0193 0194 0195 0196 0198 0199 0200 0201 0202 0203 0204 0205 0208 0209 0210 0211 0212 0213 0215 0216 0217 0218 0219 0220 0221 0225 0230 9901 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959 AN AQ AS AU EM', Locked = true;
#pragma warning restore AA0240
ResourceSchemeIdPath: Label 'SchemeIds.txt', Locked = true;

}
21 changes: 14 additions & 7 deletions Apps/W1/EDocumentConnectors/Tietoevry/app/src/Requests.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using Microsoft.EServices.EDocumentConnector;
using Microsoft.eServices.EDocument;
using System.Text;
using System.Reflection;
using Microsoft.eServices.EDocument.Service.Participant;


/// <summary>
Expand All @@ -24,15 +25,17 @@ codeunit 6396 Requests
HttpRequestMessage: HttpRequestMessage;
BaseUrl, AuthUrl, CompanyId : Text;
AccessToken: SecretText;
ServiceParticipantNotFoundErr: Label 'No Service Participant defined for Customer %1 and E-Document Service %2.', Comment = '%1 - The customer no., %2 - The e-document service code';

/// <summary>
/// Create request for /outbound API
/// https://accesspoint.qa.dataplatfor.ms/swagger-ui/#/Outbound%20Resource/post_outbound
/// </summary>
/// <param name="Data">The data object is the details of the invoice.</param>
/// <returns>A request object that can be used for the endpoint.</returns>
procedure CreateSubmitDocumentRequest(EDocument: Record "E-Document"; Data: Text): Codeunit Requests
procedure CreateSubmitDocumentRequest(EDocument: Record "E-Document"; EDocumentService: Record "E-Document Service"; Data: Text): Codeunit Requests
var
ServiceParticipant: Record "Service Participant";
Base64Convert: Codeunit "Base64 Convert";
HttpHeaders, HttpContentHeaders : HttpHeaders;
Content: Text;
Expand All @@ -48,14 +51,18 @@ codeunit 6396 Requests
EDocument.Get(EDocument."Entry No"); //Refresh
ContentJson.Add('payload', Base64Convert.ToBase64(Data));
ContentJson.Add('sender', CompanyId);
ContentJson.Add('receiver', EDocument."Bill-to/Pay-to Id");

EDocument.TestField("Bill-to/Pay-to No.");
if not ServiceParticipant.Get(EDocumentService.Code, ServiceParticipant."Participant Type"::Customer, EDocument."Bill-to/Pay-to No.") then
Error(ServiceParticipantNotFoundErr, EDocument."Bill-to/Pay-to No.", EDocumentService.Code);

ContentJson.Add('receiver', ServiceParticipant."Participant Identifier");
ContentJson.Add('profileId', EDocument."Message Profile Id");
ContentJson.Add('documentId', EDocument."Message Document Id");
ContentJson.Add('channel', 'PEPPOL');
ContentJson.Add('reference', Format(EDocument."Entry No"));
ContentJson.WriteTo(Content);


this.HttpRequestMessage.Content.WriteFrom(Content);

this.HttpRequestMessage.Content.GetHeaders(HttpContentHeaders);
Expand Down Expand Up @@ -207,9 +214,9 @@ codeunit 6396 Requests
ConnectionSetup.Get();

case ConnectionSetup."Send Mode" of
"E-Doc. Ext. Send Mode"::Production:
"Send Mode"::Production:
exit(ConnectionSetup."API URL");
"E-Doc. Ext. Send Mode"::Test:
"Send Mode"::Test:
exit(ConnectionSetup."Sandbox API URL");
else
Error('Unsupported %1 in %2', ConnectionSetup.FieldCaption("Send Mode"), ConnectionSetup.TableCaption);
Expand All @@ -223,9 +230,9 @@ codeunit 6396 Requests
ConnectionSetup.Get();

case ConnectionSetup."Send Mode" of
"E-Doc. Ext. Send Mode"::Production:
"Send Mode"::Production:
exit(ConnectionSetup."Authentication URL");
"E-Doc. Ext. Send Mode"::Test:
"Send Mode"::Test:
exit(ConnectionSetup."Sandbox Authentication URL");
else
Error('Unsupported %1 in %2', ConnectionSetup.FieldCaption("Send Mode"), ConnectionSetup.TableCaption);
Expand Down
19 changes: 19 additions & 0 deletions Apps/W1/EDocumentConnectors/Tietoevry/app/src/SendMode.Enum.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ------------------------------------------------------------------------------------------------
// 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.Tietoevry;

enum 6390 "Send Mode"
{
Extensible = false;

value(0; Production)
{
Caption = 'Production';
}
value(1; Test)
{
Caption = 'Test';
}
}

0 comments on commit e337674

Please sign in to comment.