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
Expand Up @@ -41,7 +41,9 @@ pageextension 6149 "E-Doc. Issued Fin. Charge Memo" extends "Issued Finance Char
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Issued Finance Charge Memo") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -51,6 +53,7 @@ pageextension 6149 "E-Doc. Issued Fin. Charge Memo" extends "Issued Finance Char
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pageextension 6148 "E-Doc. Issued Reminder" extends "Issued Reminder"
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Issued Reminder") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -51,6 +53,7 @@ pageextension 6148 "E-Doc. Issued Reminder" extends "Issued Reminder"
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ pageextension 6145 "E-Doc. Posted Sales Cr. Memo" extends "Posted Sales Credit M
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Sales Credit Memo") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -52,6 +54,7 @@ pageextension 6145 "E-Doc. Posted Sales Cr. Memo" extends "Posted Sales Credit M
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pageextension 6144 "E-Doc. Posted Sales Inv." extends "Posted Sales Invoice"
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Sales Invoice") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -51,6 +53,7 @@ pageextension 6144 "E-Doc. Posted Sales Inv." extends "Posted Sales Invoice"
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pageextension 6103 "E-Doc. Posted Sales Shipment" extends "Posted Sales Shipment
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Sales Shipment") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -51,6 +53,7 @@ pageextension 6103 "E-Doc. Posted Sales Shipment" extends "Posted Sales Shipment
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pageextension 6143 "E-Doc. Posted Service Cr. Memo" extends "Posted Service Cred
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Service Credit Memo") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -51,6 +53,7 @@ pageextension 6143 "E-Doc. Posted Service Cr. Memo" extends "Posted Service Cred
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pageextension 6142 "E-Doc. Posted Service Inv." extends "Posted Service Invoice"
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Service Invoice") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -51,6 +53,7 @@ pageextension 6142 "E-Doc. Posted Service Inv." extends "Posted Service Invoice"
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ pageextension 6106 "E-Doc. Posted Transfer Shpmnt." extends "Posted Transfer Shi
EDocumentProcessing: Codeunit "E-Document Processing";
begin
if EDocumentProcessing.CreateEDocumentFromPostedDocumentPage(Rec, Enum::"E-Document Type"::"Transfer Shipment") then
Message(EDocumentCreatedMsg);
Message(EDocumentCreatedMsg)
else
Message(EDocumentNotCreatedMsg);
end;
}
}
Expand All @@ -54,6 +56,7 @@ pageextension 6106 "E-Doc. Posted Transfer Shpmnt." extends "Posted Transfer Shi
var
EDocumentExists: Boolean;
EDocumentCreatedMsg: Label 'The e-document has been created.';
EDocumentNotCreatedMsg: Label 'The e-document could not be created.';
Comment thread
georgepomazkov marked this conversation as resolved.

trigger OnAfterGetRecord()
var
Expand Down
17 changes: 13 additions & 4 deletions src/Apps/W1/EDocument/App/src/Processing/EDocExport.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ codeunit 6102 "E-Doc. Export"
OnAfterEDocumentCheck(EDocSourceRecRef, EDocumentProcessingPhase);
end;

internal procedure CreateEDocument(DocumentHeader: RecordRef; DocumentSendingProfile: Record "Document Sending Profile"; EDocumentType: Enum "E-Document Type")
/// <summary>
/// Creates a new E-Document of specified type for the provided document header and attempts to export it.
/// </summary>
/// <returns>
/// true if the E-Document has been created;
/// otherwise false.
/// </returns>
internal procedure CreateEDocument(DocumentHeader: RecordRef; DocumentSendingProfile: Record "Document Sending Profile"; EDocumentType: Enum "E-Document Type"): Boolean
var
WorkFlow: Record Workflow;
EDocument: Record "E-Document";
Expand All @@ -71,16 +78,16 @@ codeunit 6102 "E-Doc. Export"

WorkFlow.TestField(Enabled);
if DocumentSendingProfile."Electronic Document" <> DocumentSendingProfile."Electronic Document"::"Extended E-Document Service Flow" then
exit;
exit(false);

if not EDocWorkFlowProcessing.GetServicesFromEntryPointResponseInWorkflow(WorkFlow, EDocumentService) then
exit;
exit(false);

EDocument."Workflow Code" := WorkFlow.Code;
EDocument."Document Sending Profile" := DocumentSendingProfile.Code;

