Why do you need this change?
Additional to #29656
Description
We need an extension point in Codeunit 13919 "Import ZUGFeRD Document" in the ParseCompleteInfo procedure, similar to the existing OnParseBasicInfoOnBeforeDocumentTypeCheck pattern that already allows us to influence the document type validation during basic parsing.
Currently, a second document type check inside ParseCompleteInfo can reintroduce issues that have already been handled in OnParseBasicInfoOnBeforeDocumentTypeCheck. We need a way to intercept and optionally override/skip this logic during the complete parsing phase.
What we want to address
- Avoid duplicate or conflicting document type validation in
ParseCompleteInfo.
- Allow partners to control or bypass the standard logic in
ParseCompleteInfo when necessary, in the same way this is already possible in ParseBasicInfo.
Requested change (single object)
In Codeunit 13919 "Import ZUGFeRD Document", in ParseCompleteInfo:
- Introduce a
CompleteInfoParsed: Boolean flag.
- Add a new integration event, e.g.
OnParseCompleteInfoOnBeforeDocumentTypeCheck, that:
- Exposes
DocumentType, EDocument, TempXMLBuffer, DocumentNamespace, CrossIndustryInvoiceLbl, PurchaseHeader, and PurchaseLine.
- Allows the subscriber to set
CompleteInfoParsed := true to skip the standard case logic.
This will align the behavior of ParseCompleteInfo with ParseBasicInfo and allow us to prevent the problematic re-validation during complete parsing.
Describe the request
In Codeunit 13919 "Import ZUGFeRD Document", the current implementation (around line 57) only subscribes to/uses OnParseBasicInfoOnBeforeDocumentTypeCheck, but not to an equivalent in ParseCompleteInfo.
However, a second validation in ParseCompleteInfo causes issues that should already be handled by OnParseBasicInfoOnBeforeDocumentTypeCheck.
Therefore, we urgently need a solution that allows us to influence the behavior in ParseCompleteInfo in the same way. An example solution would be to extend ParseCompleteInfo as follows:
procedure ParseCompleteInfo(var EDocument: Record "E-Document"; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; var TempBlob: Codeunit "Temp Blob")
var
TempXMLBuffer: Record "XML Buffer" temporary;
DocumentType: Text;
DocumentNamespace: Text;
PdfAttachmentStream: InStream;
CompleteInfoParsed: Boolean;
DocumentElementLbl: Label '%1:%2', Comment = '%1 = Namespace, %2 = Document', Locked = true;
CrossIndustryInvoiceLbl: Label 'CrossIndustryInvoice', Locked = true;
begin
FeatureTelemetry.LogUsage('0000EXS', FeatureNameTok, ContinueEventNameTok);
TempXMLBuffer.DeleteAll();
TempBlob.CreateInStream(PdfAttachmentStream);
TempXMLBuffer.LoadFromStream(PdfAttachmentStream);
EDocument.Direction := EDocument.Direction::Incoming;
DocumentNamespace := GetNamespace(TempXMLBuffer);
DocumentType := GetDocumentType(TempXMLBuffer, DocumentNamespace);
PurchaseHeader."Buy-from Vendor No." := EDocument."Bill-to/Pay-to No.";
PurchaseHeader."Currency Code" := EDocument."Currency Code";
CompleteInfoParsed := false;
OnParseCompleteInfoOnBeforeDocumentTypeCheck(DocumentType, EDocument, TempXMLBuffer, DocumentNamespace, CrossIndustryInvoiceLbl, PurchaseHeader, PurchaseLine);
if not CompleteInfoParsed then
case UpperCase(DocumentType) of
'380', '384', '751', '877':
if DocumentNamespace <> '' then
CreateInvoice(EDocument, PurchaseHeader, PurchaseLine, TempXMLBuffer, StrSubstNo(DocumentElementLbl, DocumentNamespace, CrossIndustryInvoiceLbl))
else
CreateInvoice(EDocument, PurchaseHeader, PurchaseLine, TempXMLBuffer, CrossIndustryInvoiceLbl);
'381', '261':
if DocumentNamespace <> '' then
CreateCreditMemo(EDocument, PurchaseHeader, PurchaseLine, TempXMLBuffer, StrSubstNo(DocumentElementLbl, DocumentNamespace, CrossIndustryInvoiceLbl))
else
CreateCreditMemo(EDocument, PurchaseHeader, PurchaseLine, TempXMLBuffer, CrossIndustryInvoiceLbl);
end;
FeatureTelemetry.LogUsage('0000WXJ', FeatureNameTok, StrSubstNo(EndEventNameTok, EDocument."Document Type", EDocument."Incoming E-Document No."));
end;
<------>
[IntegrationEvent(false, false)]
internal procedure OnParseCompleteInfoOnBeforeDocumentTypeCheck(var DocumentType: Text; var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentNamespace: Text; CrossIndustryInvoiceLbl: Text; var PurchaseHeader: Record "Purchase Header" temporary; var PurchaseLine: Record "Purchase Line" temporary; var CompleteInfoParsed: Boolean)
begin
end;
Internal work item: [AB#636238](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/636238)
Why do you need this change?
Additional to #29656
Description
We need an extension point in
Codeunit 13919 "Import ZUGFeRD Document"in theParseCompleteInfoprocedure, similar to the existingOnParseBasicInfoOnBeforeDocumentTypeCheckpattern that already allows us to influence the document type validation during basic parsing.Currently, a second document type check inside
ParseCompleteInfocan reintroduce issues that have already been handled inOnParseBasicInfoOnBeforeDocumentTypeCheck. We need a way to intercept and optionally override/skip this logic during the complete parsing phase.What we want to address
ParseCompleteInfo.ParseCompleteInfowhen necessary, in the same way this is already possible inParseBasicInfo.Requested change (single object)
In Codeunit 13919 "Import ZUGFeRD Document", in
ParseCompleteInfo:CompleteInfoParsed: Booleanflag.OnParseCompleteInfoOnBeforeDocumentTypeCheck, that:DocumentType,EDocument,TempXMLBuffer,DocumentNamespace,CrossIndustryInvoiceLbl,PurchaseHeader, andPurchaseLine.CompleteInfoParsed := trueto skip the standardcaselogic.This will align the behavior of
ParseCompleteInfowithParseBasicInfoand allow us to prevent the problematic re-validation during complete parsing.Describe the request
In Codeunit
13919 "Import ZUGFeRD Document", the current implementation (around line 57) only subscribes to/usesOnParseBasicInfoOnBeforeDocumentTypeCheck, but not to an equivalent inParseCompleteInfo.However, a second validation in
ParseCompleteInfocauses issues that should already be handled byOnParseBasicInfoOnBeforeDocumentTypeCheck.Therefore, we urgently need a solution that allows us to influence the behavior in
ParseCompleteInfoin the same way. An example solution would be to extendParseCompleteInfoas follows: