Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E-Documents Core] - Manual multiple files import #27975

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3e81f6a
add EDocument app workspace
petemchlk Dec 11, 2024
f4c11e2
add code analyzers settings to code workspace
petemchlk Dec 12, 2024
26753b9
Merge pull request #1 from GMatuleviciute/dev/pmi/EDocumentWorkspace
GMatuleviciute Dec 12, 2024
f675911
add action to handle both multiple and single file upload
petemchlk Jan 16, 2025
849de29
Duplicate handling in multiple documents import, make import action …
petemchlk Jan 17, 2025
516a5fd
change the action name
petemchlk Jan 20, 2025
42e0127
change e-document to use silent processing in multiple files upload
petemchlk Jan 20, 2025
d8744e0
remove unused variable
petemchlk Jan 20, 2025
d3959f7
refactor code add test
petemchlk Jan 20, 2025
e2cf0ed
add test
petemchlk Jan 21, 2025
2e3ed9b
hide old import, change tooltip
petemchlk Jan 22, 2025
396aead
remove commented code
petemchlk Jan 22, 2025
fe9620b
pr changes
petemchlk Jan 23, 2025
bbbf26c
rename test
petemchlk Jan 23, 2025
f3ce7d5
pr fixes
petemchlk Jan 23, 2025
0e1ab15
adjust test after changes
petemchlk Jan 23, 2025
fda3b51
obsolete actionref
petemchlk Jan 23, 2025
fe085f2
pr fixes
petemchlk Jan 24, 2025
1dcb965
pr fixes, add test
petemchlk Jan 24, 2025
b3af735
pr fixes
petemchlk Feb 3, 2025
2c1613e
pr fixes
petemchlk Feb 3, 2025
d51e58c
Removed workspace
GMatuleviciute Feb 3, 2025
13cdd7d
move duplicate checking to processing stage
petemchlk Feb 4, 2025
67671f4
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
GMatuleviciute Feb 10, 2025
9a3c7f0
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
petemchlk Feb 11, 2025
e9fd327
Update EDocument Table with dulicate detect procedure
petemchlk Feb 11, 2025
833203b
remove unused codeunit
petemchlk Feb 12, 2025
498825b
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
GMatuleviciute Feb 13, 2025
5254d23
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
petemchlk Feb 13, 2025
b5c5541
Merge branch 'main' into dev/pmi/ImportMultipleFilesManually
petemchlk Feb 13, 2025
5df55fc
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
petemchlk Feb 13, 2025
aef32eb
merge changes
petemchlk Feb 13, 2025
0178e16
Revert "merge changes"
petemchlk Feb 13, 2025
634c86a
Revert "Merge branch 'main' into dev/pmi/ImportMultipleFilesManually"
petemchlk Feb 13, 2025
3f5cad7
Merge remote-tracking branch 'origin/main' into dev/pmi/ImportMultipl…
petemchlk Feb 14, 2025
d8c4999
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
GMatuleviciute Feb 14, 2025
660ba62
merge changes
petemchlk Feb 13, 2025
c28318e
remove unused label
petemchlk Feb 14, 2025
f072ba0
make tests using one vatpostingsetup
petemchlk Feb 14, 2025
c4fcc52
Merge branch 'main' of https://github.com/GMatuleviciute/ALAppExtensions
petemchlk Feb 17, 2025
77b51c6
Merge branch 'main' into dev/pmi/ImportMultipleFilesManually
petemchlk Feb 17, 2025
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
8 changes: 6 additions & 2 deletions Apps/W1/EDocument/app/src/Document/EDocument.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,13 @@ page 6121 "E-Document"
Visible = IsIncomingDoc and (not IsProcessed);

trigger OnAction()
var
EDocumentService: Record "E-Document Service";
begin
EDocImport.UploadDocument(Rec);
CurrPage.Update();
if EDocImport.ChooseEDocumentService(EDocumentService) then begin
EDocImport.UploadDocument(Rec, EDocumentService);
CurrPage.Update(false);
end;
end;
}
action(TextToAccountMapping)
Expand Down
59 changes: 59 additions & 0 deletions Apps/W1/EDocument/app/src/Document/EDocument.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Microsoft.eServices.EDocument;

