-
Notifications
You must be signed in to change notification settings - Fork 0
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 #8
base: main
Are you sure you want to change the base?
Changes from 17 commits
3e81f6a
f4c11e2
26753b9
f675911
849de29
516a5fd
42e0127
d8744e0
d3959f7
e2cf0ed
2e3ed9b
396aead
fe9620b
bbbf26c
f3ce7d5
0e1ab15
fda3b51
fe085f2
1dcb965
b3af735
2c1613e
d51e58c
13cdd7d
e9fd327
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,6 +198,7 @@ codeunit 6134 "E-Doc. Integration Management" | |
local procedure ReceiveSingleDocument(var EDocument: Record "E-Document"; var EDocumentService: Record "E-Document Service"; DocumentMetadata: Codeunit "Temp Blob"; IDocumentReceiver: Interface IDocumentReceiver): Boolean | ||
var | ||
ReceiveContext, FetchContextImpl : Codeunit ReceiveContext; | ||
EDocumentContent: Codeunit "Temp Blob"; | ||
ErrorCount: Integer; | ||
Success, IsFetchableType : Boolean; | ||
begin | ||
|
@@ -209,19 +210,22 @@ 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; | ||
|
||
if HasDuplicate(EDocument, EDocumentContent, EDocumentService."Document Format") then | ||
exit(false); | ||
|
||
// Only after sucecssfully downloading and (optionally) marking as fetched, the document is considered imported | ||
// Insert logs for downloading document | ||
InsertLogAndEDocumentStatus(EDocument, EDocumentService, ReceiveContext.GetTempBlob(), ReceiveContext.Status().GetStatus()); | ||
|
@@ -235,6 +239,24 @@ codeunit 6134 "E-Doc. Integration Management" | |
end; | ||
|
||
petemchlk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
internal procedure HasDuplicate(var IncomingEDocument: Record "E-Document"; var EDocumentContent: Codeunit "Temp Blob"; IEDocument: Interface "E-Document"): Boolean | ||
petemchlk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var | ||
EDocument: Record "E-Document"; | ||
EDocGetBasicInfo: Codeunit "E-Doc. Get Basic Info"; | ||
begin | ||
// Commit before getting basic info with error handling (if Codeunit.Run then) | ||
Commit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is from another PR, but this commit in here makes me a bit nervous. Because seeing a procedure like HasDuplicates doesn't make you think that the transaction will be commited in here... You don't have to change anything, because I know you have other fires to fight, and I know MS is quite liberal with their commits as well, but just something to think about... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually tried to avoid this commit, but happened to me while testing manually to get this error. Will keep this in my mind so if there will be some time left will try to handle this :) |
||
EDocGetBasicInfo.SetValues(IEDocument, IncomingEDocument, EDocumentContent); | ||
if not EDocGetBasicInfo.Run() then | ||
exit(false); | ||
EDocGetBasicInfo.GetValues(IEDocument, IncomingEDocument, EDocumentContent); | ||
|
||
EDocument.SetFilter("Entry No", '<>%1', IncomingEDocument."Entry No"); | ||
EDocument.SetRange("Incoming E-Document No.", IncomingEDocument."Incoming E-Document No."); | ||
EDocument.SetRange("Bill-to/Pay-to No.", IncomingEDocument."Bill-to/Pay-to No."); | ||
EDocument.SetRange("Document Date", IncomingEDocument."Document Date"); | ||
exit(not EDocument.IsEmpty()); | ||
end; | ||
#endregion | ||
|
||
#region Actions | ||
|
@@ -564,7 +586,6 @@ codeunit 6134 "E-Doc. Integration Management" | |
exit(true); | ||
end; | ||
|
||
|
||
#endregion | ||
|
||
var | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"settings": { | ||
"al.enableCodeAnalysis": true, | ||
"al.codeAnalyzers": [ | ||
"${CodeCop}", | ||
"${UICop}", | ||
"${AppSourceCop}" | ||
] | ||
}, | ||
"folders": [ | ||
{ | ||
"name": "app", | ||
"path": "app" | ||
}, | ||
{ | ||
"name": "test", | ||
"path": "test" | ||
}, | ||
{ | ||
"name": "demo data", | ||
"path": "demo data" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explicit RunTrigger. Very recommend using false if that's enough for the solution