diff --git a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC14/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC14/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
index 635893d..76b4eee 100644
--- a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC14/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
+++ b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC14/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
@@ -1,9 +1,9 @@
///
-/// Gather all functions that handles specific hook code (i.e. GDO) specified in group setup.
-/// Use OnBeforeGenerateHookList or OnAfterGenerateHookList to add your own custom formats code using AddNewEntry function of HookListTMP
+/// Gather all functions that handles specific hook code (i.e. GDO) specified in group setup
///
-codeunit 50000 "Outb. EDoc. Cust. Format"
+codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
{
+
var
OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup";
TmpSalesHeader: Record "Sales Header" temporary;
@@ -178,6 +178,8 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
DocumentLineTMP."No." := FldRef.Value();
DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Cross-Reference No."));
DocumentLineTMP."Cross-Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
+ DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
ItemCrossReference.SetRange("Item No.", DocumentLineTMP."No.");
@@ -187,16 +189,17 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
ItemCrossReference.SetRange("Cross-Reference No.", DocumentLineTMP."Cross-Reference No.");
if ItemCrossReference.FindSet(false, false) then
repeat
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemCrossReference."Cross-Reference Type" of
- ItemCrossReference."Cross-Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'BP');
- ItemCrossReference."Cross-Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not ((ItemCrossReference."Cross-Reference Type" = ItemCrossReference."Cross-Reference Type"::Customer) and (ItemCrossReference."Cross-Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemCrossReference."Cross-Reference Type" of
+ ItemCrossReference."Cross-Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'BP');
+ ItemCrossReference."Cross-Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
+ XmlWriter.WriteEndElement();
end;
- XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
- XmlWriter.WriteEndElement();
-
until ItemCrossReference.Next() = 0;
end;
@@ -223,6 +226,8 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
DocumentLineTMP."No." := FldRef.Value();
DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Cross-Reference No."));
DocumentLineTMP."Cross-Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
+ DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
@@ -241,17 +246,18 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
ItemCrossReference.SetRange("Cross-Reference No.", DocumentLineTMP."Cross-Reference No.");
if ItemCrossReference.FindSet(false, false) then
repeat
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemCrossReference."Cross-Reference Type" of
- ItemCrossReference."Cross-Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', '01');
- ItemCrossReference."Cross-Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not ((ItemCrossReference."Cross-Reference Type" = ItemCrossReference."Cross-Reference Type"::Customer) and (ItemCrossReference."Cross-Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemCrossReference."Cross-Reference Type" of
+ ItemCrossReference."Cross-Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', '01');
+ ItemCrossReference."Cross-Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+
+ XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
+ XmlWriter.WriteEndElement();
end;
-
- XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
- XmlWriter.WriteEndElement();
-
until ItemCrossReference.Next() = 0;
end;
@@ -325,6 +331,8 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
DocumentLineTMP."No." := FldRef.Value();
DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Cross-Reference No."));
DocumentLineTMP."Cross-Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
+ DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
@@ -343,15 +351,17 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
ItemCrossReference.SetRange("Cross-Reference No.", DocumentLineTMP."Cross-Reference No.");
if ItemCrossReference.FindSet(false, false) then
repeat
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemCrossReference."Cross-Reference Type" of
- ItemCrossReference."Cross-Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'IN');
- ItemCrossReference."Cross-Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EN');
+ if not ((ItemCrossReference."Cross-Reference Type" = ItemCrossReference."Cross-Reference Type"::Customer) and (ItemCrossReference."Cross-Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemCrossReference."Cross-Reference Type" of
+ ItemCrossReference."Cross-Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'IN');
+ ItemCrossReference."Cross-Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
+ XmlWriter.WriteEndElement();
end;
- XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
- XmlWriter.WriteEndElement();
until ItemCrossReference.Next() = 0;
end;
@@ -378,6 +388,8 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
DocumentLineTMP."No." := FldRef.Value();
DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Cross-Reference No."));
DocumentLineTMP."Cross-Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
+ DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
@@ -397,18 +409,18 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
ItemCrossReference.SetRange("Cross-Reference No.", DocumentLineTMP."Cross-Reference No.");
if ItemCrossReference.FindSet(false, false) then
repeat
- XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'articolobrico');
- case ItemCrossReference."Cross-Reference Type" of
- ItemCrossReference."Cross-Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
- ItemCrossReference."Cross-Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not ((ItemCrossReference."Cross-Reference Type" = ItemCrossReference."Cross-Reference Type"::Customer) and (ItemCrossReference."Cross-Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemCrossReference."Cross-Reference Type" of
+ ItemCrossReference."Cross-Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
+ ItemCrossReference."Cross-Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+
+ XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
+ XmlWriter.WriteEndElement();
end;
-
- XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
- XmlWriter.WriteEndElement();
-
until ItemCrossReference.Next() = 0;
end;
@@ -501,6 +513,8 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
DocumentLineTMP."No." := FldRef.Value();
DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Cross-Reference No."));
DocumentLineTMP."Cross-Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
+ DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
@@ -519,18 +533,18 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
ItemCrossReference.SetRange("Cross-Reference No.", DocumentLineTMP."Cross-Reference No.");
if ItemCrossReference.FindSet(false, false) then
repeat
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemCrossReference."Cross-Reference Type" of
- ItemCrossReference."Cross-Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'BP');
- ItemCrossReference."Cross-Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not ((ItemCrossReference."Cross-Reference Type" = ItemCrossReference."Cross-Reference Type"::Customer) and (ItemCrossReference."Cross-Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemCrossReference."Cross-Reference Type" of
+ ItemCrossReference."Cross-Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'BP');
+ ItemCrossReference."Cross-Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
+ XmlWriter.WriteEndElement();
end;
- XmlWriter.WriteElementValue('CodiceValore', ItemCrossReference."Cross-Reference No.");
- XmlWriter.WriteEndElement();
-
until ItemCrossReference.Next() = 0;
-
end;
end;
Handled := true;
@@ -638,14 +652,14 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
'EOS_OTTIMAX':
begin
- orderNo := line.Field(BufferTMP.FieldNo("EOS Order No.")).Value();
- headerOrder.SetRange("No.", orderNo);
- if (not NotDirectShip) or headerOrder.IsEmpty then begin
+ if not NotDirectShip then begin
DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No."));
DocumentTMP."Sell-to Customer No." := FldRef.Value();
DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code"));
DocumentTMP."Ship-to Code" := FldRef.Value();
end else begin
+ orderNo := line.Field(BufferTMP.FieldNo("EOS Order No.")).Value();
+ headerOrder.SetRange("No.", orderNo);
headerOrder.FindSet();
DocumentTMP."Sell-to Customer No." := headerOrder."Sell-to Customer No.";
@@ -1338,6 +1352,7 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
DataOrd: Date;
CIG: Code[15];
CUP: Code[15];
+ CodiceCommessaConvenzione: Text[100];
IsHandled: Boolean;
NoPurchOrderErr: Label 'AMAZON: DatiOrdineAcquisto mandatory for %1 document.';
NoReasonCodeErr: Label 'AMAZON: Reason code mandatory for document %1.';
@@ -1346,7 +1361,7 @@ codeunit 50000 "Outb. EDoc. Cust. Format"
EOSFEData.setHeader(header);
DocumentReason := GetAMAZONReasonCode(header);
EOSFEData.getRelDocsTagsForCurrDoc(ElectrDocRelatedDocsTMP);
- EOSFEData.hasDirectOrder(NumeroOrd, DataOrd, CIG, CUP);
+ EOSFEData.hasDirectOrder(NumeroOrd, DataOrd, CIG, CUP, CodiceCommessaConvenzione);
case header.Number() of
database::"Sales Invoice Header":
case DocumentReason of
diff --git a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC25/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC25/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
index 53d93b1..f8bef5c 100644
--- a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC25/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
+++ b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC25/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
@@ -465,7 +465,6 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
if not isHandled then
if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'articolobrico');
case ItemReference."Reference Type" of
ItemReference."Reference Type"::Customer:
XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
diff --git a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC26/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC26/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
index 53d93b1..f8bef5c 100644
--- a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC26/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
+++ b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC26/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
@@ -465,7 +465,6 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
if not isHandled then
if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'articolobrico');
case ItemReference."Reference Type" of
ItemReference."Reference Type"::Customer:
XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
diff --git a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC27/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC27/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
index 53d93b1..1cc9c2b 100644
--- a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC27/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
+++ b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC27/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
@@ -6,54 +6,32 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
var
OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup";
- TmpSalesHeader: Record "Sales Header" temporary;
- TmpShipHeader: Record "Sales Shipment Header" temporary;
- ReturnReceiptHeaderTMP: Record "Return Receipt Header" temporary;
- TmpServiceHeader: Record "Service Header" temporary;
- TmpServShipHeader: Record "Service Shipment Header" temporary;
EOSEDocSetupMgt: Codeunit "EOS EDoc. Setup Management";
DataTypeManagement: Codeunit "Data Type Management";
EOSFEData: Codeunit "EOS FE Data";
+ [Obsolete('Not Used.', '27.0')]
procedure SetSalesInvoiceTmpBuffer(var inTmpSalesHeader: Record "Sales Header" temporary; var inTmpShipHeader: Record "Sales Shipment Header" temporary)
begin
- if inTmpSalesHeader.FindSet() then
- repeat
- TmpSalesHeader := inTmpSalesHeader;
- TmpSalesHeader.Insert();
- until inTmpSalesHeader.Next() = 0;
-
- if inTmpShipHeader.FindSet() then
- repeat
- TmpShipHeader := inTmpShipHeader;
- TmpShipHeader.Insert();
- until inTmpShipHeader.Next() = 0;
end;
+ [Obsolete('Not Used.', '27.0')]
procedure SetSalesCrMemoTmpBuffer(var inReturnReceiptHeaderTMP: Record "Return Receipt Header" temporary)
begin
- if inReturnReceiptHeaderTMP.FindSet() then
- repeat
- ReturnReceiptHeaderTMP := inReturnReceiptHeaderTMP;
- ReturnReceiptHeaderTMP.Insert();
- until inReturnReceiptHeaderTMP.Next() = 0;
end;
+ [Obsolete('Not Used.', '27.0')]
procedure SetServiceInvoiceTmpBuffer(var inTmpServiceHeader: Record "Service Header" temporary; var inTmpServShipHeader: Record "Service Shipment Header" temporary)
begin
- if inTmpServiceHeader.FindSet() then
- repeat
- TmpServiceHeader := inTmpServiceHeader;
- TmpServiceHeader.Insert();
- until inTmpServiceHeader.Next() = 0;
-
- if inTmpServShipHeader.FindSet() then
- repeat
- TmpServShipHeader := inTmpServShipHeader;
- TmpServShipHeader.Insert();
- until inTmpServShipHeader.Next() = 0;
end;
+ ///
+ /// Determines whether the PEC (Posta Elettronica Certificata) address should always be exported for the given customer.
+ /// Returns true if the customer belongs to a hook group that requires mandatory PEC export (e.g., AMAZON).
+ ///
+ /// The Customer No. to check
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// True if PEC should always be exported, false otherwise
procedure AlwaysExportPEC(CustNo: Code[20]; header: RecordRef) RetValue: Boolean
var
begin
@@ -66,6 +44,12 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
];
end;
+ ///
+ /// Retrieves the Reason Code from the document header.
+ /// Raises OnBeforeGetReasonCode event to allow customization before retrieving the standard value.
+ ///
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The Reason Code associated with the document
procedure GetDocumentReasonCode(header: RecordRef) Result: Code[10];
var
TempDocument: Record "Sales Invoice Header" temporary;
@@ -80,11 +64,20 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
+ ///
+ /// Event subscriber that handles the CodiceArticolo (Item Code) XML element generation for various GDO (Grande Distribuzione Organizzata) hook groups.
+ /// Each hook group has specific requirements for how item codes should be formatted and exported in the electronic invoice.
+ /// Supported hook groups include: AMAZON, BRICO_CENT, CANOVA, CARREFOUR, CHEF, UNICOOPTIR, CONAD_SIC, IGES, GS1, COOPALL3, METRO, AUTOGRILL, RIALTO, FERRARI, OBI, BRICO_SELF.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to indicate that the CodiceArticolo has been handled and default processing should be skipped
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddCodiceArticolo', '', true, false)]
local procedure OnBefore_CodiceArticolo(header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var handled: Boolean)
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
- DocumentLineTMP: Record "Sales Invoice Line" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
CompanyInfoPA: Record "EOS Outb. Electr. Doc. Setup";
ItemReference: Record "Item Reference";
FldRef: FieldRef;
@@ -92,7 +85,7 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
CustNo: Code[20];
isHandled: Boolean;
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
Handled := false;
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
@@ -101,41 +94,40 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
'EOS_AMAZON':
AMAZON_OnBefore_CodiceArticolo(header, line, XmlWriter, handled);
'EOS_BRICO_CENT':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
isHandled := false;
OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
if not isHandled then
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'INTERNALCODE');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
//CrossReference
- if DocumentLineTMP."Item Reference No." <> '' then begin
+ if TempDocumentLine."Item Reference No." <> '' then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'articolobrico');
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."Item Reference No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."Item Reference No.");
XmlWriter.WriteEndElement();
end;
end;
@@ -144,35 +136,31 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_CANOVA':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
+ Clear(TempDocumentLine);
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
isHandled := false;
OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
if not isHandled then
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'INTERNALCODE');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
end;
@@ -181,33 +169,30 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_CARREFOUR':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
- DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
-
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
- ItemReference.SetRange("Item No.", DocumentLineTMP."No.");
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
ItemReference.SetFilter("Reference Type", '%1|%2',
ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
- if DocumentLineTMP."Item Reference No." <> '' then
- ItemReference.SetRange("Reference No.", DocumentLineTMP."Item Reference No.");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
@@ -218,7 +203,7 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
isHandled := false;
OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
if not isHandled then
- if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
XmlWriter.WriteStartElement('CodiceArticolo');
case ItemReference."Reference Type" of
ItemReference."Reference Type"::Customer:
@@ -237,62 +222,59 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_CHEF':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
- DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
-
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', '99');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
- ItemReference.SetRange("Item No.", DocumentLineTMP."No.");
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
ItemReference.SetFilter("Reference Type", '%1|%2',
ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
- if DocumentLineTMP."Item Reference No." <> '' then
- ItemReference.SetRange("Reference No.", DocumentLineTMP."Item Reference No.");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if ItemReference.FindSet() then
- repeat
- isHandled := false;
- OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if not isHandled then
- if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemReference."Reference Type" of
- ItemReference."Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', '01');
- ItemReference."Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', '01');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
end;
-
- XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
- XmlWriter.WriteEndElement();
- end;
- until ItemReference.Next() = 0;
+ until ItemReference.Next() = 0;
end;
end;
@@ -300,117 +282,112 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_UNICOOPTIR':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
-
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
- ItemReference.SetRange("Item No.", DocumentLineTMP."No.");
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
ItemReference.SetFilter("Reference Type", '%1', ItemReference."Reference Type"::"Bar Code");
- if DocumentLineTMP."Item Reference No." <> '' then
- ItemReference.SetRange("Reference No.", DocumentLineTMP."Item Reference No.");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if ItemReference.FindSet() then
- repeat
- isHandled := false;
- OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if not isHandled then begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
- XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
- XmlWriter.WriteEndElement();
- end;
- until ItemReference.Next() = 0
- else begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'Codice Uso Fornitore');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
- else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
- XmlWriter.WriteEndElement();
-
- end;
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0
+ else begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'Codice Uso Fornitore');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+ end;
end;
end;
Handled := true;
end;
'EOS_CONAD_SIC', 'EOS_IGES', 'EOS_GS1':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
- DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
-
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'SA');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
- ItemReference.SetRange("Item No.", DocumentLineTMP."No.");
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
ItemReference.SetFilter("Reference Type", '%1|%2',
ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
- if DocumentLineTMP."Item Reference No." <> '' then
- ItemReference.SetRange("Reference No.", DocumentLineTMP."Item Reference No.");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if ItemReference.FindSet() then
- repeat
- isHandled := false;
- OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if not isHandled then
- if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemReference."Reference Type" of
- ItemReference."Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'IN');
- ItemReference."Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EN');
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'IN');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
end;
- XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
- XmlWriter.WriteEndElement();
- end;
- until ItemReference.Next() = 0;
+ until ItemReference.Next() = 0;
end;
end;
@@ -418,65 +395,61 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_COOPALL3':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
- DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
-
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Fornitore');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
- ItemReference.SetRange("Item No.", DocumentLineTMP."No.");
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
ItemReference.SetFilter("Reference Type", '%1|%2',
ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
- if DocumentLineTMP."Item Reference No." <> '' then
- ItemReference.SetRange("Reference No.", DocumentLineTMP."Item Reference No.");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if ItemReference.FindSet() then
- repeat
- isHandled := false;
- OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if not isHandled then
- if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'articolobrico');
- case ItemReference."Reference Type" of
- ItemReference."Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
- ItemReference."Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
end;
-
- XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
- XmlWriter.WriteEndElement();
- end;
- until ItemReference.Next() = 0;
+ until ItemReference.Next() = 0;
end;
end;
@@ -484,36 +457,33 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_METRO':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
isHandled := false;
OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
if not isHandled then
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'cod');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
end;
end;
@@ -521,34 +491,31 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_AUTOGRILL':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
isHandled := false;
OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
if not isHandled then
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'GDS');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
end;
end;
@@ -556,62 +523,60 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_RIALTO':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Sell-to Customer No."));
- DocumentLineTMP."Sell-to Customer No." := FldRef.Value();
-
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'SA');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
- ItemReference.SetRange("Item No.", DocumentLineTMP."No.");
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
ItemReference.SetFilter("Reference Type", '%1|%2',
ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
- if DocumentLineTMP."Item Reference No." <> '' then
- ItemReference.SetRange("Reference No.", DocumentLineTMP."Item Reference No.");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if ItemReference.FindSet() then
- repeat
- isHandled := false;
- OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if not isHandled then
- if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> DocumentLineTMP."Sell-to Customer No.")) then begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- case ItemReference."Reference Type" of
- ItemReference."Reference Type"::Customer:
- XmlWriter.WriteElementValue('CodiceTipo', 'BP');
- ItemReference."Reference Type"::"Bar Code":
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'BP');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
end;
- XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
- XmlWriter.WriteEndElement();
- end;
- until ItemReference.Next() = 0;
+ until ItemReference.Next() = 0;
end;
end;
Handled := true;
@@ -623,35 +588,32 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
// il valore deve essere allineato a sinistra, riempiendo i campi vuoti di commessa con BLANK. Commessa di riga fattura
// Creare routine custom per gestire stringa
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Job No."));
- DocumentLineTMP."Job No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Job No."));
+ TempDocumentLine."Job No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
isHandled := false;
OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
if not isHandled then
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
// Create string following Ferrari request
- DummyText := CopyStr(PadStr(DocumentLineTMP."Job No.", 9, ' ') + DocumentLineTMP."Item Reference No.", 1, 20);
+ DummyText := CopyStr(PadStr(TempDocumentLine."Job No.", 9, ' ') + TempDocumentLine."Item Reference No.", 1, 20);
if DummyText <> '' then begin
XmlWriter.WriteStartElement('CodiceArticolo');
@@ -666,35 +628,31 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_OBI', 'EOS_BRICO_SELF':
- if line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
CompanyInfoPA.Get();
if CompanyInfoPA."EOS Add Item Code" then begin
- Clear(DocumentTMP);
- Clear(DocumentLineTMP);
-
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
+ Clear(TempDocumentLine);
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
isHandled := false;
OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
if not isHandled then
- if DocumentLineTMP.Type = DocumentLineTMP.Type::Item then begin
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'SA');
- if DocumentLineTMP."Variant Code" <> '' then
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No." + ' ' + DocumentLineTMP."Variant Code")
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
else
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
end;
end;
@@ -703,20 +661,30 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
+ ///
+ /// Event subscriber that handles the CodiceCommessaConvenzione element (ID 2.1.2.5) for specific hook groups.
+ /// Fills the Store Code value from Ship-to Address or Customer for OTTIMAX hook group.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef or RifLineNo Buffer
+ /// The name of the XML element being processed
+ /// The FatturaPA element ID (e.g., '2.1.2.5' for CodiceCommessaConvenzione)
+ /// The value to be written to the XML element
+ /// The XML Writer used to generate the electronic invoice XML
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddElementText', '', true, false)]
local procedure OnFillCommConvDatiOdA(header: RecordRef; line: RecordRef; var elementName: Text[250]; id: Text; var Value: Text; var XmlWriter: Codeunit "EOS Xml Writer")
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
- BufferTMP: Record "EOS RifLineNo Buffer" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
+ TempBuffer: Record "EOS RifLineNo Buffer" temporary;
headerOrder: Record "Sales Header";
ShiptoAddress: Record "Ship-to Address";
Customer: Record Customer;
FldRef: FieldRef;
NotDirectShip: Boolean;
CustNo: Code[20];
- orderNo: code[20];
+ orderNo: Code[20];
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if id = '2.1.2.5' then begin
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
@@ -725,25 +693,25 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
'EOS_OTTIMAX':
begin
- orderNo := line.Field(BufferTMP.FieldNo("EOS Order No.")).Value();
+ orderNo := line.field(TempBuffer.FieldNo("EOS Order No.")).Value();
headerOrder.SetRange("No.", orderNo);
- if (not NotDirectShip) or headerOrder.IsEmpty then begin
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No."));
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code"));
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if (not NotDirectShip) or headerOrder.IsEmpty() then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No."));
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code"));
+ TempDocument."Ship-to Code" := FldRef.Value();
end else begin
- headerOrder.FindSet();
+ headerOrder.FindFirst();
- DocumentTMP."Sell-to Customer No." := headerOrder."Sell-to Customer No.";
- DocumentTMP."Ship-to Code" := headerOrder."Ship-to Code";
+ TempDocument."Sell-to Customer No." := headerOrder."Sell-to Customer No.";
+ TempDocument."Ship-to Code" := headerOrder."Ship-to Code";
end;
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" <> '' then
Value := ShiptoAddress."EOS Store Code"
else begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
Value := Customer."EOS Store Code";
end;
end;
@@ -753,17 +721,24 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
+ ///
+ /// Event subscriber that populates the Related Documents buffer with additional data for specific hook groups.
+ /// For METRO: Adds DatiRicezione with Store Code (ILN code).
+ /// For AGRINTESA: Adds DatiRicezione with Document No.
+ ///
+ /// The document header RecordRef
+ /// Temporary buffer containing related document information for the electronic invoice
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnFillElectrDocRelatedDocsBuffer', '', true, false)]
local procedure OnFillElectrDocRelatedDocsBuffer(header: RecordRef; var ElectrDocRelatedDocsTMP: Record "EOS Outb. EDoc. Related Docs." temporary)
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
Customer: Record Customer;
ShiptoAddress: Record "Ship-to Address";
FldRef: FieldRef;
CustNo: Code[20];
LineNo: Integer;
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
if not ElectrDocRelatedDocsTMP.FindLast() then
@@ -774,24 +749,24 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
case OutbElectrDocSetupGroup."EOS Hook Group Code" of
'EOS_METRO':
begin
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("No."));
+ TempDocument."No." := FldRef.Value();
// Codice o ILN fornitore
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Bill-to Customer No."));
- DocumentTMP."Bill-to Customer No." := FldRef.Value();
- Customer.Get(DocumentTMP."Bill-to Customer No.");
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Bill-to Customer No."));
+ TempDocument."Bill-to Customer No." := FldRef.Value();
+ Customer.Get(TempDocument."Bill-to Customer No.");
// Codice o ILN store
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No."));
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code"));
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No."));
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code"));
+ TempDocument."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
end;
@@ -800,7 +775,7 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
ElectrDocRelatedDocsTMP.Init();
ElectrDocRelatedDocsTMP."EOS Table ID" := header.Number();
ElectrDocRelatedDocsTMP."EOS Document Type" := 0;
- ElectrDocRelatedDocsTMP."EOS Document No." := DocumentTMP."No.";
+ ElectrDocRelatedDocsTMP."EOS Document No." := TempDocument."No.";
ElectrDocRelatedDocsTMP."EOS Document RecordID" := header.RecordId();
ElectrDocRelatedDocsTMP."EOS Type" := ElectrDocRelatedDocsTMP."EOS Type"::DatiRicezione;
ElectrDocRelatedDocsTMP."EOS IdDocumento" := ShiptoAddress."EOS Store Code";
@@ -812,28 +787,38 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
'EOS_AGRINTESA':
begin
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("No."));
+ TempDocument."No." := FldRef.Value();
LineNo += 10000;
ElectrDocRelatedDocsTMP.Init();
ElectrDocRelatedDocsTMP."EOS Table ID" := header.Number();
ElectrDocRelatedDocsTMP."EOS Document Type" := 0;
- ElectrDocRelatedDocsTMP."EOS Document No." := DocumentTMP."No.";
+ ElectrDocRelatedDocsTMP."EOS Document No." := TempDocument."No.";
ElectrDocRelatedDocsTMP."EOS Document RecordID" := header.RecordId();
ElectrDocRelatedDocsTMP."EOS Type" := ElectrDocRelatedDocsTMP."EOS Type"::DatiRicezione;
- ElectrDocRelatedDocsTMP."EOS IdDocumento" := DocumentTMP."No.";
+ ElectrDocRelatedDocsTMP."EOS IdDocumento" := TempDocument."No.";
ElectrDocRelatedDocsTMP."EOS Line No." := LineNo;
ElectrDocRelatedDocsTMP.Insert(true);
end;
end;
end;
+ ///
+ /// Event subscriber that handles the AltriDatiGestionali (Other Management Data) XML element (ID 2.2.1.16) for various hook groups.
+ /// Each hook group has specific requirements for additional data to be included at the line level.
+ /// Supported hook groups: LEROY (Negozio), BRICO_IO (CDC), CANOVA/CARREFOUR/RIALTO (DP), ESSELUNGA (DP with shipment info),
+ /// CAMST (PLANT from dimension), CONAD_SIC/IGES (PCONSEGNA), COOPALL3 (DP, DEST.MERCI, INDIRIZZO),
+ /// UNICOOPTIR (CPV), AUTOGRILL (PV), CHEF (DP), OBI (DP).
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnAddAltriDatiGestionali_2_2_1_16', '', true, false)]
local procedure OnFillAltriDatiGestionaliTag(header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer")
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
- DocumentLineTMP: Record "Sales Invoice Line" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
ShiptoAddress: Record "Ship-to Address";
Customer: Record Customer;
TempDimSetEntry: Record "Dimension Set Entry" temporary;
@@ -843,49 +828,47 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
SalesShipmentHeader: Record "Sales Shipment Header";
DimensionManagement: Codeunit DimensionManagement;
FldRef: FieldRef;
- HeaderDone: Boolean;
CustNo: Code[20];
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
-
case OutbElectrDocSetupGroup."EOS Hook Group Code" of
'EOS_LEROY':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Description" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
end;
if ShiptoAddress."EOS Store Description" <> '' then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'Negozio');
- XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Description" <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Description");
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Description");
XmlWriter.WriteEndElement();
end;
end;
'EOS_BRICO_IO':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
-
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
exit;
XmlWriter.WriteStartElement('AltriDatiGestionali');
@@ -895,77 +878,77 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_CANOVA', 'EOS_CARREFOUR', 'EOS_RIALTO':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
end;
if ShiptoAddress."EOS Store Code" <> '' then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'DP');
- XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Code" <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
XmlWriter.WriteEndElement();
end;
end;
'EOS_ESSELUNGA':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
- if Line.Number() = DATABASE::"Sales Invoice Line" then begin
+ if Line.Number() = Database::"Sales Invoice Line" then begin
DataTypeManagement.FindFieldByName(Line, FldRef, SalesInvoiceLine.FieldName("Shipment No."));
- DocumentTMP."Order No." := FldRef.Value();
- if SalesShipmentHeader.Get(DocumentTMP."Order No.") then
+ TempDocument."Order No." := FldRef.Value();
+ if SalesShipmentHeader.Get(TempDocument."Order No.") then
if SalesShipmentHeader."Ship-to Code" <> '' then
- DocumentTMP."Ship-to Code" := SalesShipmentHeader."Ship-to Code";
+ TempDocument."Ship-to Code" := SalesShipmentHeader."Ship-to Code";
end else
- if Line.Number() = DATABASE::"Sales Cr.Memo Line" then begin
+ if Line.Number() = Database::"Sales Cr.Memo Line" then begin
DataTypeManagement.FindFieldByName(Line, FldRef, SalesCrMemoLine.FieldName("Return Receipt No."));
- DocumentTMP."Order No." := FldRef.Value();
- if ReturnReceiptHeader.Get(DocumentTMP."Order No.") then
+ TempDocument."Order No." := FldRef.Value();
+ if ReturnReceiptHeader.Get(TempDocument."Order No.") then
if ReturnReceiptHeader."Ship-to Code" <> '' then
- DocumentTMP."Ship-to Code" := ReturnReceiptHeader."Ship-to Code";
+ TempDocument."Ship-to Code" := ReturnReceiptHeader."Ship-to Code";
end;
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
end;
if ShiptoAddress."EOS Store Code" <> '' then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'DP');
- XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Code" <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
XmlWriter.WriteEndElement();
end;
end;
'EOS_CAMST':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(Line, FldRef, DocumentLineTMP.FieldName("Dimension Set ID")) then
- DocumentTMP."Dimension Set ID" := FldRef.Value();
- if DocumentTMP."Dimension Set ID" = 0 then
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(Line, FldRef, TempDocumentLine.FieldName("Dimension Set ID")) then
+ TempDocument."Dimension Set ID" := FldRef.Value();
+ if TempDocument."Dimension Set ID" = 0 then
exit;
- DimensionManagement.GetDimensionSet(TempDimSetEntry, DocumentTMP."Dimension Set ID");
+ DimensionManagement.GetDimensionSet(TempDimSetEntry, TempDocument."Dimension Set ID");
TempDimSetEntry.SetRange("Dimension Code", 'CDCCAMST'); // Centro di Costo fornito da CAMST
if TempDimSetEntry.FindFirst() then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
@@ -976,16 +959,16 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_CONAD_SIC', 'EOS_IGES':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" + ShiptoAddress."EOS Store Description" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
end;
@@ -1000,65 +983,56 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_COOPALL3':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" + ShiptoAddress."EOS Store Description" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
end;
// GLN code
if ShiptoAddress."EOS Store Code" <> '' then begin
- if not HeaderDone then begin
- XmlWriter.WriteStartElement('AltriDatiGestionali');
- HeaderDone := true;
- end;
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'DP');
XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
end;
// Store Description
if ShiptoAddress."EOS Store Description" <> '' then begin
- if not HeaderDone then begin
- XmlWriter.WriteStartElement('AltriDatiGestionali');
- HeaderDone := true;
- end;
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'DEST.MERCI');
XmlWriter.WriteElementValue('RiferimentoTesto', CopyStr(ShiptoAddress."EOS Store Description", 1, 60));
-
+ XmlWriter.WriteEndElement();
end;
// Store Address
if ShiptoAddress.Address <> '' then begin
- if not HeaderDone then begin
- XmlWriter.WriteStartElement('AltriDatiGestionali');
- HeaderDone := true;
- end;
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'INDIRIZZO');
XmlWriter.WriteElementValue('RiferimentoTesto', CopyStr(ShiptoAddress.Address + ' ' + ShiptoAddress."Post Code" + ' ' + ShiptoAddress.County, 1, 60));
- end;
- if HeaderDone then
XmlWriter.WriteEndElement();
+ end;
end;
'EOS_UNICOOPTIR':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
end;
@@ -1072,42 +1046,42 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'EOS_AUTOGRILL':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
end;
if ShiptoAddress."EOS Store Code" <> '' then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'PV');
- XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Code" <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
XmlWriter.WriteEndElement();
end;
end;
'EOS_CHEF':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" + ShiptoAddress."EOS Store Description" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
end;
@@ -1115,31 +1089,31 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
if ShiptoAddress."EOS Store Description" + ShiptoAddress."EOS Store Code" <> '' then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'DP');
- XmlWriter.WriteElementValueIf((ShiptoAddress."EOS Store Description" + ShiptoAddress."EOS Store Code") <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Description" + ' - ' + ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Description" + ' - ' + ShiptoAddress."EOS Store Code");
XmlWriter.WriteEndElement();
end;
end;
'EOS_OBI':
- if Line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"] then begin
- Clear(DocumentTMP);
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Sell-to Customer No.")) then
- DocumentTMP."Sell-to Customer No." := FldRef.Value();
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
- if DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Code")) then
- DocumentTMP."Ship-to Code" := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
- if not ShiptoAddress.Get(DocumentTMP."Sell-to Customer No.", DocumentTMP."Ship-to Code") then
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
Clear(ShiptoAddress);
if ShiptoAddress."EOS Store Code" = '' then begin
- Customer.get(DocumentTMP."Sell-to Customer No.");
+ Customer.Get(TempDocument."Sell-to Customer No.");
ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
end;
if ShiptoAddress."EOS Store Code" <> '' then begin
XmlWriter.WriteStartElement('AltriDatiGestionali');
XmlWriter.WriteElementValue('TipoDato', 'DP');
- XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Code" <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
XmlWriter.WriteEndElement();
end;
end;
@@ -1147,16 +1121,26 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
+ ///
+ /// Event subscriber that handles the Causale (Reason) XML element for various hook groups.
+ /// Each hook group has specific requirements for how the reason/cause should be formatted.
+ /// Supported hook groups: AMAZON (exports Reason Code for Credit Memos), CARREFOUR (MERCI/FRANCHISING/EXTRAFATTURA),
+ /// CONAD_SIC/IGES (MAGAZZINO/RIFATTURAZIONE/SERVIZI), UNICOOPTIR (M/S), COOPALL3, STEFF (DANNI_/GEN_),
+ /// ASCA/MARR (Ship-to address information).
+ ///
+ /// The document header RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to indicate that default Causale processing should be skipped
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddCausaleTags', '', true, false)]
local procedure OnFillCausaleTag(header: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var handled: Boolean)
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
ReasonCode: Record "Reason Code";
FldRef: FieldRef;
CustNo: Code[20];
SkipHookHandling: Boolean;
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
@@ -1166,73 +1150,82 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
if SkipHookHandling then
exit;
- DocumentTMP."Reason Code" := GetDocumentReasonCode(header);
+ TempDocument."Reason Code" := GetDocumentReasonCode(header);
case OutbElectrDocSetupGroup."EOS Hook Group Code" of
'EOS_AMAZON':
- IF header.NUMBER() IN [DATABASE::"Sales Cr.Memo Header"] THEN
- IF DocumentTMP."Reason Code" <> '' THEN
- IF ReasonCode.GET(DocumentTMP."Reason Code") THEN
+ if header.NUMBER() in [Database::"Sales Cr.Memo Header"] then
+ if TempDocument."Reason Code" <> '' then
+ if ReasonCode.Get(TempDocument."Reason Code") then
XmlWriter.WriteElementValueIf(ReasonCode."EOS AMZ Exp. To EDoc.", 'Causale', ReasonCode.Code);
'EOS_CARREFOUR':
// Check reasons mapped as "MERCI", "FRANCHISING", "EXTRAFATTURA" or customize
- XmlWriter.WriteElementValueIf(ReasonCode.Get(DocumentTMP."Reason Code"), 'Causale', ReasonCode.Description);
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
'EOS_CONAD_SIC', 'EOS_IGES':
// Check reasons mapped as "MAGAZZINO", "RIFATTURAZIONE", "SERVIZI" or customize
- XmlWriter.WriteElementValueIf(ReasonCode.Get(DocumentTMP."Reason Code"), 'Causale', ReasonCode.Description);
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
'EOS_UNICOOPTIR':
// Check reasons mapped as "M" (merci), "S" (servizi) or customize
- XmlWriter.WriteElementValueIf(ReasonCode.Get(DocumentTMP."Reason Code"), 'Causale', ReasonCode.Description);
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
'EOS_COOPALL3':
- XmlWriter.WriteElementValueIf(ReasonCode.Get(DocumentTMP."Reason Code"), 'Causale', ReasonCode.Description);
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
'EOS_STEFF':
// Check reasons mapped as "DANNI_", "GEN_" or customize
- XmlWriter.WriteElementValueIf(ReasonCode.Get(DocumentTMP."Reason Code"), 'Causale', ReasonCode.Description);
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
'EOS_ASCA', 'EOS_MARR':
begin
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Name"));
- DocumentTMP."Ship-to Name" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Name 2"));
- DocumentTMP."Ship-to Name 2" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Address"));
- DocumentTMP."Ship-to Address" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Address 2"));
- DocumentTMP."Ship-to Address 2" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to City"));
- DocumentTMP."Ship-to City" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to County"));
- DocumentTMP."Ship-to County" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Country/Region Code"));
- DocumentTMP."Ship-to Country/Region Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Post Code"));
- DocumentTMP."Ship-to Post Code" := FldRef.Value();
-
- if DocumentTMP."Ship-to Name" + DocumentTMP."Ship-to Name 2" <> '' then
- XmlWriter.WriteElementValue('Causale', DocumentTMP."Ship-to Name" + ' ' + DocumentTMP."Ship-to Name 2");
-
- if DocumentTMP."Ship-to Address" + DocumentTMP."Ship-to Address 2" <> '' then
- XmlWriter.WriteElementValue('Causale', DocumentTMP."Ship-to Address" + ' ' + DocumentTMP."Ship-to Address 2");
-
- if DocumentTMP."Ship-to Post Code" + DocumentTMP."Ship-to City" +
- DocumentTMP."Ship-to County" + DocumentTMP."Ship-to Country/Region Code" <> '' then
- XmlWriter.WriteElementValue('Causale', DocumentTMP."Ship-to Post Code" + ' ' + DocumentTMP."Ship-to City" + ' ' +
- DocumentTMP."Ship-to County" + ' ' + DocumentTMP."Ship-to Country/Region Code");
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Name"));
+ TempDocument."Ship-to Name" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Name 2"));
+ TempDocument."Ship-to Name 2" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Address"));
+ TempDocument."Ship-to Address" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Address 2"));
+ TempDocument."Ship-to Address 2" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to City"));
+ TempDocument."Ship-to City" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to County"));
+ TempDocument."Ship-to County" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Country/Region Code"));
+ TempDocument."Ship-to Country/Region Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Post Code"));
+ TempDocument."Ship-to Post Code" := FldRef.Value();
+
+ if TempDocument."Ship-to Name" + TempDocument."Ship-to Name 2" <> '' then
+ XmlWriter.WriteElementValue('Causale', TempDocument."Ship-to Name" + ' ' + TempDocument."Ship-to Name 2");
+
+ if TempDocument."Ship-to Address" + TempDocument."Ship-to Address 2" <> '' then
+ XmlWriter.WriteElementValue('Causale', TempDocument."Ship-to Address" + ' ' + TempDocument."Ship-to Address 2");
+
+ if TempDocument."Ship-to Post Code" + TempDocument."Ship-to City" +
+ TempDocument."Ship-to County" + TempDocument."Ship-to Country/Region Code" <> '' then
+ XmlWriter.WriteElementValue('Causale', TempDocument."Ship-to Post Code" + ' ' + TempDocument."Ship-to City" + ' ' +
+ TempDocument."Ship-to County" + ' ' + TempDocument."Ship-to Country/Region Code");
end;
end;
end;
- //endElement('DettaglioPagamento', '2.4.2', true);//DettaglioPagamento
+ ///
+ /// Event subscriber that handles the CodicePagamento (Payment Code) XML element within DettaglioPagamento (ID 2.4.2) for specific hook groups.
+ /// For BRICO_IO: Combines Payment Method Description and Payment Terms Description into the CodicePagamento field.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The name of the XML element being processed
+ /// The FatturaPA element ID (e.g., '2.4.2' for DettaglioPagamento)
+ /// Indicates whether the end tag should be inserted
+ /// The XML Writer used to generate the electronic invoice XML
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeWriteEndTag', '', true, false)]
- local procedure OnFillCodicePagamento(header: RecordRef; line: RecordRef; var elementName: Text[250]; id: Text; var insert: Boolean; var XmlWriter: Codeunit "EOS Xml Writer")
+ local procedure OnFillCodicePagamento(header: RecordRef; line: RecordRef; var elementName: Text[250]; id: Text; var Insert: Boolean; var XmlWriter: Codeunit "EOS Xml Writer")
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
PaymentMethod: Record "Payment Method";
PaymentTerms: Record "Payment Terms";
FldRef: FieldRef;
@@ -1240,20 +1233,20 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
CustNo: Code[20];
begin
if id = '2.4.2' then begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
case OutbElectrDocSetupGroup."EOS Hook Group Code" of
'EOS_BRICO_IO':
begin
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Payment Method Code"));
- DocumentTMP."Payment Method Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Payment Terms Code"));
- DocumentTMP."Payment Terms Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Payment Method Code"));
+ TempDocument."Payment Method Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Payment Terms Code"));
+ TempDocument."Payment Terms Code" := FldRef.Value();
- if PaymentMethod.Get(DocumentTMP."Payment Method Code") then
+ if PaymentMethod.Get(TempDocument."Payment Method Code") then
CodicePagamentoStr += PaymentMethod.Description;
- if PaymentTerms.Get(DocumentTMP."Payment Terms Code") then
+ if PaymentTerms.Get(TempDocument."Payment Terms Code") then
CodicePagamentoStr += ' ' + PaymentTerms.Description;
CodicePagamentoStr := DelChr(CodicePagamentoStr, '<', ' ');
@@ -1263,43 +1256,48 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
-
+ ///
+ /// Event subscriber that handles additional transport data (DatiTrasporto) after DatiDDT (ID 2.1.8) for specific hook groups.
+ /// For BRICO_CENT and LEROY: Adds IndirizzoResa (Delivery Address) element with Ship-to Address information.
+ ///
+ /// The document header RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnAfterWriteDatiDDT_2_1_8', '', true, false)]
local procedure OnAfterWriteDatiDDT_2_1_8(header: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer")
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
FldRef: FieldRef;
CustNo: Code[20];
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
case OutbElectrDocSetupGroup."EOS Hook Group Code" of
'EOS_BRICO_CENT', 'EOS_LEROY':
- if header.Number() in [DATABASE::"Sales Invoice Header", DATABASE::"Sales Cr.Memo Header"] then begin
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("No."));
- DocumentTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Address"));
- DocumentTMP."Ship-to Address" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Post Code"));
- DocumentTMP."Ship-to Post Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to County"));
- DocumentTMP."Ship-to County" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to Country/Region Code"));
- DocumentTMP."Ship-to Country/Region Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("Ship-to City"));
- DocumentTMP."Ship-to City" := FldRef.Value();
-
- if (DocumentTMP."Ship-to Address" <> '') and (DocumentTMP."Ship-to Post Code" <> '') and
- (DocumentTMP."Ship-to City" <> '') and (DocumentTMP."Ship-to Country/Region Code" <> '') then begin
+ if header.Number() in [Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header"] then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("No."));
+ TempDocument."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Address"));
+ TempDocument."Ship-to Address" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Post Code"));
+ TempDocument."Ship-to Post Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to County"));
+ TempDocument."Ship-to County" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Country/Region Code"));
+ TempDocument."Ship-to Country/Region Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to City"));
+ TempDocument."Ship-to City" := FldRef.Value();
+
+ if (TempDocument."Ship-to Address" <> '') and (TempDocument."Ship-to Post Code" <> '') and
+ (TempDocument."Ship-to City" <> '') and (TempDocument."Ship-to Country/Region Code" <> '') then begin
XmlWriter.WriteStartElement('DatiTrasporto');
XmlWriter.WriteStartElement('IndirizzoResa');
- XmlWriter.WriteElementValue('Indirizzo', DocumentTMP."Ship-to Address");
- XmlWriter.WriteElementValue('CAP', DocumentTMP."Ship-to Post Code");
- XmlWriter.WriteElementValue('Comune', DocumentTMP."Ship-to City");
- XmlWriter.WriteElementValueIf(DocumentTMP."Ship-to County" <> '', 'Provincia', CopyStr(DocumentTMP."Ship-to County", 1, 2));
- XmlWriter.WriteElementValue('Nazione', CopyStr(DocumentTMP."Ship-to Country/Region Code", 1, 2));
+ XmlWriter.WriteElementValue('Indirizzo', TempDocument."Ship-to Address");
+ XmlWriter.WriteElementValue('CAP', TempDocument."Ship-to Post Code");
+ XmlWriter.WriteElementValue('Comune', TempDocument."Ship-to City");
+ XmlWriter.WriteElementValueIf(TempDocument."Ship-to County" <> '', 'Provincia', CopyStr(TempDocument."Ship-to County", 1, 2));
+ XmlWriter.WriteElementValue('Nazione', CopyStr(TempDocument."Ship-to Country/Region Code", 1, 2));
XmlWriter.WriteEndElement();//IndirizzoResa
XmlWriter.WriteEndElement();//DatiTrasporto
@@ -1309,6 +1307,12 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
+ ///
+ /// Opens the corresponding line table based on the header table type.
+ /// Maps Sales/Service Invoice/Credit Memo headers to their respective line tables.
+ ///
+ /// Output RecordRef that will be opened to the appropriate line table
+ /// Input header RecordRef used to determine the line table to open
local procedure getLineFromheaderHdr(var Lineheader: RecordRef; header: RecordRef)
var
begin
@@ -1324,6 +1328,16 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
+ ///
+ /// Event subscriber that handles the RiferimentoAmministrazione element (ID 2.2.1.15) for specific hook groups.
+ /// For AMAZON: Fills the External Document No. as the administrative reference for Sales Invoice and Credit Memo documents.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The name of the XML element being processed
+ /// The FatturaPA element ID (e.g., '2.2.1.15' for RiferimentoAmministrazione)
+ /// The value to be written to the XML element
+ /// The XML Writer used to generate the electronic invoice XML
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddElementText', '', true, true)]
local procedure "EOS FE Writer_OnBeforeAddElementText"
(
@@ -1335,40 +1349,47 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
var XmlWriter: Codeunit "EOS Xml Writer"
)
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
FldRef: FieldRef;
- CustNo: code[20];
+ CustNo: Code[20];
begin
case id of
'2.2.1.15':
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
- CASE OutbElectrDocSetupGroup."EOS Hook Group Code" OF
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
'EOS_AMAZON':
- IF header.NUMBER() IN [DATABASE::"Sales Invoice Header", DATABASE::"Sales Cr.Memo Header"] THEN BEGIN
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FIELDNAME("External Document No."));
- DocumentTMP."External Document No." := FldRef.VALUE();
+ if header.NUMBER() in [Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header"] then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FIELDNAME("External Document No."));
+ TempDocument."External Document No." := FldRef.VALUE();
- IF DocumentTMP."External Document No." <> '' THEN
- Value := COPYSTR(DocumentTMP."External Document No.", 1, 20)
+ if TempDocument."External Document No." <> '' then
+ Value := CopyStr(TempDocument."External Document No.", 1, 20)
- END;
+ end;
end;
end;
end;
end;
+ ///
+ /// Event subscriber that validates DatiBeniServizi (Goods and Services Data) section for specific hook groups.
+ /// Performs hook-specific validation before generating the electronic invoice.
+ /// For AMAZON: Delegates to AMAZON_OnCheckDatiBeniServizi for specific validation rules.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnCheckDatiBeniServizi', '', true, true)]
local procedure OnCheckDatiBeniServizi(header: RecordRef; line: RecordRef)
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
- CustNo: code[20];
+ TempDocument: Record "Sales Invoice Header" temporary;
+ CustNo: Code[20];
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
@@ -1379,13 +1400,20 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
+ ///
+ /// Event subscriber that validates DatiGenerali (General Data) section for specific hook groups.
+ /// Performs hook-specific validation of order references and related documents before generating the electronic invoice.
+ /// For AMAZON: Delegates to AMAZON_OnCheckDatiGenerali for specific validation rules.
+ ///
+ /// The document header RecordRef
+ /// Temporary buffer containing order number references
[EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnCheckDatiGenerali', '', true, true)]
local procedure OnCheckDatiGenerali(header: RecordRef; var OrderNoBuffer: Record "EOS RifLineNo Buffer" temporary)
var
- DocumentTMP: Record "Sales Invoice Header" temporary;
- CustNo: code[20];
+ TempDocument: Record "Sales Invoice Header" temporary;
+ CustNo: Code[20];
begin
- CustNo := header.Field(DocumentTMP.FieldNo("Bill-to Customer No.")).Value();
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
exit;
@@ -1397,10 +1425,18 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
//#region AMAZON
+ ///
+ /// Validates the General Data section for AMAZON electronic invoices.
+ /// Performs specific validations based on document type and reason code:
+ /// - Sales Invoice: Validates DatiOrdineAcquisto (Purchase Order Data) is present, or validates DatiFattureCollegate for NDEB reason.
+ /// - Sales Credit Memo: Validates reason code is present and validates related documents based on reason code (NCSTT, QPD, NCDIF, CCOGS).
+ ///
+ /// The document header RecordRef
+ /// Temporary buffer containing order number references
local procedure AMAZON_OnCheckDatiGenerali(header: RecordRef; var OrderNoBuffer: Record "EOS RifLineNo Buffer" temporary)
var
- ElectrDocRelatedDocsTMP: Record "EOS Outb. EDoc. Related Docs." temporary;
- DocumentReason: code[10];
+ TempElectrDocRelatedDocs: Record "EOS Outb. EDoc. Related Docs." temporary;
+ DocumentReason: Code[10];
NumeroOrd: Text;
DataOrd: Date;
CIG: Code[15];
@@ -1413,10 +1449,10 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
begin
EOSFEData.setHeader(header);
DocumentReason := GetAMAZONReasonCode(header);
- EOSFEData.getRelDocsTagsForCurrDoc(ElectrDocRelatedDocsTMP);
+ EOSFEData.getRelDocsTagsForCurrDoc(TempElectrDocRelatedDocs);
EOSFEData.hasDirectOrder(NumeroOrd, DataOrd, CIG, CUP, CodiceCommessaConvenzione);
case header.Number() of
- database::"Sales Invoice Header":
+ Database::"Sales Invoice Header":
case DocumentReason of
'':
begin
@@ -1424,8 +1460,8 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
Error(NoPurchOrderErr, 'Invoice');
if NumeroOrd <> '' then
exit;
- ElectrDocRelatedDocsTMP.SetRange("EOS Type", ElectrDocRelatedDocsTMP."EOS Type"::DatiOrdineAcquisto);
- if not ElectrDocRelatedDocsTMP.IsEmpty() then
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiOrdineAcquisto);
+ if not TempElectrDocRelatedDocs.IsEmpty() then
exit;
OrderNoBuffer.SetFilter("EOS Doc No.", '<>%1', '');
if OrderNoBuffer.IsEmpty() then
@@ -1435,12 +1471,12 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
'NDEB':
begin
- ElectrDocRelatedDocsTMP.SetRange("EOS Type", ElectrDocRelatedDocsTMP."EOS Type"::DatiFattureCollegate);
- if ElectrDocRelatedDocsTMP.IsEmpty() then
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiFattureCollegate);
+ if TempElectrDocRelatedDocs.IsEmpty() then
Error(NoAppliesToDocErr, DocumentReason);
end;
end;
- database::"Sales Cr.Memo Header":
+ Database::"Sales Cr.Memo Header":
begin
IsHandled := false;
OnBeforeCheckAmazonDocumentReasonSalesCrMemo(header, DocumentReason, IsHandled);
@@ -1451,20 +1487,20 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
'NCSTT',
'QPD':
begin
- ElectrDocRelatedDocsTMP.SetRange("EOS Type", ElectrDocRelatedDocsTMP."EOS Type"::DatiOrdineAcquisto);
- if ElectrDocRelatedDocsTMP.IsEmpty() then
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiOrdineAcquisto);
+ if TempElectrDocRelatedDocs.IsEmpty() then
if NumeroOrd = '' then
Error(NoPurchOrderErr, DocumentReason);
- ElectrDocRelatedDocsTMP.SetRange("EOS Type", ElectrDocRelatedDocsTMP."EOS Type"::DatiFattureCollegate);
- if ElectrDocRelatedDocsTMP.IsEmpty() then
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiFattureCollegate);
+ if TempElectrDocRelatedDocs.IsEmpty() then
Error(NoAppliesToDocErr, DocumentReason);
end;
'NCDIF',
'CCOGS':
begin
- ElectrDocRelatedDocsTMP.SetRange("EOS Type", ElectrDocRelatedDocsTMP."EOS Type"::DatiFattureCollegate);
- if ElectrDocRelatedDocsTMP.IsEmpty() then
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiFattureCollegate);
+ if TempElectrDocRelatedDocs.IsEmpty() then
Error(NoAppliesToDocErr, DocumentReason);
end;
end;
@@ -1472,10 +1508,19 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
+ ///
+ /// Validates the Goods and Services Data section for AMAZON electronic invoices at line level.
+ /// Performs specific validations based on document type and reason code:
+ /// - Sales Invoice with NDEB: Validates RiferimentoAmministrazione is present.
+ /// - Sales Credit Memo with VRET/NCDIF: Validates CodiceArticolo and RiferimentoAmministrazione are present.
+ /// - Sales Credit Memo with QPD/NCSTT/COGS: Validates RiferimentoAmministrazione is present.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
local procedure AMAZON_OnCheckDatiBeniServizi(header: RecordRef; line: RecordRef)
var
- DocumentLineTMP: Record "Sales Invoice Line" temporary;
- DocumentTMP: Record "Sales Invoice Header" temporary;
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
EOSEDocRelDocLines: Record "EOS EDoc. Rel. Doc. Lines";
EOSOutbElectrDocSetup: Record "EOS Outb. Electr. Doc. Setup";
FldRef: FieldRef;
@@ -1487,54 +1532,62 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
DocumentReason := GetAMAZONReasonCode(header);
EOSFEData.setLineRecRef(line);
EOSFEData.getRelDocsLineTagsForCurrDoc(EOSEDocRelDocLines);
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(header, FldRef, DocumentTMP.FieldName("External Document No."));
- DocumentTMP."External Document No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("External Document No."));
+ TempDocument."External Document No." := FldRef.Value();
case header.Number() of
- database::"Sales Invoice Header":
+ Database::"Sales Invoice Header":
case DocumentReason of
'NDEB':
- if DocumentTMP."External Document No." = '' then begin
+ if TempDocument."External Document No." = '' then begin
EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::RiferimentoAmministrazione);
if EOSEDocRelDocLines.IsEmpty() then
- error(NoRiferimentoAmministrazioneErr, DocumentReason, DocumentLineTMP."Line No.");
+ Error(NoRiferimentoAmministrazioneErr, DocumentReason, TempDocumentLine."Line No.");
end;
end;
- database::"Sales Cr.Memo Header":
+ Database::"Sales Cr.Memo Header":
case DocumentReason of
'VRET',
'NCDIF':
begin
- EOSOutbElectrDocSetup.get();
+ EOSOutbElectrDocSetup.Get();
if not EOSOutbElectrDocSetup."EOS Add Item Code" then
- Error(NoItemCodeErr, DocumentReason, DocumentLineTMP."Line No.");
- if DocumentLineTMP.Type <> DocumentLineTMP.Type::Item then begin
+ Error(NoItemCodeErr, DocumentReason, TempDocumentLine."Line No.");
+ if TempDocumentLine.Type <> TempDocumentLine.Type::Item then begin
EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::CodiceArticolo);
if EOSEDocRelDocLines.IsEmpty() then
- Error(NoItemCodeErr, DocumentReason, DocumentLineTMP."Line No.");
+ Error(NoItemCodeErr, DocumentReason, TempDocumentLine."Line No.");
end;
- if DocumentTMP."External Document No." = '' then begin
+ if TempDocument."External Document No." = '' then begin
EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::RiferimentoAmministrazione);
if EOSEDocRelDocLines.IsEmpty() then
- error(NoRiferimentoAmministrazioneErr, DocumentReason, DocumentLineTMP."Line No.");
+ Error(NoRiferimentoAmministrazioneErr, DocumentReason, TempDocumentLine."Line No.");
end;
end;
'QPD',
'NCSTT',
'COGS':
- if DocumentTMP."External Document No." = '' then begin
+ if TempDocument."External Document No." = '' then begin
EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::RiferimentoAmministrazione);
if EOSEDocRelDocLines.IsEmpty() then
- error(NoRiferimentoAmministrazioneErr, DocumentReason, DocumentLineTMP."Line No.");
+ Error(NoRiferimentoAmministrazioneErr, DocumentReason, TempDocumentLine."Line No.");
end;
end;
end;
end;
+ ///
+ /// Retrieves the AMAZON-specific reason code from the document header.
+ /// Evaluates the Causale tags and Reason Code description to determine the appropriate AMAZON reason code.
+ /// Valid reason codes for Sales Invoice: NDEB.
+ /// Valid reason codes for Sales Credit Memo: NCSTT, NCDIF, QPD, VRET, CCOGS.
+ ///
+ /// The document header RecordRef
+ /// The AMAZON-specific reason code, or empty if no matching reason is found
local procedure GetAMAZONReasonCode(header: RecordRef) Reason: Code[10]
var
ReasonCode: Record "Reason Code";
@@ -1551,13 +1604,13 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
CausaleList.Add(ReasonCode.Description);
case header.Number() of
- database::"Sales Invoice Header":
+ Database::"Sales Invoice Header":
begin
ReasonCodeValue := 'NDEB';
if CausaleList.Contains(ReasonCodeValue) then
Reason := ReasonCodeValue;
end;
- database::"Sales Cr.Memo Header":
+ Database::"Sales Cr.Memo Header":
begin
ReasonCodeValue := 'NCSTT';
if CausaleList.Contains(ReasonCodeValue) then
@@ -1578,95 +1631,109 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
end;
+ ///
+ /// Handles the CodiceArticolo (Item Code) XML element generation specifically for AMAZON hook group.
+ /// Generates two CodiceArticolo elements for items:
+ /// 1. EAN code from Item Reference (Bar Code type with Hook Group Code as Reference Type No.)
+ /// 2. SKU code with the Item No.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to indicate that the CodiceArticolo has been handled
local procedure AMAZON_OnBefore_CodiceArticolo(header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var handled: Boolean)
var
- DocumentLineTMP: Record "Sales Invoice Line" temporary;
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
ItemReference: Record "Item Reference";
FldRef: FieldRef;
isHandled: Boolean;
begin
- if not (line.Number() in [DATABASE::"Sales Invoice Line", DATABASE::"Sales Cr.Memo Line"]) then
+ if not (line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"]) then
exit;
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Line No."));
- DocumentLineTMP."Line No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName(Type));
- DocumentLineTMP.Type := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Variant Code"));
- DocumentLineTMP."Variant Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("No."));
- DocumentLineTMP."No." := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Unit of Measure Code"));
- DocumentLineTMP."Unit of Measure Code" := FldRef.Value();
- DataTypeManagement.FindFieldByName(line, FldRef, DocumentLineTMP.FieldName("Item Reference No."));
- DocumentLineTMP."Item Reference No." := FldRef.Value();
-
- IF DocumentLineTMP.Type = DocumentLineTMP.Type::Item THEN begin
- ItemReference.SETRANGE("Item No.", DocumentLineTMP."No.");
- ItemReference.SETRANGE("Variant Code", DocumentLineTMP."Variant Code");
- ItemReference.SETRANGE("Reference Type", ItemReference."Reference Type"::"Bar Code");
- ItemReference.SETRANGE("Unit of Measure", DocumentLineTMP."Unit of Measure Code");
- ItemReference.SETRANGE("Reference Type No.", OutbElectrDocSetupGroup."EOS Hook Group Code");
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Unit of Measure Code"));
+ TempDocumentLine."Unit of Measure Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetRange("Variant Code", TempDocumentLine."Variant Code");
+ ItemReference.SetRange("Reference Type", ItemReference."Reference Type"::"Bar Code");
+ ItemReference.SetRange("Unit of Measure", TempDocumentLine."Unit of Measure Code");
+ ItemReference.SetRange("Reference Type No.", OutbElectrDocSetupGroup."EOS Hook Group Code");
//TempItemReference.SETRANGE("Discontinue Bar Code", false);
if not ItemReference.FindFirst() then
- ItemReference.SETRANGE("Unit of Measure");
+ ItemReference.SetRange("Unit of Measure");
isHandled := false;
OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- IF ItemReference.FINDFIRST() THEN BEGIN
- isHandled := false;
- OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
- if not isHandled then begin
- XmlWriter.WriteStartElement('CodiceArticolo');
- XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
- XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
- XmlWriter.WriteEndElement();
+ if not isHandled then
+ if ItemReference.FindFirst() then begin
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
end;
- end;
XmlWriter.WriteStartElement('CodiceArticolo');
XmlWriter.WriteElementValue('CodiceTipo', 'SKU');
- XmlWriter.WriteElementValue('CodiceValore', DocumentLineTMP."No.");
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
XmlWriter.WriteEndElement();
- END;
- Handled := TRUE;
+ end;
+ Handled := true;
end;
//#endregion AMAZON
///
- /// Raised during the General Data check for Amazon, before checking the Reason Code, while generating an electronic document for a Sales Cr.Memo for AMAZON
+ /// Raised during the General Data validation for AMAZON, before checking the Reason Code, while generating an electronic document for a Sales Credit Memo.
+ /// Use this event to provide a custom reason code or to skip the reason code validation.
///
- /// Document header
- /// Reason Code, if empty an error will be raised after the event
- /// if true, the error will be skipped
+ /// The Sales Credit Memo header RecordRef
+ /// The Reason Code value. If empty after the event and IsHandled is false, an error will be raised
+ /// Set to true to skip the default reason code validation error
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckAmazonDocumentReasonSalesCrMemo(header: RecordRef; var DocumentReason: Code[10]; var IsHandled: Boolean)
begin
end;
///
- /// Raised before the Causale tag is filled, to allow customization of the tag
+ /// Raised before the Causale (Reason) XML tag is filled, allowing customization of the tag content.
+ /// Use this event to implement custom Causale logic for specific hook groups or customers.
///
- /// Document header
- /// XML Writer
- /// Document setup group
- /// if true, the default behavior will be skipped
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The XML Writer used to generate the electronic invoice XML
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// Set to true to skip the default Causale tag filling behavior
[IntegrationEvent(false, false)]
local procedure OnBeforeOnFillCausaleTag(var header: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; var Handled: Boolean)
begin
end;
///
- /// Raised after applying filters to the ItemReference record; you can apply additional filters for customization.
+ /// Raised after applying default filters to the Item Reference record during CodiceArticolo processing.
+ /// Use this event to apply additional filters, modify existing filters, or implement custom Item Reference lookup logic.
///
- /// Current OutbElectrDocSetupGroup
- /// Current Header RecordRef. It cound be Sales/Service Invoice/CreditMemo
- /// Current Line RecordRef
- /// Filterd Item Reference
- /// XML Writer
- /// if true, the default behavior will be skipped
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The document line RecordRef
+ /// The Item Reference record with default filters applied. Modify this to change lookup behavior
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to skip the default Item Reference processing and CodiceArticolo XML generation
[IntegrationEvent(false, false)]
local procedure OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; line: RecordRef;
var ItemReference: Record "Item Reference"; var XmlWriter: Codeunit "EOS Xml Writer"; var isHandled: Boolean)
@@ -1674,14 +1741,15 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
///
- /// Raised before creating CodiceArticolo XML node; you can customize the behavior or skip it by setting isHandled to true.
+ /// Raised before creating the CodiceArticolo XML node for each Item Reference during the loop.
+ /// Use this event to customize how individual Item References are exported or to skip specific references.
///
- /// Current OutbElectrDocSetupGroup
- /// Current Header RecordRef. It cound be Sales/Service Invoice/CreditMemo
- /// Current Line RecordRef
- /// Current Item Reference
- /// XML Writer
- /// if true, the default behavior will be skipped
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The document line RecordRef
+ /// The current Item Reference record being processed
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to skip the default CodiceArticolo XML generation for this Item Reference
[IntegrationEvent(false, false)]
local procedure OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; line: RecordRef;
var ItemReference: Record "Item Reference"; var XmlWriter: Codeunit "EOS Xml Writer"; var isHandled: Boolean)
@@ -1689,25 +1757,28 @@ codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
end;
///
- /// Raised before creating CodiceArticolo XML node; you can customize the behavior or skip it by setting isHandled to true.
+ /// Raised before creating any CodiceArticolo XML node for the document line.
+ /// Use this event to completely customize the CodiceArticolo generation or to add custom item codes before the default processing.
+ /// This event is raised for hook groups that do not use Item Reference lookup (e.g., METRO, AUTOGRILL, FERRARI, OBI, BRICO_SELF).
///
- /// Current OutbElectrDocSetupGroup
- /// Current Header RecordRef. It cound be Sales/Service Invoice/CreditMemo
- /// Current Line RecordRef
- /// XML Writer
- /// if true, the default behavior will be skipped
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to skip the default CodiceArticolo XML generation for this line
[IntegrationEvent(false, false)]
local procedure OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var isHandled: Boolean)
begin
end;
///
- /// Raised before get standard header."Reason Code" value. you can customize the behavior or skip it by setting isHandled to true.
+ /// Raised before retrieving the standard Reason Code value from the document header.
+ /// Use this event to provide a custom Reason Code value based on document data or external logic.
///
- /// Current OutbElectrDocSetupGroup
- /// Current Header RecordRef. It cound be Sales/Service Invoice/CreditMemo
- /// Reason Code value
- /// if true, the default behavior will be skipped
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The Reason Code value. Set this to provide a custom value
+ /// Set to true to use the custom ReasonCode value and skip the default field retrieval
[IntegrationEvent(false, false)]
local procedure OnBeforeGetReasonCode(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; var ReasonCode: Code[10]; var isHandled: Boolean)
begin
diff --git a/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC28/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC28/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
new file mode 100644
index 0000000..1cc9c2b
--- /dev/null
+++ b/EX063.ElectronicInvoice.IT/Custom E-Doc Format/MasterBC28/codeunit 18123040 EOS Outb. EDoc. Hook Handler.al
@@ -0,0 +1,1787 @@
+///
+/// Gather all functions that handles specific hook code (i.e. GDO) specified in group setup
+///
+codeunit 18123040 "EOS Outb. EDoc. Hook Handler"
+{
+
+ var
+ OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup";
+ EOSEDocSetupMgt: Codeunit "EOS EDoc. Setup Management";
+ DataTypeManagement: Codeunit "Data Type Management";
+ EOSFEData: Codeunit "EOS FE Data";
+
+ [Obsolete('Not Used.', '27.0')]
+ procedure SetSalesInvoiceTmpBuffer(var inTmpSalesHeader: Record "Sales Header" temporary; var inTmpShipHeader: Record "Sales Shipment Header" temporary)
+ begin
+ end;
+
+ [Obsolete('Not Used.', '27.0')]
+ procedure SetSalesCrMemoTmpBuffer(var inReturnReceiptHeaderTMP: Record "Return Receipt Header" temporary)
+ begin
+ end;
+
+ [Obsolete('Not Used.', '27.0')]
+ procedure SetServiceInvoiceTmpBuffer(var inTmpServiceHeader: Record "Service Header" temporary; var inTmpServShipHeader: Record "Service Shipment Header" temporary)
+ begin
+ end;
+
+ ///
+ /// Determines whether the PEC (Posta Elettronica Certificata) address should always be exported for the given customer.
+ /// Returns true if the customer belongs to a hook group that requires mandatory PEC export (e.g., AMAZON).
+ ///
+ /// The Customer No. to check
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// True if PEC should always be exported, false otherwise
+ procedure AlwaysExportPEC(CustNo: Code[20]; header: RecordRef) RetValue: Boolean
+ var
+ begin
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+
+ RetValue :=
+ OutbElectrDocSetupGroup."EOS Hook Group Code" in [
+ 'EOS_AMAZON'
+ ];
+ end;
+
+ ///
+ /// Retrieves the Reason Code from the document header.
+ /// Raises OnBeforeGetReasonCode event to allow customization before retrieving the standard value.
+ ///
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The Reason Code associated with the document
+ procedure GetDocumentReasonCode(header: RecordRef) Result: Code[10];
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ FldRef: FieldRef;
+ isHandled: Boolean;
+ begin
+ isHandled := false;
+ OnBeforeGetReasonCode(OutbElectrDocSetupGroup, header, Result, isHandled);
+ if not isHandled then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Reason Code"));
+ Result := FldRef.Value();
+ end;
+ end;
+
+ ///
+ /// Event subscriber that handles the CodiceArticolo (Item Code) XML element generation for various GDO (Grande Distribuzione Organizzata) hook groups.
+ /// Each hook group has specific requirements for how item codes should be formatted and exported in the electronic invoice.
+ /// Supported hook groups include: AMAZON, BRICO_CENT, CANOVA, CARREFOUR, CHEF, UNICOOPTIR, CONAD_SIC, IGES, GS1, COOPALL3, METRO, AUTOGRILL, RIALTO, FERRARI, OBI, BRICO_SELF.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to indicate that the CodiceArticolo has been handled and default processing should be skipped
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddCodiceArticolo', '', true, false)]
+ local procedure OnBefore_CodiceArticolo(header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var handled: Boolean)
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
+ CompanyInfoPA: Record "EOS Outb. Electr. Doc. Setup";
+ ItemReference: Record "Item Reference";
+ FldRef: FieldRef;
+ DummyText: Text[20];
+ CustNo: Code[20];
+ isHandled: Boolean;
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ Handled := false;
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_AMAZON':
+ AMAZON_OnBefore_CodiceArticolo(header, line, XmlWriter, handled);
+ 'EOS_BRICO_CENT':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ isHandled := false;
+ OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
+
+ if not isHandled then
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'INTERNALCODE');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+
+ //CrossReference
+ if TempDocumentLine."Item Reference No." <> '' then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'articolobrico');
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."Item Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_CANOVA':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+
+ isHandled := false;
+ OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
+
+ if not isHandled then
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'INTERNALCODE');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_CARREFOUR':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetFilter("Reference Type", '%1|%2',
+ ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
+
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'BP');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0;
+
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_CHEF':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', '99');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetFilter("Reference Type", '%1|%2',
+ ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
+
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', '01');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0;
+
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_UNICOOPTIR':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetFilter("Reference Type", '%1', ItemReference."Reference Type"::"Bar Code");
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
+
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0
+ else begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'Codice Uso Fornitore');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_CONAD_SIC', 'EOS_IGES', 'EOS_GS1':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'SA');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetFilter("Reference Type", '%1|%2',
+ ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
+
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'IN');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0;
+
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_COOPALL3':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Fornitore');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetFilter("Reference Type", '%1|%2',
+ ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
+
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'Codice Art. Cliente');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0;
+
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_METRO':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ isHandled := false;
+ OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
+
+ if not isHandled then
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'cod');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_AUTOGRILL':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+
+ isHandled := false;
+ OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
+
+ if not isHandled then
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'GDS');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_RIALTO':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Sell-to Customer No."));
+ TempDocumentLine."Sell-to Customer No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'SA');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetFilter("Reference Type", '%1|%2',
+ ItemReference."Reference Type"::"Bar Code", ItemReference."Reference Type"::Customer);
+ if TempDocumentLine."Item Reference No." <> '' then
+ ItemReference.SetRange("Reference No.", TempDocumentLine."Item Reference No.");
+
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+
+ if not isHandled then
+ if ItemReference.FindSet() then
+ repeat
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then
+ if not ((ItemReference."Reference Type" = ItemReference."Reference Type"::Customer) and (ItemReference."Reference Type No." <> TempDocumentLine."Sell-to Customer No.")) then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ case ItemReference."Reference Type" of
+ ItemReference."Reference Type"::Customer:
+ XmlWriter.WriteElementValue('CodiceTipo', 'BP');
+ ItemReference."Reference Type"::"Bar Code":
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ end;
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ until ItemReference.Next() = 0;
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_FERRARI':
+ // CodiceValore:
+ // Commessa primi 9 caratteri + codice articolo ordine Ferrari. Nei 9 caratteri riservati alla commessa
+ // il valore deve essere allineato a sinistra, riempiendo i campi vuoti di commessa con BLANK. Commessa di riga fattura
+ // Creare routine custom per gestire stringa
+
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Job No."));
+ TempDocumentLine."Job No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ isHandled := false;
+ OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
+
+ if not isHandled then
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+
+ // Create string following Ferrari request
+ DummyText := CopyStr(PadStr(TempDocumentLine."Job No.", 9, ' ') + TempDocumentLine."Item Reference No.", 1, 20);
+
+ if DummyText <> '' then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'CODICE');
+ XmlWriter.WriteElementValue('CodiceValore', DummyText);
+ XmlWriter.WriteEndElement();
+ end;
+
+ end;
+ end;
+ Handled := true;
+ end;
+
+ 'EOS_OBI', 'EOS_BRICO_SELF':
+ if line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ CompanyInfoPA.Get();
+ if CompanyInfoPA."EOS Add Item Code" then begin
+ Clear(TempDocumentLine);
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+
+ isHandled := false;
+ OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup, header, line, XmlWriter, isHandled);
+
+ if not isHandled then
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'SA');
+ if TempDocumentLine."Variant Code" <> '' then
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No." + ' ' + TempDocumentLine."Variant Code")
+ else
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+ Handled := true;
+ end;
+ end;
+ end;
+
+ ///
+ /// Event subscriber that handles the CodiceCommessaConvenzione element (ID 2.1.2.5) for specific hook groups.
+ /// Fills the Store Code value from Ship-to Address or Customer for OTTIMAX hook group.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef or RifLineNo Buffer
+ /// The name of the XML element being processed
+ /// The FatturaPA element ID (e.g., '2.1.2.5' for CodiceCommessaConvenzione)
+ /// The value to be written to the XML element
+ /// The XML Writer used to generate the electronic invoice XML
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddElementText', '', true, false)]
+ local procedure OnFillCommConvDatiOdA(header: RecordRef; line: RecordRef; var elementName: Text[250]; id: Text; var Value: Text; var XmlWriter: Codeunit "EOS Xml Writer")
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ TempBuffer: Record "EOS RifLineNo Buffer" temporary;
+ headerOrder: Record "Sales Header";
+ ShiptoAddress: Record "Ship-to Address";
+ Customer: Record Customer;
+ FldRef: FieldRef;
+ NotDirectShip: Boolean;
+ CustNo: Code[20];
+ orderNo: Code[20];
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if id = '2.1.2.5' then begin
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+ NotDirectShip := line.Number() = Database::"EOS RifLineNo Buffer";
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+
+ 'EOS_OTTIMAX':
+ begin
+ orderNo := line.field(TempBuffer.FieldNo("EOS Order No.")).Value();
+ headerOrder.SetRange("No.", orderNo);
+ if (not NotDirectShip) or headerOrder.IsEmpty() then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No."));
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code"));
+ TempDocument."Ship-to Code" := FldRef.Value();
+ end else begin
+ headerOrder.FindFirst();
+
+ TempDocument."Sell-to Customer No." := headerOrder."Sell-to Customer No.";
+ TempDocument."Ship-to Code" := headerOrder."Ship-to Code";
+ end;
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" <> '' then
+ Value := ShiptoAddress."EOS Store Code"
+ else begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ Value := Customer."EOS Store Code";
+ end;
+ end;
+
+ end;
+ end;
+ end;
+
+
+ ///
+ /// Event subscriber that populates the Related Documents buffer with additional data for specific hook groups.
+ /// For METRO: Adds DatiRicezione with Store Code (ILN code).
+ /// For AGRINTESA: Adds DatiRicezione with Document No.
+ ///
+ /// The document header RecordRef
+ /// Temporary buffer containing related document information for the electronic invoice
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnFillElectrDocRelatedDocsBuffer', '', true, false)]
+ local procedure OnFillElectrDocRelatedDocsBuffer(header: RecordRef; var ElectrDocRelatedDocsTMP: Record "EOS Outb. EDoc. Related Docs." temporary)
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ Customer: Record Customer;
+ ShiptoAddress: Record "Ship-to Address";
+ FldRef: FieldRef;
+ CustNo: Code[20];
+ LineNo: Integer;
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+ if not ElectrDocRelatedDocsTMP.FindLast() then
+ LineNo := 10000
+ else
+ LineNo := ElectrDocRelatedDocsTMP."EOS Line No.";
+
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_METRO':
+ begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("No."));
+ TempDocument."No." := FldRef.Value();
+
+ // Codice o ILN fornitore
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Bill-to Customer No."));
+ TempDocument."Bill-to Customer No." := FldRef.Value();
+ Customer.Get(TempDocument."Bill-to Customer No.");
+
+ // Codice o ILN store
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No."));
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code"));
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ end;
+
+ if ShiptoAddress."EOS Store Code" <> '' then begin
+ LineNo += 10000;
+ ElectrDocRelatedDocsTMP.Init();
+ ElectrDocRelatedDocsTMP."EOS Table ID" := header.Number();
+ ElectrDocRelatedDocsTMP."EOS Document Type" := 0;
+ ElectrDocRelatedDocsTMP."EOS Document No." := TempDocument."No.";
+ ElectrDocRelatedDocsTMP."EOS Document RecordID" := header.RecordId();
+ ElectrDocRelatedDocsTMP."EOS Type" := ElectrDocRelatedDocsTMP."EOS Type"::DatiRicezione;
+ ElectrDocRelatedDocsTMP."EOS IdDocumento" := ShiptoAddress."EOS Store Code";
+ ElectrDocRelatedDocsTMP."EOS NumItem" := 'store';
+ ElectrDocRelatedDocsTMP."EOS Line No." := LineNo;
+ ElectrDocRelatedDocsTMP.Insert(true);
+ end;
+ end;
+
+ 'EOS_AGRINTESA':
+ begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("No."));
+ TempDocument."No." := FldRef.Value();
+
+ LineNo += 10000;
+ ElectrDocRelatedDocsTMP.Init();
+ ElectrDocRelatedDocsTMP."EOS Table ID" := header.Number();
+ ElectrDocRelatedDocsTMP."EOS Document Type" := 0;
+ ElectrDocRelatedDocsTMP."EOS Document No." := TempDocument."No.";
+ ElectrDocRelatedDocsTMP."EOS Document RecordID" := header.RecordId();
+ ElectrDocRelatedDocsTMP."EOS Type" := ElectrDocRelatedDocsTMP."EOS Type"::DatiRicezione;
+ ElectrDocRelatedDocsTMP."EOS IdDocumento" := TempDocument."No.";
+ ElectrDocRelatedDocsTMP."EOS Line No." := LineNo;
+ ElectrDocRelatedDocsTMP.Insert(true);
+ end;
+ end;
+ end;
+
+ ///
+ /// Event subscriber that handles the AltriDatiGestionali (Other Management Data) XML element (ID 2.2.1.16) for various hook groups.
+ /// Each hook group has specific requirements for additional data to be included at the line level.
+ /// Supported hook groups: LEROY (Negozio), BRICO_IO (CDC), CANOVA/CARREFOUR/RIALTO (DP), ESSELUNGA (DP with shipment info),
+ /// CAMST (PLANT from dimension), CONAD_SIC/IGES (PCONSEGNA), COOPALL3 (DP, DEST.MERCI, INDIRIZZO),
+ /// UNICOOPTIR (CPV), AUTOGRILL (PV), CHEF (DP), OBI (DP).
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnAddAltriDatiGestionali_2_2_1_16', '', true, false)]
+ local procedure OnFillAltriDatiGestionaliTag(header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer")
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
+ ShiptoAddress: Record "Ship-to Address";
+ Customer: Record Customer;
+ TempDimSetEntry: Record "Dimension Set Entry" temporary;
+ SalesCrMemoLine: Record "Sales Cr.Memo Line";
+ SalesInvoiceLine: Record "Sales Invoice Line";
+ ReturnReceiptHeader: Record "Return Receipt Header";
+ SalesShipmentHeader: Record "Sales Shipment Header";
+ DimensionManagement: Codeunit DimensionManagement;
+ FldRef: FieldRef;
+ CustNo: Code[20];
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+
+ 'EOS_LEROY':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Description" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
+ end;
+
+ if ShiptoAddress."EOS Store Description" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'Negozio');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Description");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_BRICO_IO':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ exit;
+
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'CDC');
+ XmlWriter.WriteElementValueIf(ShiptoAddress.Name <> '', 'RiferimentoTesto', ShiptoAddress.Name);
+ XmlWriter.WriteEndElement();
+ end;
+
+ 'EOS_CANOVA', 'EOS_CARREFOUR', 'EOS_RIALTO':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ end;
+
+ if ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'DP');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_ESSELUNGA':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if Line.Number() = Database::"Sales Invoice Line" then begin
+ DataTypeManagement.FindFieldByName(Line, FldRef, SalesInvoiceLine.FieldName("Shipment No."));
+ TempDocument."Order No." := FldRef.Value();
+ if SalesShipmentHeader.Get(TempDocument."Order No.") then
+ if SalesShipmentHeader."Ship-to Code" <> '' then
+ TempDocument."Ship-to Code" := SalesShipmentHeader."Ship-to Code";
+ end else
+ if Line.Number() = Database::"Sales Cr.Memo Line" then begin
+ DataTypeManagement.FindFieldByName(Line, FldRef, SalesCrMemoLine.FieldName("Return Receipt No."));
+ TempDocument."Order No." := FldRef.Value();
+ if ReturnReceiptHeader.Get(TempDocument."Order No.") then
+ if ReturnReceiptHeader."Ship-to Code" <> '' then
+ TempDocument."Ship-to Code" := ReturnReceiptHeader."Ship-to Code";
+ end;
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ end;
+
+ if ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'DP');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_CAMST':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(Line, FldRef, TempDocumentLine.FieldName("Dimension Set ID")) then
+ TempDocument."Dimension Set ID" := FldRef.Value();
+ if TempDocument."Dimension Set ID" = 0 then
+ exit;
+
+ DimensionManagement.GetDimensionSet(TempDimSetEntry, TempDocument."Dimension Set ID");
+ TempDimSetEntry.SetRange("Dimension Code", 'CDCCAMST'); // Centro di Costo fornito da CAMST
+ if TempDimSetEntry.FindFirst() then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'PLANT');
+ XmlWriter.WriteElementValue('RiferimentoTesto', TempDimSetEntry."Dimension Value Code");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_CONAD_SIC', 'EOS_IGES':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" + ShiptoAddress."EOS Store Description" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
+ end;
+
+ if ShiptoAddress."EOS Store Description" + ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'PCONSEGNA');
+ XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Code" <> '', 'RiferimentoNumero', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Description" <> '', 'RiferimentoTesto', ShiptoAddress."EOS Store Description");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_COOPALL3':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" + ShiptoAddress."EOS Store Description" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
+ end;
+
+ // GLN code
+ if ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'DP');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
+ end;
+
+ // Store Description
+ if ShiptoAddress."EOS Store Description" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'DEST.MERCI');
+ XmlWriter.WriteElementValue('RiferimentoTesto', CopyStr(ShiptoAddress."EOS Store Description", 1, 60));
+ XmlWriter.WriteEndElement();
+ end;
+
+ // Store Address
+ if ShiptoAddress.Address <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'INDIRIZZO');
+ XmlWriter.WriteElementValue('RiferimentoTesto', CopyStr(ShiptoAddress.Address + ' ' + ShiptoAddress."Post Code" + ' ' + ShiptoAddress.County, 1, 60));
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_UNICOOPTIR':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ end;
+
+ if ShiptoAddress.Address + ShiptoAddress.City + ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'CPV');
+ XmlWriter.WriteElementValueIf(ShiptoAddress."EOS Store Code" <> '', 'RiferimentoNumero', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteElementValueIf(((ShiptoAddress.Address <> '') or (ShiptoAddress.City <> '')), 'RiferimentoTesto', ShiptoAddress.Address + ' ' + ShiptoAddress.City);
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_AUTOGRILL':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ end;
+
+ if ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'PV');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_CHEF':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" + ShiptoAddress."EOS Store Description" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ ShiptoAddress."EOS Store Description" := Customer."EOS Store Description";
+ end;
+
+ if ShiptoAddress."EOS Store Description" + ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'DP');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Description" + ' - ' + ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ 'EOS_OBI':
+ if Line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"] then begin
+ Clear(TempDocument);
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Sell-to Customer No.")) then
+ TempDocument."Sell-to Customer No." := FldRef.Value();
+
+ if DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Code")) then
+ TempDocument."Ship-to Code" := FldRef.Value();
+
+ if not ShiptoAddress.Get(TempDocument."Sell-to Customer No.", TempDocument."Ship-to Code") then
+ Clear(ShiptoAddress);
+ if ShiptoAddress."EOS Store Code" = '' then begin
+ Customer.Get(TempDocument."Sell-to Customer No.");
+ ShiptoAddress."EOS Store Code" := Customer."EOS Store Code";
+ end;
+
+ if ShiptoAddress."EOS Store Code" <> '' then begin
+ XmlWriter.WriteStartElement('AltriDatiGestionali');
+ XmlWriter.WriteElementValue('TipoDato', 'DP');
+ XmlWriter.WriteElementValue('RiferimentoTesto', ShiptoAddress."EOS Store Code");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+ end;
+ end;
+
+
+ ///
+ /// Event subscriber that handles the Causale (Reason) XML element for various hook groups.
+ /// Each hook group has specific requirements for how the reason/cause should be formatted.
+ /// Supported hook groups: AMAZON (exports Reason Code for Credit Memos), CARREFOUR (MERCI/FRANCHISING/EXTRAFATTURA),
+ /// CONAD_SIC/IGES (MAGAZZINO/RIFATTURAZIONE/SERVIZI), UNICOOPTIR (M/S), COOPALL3, STEFF (DANNI_/GEN_),
+ /// ASCA/MARR (Ship-to address information).
+ ///
+ /// The document header RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to indicate that default Causale processing should be skipped
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddCausaleTags', '', true, false)]
+ local procedure OnFillCausaleTag(header: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var handled: Boolean)
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ ReasonCode: Record "Reason Code";
+ FldRef: FieldRef;
+ CustNo: Code[20];
+ SkipHookHandling: Boolean;
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+
+ Clear(SkipHookHandling);
+ OnBeforeOnFillCausaleTag(header, XmlWriter, OutbElectrDocSetupGroup, SkipHookHandling);
+
+ if SkipHookHandling then
+ exit;
+
+ TempDocument."Reason Code" := GetDocumentReasonCode(header);
+
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_AMAZON':
+ if header.NUMBER() in [Database::"Sales Cr.Memo Header"] then
+ if TempDocument."Reason Code" <> '' then
+ if ReasonCode.Get(TempDocument."Reason Code") then
+ XmlWriter.WriteElementValueIf(ReasonCode."EOS AMZ Exp. To EDoc.", 'Causale', ReasonCode.Code);
+ 'EOS_CARREFOUR':
+ // Check reasons mapped as "MERCI", "FRANCHISING", "EXTRAFATTURA" or customize
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
+
+ 'EOS_CONAD_SIC', 'EOS_IGES':
+ // Check reasons mapped as "MAGAZZINO", "RIFATTURAZIONE", "SERVIZI" or customize
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
+
+ 'EOS_UNICOOPTIR':
+ // Check reasons mapped as "M" (merci), "S" (servizi) or customize
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
+
+ 'EOS_COOPALL3':
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
+
+ 'EOS_STEFF':
+ // Check reasons mapped as "DANNI_", "GEN_" or customize
+ XmlWriter.WriteElementValueIf(ReasonCode.Get(TempDocument."Reason Code"), 'Causale', ReasonCode.Description);
+
+ 'EOS_ASCA', 'EOS_MARR':
+ begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Name"));
+ TempDocument."Ship-to Name" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Name 2"));
+ TempDocument."Ship-to Name 2" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Address"));
+ TempDocument."Ship-to Address" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Address 2"));
+ TempDocument."Ship-to Address 2" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to City"));
+ TempDocument."Ship-to City" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to County"));
+ TempDocument."Ship-to County" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Country/Region Code"));
+ TempDocument."Ship-to Country/Region Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Post Code"));
+ TempDocument."Ship-to Post Code" := FldRef.Value();
+
+ if TempDocument."Ship-to Name" + TempDocument."Ship-to Name 2" <> '' then
+ XmlWriter.WriteElementValue('Causale', TempDocument."Ship-to Name" + ' ' + TempDocument."Ship-to Name 2");
+
+ if TempDocument."Ship-to Address" + TempDocument."Ship-to Address 2" <> '' then
+ XmlWriter.WriteElementValue('Causale', TempDocument."Ship-to Address" + ' ' + TempDocument."Ship-to Address 2");
+
+ if TempDocument."Ship-to Post Code" + TempDocument."Ship-to City" +
+ TempDocument."Ship-to County" + TempDocument."Ship-to Country/Region Code" <> '' then
+ XmlWriter.WriteElementValue('Causale', TempDocument."Ship-to Post Code" + ' ' + TempDocument."Ship-to City" + ' ' +
+ TempDocument."Ship-to County" + ' ' + TempDocument."Ship-to Country/Region Code");
+
+ end;
+
+ end;
+ end;
+
+ ///
+ /// Event subscriber that handles the CodicePagamento (Payment Code) XML element within DettaglioPagamento (ID 2.4.2) for specific hook groups.
+ /// For BRICO_IO: Combines Payment Method Description and Payment Terms Description into the CodicePagamento field.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The name of the XML element being processed
+ /// The FatturaPA element ID (e.g., '2.4.2' for DettaglioPagamento)
+ /// Indicates whether the end tag should be inserted
+ /// The XML Writer used to generate the electronic invoice XML
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeWriteEndTag', '', true, false)]
+ local procedure OnFillCodicePagamento(header: RecordRef; line: RecordRef; var elementName: Text[250]; id: Text; var Insert: Boolean; var XmlWriter: Codeunit "EOS Xml Writer")
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ PaymentMethod: Record "Payment Method";
+ PaymentTerms: Record "Payment Terms";
+ FldRef: FieldRef;
+ CodicePagamentoStr: Text[60];
+ CustNo: Code[20];
+ begin
+ if id = '2.4.2' then begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_BRICO_IO':
+ begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Payment Method Code"));
+ TempDocument."Payment Method Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Payment Terms Code"));
+ TempDocument."Payment Terms Code" := FldRef.Value();
+
+ if PaymentMethod.Get(TempDocument."Payment Method Code") then
+ CodicePagamentoStr += PaymentMethod.Description;
+ if PaymentTerms.Get(TempDocument."Payment Terms Code") then
+ CodicePagamentoStr += ' ' + PaymentTerms.Description;
+
+ CodicePagamentoStr := DelChr(CodicePagamentoStr, '<', ' ');
+ XmlWriter.WriteElementValueIf(CodicePagamentoStr <> '', 'CodicePagamento', CopyStr(CodicePagamentoStr, 1, 60));
+ end;
+ end;
+ end;
+ end;
+
+ ///
+ /// Event subscriber that handles additional transport data (DatiTrasporto) after DatiDDT (ID 2.1.8) for specific hook groups.
+ /// For BRICO_CENT and LEROY: Adds IndirizzoResa (Delivery Address) element with Ship-to Address information.
+ ///
+ /// The document header RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnAfterWriteDatiDDT_2_1_8', '', true, false)]
+ local procedure OnAfterWriteDatiDDT_2_1_8(header: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer")
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ FldRef: FieldRef;
+ CustNo: Code[20];
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+
+ 'EOS_BRICO_CENT', 'EOS_LEROY':
+ if header.Number() in [Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header"] then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("No."));
+ TempDocument."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Address"));
+ TempDocument."Ship-to Address" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Post Code"));
+ TempDocument."Ship-to Post Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to County"));
+ TempDocument."Ship-to County" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to Country/Region Code"));
+ TempDocument."Ship-to Country/Region Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("Ship-to City"));
+ TempDocument."Ship-to City" := FldRef.Value();
+
+ if (TempDocument."Ship-to Address" <> '') and (TempDocument."Ship-to Post Code" <> '') and
+ (TempDocument."Ship-to City" <> '') and (TempDocument."Ship-to Country/Region Code" <> '') then begin
+ XmlWriter.WriteStartElement('DatiTrasporto');
+ XmlWriter.WriteStartElement('IndirizzoResa');
+ XmlWriter.WriteElementValue('Indirizzo', TempDocument."Ship-to Address");
+ XmlWriter.WriteElementValue('CAP', TempDocument."Ship-to Post Code");
+ XmlWriter.WriteElementValue('Comune', TempDocument."Ship-to City");
+ XmlWriter.WriteElementValueIf(TempDocument."Ship-to County" <> '', 'Provincia', CopyStr(TempDocument."Ship-to County", 1, 2));
+ XmlWriter.WriteElementValue('Nazione', CopyStr(TempDocument."Ship-to Country/Region Code", 1, 2));
+
+ XmlWriter.WriteEndElement();//IndirizzoResa
+ XmlWriter.WriteEndElement();//DatiTrasporto
+ end;
+ end;
+
+ end;
+ end;
+
+ ///
+ /// Opens the corresponding line table based on the header table type.
+ /// Maps Sales/Service Invoice/Credit Memo headers to their respective line tables.
+ ///
+ /// Output RecordRef that will be opened to the appropriate line table
+ /// Input header RecordRef used to determine the line table to open
+ local procedure getLineFromheaderHdr(var Lineheader: RecordRef; header: RecordRef)
+ var
+ begin
+ case header.Number() of
+ Database::"Sales Invoice Header":
+ Lineheader.Open(Database::"Sales Invoice Line");
+ Database::"Service Invoice Header":
+ Lineheader.Open(Database::"Service Invoice Line");
+ Database::"Sales Cr.Memo Header":
+ Lineheader.Open(Database::"Sales Cr.Memo Line");
+ Database::"Service Cr.Memo Header":
+ Lineheader.Open(Database::"Service Cr.Memo Line");
+ end;
+ end;
+
+ ///
+ /// Event subscriber that handles the RiferimentoAmministrazione element (ID 2.2.1.15) for specific hook groups.
+ /// For AMAZON: Fills the External Document No. as the administrative reference for Sales Invoice and Credit Memo documents.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The name of the XML element being processed
+ /// The FatturaPA element ID (e.g., '2.2.1.15' for RiferimentoAmministrazione)
+ /// The value to be written to the XML element
+ /// The XML Writer used to generate the electronic invoice XML
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnBeforeAddElementText', '', true, true)]
+ local procedure "EOS FE Writer_OnBeforeAddElementText"
+ (
+ header: RecordRef;
+ line: RecordRef;
+ var elementName: Text[250];
+ id: Text;
+ var Value: Text;
+ var XmlWriter: Codeunit "EOS Xml Writer"
+ )
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ FldRef: FieldRef;
+ CustNo: Code[20];
+ begin
+ case id of
+ '2.2.1.15':
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_AMAZON':
+
+ if header.NUMBER() in [Database::"Sales Invoice Header", Database::"Sales Cr.Memo Header"] then begin
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FIELDNAME("External Document No."));
+ TempDocument."External Document No." := FldRef.VALUE();
+
+ if TempDocument."External Document No." <> '' then
+ Value := CopyStr(TempDocument."External Document No.", 1, 20)
+
+ end;
+
+ end;
+ end;
+ end;
+ end;
+
+ ///
+ /// Event subscriber that validates DatiBeniServizi (Goods and Services Data) section for specific hook groups.
+ /// Performs hook-specific validation before generating the electronic invoice.
+ /// For AMAZON: Delegates to AMAZON_OnCheckDatiBeniServizi for specific validation rules.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnCheckDatiBeniServizi', '', true, true)]
+ local procedure OnCheckDatiBeniServizi(header: RecordRef; line: RecordRef)
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ CustNo: Code[20];
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_AMAZON':
+ AMAZON_OnCheckDatiBeniServizi(header, line);
+ end;
+ end;
+
+
+ ///
+ /// Event subscriber that validates DatiGenerali (General Data) section for specific hook groups.
+ /// Performs hook-specific validation of order references and related documents before generating the electronic invoice.
+ /// For AMAZON: Delegates to AMAZON_OnCheckDatiGenerali for specific validation rules.
+ ///
+ /// The document header RecordRef
+ /// Temporary buffer containing order number references
+ [EventSubscriber(ObjectType::Codeunit, Codeunit::"EOS FE Writer", 'OnCheckDatiGenerali', '', true, true)]
+ local procedure OnCheckDatiGenerali(header: RecordRef; var OrderNoBuffer: Record "EOS RifLineNo Buffer" temporary)
+ var
+ TempDocument: Record "Sales Invoice Header" temporary;
+ CustNo: Code[20];
+ begin
+ CustNo := header.field(TempDocument.FieldNo("Bill-to Customer No.")).Value();
+ if not EOSEDocSetupMgt.GetCustGroupSetup(CustNo, OutbElectrDocSetupGroup, header) then
+ exit;
+
+ case OutbElectrDocSetupGroup."EOS Hook Group Code" of
+ 'EOS_AMAZON':
+ AMAZON_OnCheckDatiGenerali(header, OrderNoBuffer);
+ end;
+ end;
+
+ //#region AMAZON
+
+ ///
+ /// Validates the General Data section for AMAZON electronic invoices.
+ /// Performs specific validations based on document type and reason code:
+ /// - Sales Invoice: Validates DatiOrdineAcquisto (Purchase Order Data) is present, or validates DatiFattureCollegate for NDEB reason.
+ /// - Sales Credit Memo: Validates reason code is present and validates related documents based on reason code (NCSTT, QPD, NCDIF, CCOGS).
+ ///
+ /// The document header RecordRef
+ /// Temporary buffer containing order number references
+ local procedure AMAZON_OnCheckDatiGenerali(header: RecordRef; var OrderNoBuffer: Record "EOS RifLineNo Buffer" temporary)
+ var
+ TempElectrDocRelatedDocs: Record "EOS Outb. EDoc. Related Docs." temporary;
+ DocumentReason: Code[10];
+ NumeroOrd: Text;
+ DataOrd: Date;
+ CIG: Code[15];
+ CUP: Code[15];
+ CodiceCommessaConvenzione: Text[100];
+ IsHandled: Boolean;
+ NoPurchOrderErr: Label 'AMAZON: DatiOrdineAcquisto mandatory for %1 document.';
+ NoReasonCodeErr: Label 'AMAZON: Reason code mandatory for document %1.';
+ NoAppliesToDocErr: Label 'AMAZON: DatiFattureCollegate mandatory for %1 document.';
+ begin
+ EOSFEData.setHeader(header);
+ DocumentReason := GetAMAZONReasonCode(header);
+ EOSFEData.getRelDocsTagsForCurrDoc(TempElectrDocRelatedDocs);
+ EOSFEData.hasDirectOrder(NumeroOrd, DataOrd, CIG, CUP, CodiceCommessaConvenzione);
+ case header.Number() of
+ Database::"Sales Invoice Header":
+ case DocumentReason of
+ '':
+ begin
+ if not EOSFEData.insertOrderData() then
+ Error(NoPurchOrderErr, 'Invoice');
+ if NumeroOrd <> '' then
+ exit;
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiOrdineAcquisto);
+ if not TempElectrDocRelatedDocs.IsEmpty() then
+ exit;
+ OrderNoBuffer.SetFilter("EOS Doc No.", '<>%1', '');
+ if OrderNoBuffer.IsEmpty() then
+ Error(NoPurchOrderErr, 'Invoice');
+ if not OutbElectrDocSetupGroup."EOS Exp. DatiOrdAcq Sales Inv." then
+ Error(NoPurchOrderErr, 'Invoice');
+ end;
+ 'NDEB':
+ begin
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiFattureCollegate);
+ if TempElectrDocRelatedDocs.IsEmpty() then
+ Error(NoAppliesToDocErr, DocumentReason);
+ end;
+ end;
+ Database::"Sales Cr.Memo Header":
+ begin
+ IsHandled := false;
+ OnBeforeCheckAmazonDocumentReasonSalesCrMemo(header, DocumentReason, IsHandled);
+ case DocumentReason of
+ '':
+ if not IsHandled then
+ Error(NoReasonCodeErr, header.Caption());
+ 'NCSTT',
+ 'QPD':
+ begin
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiOrdineAcquisto);
+ if TempElectrDocRelatedDocs.IsEmpty() then
+ if NumeroOrd = '' then
+ Error(NoPurchOrderErr, DocumentReason);
+
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiFattureCollegate);
+ if TempElectrDocRelatedDocs.IsEmpty() then
+ Error(NoAppliesToDocErr, DocumentReason);
+ end;
+ 'NCDIF',
+ 'CCOGS':
+ begin
+ TempElectrDocRelatedDocs.SetRange("EOS Type", TempElectrDocRelatedDocs."EOS Type"::DatiFattureCollegate);
+ if TempElectrDocRelatedDocs.IsEmpty() then
+ Error(NoAppliesToDocErr, DocumentReason);
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ ///
+ /// Validates the Goods and Services Data section for AMAZON electronic invoices at line level.
+ /// Performs specific validations based on document type and reason code:
+ /// - Sales Invoice with NDEB: Validates RiferimentoAmministrazione is present.
+ /// - Sales Credit Memo with VRET/NCDIF: Validates CodiceArticolo and RiferimentoAmministrazione are present.
+ /// - Sales Credit Memo with QPD/NCSTT/COGS: Validates RiferimentoAmministrazione is present.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ local procedure AMAZON_OnCheckDatiBeniServizi(header: RecordRef; line: RecordRef)
+ var
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
+ TempDocument: Record "Sales Invoice Header" temporary;
+ EOSEDocRelDocLines: Record "EOS EDoc. Rel. Doc. Lines";
+ EOSOutbElectrDocSetup: Record "EOS Outb. Electr. Doc. Setup";
+ FldRef: FieldRef;
+ DocumentReason: Code[10];
+ NoItemCodeErr: Label 'AMAZON: CodiceArticolo mandatory for document %1 line %2.';
+ NoRiferimentoAmministrazioneErr: Label 'AMAZON: RiferimentoAmministrazione mandatory for %1 document line %2.';
+ begin
+ EOSFEData.setHeader(header);
+ DocumentReason := GetAMAZONReasonCode(header);
+ EOSFEData.setLineRecRef(line);
+ EOSFEData.getRelDocsLineTagsForCurrDoc(EOSEDocRelDocLines);
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(header, FldRef, TempDocument.FieldName("External Document No."));
+ TempDocument."External Document No." := FldRef.Value();
+ case header.Number() of
+ Database::"Sales Invoice Header":
+ case DocumentReason of
+ 'NDEB':
+ if TempDocument."External Document No." = '' then begin
+ EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::RiferimentoAmministrazione);
+ if EOSEDocRelDocLines.IsEmpty() then
+ Error(NoRiferimentoAmministrazioneErr, DocumentReason, TempDocumentLine."Line No.");
+ end;
+ end;
+ Database::"Sales Cr.Memo Header":
+ case DocumentReason of
+ 'VRET',
+ 'NCDIF':
+ begin
+ EOSOutbElectrDocSetup.Get();
+ if not EOSOutbElectrDocSetup."EOS Add Item Code" then
+ Error(NoItemCodeErr, DocumentReason, TempDocumentLine."Line No.");
+ if TempDocumentLine.Type <> TempDocumentLine.Type::Item then begin
+ EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::CodiceArticolo);
+ if EOSEDocRelDocLines.IsEmpty() then
+ Error(NoItemCodeErr, DocumentReason, TempDocumentLine."Line No.");
+ end;
+
+ if TempDocument."External Document No." = '' then begin
+ EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::RiferimentoAmministrazione);
+ if EOSEDocRelDocLines.IsEmpty() then
+ Error(NoRiferimentoAmministrazioneErr, DocumentReason, TempDocumentLine."Line No.");
+ end;
+ end;
+ 'QPD',
+ 'NCSTT',
+ 'COGS':
+ if TempDocument."External Document No." = '' then begin
+ EOSEDocRelDocLines.SetRange(Type, EOSEDocRelDocLines.Type::RiferimentoAmministrazione);
+ if EOSEDocRelDocLines.IsEmpty() then
+ Error(NoRiferimentoAmministrazioneErr, DocumentReason, TempDocumentLine."Line No.");
+ end;
+ end;
+ end;
+ end;
+
+ ///
+ /// Retrieves the AMAZON-specific reason code from the document header.
+ /// Evaluates the Causale tags and Reason Code description to determine the appropriate AMAZON reason code.
+ /// Valid reason codes for Sales Invoice: NDEB.
+ /// Valid reason codes for Sales Credit Memo: NCSTT, NCDIF, QPD, VRET, CCOGS.
+ ///
+ /// The document header RecordRef
+ /// The AMAZON-specific reason code, or empty if no matching reason is found
+ local procedure GetAMAZONReasonCode(header: RecordRef) Reason: Code[10]
+ var
+ ReasonCode: Record "Reason Code";
+ ReasonCodeValue: Code[10];
+ CausaleList: List of [Text];
+ CausaleConai: Text;
+ CausaleDutyStamp: Text;
+ begin
+ EOSFEData.getCausaleTags(CausaleList, CausaleConai, CausaleDutyStamp);
+
+ ReasonCodeValue := GetDocumentReasonCode(header);
+
+ if ReasonCode.Get(ReasonCodeValue) then
+ CausaleList.Add(ReasonCode.Description);
+
+ case header.Number() of
+ Database::"Sales Invoice Header":
+ begin
+ ReasonCodeValue := 'NDEB';
+ if CausaleList.Contains(ReasonCodeValue) then
+ Reason := ReasonCodeValue;
+ end;
+ Database::"Sales Cr.Memo Header":
+ begin
+ ReasonCodeValue := 'NCSTT';
+ if CausaleList.Contains(ReasonCodeValue) then
+ Reason := ReasonCodeValue;
+ ReasonCodeValue := 'NCDIF';
+ if CausaleList.Contains(ReasonCodeValue) then
+ Reason := ReasonCodeValue;
+ ReasonCodeValue := 'QPD';
+ if CausaleList.Contains(ReasonCodeValue) then
+ Reason := ReasonCodeValue;
+ ReasonCodeValue := 'VRET';
+ if CausaleList.Contains(ReasonCodeValue) then
+ Reason := ReasonCodeValue;
+ ReasonCodeValue := 'CCOGS';
+ if CausaleList.Contains(ReasonCodeValue) then
+ Reason := ReasonCodeValue;
+ end;
+ end;
+ end;
+
+ ///
+ /// Handles the CodiceArticolo (Item Code) XML element generation specifically for AMAZON hook group.
+ /// Generates two CodiceArticolo elements for items:
+ /// 1. EAN code from Item Reference (Bar Code type with Hook Group Code as Reference Type No.)
+ /// 2. SKU code with the Item No.
+ ///
+ /// The document header RecordRef
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to indicate that the CodiceArticolo has been handled
+ local procedure AMAZON_OnBefore_CodiceArticolo(header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var handled: Boolean)
+ var
+ TempDocumentLine: Record "Sales Invoice Line" temporary;
+ ItemReference: Record "Item Reference";
+ FldRef: FieldRef;
+ isHandled: Boolean;
+ begin
+ if not (line.Number() in [Database::"Sales Invoice Line", Database::"Sales Cr.Memo Line"]) then
+ exit;
+
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Line No."));
+ TempDocumentLine."Line No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName(Type));
+ TempDocumentLine.Type := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Variant Code"));
+ TempDocumentLine."Variant Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("No."));
+ TempDocumentLine."No." := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Unit of Measure Code"));
+ TempDocumentLine."Unit of Measure Code" := FldRef.Value();
+ DataTypeManagement.FindFieldByName(line, FldRef, TempDocumentLine.FieldName("Item Reference No."));
+ TempDocumentLine."Item Reference No." := FldRef.Value();
+
+ if TempDocumentLine.Type = TempDocumentLine.Type::Item then begin
+ ItemReference.SetRange("Item No.", TempDocumentLine."No.");
+ ItemReference.SetRange("Variant Code", TempDocumentLine."Variant Code");
+ ItemReference.SetRange("Reference Type", ItemReference."Reference Type"::"Bar Code");
+ ItemReference.SetRange("Unit of Measure", TempDocumentLine."Unit of Measure Code");
+ ItemReference.SetRange("Reference Type No.", OutbElectrDocSetupGroup."EOS Hook Group Code");
+ //TempItemReference.SETRANGE("Discontinue Bar Code", false);
+ if not ItemReference.FindFirst() then
+ ItemReference.SetRange("Unit of Measure");
+ isHandled := false;
+ OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+
+ if not isHandled then
+ if ItemReference.FindFirst() then begin
+ isHandled := false;
+ OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup, header, line, ItemReference, XmlWriter, isHandled);
+ if not isHandled then begin
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'EAN');
+ XmlWriter.WriteElementValue('CodiceValore', ItemReference."Reference No.");
+ XmlWriter.WriteEndElement();
+ end;
+ end;
+
+ XmlWriter.WriteStartElement('CodiceArticolo');
+ XmlWriter.WriteElementValue('CodiceTipo', 'SKU');
+ XmlWriter.WriteElementValue('CodiceValore', TempDocumentLine."No.");
+ XmlWriter.WriteEndElement();
+ end;
+ Handled := true;
+ end;
+
+
+ //#endregion AMAZON
+
+ ///
+ /// Raised during the General Data validation for AMAZON, before checking the Reason Code, while generating an electronic document for a Sales Credit Memo.
+ /// Use this event to provide a custom reason code or to skip the reason code validation.
+ ///
+ /// The Sales Credit Memo header RecordRef
+ /// The Reason Code value. If empty after the event and IsHandled is false, an error will be raised
+ /// Set to true to skip the default reason code validation error
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforeCheckAmazonDocumentReasonSalesCrMemo(header: RecordRef; var DocumentReason: Code[10]; var IsHandled: Boolean)
+ begin
+ end;
+
+ ///
+ /// Raised before the Causale (Reason) XML tag is filled, allowing customization of the tag content.
+ /// Use this event to implement custom Causale logic for specific hook groups or customers.
+ ///
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The XML Writer used to generate the electronic invoice XML
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// Set to true to skip the default Causale tag filling behavior
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforeOnFillCausaleTag(var header: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; var Handled: Boolean)
+ begin
+ end;
+
+ ///
+ /// Raised after applying default filters to the Item Reference record during CodiceArticolo processing.
+ /// Use this event to apply additional filters, modify existing filters, or implement custom Item Reference lookup logic.
+ ///
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The document line RecordRef
+ /// The Item Reference record with default filters applied. Modify this to change lookup behavior
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to skip the default Item Reference processing and CodiceArticolo XML generation
+ [IntegrationEvent(false, false)]
+ local procedure OnAfterItemReferenceFilters_CodiceArticolo(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; line: RecordRef;
+ var ItemReference: Record "Item Reference"; var XmlWriter: Codeunit "EOS Xml Writer"; var isHandled: Boolean)
+ begin
+ end;
+
+ ///
+ /// Raised before creating the CodiceArticolo XML node for each Item Reference during the loop.
+ /// Use this event to customize how individual Item References are exported or to skip specific references.
+ ///
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The document line RecordRef
+ /// The current Item Reference record being processed
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to skip the default CodiceArticolo XML generation for this Item Reference
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforeExportItemReference_CodiceArticolo(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; line: RecordRef;
+ var ItemReference: Record "Item Reference"; var XmlWriter: Codeunit "EOS Xml Writer"; var isHandled: Boolean)
+ begin
+ end;
+
+ ///
+ /// Raised before creating any CodiceArticolo XML node for the document line.
+ /// Use this event to completely customize the CodiceArticolo generation or to add custom item codes before the default processing.
+ /// This event is raised for hook groups that do not use Item Reference lookup (e.g., METRO, AUTOGRILL, FERRARI, OBI, BRICO_SELF).
+ ///
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The document line RecordRef
+ /// The XML Writer used to generate the electronic invoice XML
+ /// Set to true to skip the default CodiceArticolo XML generation for this line
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforeExport_CodiceArticolo(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; line: RecordRef; var XmlWriter: Codeunit "EOS Xml Writer"; var isHandled: Boolean)
+ begin
+ end;
+
+ ///
+ /// Raised before retrieving the standard Reason Code value from the document header.
+ /// Use this event to provide a custom Reason Code value based on document data or external logic.
+ ///
+ /// The Outbound Electronic Document Group Setup record containing hook configuration
+ /// The document header RecordRef (Sales/Service Invoice or Credit Memo)
+ /// The Reason Code value. Set this to provide a custom value
+ /// Set to true to use the custom ReasonCode value and skip the default field retrieval
+ [IntegrationEvent(false, false)]
+ local procedure OnBeforeGetReasonCode(OutbElectrDocSetupGroup: Record "EOS Outb. EDoc. Group Setup"; header: RecordRef; var ReasonCode: Code[10]; var isHandled: Boolean)
+ begin
+ end;
+
+}