using Microsoft.Foundation.Reporting;
using Microsoft.Finance.Currency;
using Microsoft.Foundation.Attachment;
using Microsoft.Utilities;
using System.Automation;
using System.IO;
Expand Down Expand Up @@ -230,6 +231,61 @@ table 6121 "E-Document"
}
}

trigger OnDelete()
begin
if (Rec.Status = Rec.Status::Processed) then
Error(this.DeleteProcessedNotAllowedErr);

if (Rec."Document Record ID".TableNo <> 0) then
Error(this.DeleteLinkedNotAllowedErr);

if (not Rec.IsDuplicate()) then
Error(this.DeleteUniqueNotAllowedErr);

this.DeleteRelatedRecords();
end;

internal procedure IsDuplicate(): Boolean
var
EDocument: Record "E-Document";
begin
EDocument.SetRange("Incoming E-Document No.", Rec."Incoming E-Document No.");
EDocument.SetRange("Bill-to/Pay-to No.", Rec."Bill-to/Pay-to No.");
EDocument.SetRange("Document Date", Rec."Document Date");
EDocument.SetFilter("Entry No", '<>%1', Rec."Entry No");
exit(not EDocument.IsEmpty());
end;

local procedure DeleteRelatedRecords()
var
DocumentAttachment: Record "Document Attachment";
EDocMappingLog: Record "E-Doc. Mapping Log";
EDocumentIntegrationLog: Record "E-Document Integration Log";
EDocumentLog: Record "E-Document Log";
EDocumentServiceStatus: Record "E-Document Service Status";
begin
EDocumentLog.SetRange("E-Doc. Entry No", Rec."Entry No");
if not EDocumentLog.IsEmpty() then
EDocumentLog.DeleteAll(true);

EDocumentIntegrationLog.SetRange("E-Doc. Entry No", Rec."Entry No");
if not EDocumentIntegrationLog.IsEmpty() then
EDocumentIntegrationLog.DeleteAll(true);

EDocumentServiceStatus.SetRange("E-Document Entry No", Rec."Entry No");
if not EDocumentServiceStatus.IsEmpty() then
EDocumentServiceStatus.DeleteAll(true);

DocumentAttachment.SetRange("E-Document Attachment", true);
DocumentAttachment.SetRange("E-Document Entry No.", Rec."Entry No");
if not DocumentAttachment.IsEmpty() then
DocumentAttachment.DeleteAll(true);

EDocMappingLog.SetRange("E-Doc Entry No.", Rec."Entry No");
if not EDocMappingLog.IsEmpty() then
EDocMappingLog.DeleteAll(true);
end;

internal procedure PreviewContent()
var
EDocDataStorage: Record "E-Doc. Data Storage";
Expand Down Expand Up @@ -345,6 +401,9 @@ table 6121 "E-Document"

