Skip to content

Commit

Permalink
Syncing with version 26.0.27457.0 (#27732)
Browse files Browse the repository at this point in the history
  • Loading branch information
Groenbech96 and magnushar authored Nov 30, 2024
1 parent 8cb747a commit d311efd
Show file tree
Hide file tree
Showing 52 changed files with 426 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/AL-Go-Settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"runs-on": "windows-latest",
"cacheImageName": "",
"UsePsSession": false,
"artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/26.0.27417.0/base",
"artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/26.0.27457.0/base",
"country": "base",
"useProjectDependencies": true,
"repoVersion": "26.0",
Expand Down
26 changes: 7 additions & 19 deletions Apps/W1/BankAccRecWithAI/app/src/BankAccRecTransToAcc.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ codeunit 7251 "Bank Acc. Rec. Trans. to Acc."

[NonDebuggable]
local procedure GetCompletionResponse(var AOAIChatMessages: Codeunit "AOAI Chat Messages"; var BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line"; var TempBankStatementMatchingBuffer: Record "Bank Statement Matching Buffer" temporary; var GLAccount: Record "G/L Account"; var AzureOpenAI: Codeunit "Azure OpenAi"; var AOAIChatCompletionParams: Codeunit "AOAI Chat Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response")
var
SysMsg: Text;
UserMsg: Text;
begin
AOAIChatMessages.AddSystemMessage(BuildMostAppropriateGLAccountPromptTask().Unwrap());
AOAIChatMessages.AddUserMessage(BuildBankRecPromptUserMessage(BuildBankRecStatementLines(BankAccReconciliationLine, TempBankStatementMatchingBuffer), BuildGLAccounts(GLAccount)).Unwrap());
SysMsg := BuildMostAppropriateGLAccountPromptTask().Unwrap();
UserMsg := BuildBankRecPromptUserMessage(BuildBankRecStatementLines(BankAccReconciliationLine, TempBankStatementMatchingBuffer), BuildGLAccounts(GLAccount)).Unwrap();
AOAIChatMessages.AddSystemMessage(SysMsg);
AOAIChatMessages.AddUserMessage(UserMsg);
AzureOpenAI.GenerateChatCompletion(AOAIChatMessages, AOAIChatCompletionParams, AOAIOperationResponse);
end;

Expand Down Expand Up @@ -247,36 +252,19 @@ codeunit 7251 "Bank Acc. Rec. Trans. to Acc."

procedure BuildBankRecStatementLines(var BankAccReconciliationLine: Record "Bank Acc. Reconciliation Line"; var TempBankStatementMatchingBuffer: Record "Bank Statement Matching Buffer" temporary): Text
var
GLAccount: Record "G/L Account";
BankRecAIMatchingImpl: Codeunit "Bank Rec. AI Matching Impl.";
LocalStatementLines: Text;
InitialGLAccountFound: Boolean;
InitialGLAccountInsertDone: Boolean;
begin
if (LocalStatementLines = '') then
LocalStatementLines := '**Statement Lines**:\n"""\n';

GLAccount.SetRange("Direct Posting", true);
if GLAccount.FindFirst() then
if not BankRecAIMatchingImpl.HasReservedWords(GLAccount.Name) then
InitialGLAccountFound := true;

BankAccReconciliationLine.Ascending(true);
if BankAccReconciliationLine.FindSet() then
repeat
if not BankRecAIMatchingImpl.HasReservedWords(BankAccReconciliationLine.Description) then begin
TempBankStatementMatchingBuffer.Reset();
TempBankStatementMatchingBuffer.SetRange("Line No.", BankAccReconciliationLine."Statement Line No.");
if TempBankStatementMatchingBuffer.IsEmpty() then begin
if InitialGLAccountFound then
if not InitialGLAccountInsertDone then begin
if BankAccReconciliationLine."Statement Line No." > 1 then begin
LocalStatementLines += '#Id: ' + Format(BankAccReconciliationLine."Statement Line No." - 1);
LocalStatementLines += ', Description: ' + GLAccount.Name;
LocalStatementLines += '\n';
end;
InitialGLAccountInsertDone := true;
end;
LocalStatementLines += '#Id: ' + Format(BankAccReconciliationLine."Statement Line No.");
LocalStatementLines += ', Description: ' + BankAccReconciliationLine.Description;
LocalStatementLines += '\n';
Expand Down
6 changes: 6 additions & 0 deletions Apps/W1/EDocument/app/src/Document/EDocument.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ table 6121 "E-Document"
{
Caption = 'Receiving Company Address';
}
field(31; "Receiving Company Id"; Text[250])
{
Caption = 'Receiving Company Id';
ToolTip = 'Specifies the receiving company id, such as PEPPOL id, or other identifiers used in the electronic document exchange.';
}
field(26; "Currency Code"; Code[10])
{
Caption = 'Currency Code';
Expand All @@ -177,6 +182,7 @@ table 6121 "E-Document"
{
DataClassification = SystemMetadata;
}

}
keys
{
Expand Down
41 changes: 39 additions & 2 deletions Apps/W1/EDocument/app/src/Format/EDocImportPEPPOLBIS30.Codeunit.al
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.eServices.EDocument.IO.Peppol;

using Microsoft.eServices.EDocument;
using Microsoft.EServices.EDocument.Service.Participant;
using System.Utilities;
using Microsoft.Purchases.Document;
using System.IO;
Expand Down Expand Up @@ -110,16 +111,37 @@ codeunit 6166 "EDoc Import PEPPOL BIS 3.0"
local procedure ParseAccountingSupplierParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentType: Text)
var
Vendor: Record Vendor;
ServiceParticipant: Record "Service Participant";
EDocumentService: Record "E-Document Service";
EDocumentHelper: Codeunit "E-Document Helper";
VendorName, VendorAddress : Text;
VATRegistrationNo: Text[20];
VendorId: Text;
VendorNo: Code[20];
begin
// Vendor
VATRegistrationNo := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(VATRegistrationNo));
VendorNo := EDocumentImportHelper.FindVendor('', '', VATRegistrationNo);

if VendorNo = '' then begin
VendorId := GetNodeAttributeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') + ':';
VendorId += this.GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID');

EDocumentHelper.GetEdocumentService(EDocument, EDocumentService);
ServiceParticipant.SetRange("Participant Type", ServiceParticipant."Participant Type"::Vendor);
ServiceParticipant.SetRange("Participant Identifier", VendorId);
ServiceParticipant.SetRange(Service, EDocumentService.Code);
if not ServiceParticipant.FindFirst() then begin
ServiceParticipant.SetRange(Service);
if ServiceParticipant.FindFirst() then;
end;

VendorNo := ServiceParticipant.Participant;
end;

if VendorNo = '' then begin
VendorName := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name'), 1, MaxStrLen(VATRegistrationNo));
VendorAddress := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName'), 1, MaxStrLen(VATRegistrationNo));
VendorName := GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name');
VendorAddress := GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName');
VendorNo := EDocumentImportHelper.FindVendorByNameAndAddress(VendorName, VendorAddress);
EDocument."Bill-to/Pay-to Name" := CopyStr(VendorName, 1, MaxStrLen(EDocument."Bill-to/Pay-to Name"));
end;
Expand All @@ -132,11 +154,16 @@ codeunit 6166 "EDoc Import PEPPOL BIS 3.0"
end;

local procedure ParseAccountingCustomerParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentType: Text)
var
ReceivingId: Text[250];
begin
EDocument."Receiving Company Name" := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PartyName/cbc:Name'), 1, MaxStrLen(EDocument."Receiving Company Name"));
EDocument."Receiving Company Address" := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:StreetName'), 1, MaxStrLen(EDocument."Receiving Company Address"));
EDocument."Receiving Company GLN" := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(EDocument."Receiving Company GLN"));
EDocument."Receiving Company VAT Reg. No." := CopyStr(GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID'), 1, MaxStrLen(EDocument."Receiving Company VAT Reg. No."));
ReceivingId := CopyStr(this.GetNodeAttributeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID/@schemeID'), 1, (MaxStrLen(EDocument."Receiving Company Id") - 1)) + ':';
ReceivingId += CopyStr(this.GetNodeByPath(TempXMLBuffer, '/' + DocumentType + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(EDocument."Receiving Company Id") - StrLen(ReceivingId));
EDocument."Receiving Company Id" := ReceivingId;
end;

local procedure CreateInvoice(var EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: record "Purchase Line" temporary; var TempXMLBuffer: Record "XML Buffer" temporary)
Expand Down Expand Up @@ -514,6 +541,16 @@ codeunit 6166 "EDoc Import PEPPOL BIS 3.0"
exit(TempXMLBuffer.Value);
end;

local procedure GetNodeAttributeByPath(var TempXMLBuffer: Record "XML Buffer" temporary; XPath: Text): Text
begin
TempXMLBuffer.Reset();
TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Attribute);
TempXMLBuffer.SetRange(Path, XPath);

if TempXMLBuffer.FindFirst() then
exit(TempXMLBuffer.Value);
end;

local procedure GetDocumentType(var TempXMLBuffer: Record "XML Buffer" temporary): Text
var
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ codeunit 6178 "E-Document Action Runner"
this.EDocumentService.Copy(EDocumentService);
end;

/// <summary>
/// Gets the E-Document and the E-Document Service for the E-Document Action
/// </summary>
procedure GetEDocumentAndService(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service")
begin
EDocument.Copy(this.EDocument);
EDocumentService.Copy(this.EDocumentService);
end;

/// <summary>
/// Returns if running action lead to update in service status.
/// Certain actions dont need to update service status, like asking if document was approved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ codeunit 6134 "E-Doc. Integration Management"
EDocServiceStatus := Enum::"E-Document Service Status"::Rejected
end;

// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocument.Get(EDocument."Entry No");
EDocumentService.Get(EDocumentService.Code);

if not IsHandled then begin
AddLogAndUpdateEDocument(EDocument, EDocumentService, EDocServiceStatus);
EDocumentLog.InsertIntegrationLog(EDocument, EDocumentService, HttpRequest, HttpResponse);
Expand Down Expand Up @@ -346,6 +350,10 @@ codeunit 6134 "E-Doc. Integration Management"
EDocServiceStatus := Enum::"E-Document Service Status"::"Cancel Error";
end;

// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocument.Get(EDocument."Entry No");
EDocumentService.Get(EDocumentService.Code);

if not IsHandled then begin
AddLogAndUpdateEDocument(EDocument, EDocumentService, EDocServiceStatus);
EDocumentLog.InsertIntegrationLog(EDocument, EDocumentService, HttpRequest, HttpResponse);
Expand All @@ -355,51 +363,62 @@ codeunit 6134 "E-Doc. Integration Management"

#endregion

local procedure RunSend(EDocService: Record "E-Document Service"; var EDocument: Record "E-Document"; SendContext: Codeunit SendContext; var IsAsync: Boolean)
local procedure RunSend(EDocumentService: Record "E-Document Service"; var EDocument: Record "E-Document"; SendContext: Codeunit SendContext; var IsAsync: Boolean)
var
SendRunner: Codeunit "Send Runner";
TelemetryDimensions: Dictionary of [Text, Text];
begin
// Commit needed for "if codeunit run" pattern when catching errors.
Commit();
EDocumentProcessing.GetTelemetryDimensions(EDocService, EDocument, TelemetryDimensions);
EDocumentProcessing.GetTelemetryDimensions(EDocumentService, EDocument, TelemetryDimensions);
Telemetry.LogMessage('0000LBL', EDocTelemetrySendScopeStartLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All, TelemetryDimensions);
OnBeforeSendDocument(EDocument, EDocService, SendContext.Http().GetHttpRequestMessage(), SendContext.Http().GetHttpResponseMessage());
OnBeforeSendDocument(EDocument, EDocumentService, SendContext.Http().GetHttpRequestMessage(), SendContext.Http().GetHttpResponseMessage());

SendRunner.SetDocumentAndService(EDocument, EDocService);
SendRunner.SetDocumentAndService(EDocument, EDocumentService);
SendRunner.SetContext(SendContext);
if not SendRunner.Run() then
EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, GetLastErrorText());

SendRunner.GetDocumentAndService(EDocument, EDocService);
// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocument.Get(EDocument."Entry No");
EDocumentService.Get(EDocumentService.Code);
IsAsync := SendRunner.GetIsAsync();

OnAfterSendDocument(EDocument, EDocService, SendContext.Http().GetHttpRequestMessage(), SendContext.Http().GetHttpResponseMessage());
OnAfterSendDocument(EDocument, EDocumentService, SendContext.Http().GetHttpRequestMessage(), SendContext.Http().GetHttpResponseMessage());
Telemetry.LogMessage('0000LBM', EDocTelemetrySendScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All);
end;

local procedure RunSendBatch(EDocService: Record "E-Document Service"; var EDocuments: Record "E-Document"; SendContext: Codeunit SendContext; var IsAsync: Boolean)
local procedure RunSendBatch(EDocumentService: Record "E-Document Service"; var EDocuments: Record "E-Document"; SendContext: Codeunit SendContext; var IsAsync: Boolean)
var
SendRunner: Codeunit "Send Runner";
ErrorText: Text;
TelemetryDimensions: Dictionary of [Text, Text];
Sucecss: Boolean;
begin
// Commit needed for "if codeunit run" pattern when catching errors.
Commit();
EDocumentProcessing.GetTelemetryDimensions(EDocService, EDocuments, TelemetryDimensions);
EDocumentProcessing.GetTelemetryDimensions(EDocumentService, EDocuments, TelemetryDimensions);
Telemetry.LogMessage('0000LBN', EDocTelemetrySendBatchScopeStartLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All, TelemetryDimensions);

SendRunner.SetDocumentAndService(EDocuments, EDocService);
SendRunner.SetDocumentAndService(EDocuments, EDocumentService);
SendRunner.SetContext(SendContext);
if not SendRunner.Run() then begin
Sucecss := SendRunner.Run();

// Check filter exists
if EDocuments.GetFilter("Entry No") = '' then
Error(EDocNoFilterOnBatchSendErr);

if not Sucecss then begin
ErrorText := GetLastErrorText();
EDocuments.FindSet();
repeat
EDocumentErrorHelper.LogSimpleErrorMessage(EDocuments, ErrorText);
until EDocuments.Next() = 0;
end;

SendRunner.GetDocumentAndService(EDocuments, EDocService);
// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocuments.FindSet();
EDocumentService.Get(EDocumentService.Code);
IsAsync := SendRunner.GetIsAsync();

Telemetry.LogMessage('0000LBO', EDocTelemetrySendBatchScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All);
Expand All @@ -421,7 +440,8 @@ codeunit 6134 "E-Doc. Integration Management"
if not ReceiveDocs.Run() then
exit;

ReceiveDocs.GetService(EDocumentService);
// After interface call, reread the EDocumentService for the latest values.
EDocumentService.Get(EDocumentService.Code);
Telemetry.LogMessage('0000O0B', EDocTelemetryReceiveDocsScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All);
end;

Expand All @@ -440,7 +460,9 @@ codeunit 6134 "E-Doc. Integration Management"
if not DownloadDoc.Run() then
EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, GetLastErrorText());

DownloadDoc.GetDocumentAndService(EDocument, EDocumentService);
// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocument.Get(EDocument."Entry No");
EDocumentService.Get(EDocumentService.Code);
Telemetry.LogMessage('0000O0D', EDocTelemetryReciveDownloadDocScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All);
end;

Expand All @@ -459,7 +481,9 @@ codeunit 6134 "E-Doc. Integration Management"
if not MarkFetched.Run() then
EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, GetLastErrorText());