if not CreateEDocument(EDocument, DocumentHeader, EDocumentService, EDocumentType) then
exit;
exit(false);

// For each service supporting the document type, export it before creating E-Document Created Flow
EDocumentServiceStatus.SetRange("E-Document Entry No", EDocument."Entry No");
Expand All @@ -95,6 +102,8 @@ codeunit 6102 "E-Doc. Export"
until EDocumentServiceStatus.Next() = 0;

EDocumentBackgroundJobs.StartEDocumentCreatedFlow(EDocument);

exit(true);
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ codeunit 6108 "E-Document Processing"
EDocExport.CheckEDocument(SourceDocumentHeader, EDocumentProcPhase);
end;

/// <summary>
/// Creates a new E-Document for specified posted document if possible.
/// </summary>
/// <returns>
/// true if the E-Document has been created;
/// otherwise false.
/// </returns>
procedure CreateEDocumentFromPostedDocumentPage(PostedRecord: Variant; DocumentType: Enum "E-Document Type"): Boolean
var
DocumentSendingProfile: Record "Document Sending Profile";
Expand All @@ -155,8 +162,8 @@ codeunit 6108 "E-Document Processing"
Error(ElectronicDocumentErr, DocumentSendingProfile.Code);

RunEDocumentCheck(PostedRecord, Enum::"E-Document Processing Phase"::Post);
EDocumentSubscribers.CreateEDocumentFromPostedDocument(PostedRecord, DocumentSendingProfile, DocumentType);
exit(true);

exit(EDocumentSubscribers.CreateEDocumentFromPostedDocument(PostedRecord, DocumentSendingProfile, DocumentType));
end;

procedure ProcessEDocumentAsEmail(DocumentSendingProfile: Record "Document Sending Profile"; ReportUsage: Enum "Report Selection Usage"; RecordVariant: Variant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,26 @@ codeunit 6103 "E-Document Subscribers"
EDocLogHelper.InsertLog(EDocument, EDocService, Enum::"E-Document Service Status"::"Imported Document Created");
end;

procedure CreateEDocumentFromPostedDocument(PostedRecord: Variant; DocumentSendingProfile: Record "Document Sending Profile")
/// <summary>
/// Creates a new E-Document for the provided posted document if possible.
/// </summary>
/// <returns>
/// true if the E-Document has been created;
/// otherwise false.
/// </returns>
procedure CreateEDocumentFromPostedDocument(PostedRecord: Variant; DocumentSendingProfile: Record "Document Sending Profile"): Boolean
begin
CreateEDocumentFromPostedDocument(PostedRecord, DocumentSendingProfile, EDocumentProcessing.GetTypeFromSourceDocument(PostedRecord));
exit(CreateEDocumentFromPostedDocument(PostedRecord, DocumentSendingProfile, EDocumentProcessing.GetTypeFromSourceDocument(PostedRecord)));
end;

procedure CreateEDocumentFromPostedDocument(PostedRecord: Variant; DocumentSendingProfile: Record "Document Sending Profile"; DocumentType: Enum "E-Document Type")
/// <summary>
/// Creates a new E-Document of specified type for the provided posted document if possible.
/// </summary>
/// <returns>
/// true if the E-Document has been created;
/// otherwise false.
/// </returns>
procedure CreateEDocumentFromPostedDocument(PostedRecord: Variant; DocumentSendingProfile: Record "Document Sending Profile"; DocumentType: Enum "E-Document Type"): Boolean
var
TypeHelper: Codeunit "Type Helper";
RecordRef: RecordRef;
Expand All @@ -658,9 +672,9 @@ codeunit 6103 "E-Document Subscribers"

PostedSourceDocumentHeader.GetTable(PostedRecord);
if (DocumentSendingProfile."Electronic Document" <> DocumentSendingProfile."Electronic Document"::"Extended E-Document Service Flow") then
exit;
exit(false);

EDocExport.CreateEDocument(PostedSourceDocumentHeader, DocumentSendingProfile, DocumentType);
exit(EDocExport.CreateEDocument(PostedSourceDocumentHeader, DocumentSendingProfile, DocumentType));
end;

local procedure PointEDocumentToPostedDocument(OpenRecord: Variant; PostedRecord: Variant; PostedDocumentNo: Code[20]; DocumentType: Enum "E-Document Type")
Expand Down