var
ToStringLbl: Label '%1,%2,%3,%4', Locked = true;
DeleteLinkedNotAllowedErr: Label 'The E-Document is linked to sales or purchase document and cannot be deleted.';
DeleteProcessedNotAllowedErr: Label 'The E-Document has already been processed and cannot be deleted.';
DeleteUniqueNotAllowedErr: Label 'Only duplicate E-Documents can be deleted.';
NoFileErr: label 'No previewable attachment exists for this %2.', Comment = '%1 - a table caption';
NoFileContentErr: label 'Previewing file %1 failed. The file was found in table %2, but it has no content.', Comment = '%1 - a file name; %2 - a table caption';
}
44 changes: 38 additions & 6 deletions Apps/W1/EDocument/app/src/Document/EDocuments.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,42 @@ page 6122 "E-Documents"
{
area(Processing)
{
#if not CLEAN26
action(ImportManually)
{
Caption = 'New From File';
ToolTip = 'Create an electronic document by manually uploading a file.';
Image = Import;
Visible = false;
ObsoleteState = Pending;
ObsoleteTag = '26.0';
ObsoleteReason = 'Functionality moved to "Import Files" action.';

trigger OnAction()
begin
NewFromFile();
end;
}
#endif
fileuploadaction(ImportManuallyMultiple)
{
Caption = 'Import Files';
ToolTip = 'Create electronic documents by uploading single or multiple files.';
Image = Import;
AllowedFileExtensions = '.xml';
AllowMultipleFiles = true;

trigger OnAction(Files: List of [FileUpload])
var
EDocumentService: Record "E-Document Service";
EDocImport: Codeunit "E-Doc. Import";
begin
if EDocImport.ChooseEDocumentService(EDocumentService) then begin
EDocImport.UploadDocuments(Files, EDocumentService);
CurrPage.Update(false);
end;
end;
}
action(EDocumentServices)
{
RunObject = Page "E-Document Services";
Expand Down Expand Up @@ -100,7 +125,16 @@ page 6122 "E-Documents"
}
area(Promoted)
{
actionref(Promoted_ImportManually; ImportManually) { }
#if not CLEAN26
actionref(Promoted_ImportManually; ImportManually)
{
Visible = false;
ObsoleteState = Pending;
ObsoleteTag = '26.0';
ObsoleteReason = 'Functionality moved to "Import Files" action.';
}
#endif
actionref(Promoted_ImportManuallyMultiple; ImportManuallyMultiple) { }
actionref(Promoted_EDocumentServices; EDocumentServices) { }
actionref(Promoted_ViewFile; ViewFile) { }
}
Expand All @@ -109,12 +143,10 @@ page 6122 "E-Documents"
local procedure NewFromFile()
var
EDocument: Record "E-Document";
EDocumentService: Record "E-Document Service";
EDocImport: Codeunit "E-Doc. Import";
begin
EDocImport.UploadDocument(EDocument);
if EDocument."Entry No" <> 0 then begin
EDocImport.ProcessIncomingEDocument(EDocument, EDocument.GetEDocumentService().GetDefaultImportParameters());
Page.Run(Page::"E-Document", EDocument);
end;
if EDocImport.ChooseEDocumentService(EDocumentService) then
EDocImport.UploadDocument(EDocument, EDocumentService);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ page 6105 "Inbound E-Documents"
local procedure NewFromFile()
var
EDocument: Record "E-Document";
EDocumentService: Record "E-Document Service";
EDocImport: Codeunit "E-Doc. Import";
begin
EDocImport.UploadDocument(EDocument);
EDocImport.ChooseEDocumentService(EDocumentService);
EDocImport.UploadDocument(EDocument, EDocumentService);
if EDocument."Entry No" = 0 then
exit;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ codeunit 6134 "E-Doc. Integration Management"
var
EDocLog: Record "E-Document Log";
ReceiveContext, FetchContextImpl : Codeunit ReceiveContext;
EDocumentContent: Codeunit "Temp Blob";
ErrorCount: Integer;
Success, IsFetchableType : Boolean;
begin
Expand All @@ -214,15 +215,15 @@ codeunit 6134 "E-Doc. Integration Management"
if not Success then
exit(false);

if not ReceiveContext.GetTempBlob().HasValue() then
EDocumentContent := ReceiveContext.GetTempBlob();
if not EDocumentContent.HasValue() then
exit(false);

IsFetchableType := IDocumentReceiver is IReceivedDocumentMarker;
if IsFetchableType then begin
ErrorCount := EDocumentErrorHelper.ErrorMessageCount(EDocument);
RunMarkFetched(EDocument, EDocumentService, ReceiveContext.GetTempBlob(), IDocumentReceiver, FetchContextImpl);
Success := EDocumentErrorHelper.ErrorMessageCount(EDocument) = ErrorCount;

if not Success then
exit(false);
end;
Expand All @@ -248,7 +249,6 @@ codeunit 6134 "E-Doc. Integration Management"
exit(true);
end;


#endregion

#region Actions
Expand Down Expand Up @@ -576,7 +576,6 @@ codeunit 6134 "E-Doc. Integration Management"
exit(true);
end;


#endregion

var
Expand Down
Loading
Loading