MarkFetched.GetParameters(EDocument, EDocumentService);
// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocument.Get(EDocument."Entry No");
EDocumentService.Get(EDocumentService.Code);
Telemetry.LogMessage('0000O2Y', EDocTelemetryMarkFetchedScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All);
end;

Expand All @@ -480,7 +504,9 @@ codeunit 6134 "E-Doc. Integration Management"
if not Success then
EDocumentErrorHelper.LogSimpleErrorMessage(EDocument, GetLastErrorText());

EDocumentActionRunner.GetEDocumentAndService(EDocument, EDocumentService);
// After interface call, reread the EDocument and EDocumentService for the latest values.
EDocument.Get(EDocument."Entry No");
EDocumentService.Get(EDocumentService.Code);
Telemetry.LogMessage('0000O09', EDocTelemetryActionScopeEndLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, TelemetryScope::All);
exit(EDocumentActionRunner.ShouldActionUpdateStatus())
end;
Expand Down Expand Up @@ -560,6 +586,7 @@ codeunit 6134 "E-Doc. Integration Management"
EDocTelemetryReciveDownloadDocScopeEndLbl: Label 'E-Document Receive Download Doc: End Scope', Locked = true;
EDocTelemetryMarkFetchedScopeStartLbl: Label 'E-Document Mark Fetched: Start Scope', Locked = true;
EDocTelemetryMarkFetchedScopeEndLbl: Label 'E-Document Mark Fetched: End Scope', Locked = true;
EDocNoFilterOnBatchSendErr: Label 'No Entry No. filter is set on the E-Document for batch to sending';
#if not CLEAN26
DocNotCreatedQst: Label 'Failed to create new Purchase %1 from E-Document. Do you want to open E-Document to see reported errors?', Comment = '%1 - Purchase Document Type';
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ codeunit 6180 "Download Document"
this.DocumentMetadata := DocumentMetadata;
end;

procedure GetDocumentAndService(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service")
begin
EDocument.Copy(this.EDocument);
EDocumentService.Copy(this.EDocumentService);
end;

var
EDocument: Record "E-Document";
EDocumentService: Record "E-Document Service";
Expand Down
Loading

0 comments on commit d311efd

Please sign in to comment.