Custom Event
Partner haben die Möglichkeit, die Tabelle DATEV Exportierte Anhänge selbst zu füllen. Hierzu dient ein Event. Das wurde beispielhaft ebenfalls mit den Beleganhängen programmiert, um darzustellen, wie ein Partner die Tabellenfelder zu füllen hat.
Achtung
Bei fehlerhafter Bedienung gibt die SIEVERS-GROUP keine Gewährleistung auf einen fehlerfreien DATEV Export.
/// <summary>
/// Custom Event for DATEV Attachment files.
/// Only Tables Database::"Purch. Inv. Header", Database::"Purch. Cr. Memo Hdr.",
/// Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header",
/// Database::"Service Invoice Header", Database::"Service Cr.Memo Header"
/// are allowed for adding document pictures.
/// Only the following document types are allowed:
/// "Posted Purchase Invoice", "Posted Purchase Credit Memo",
/// "Posted Sales Invoice", "Posted Sales Credit Memo",
/// "Posted Service Invoice", "Posted Service Credit Memo".
/// You have to fill the following fields:
/// "File Name", "File Extension", Content.
/// Only fill the named fields. Do not insert the entry. There are some checks made on our side to prevent multiple entries.
/// Only one entry is allowed.
/// </summary>
/// <param name="DATEVSetupNo"></param>
/// <param name="SNCDATEVEntry"></param>
/// <param name="SNCDATEVExportedAttachment"></param>
[EventSubscriber(ObjectType::Codeunit, Codeunit::"SNC DATEV Export Attachm. Mgt", 'OnCreateCreateExportAttachmentForCustomSource', '', false, false)]
local procedure OnCreateCreateExportAttachmentForCustomSourceInDatevExportAttachmentMgt(
DATEVSetupNo: Code[10];
SNCDATEVEntry: Record "SNC Datev Entry";
var SNCDATEVExportedAttachment: Record "SNC DATEV Exported Attachment";
var IsHandled: Boolean
)
var
SalesInvoiceHeader: Record "Sales Invoice Header";
DocumentAttachment: Record "Document Attachment";
DocumentOutStream: OutStream;
begin
case SNCDATEVEntry."Attachment Document Type" of
SNCDATEVEntry."Attachment Document Type"::"Posted Purchase Invoice":
begin
end;
SNCDATEVEntry."Attachment Document Type"::"Posted Purchase Credit Memo":
begin
end;
SNCDATEVEntry."Attachment Document Type"::"Posted Sales Invoice":
begin
// Check if you get the posted document.
if not SalesInvoiceHeader.Get(SNCDATEVEntry."Original Document No.") then
exit;
DocumentAttachment.SetRange("File Type", DocumentAttachment."File Type"::PDF);
DocumentAttachment.SetRange("No.", SalesInvoiceHeader."No.");
if not DocumentAttachment.FindFirst() then
exit;
SNCDATEVExportedAttachment.Validate("File Name", DocumentAttachment."File Name");
SNCDATEVExportedAttachment.Validate("File Extension", DocumentAttachment."File Extension");
SNCDATEVExportedAttachment.Content.CreateOutStream(DocumentOutStream);
DocumentAttachment."Document Reference ID".ExportStream(DocumentOutStream);
// Do not Insert the entry!
IsHandled := true;
end;
SNCDATEVEntry."Attachment Document Type"::"Posted Sales Credit Memo":
begin
end;
SNCDATEVEntry."Attachment Document Type"::"Posted Service Invoice":
begin
end;
SNCDATEVEntry."Attachment Document Type"::"Posted Service Credit Memo":
begin
end;
end;
end;
Es müssen alle drei benötigten Felder gefüllt werden:
- File Name (Text[25])
- File Extension (Text[30])
- Content (Blob)
Es darf kein Insert durchgeführt werden.