Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode an XMLPorts #7905

Open
jmadrigalTCN opened this issue Nov 15, 2024 · 10 comments
Open

VSCode an XMLPorts #7905

jmadrigalTCN opened this issue Nov 15, 2024 · 10 comments
Labels
investigate The issue requires further investigation to determine if this is a product bug no-repro static-code-analysis

Comments

@jmadrigalTCN
Copy link

  1. Describe the bug
    XMLPorts do not show error, warnings, etc.

  2. To Reproduce
    Create a new XMLPort and write anything, an Lorem Ipsum i.e.

  3. Expected behavior
    Show errors and warnings

  4. Actual behavior
    Do not show any error nor warning

  5. Versions:

AL Language: v15.0.1177813 (pre-release)
Visual Studio Code: 1.95.2
Operating System:
Windows 11

@BazookaMusic
Copy link
Contributor

Image

Latest pre-release

Have you named your file with ".al"? If not, then the extension will not run on it.

@jmadrigalTCN
Copy link
Author

jmadrigalTCN commented Nov 15, 2024

Image

Latest pre-release

Have you named your file with ".al"? If not, then the extension will not run on it.

Yes.
I have a lot of xmlports and I do not get the error.
Very weird

Image

@BazookaMusic
Copy link
Contributor

Can you share an example project where it reproduces?

@jmadrigalTCN
Copy link
Author

///


/// XmlPort TCN_e-Factura 3.2 Formato Face (ID 7149200).
///

xmlport 7149200 "TCN_e-Factura 3.2 Formato Face"
{

Direction = Export;
Encoding = UTF8;
Namespaces = ds = 'http://www.w3.org/2000/09/xmldsig#', fe = 'http://www.facturae.es/Facturae/2009/v3.2/Facturae', es = 'http://www.facturae.es/Facturae/2';
schema
{
    textelement(Facturae)
    {
        MaxOccurs = Once;
        MinOccurs = Once;
        NamespacePrefix = 'fe';
        tableelement("1."; Integer)
        {
            MaxOccurs = Once;
            MinOccurs = Once;
            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
            XmlName = 'FileHeader';
            textelement("1.1.")
            {
                MaxOccurs = Once;
                MinOccurs = Once;
                XmlName = 'SchemaVersion';

                trigger OnBeforePassVariable()
                var
                    clTresPuntoDos: Label '3.2';
                begin
                    "1.1." := clTresPuntoDos;
                end;

            }
            textelement("1.2.")
            {
                MaxOccurs = Once;
                MinOccurs = Once;
                XmlName = 'Modality';

                trigger OnBeforePassVariable()
                var
                    clI: Label 'I';
                begin
                    "1.2." := clI;
                end;
            }
            textelement("1.3.")
            {
                MaxOccurs = Once;
                MinOccurs = Once;
                XmlName = 'InvoiceIssuerType';

                trigger OnBeforePassVariable()
                var
                    clRE: Label 'RE';
                begin
                    "1.3." := clRE;
                end;
            }
            tableelement("1.4."; Integer)
            {
                MaxOccurs = Unbounded;
                MinOccurs = Zero;
                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                XmlName = 'ThirdParty';
                tableelement("1.4.1."; Integer)
                {
                    MaxOccurs = Once;
                    MinOccurs = Once;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TaxIdentification';
                    textelement("1.4.1.1.")
                    {
                        MinOccurs = Once;
                        XmlName = 'PersonTypeCode';
                    }
                    textelement("1.4.1.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'ResidenceTypeCode';
                    }
                    textelement("1.4.1.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TaxIdentificationNumber';
                    }
                }
                tableelement("1.4.2."; Integer)
                {
                    MaxOccurs = Once;
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'LegalEntity';
                    textelement("1.4.2.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'CorporateName';
                    }
                    textelement("1.4.2.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TradeName';
                    }
                    tableelement("1.4.2.3."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'RegistrationData';
                        textelement("1.4.2.3.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Book';
                        }
                        textelement("1.4.2.3.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'RegisterOfCompaniesLocation';
                        }
                        textelement("1.4.2.3.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Sheet';
                        }
                        textelement("1.4.2.3.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Folio';
                        }
                        textelement("1.4.2.3.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Section';
                        }
                        textelement("1.4.2.3.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Volume';
                        }
                        textelement("1.4.2.3.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalRegistrationData';
                        }
                    }
                    tableelement("1.4.2.4."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AddressInSpain';
                        textelement("1.4.2.4.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';
                        }
                        textelement("1.4.2.4.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';
                        }
                        textelement("1.4.2.4.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Town';
                        }
                        textelement("1.4.2.4.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';
                        }
                        textelement("1.4.2.4.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';
                        }
                    }
                    tableelement("1.4.2.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'OverseasAddress';
                        textelement("1.4.2.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';
                        }
                        textelement("1.4.2.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCodeandTown';
                        }
                        textelement("1.4.2.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';
                        }
                        textelement("1.4.2.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';
                        }
                    }
                    tableelement("1.4.2.6."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ContactDetails';
                        textelement("1.4.2.6.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Telephone';
                        }
                        textelement("1.4.2.6.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TeleFax';
                        }
                        textelement("1.4.2.6.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WebAddress';
                        }
                        textelement("1.4.2.6.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ElectronicMail';
                        }
                        textelement("1.4.2.6.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ContactPersons';
                        }
                        textelement("1.4.2.6.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CnoCnae';
                        }
                        textelement("1.4.2.6.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'INETownCode';
                        }
                        textelement("1.4.2.6.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalContactDetails';
                        }
                    }
                }
                tableelement("1.4.3."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'Individual';
                    textelement("1.4.3.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'Name';
                    }
                    textelement("1.4.3.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'FirstSurname';
                    }
                    textelement("1.4.3.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'SecondSurname';
                    }
                    tableelement("1.4.3.4."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AddressInSpain';
                        textelement("1.4.3.4.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';
                        }
                        textelement("1.4.3.4.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';
                        }
                        textelement("1.4.3.4.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Town';
                        }
                        textelement("1.4.3.4.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';
                        }
                        textelement("1.4.3.4.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';
                        }
                    }
                    tableelement("1.4.3.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'OverseasAddress';
                        textelement("1.4.3.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';
                        }
                        textelement("1.4.3.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCodeAndTown';
                        }
                        textelement("1.4.3.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';
                        }
                        textelement("1.4.3.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';
                        }
                    }
                    tableelement("1.4.3.6."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ContactDetails';
                        textelement("1.4.3.6.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Telephone';
                        }
                        textelement("1.4.3.6.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TeleFax';
                        }
                        textelement("1.4.3.6.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WebAddress';
                        }
                        textelement("1.4.3.6.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ElectronicMail';
                        }
                        textelement("1.4.3.6.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ContactPersons';
                        }
                        textelement("1.4.3.6.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CnoCnae';
                        }
                        textelement("1.4.3.6.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'INETownCode';
                        }
                        textelement("1.4.3.6.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalContactDetails';
                        }
                    }
                }

                trigger OnAfterGetRecord()
                begin
                    currXMLport.Break();
                end;
            }
            tableelement("1.5."; Integer)
            {
                MaxOccurs = Once;
                MinOccurs = Once;
                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                XmlName = 'Batch';
                textelement("1.5.1.")
                {
                    MaxOccurs = Once;
                    MinOccurs = Once;
                    XmlName = 'BatchIdentifier';

                    trigger OnBeforePassVariable()
                    begin
                        "1.5.1." := rCompanyInformation."VAT Registration No." + TempTCNCabeceraGenericaVentas."No." + TempTCNCabeceraGenericaVentas."No. Series";
                    end;
                }
                textelement("1.5.2.")
                {
                    MaxOccurs = Once;
                    MinOccurs = Once;
                    XmlName = 'InvoicesCount';

                    trigger OnBeforePassVariable()
                    var
                        clUno: Label '1';
                    begin
                        "1.5.2." := clUno;
                    end;
                }
                tableelement("1.5.3."; Integer)
                {
                    MaxOccurs = Once;
                    MinOccurs = Once;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TotalInvoicesAmount';
                    textelement("1.5.3.1.")
                    {
                        MaxOccurs = Once;
                        MinOccurs = Once;
                        XmlName = 'TotalAmount';

                        trigger OnBeforePassVariable()
                        begin

                            "1.5.3.1." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);
                            "1.5.3.2." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);

                        end;
                    }
                    textelement("1.5.3.2.")
                    {
                        MaxOccurs = Unbounded;
                        MinOccurs = Zero;
                        XmlName = 'EquivalentInEuros';
                    }
                }
                tableelement("1.5.4."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TotalOutstandingAmount';
                    textelement("1.5.4.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalAmount';

                        trigger OnBeforePassVariable()
                        begin
                            "1.5.4.1." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);
                            "1.5.4.2." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);

                        end;
                    }
                    textelement("1.5.4.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'EquivalentInEuros';

                    }
                }
                tableelement("1.5.5."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TotalExecutableAmount';
                    textelement("1.5.5.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalAmount';

                        trigger OnBeforePassVariable()
                        begin
                            "1.5.5.1." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);

                            "1.5.5.2." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);

                        end;
                    }
                    textelement("1.5.5.2.")
                    {
                        MaxOccurs = Unbounded;
                        MinOccurs = Zero;
                        XmlName = 'EquivalentInEuros';

                    }
                }
                textelement("1.5.6.")
                {
                    MinOccurs = Zero;
                    XmlName = 'InvoiceCurrencyCode';

                    trigger OnBeforePassVariable()
                    begin
                        "1.5.6." := TempTCNCabeceraGenericaVentas."Currency Code";
                        if "1.5.6." = '' then
                            "1.5.6." := rGeneralLedgerSetup."LCY Code";
                    end;
                }
            }
            tableelement("1.6."; Integer)
            {
                MaxOccurs = Once;
                MinOccurs = Zero;
                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                XmlName = 'FactoringAssignmentData';
                tableelement("1.6.1."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'Assignee';
                    tableelement("1.6.1.1."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'TaxIdentification';
                        textelement("1.6.1.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PersonTypeCode';
                        }
                        textelement("1.6.1.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ResidenceTypeCode';
                        }
                        textelement("1.6.1.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TaxIdentificationNumber';
                        }
                    }
                    tableelement("1.6.1.2."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'LegalEntity';
                        textelement("1.6.1.2.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CorporateName';
                        }
                        textelement("1.6.1.2.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TradeName';
                        }
                        tableelement("1.6.1.2.3."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'RegistrationData';
                            textelement("1.6.1.2.3.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Book';
                            }
                            textelement("1.6.1.2.3.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'RegisterOfCompaniesLocation';
                            }
                            textelement("1.6.1.2.3.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Sheet';
                            }
                            textelement("1.6.1.2.3.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Folio';
                            }
                            textelement("1.6.1.2.3.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Section';
                            }
                            textelement("1.6.1.2.3.6.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Volume';
                            }
                            textelement("1.6.1.2.3.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AdditionalRegistrationData';
                            }
                        }
                        tableelement("1.6.1.2.4."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AddressInSpain';
                            textelement("1.6.1.2.4.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("1.6.1.2.4.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCode';
                            }
                            textelement("1.6.1.2.4.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Town';
                            }
                            textelement("1.6.1.2.4.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("1.6.1.2.4.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';
                            }
                        }
                        tableelement("1.6.1.2.5."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'OverseasAddress';
                            textelement("1.6.1.2.5.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("1.6.1.2.5.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCodeAndTown';
                            }
                            textelement("1.6.1.2.5.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("1.6.1.2.5.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';
                            }
                        }
                        tableelement("1.6.1.2.6."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'ContactDetails';
                            textelement("1.6.1.2.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Telephone';
                            }
                            textelement("1.6.1.2.6.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TeleFax';
                            }
                            textelement("1.6.1.2.6.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'WebAddress';
                            }
                            textelement("1.6.1.2.6.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ElectronicMail';
                            }
                            textelement("1.6.1.2.6.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ContactPersons';
                            }
                            textelement("1.6.1.2.6.6.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CnoCnae';
                            }
                            textelement("1.6.1.2.6.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'INETownCode';
                            }
                            textelement("1.6.1.2.6.8.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AdditionalContactDetails';
                            }
                        }
                    }
                    tableelement("1.6.1.3."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'Individual';
                        textelement("1.6.1.3.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Name';
                        }
                        textelement("1.6.1.3.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'FirstSurname';
                        }
                        textelement("1.6.1.3.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'SecondSurname';
                        }
                        tableelement("1.6.1.3.4."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AddressInSpain';
                            textelement("1.6.1.3.4.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("1.6.1.3.4.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCode';
                            }
                            textelement("1.6.1.3.4.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Town';
                            }
                            textelement("1.6.1.3.4.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("1.6.1.3.4.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';
                            }
                        }
                        tableelement("1.6.1.3.5."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'OverseasAddress';
                            textelement("1.6.1.3.5.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("1.6.1.3.5.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCodeAndTown';
                            }
                            textelement("1.6.1.3.5.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("1.6.1.3.5.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';
                            }
                        }
                        tableelement("1.6.1.3.6."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'ContactDetails';
                            textelement("1.6.1.3.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Telephone';
                            }
                            textelement("1.6.1.3.6.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TeleFax';
                            }
                            textelement("1.6.1.3.6.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'WebAddress';
                            }
                            textelement("1.6.1.3.6.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ElectronicMail';
                            }
                            textelement("1.6.1.3.6.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ContactPersons';
                            }
                            textelement("1.6.1.3.6.6.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CnoCnae';
                            }
                            textelement("1.6.1.3.6.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'INETownCode';
                            }
                            textelement("1.6.1.3.6.8.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AdditionalContactDetails';
                            }
                        }
                    }
                }
                tableelement("1.6.2."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'PaymentDetails';
                    tableelement("1.6.2.1."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'Installment';
                        textelement("1.6.2.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'InstallmentDueDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("1.6.2.1.1." = '') or ("1.6.2.1.1." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("1.6.2.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'InstallmentAmount';
                        }
                        textelement("1.6.2.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentMeans';
                        }
                        tableelement("1.6.2.1.4."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AccountToBeCredited';
                            textelement("1.6.2.1.4.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'IBAN';
                            }
                            textelement("1.6.2.1.4.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AccountNumber';
                            }
                            textelement("1.6.2.1.4.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BankCode';
                            }
                            textelement("1.6.2.1.4.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BranchCode';
                            }
                            tableelement("1.6.2.1.4.5."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'BranchInSpainAddress';
                                textelement("1.6.2.1.4.5.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("1.6.2.1.4.5.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCode';
                                }
                                textelement("1.6.2.1.4.5.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Town';
                                }
                                textelement("1.6.2.1.4.5.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("1.6.2.1.4.5.5.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }
                            }
                            tableelement("1.6.2.1.4.6."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'OverseasBranchAddress';
                                textelement("1.6.2.1.4.6.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("1.6.2.1.4.6.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCodeAndTown';
                                }
                                textelement("1.6.2.1.4.6.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("1.6.2.1.4.6.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }
                            }
                            textelement("1.6.2.1.4.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BIC';
                            }
                        }
                        textelement("1.6.2.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentReconciliationReference';
                        }
                        tableelement("1.6.2.1.6."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AccountToBeDebited';
                            textelement("1.6.2.1.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'IBAN';
                            }
                            textelement("1.6.2.1.6.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AccountNumber';
                            }
                            textelement("1.6.2.1.6.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BankCode';
                            }
                            textelement("1.6.2.1.6.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BranchCode';
                            }
                            tableelement("1.6.2.1.6.5."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'BranchInSpainAddress';
                                textelement("1.6.2.1.6.5.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("1.6.2.1.6.5.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCode';
                                }
                                textelement("1.6.2.1.6.5.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Town';
                                }
                                textelement("1.6.2.1.6.5.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("1.6.2.1.6.5.5.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }
                            }
                            tableelement("1.6.2.1.6.6."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'OverseasBranchAddress';
                                textelement("1.6.2.1.6.6.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("1.6.2.1.6.6.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCodeAndTown';
                                }
                                textelement("1.6.2.1.6.6.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("1.6.2.1.6.6.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }
                            }
                            textelement("1.6.2.1.6.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BIC';
                            }
                        }
                        textelement("1.6.2.1.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CollectionAdditionalInformation';
                        }
                        textelement("1.6.2.1.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'RegulatoryReportingData';
                        }
                        textelement("1.6.2.1.9.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'DebitReconciliationReference';
                        }
                    }
                }
                textelement("1.6.3.")
                {
                    MinOccurs = Zero;
                    XmlName = 'FactoringAssignmentClauses';
                }

                trigger OnPreXmlItem()
                begin
                    currXMLport.Break();
                end;
            }
        }
        tableelement("2."; Integer)
        {
            MinOccurs = Zero;
            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
            XmlName = 'Parties';
            tableelement("2.1."; Integer)
            {
                MinOccurs = Zero;
                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                XmlName = 'SellerParty';
                tableelement("2.1.1."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TaxIdentification';
                    textelement("2.1.1.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'PersonTypeCode';

                        trigger OnBeforePassVariable()
                        var
                            clJ: Label 'J';
                        begin
                            "2.1.1.1." := clJ;
                        end;
                    }
                    textelement("2.1.1.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'ResidenceTypeCode';

                        trigger OnBeforePassVariable()
                        var
                            clR: Label 'R';
                        begin
                            "2.1.1.2." := clR;
                        end;
                    }
                    textelement("2.1.1.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TaxIdentificationNumber';

                        trigger OnBeforePassVariable()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            "2.1.1.3." := RecortaF(rCompanyInformation."Country/Region Code" + rCompanyInformation."VAT Registration No.", 30);
                            if rCompanyInformation."Country/Region Code" = '' then begin
                                "2.1.1.3." := RecortaF(culTCNEtiquetasCOM.PaisEspF() + rCompanyInformation."VAT Registration No.", 30);
                            end;
                        end;
                    }
                }
                textelement("2.1.2.")
                {
                    MinOccurs = Zero;
                    XmlName = 'PartyIdentification';
                }
                tableelement("2.1.3."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'AdministrativeCentres';
                    tableelement("2.1.3.1."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AdministrativeCentre';
                        textelement("2.1.3.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CentreCode';
                        }
                        textelement("2.1.3.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'RoleTypeCode';
                        }
                        textelement("2.1.3.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Name';
                        }
                        textelement("2.1.3.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'FirstSurname';
                        }
                        textelement("2.1.3.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'SecondSurname';
                        }
                        tableelement("2.1.3.1.6."; Integer)
                        {
                            MinOccurs = Once;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AddressInSpain';
                            textelement("2.1.3.1.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("2.1.3.1.6.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCode';
                            }
                            textelement("2.1.3.1.6.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Town';
                            }
                            textelement("2.1.3.1.6.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("2.1.3.1.6.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';
                            }
                        }
                        tableelement("2.1.3.1.7."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'OverseasAddress';
                            textelement("2.1.3.1.7.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("2.1.3.1.7.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCodeAndTown';
                            }
                            textelement("2.1.3.1.7.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("2.1.3.1.7.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        tableelement("2.1.3.1.7.8."; Integer)
                        {
                            MinOccurs = Once;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'ContactDetails';
                            textelement("2.1.3.1.7.8.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Telephone';
                            }
                            textelement("2.1.3.1.7.8.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TeleFax';
                            }
                            textelement("2.1.3.1.7.8.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'WebAddress';
                            }
                            textelement("2.1.3.1.7.8.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ElectronicMail';
                            }
                            textelement("2.1.3.1.7.8.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ContactPersons';
                            }
                            textelement("2.1.3.1.7.8.6.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CnoCnae';
                            }
                            textelement("2.1.3.1.7.8.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'INETownCode';
                            }
                            textelement("2.1.3.1.7.8.8.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AdditionalContactDetails';
                            }
                        }
                        textelement("2.1.3.1.9.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PhysicalGLN';
                        }
                        textelement("2.1.3.1.10.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'LogicalOperationalPoint';
                        }
                        textelement("2.1.3.1.11.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CentreDescription';
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }

                    trigger OnAfterGetRecord()
                    begin
                        currXMLport.Break();
                    end;
                }
                tableelement("2.1.4."; Integer)
                {
                    MinOccurs = Once;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'LegalEntity';
                    textelement("2.1.4.1.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'CorporateName';

                        trigger OnBeforePassVariable()
                        begin
                            "2.1.4.1.1." := AjustaLenTextoF(rCompanyInformation.Name);
                        end;
                    }
                    textelement("2.1.4.1.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TradeName';

                        trigger OnBeforePassVariable()
                        begin
                            "2.1.4.1.2." := AjustaLenTextoF(rCompanyInformation."Name 2");
                        end;
                    }
                    tableelement("2.1.4.1.3."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                        XmlName = 'RegistrationData';
                        textelement("2.1.4.1.3.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Book';
                        }
                        textelement("2.1.4.1.3.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'RegisterOfCompaniesLocation';
                        }
                        textelement("2.1.4.1.3.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Sheet';
                        }
                        textelement("2.1.4.1.3.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Folio';
                        }
                        textelement("2.1.4.1.3.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Section';
                        }
                        textelement("2.1.4.1.3.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Volume';
                        }
                        textelement("2.1.4.1.3.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalRegistrationData';
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    tableelement("2.1.4.1.4."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AddressInSpain';
                        textelement("2.1.4.1.4.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.1.1." := AjustaLenTextoF(rCompanyInformation.Address);
                            end;
                        }
                        textelement("2.1.4.1.4.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.1.2." := rCompanyInformation."Post Code";
                            end;
                        }
                        textelement("2.1.4.1.4.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Town';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.1.3." := AjustaLenTextoF(rCompanyInformation.City);
                            end;
                        }
                        textelement("2.1.4.1.4.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.1.4." := RecortaF(rCompanyInformation.County, 20);
                            end;
                        }
                        textelement("2.1.4.1.4.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.1.5." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais, rCompanyInformation."Country/Region Code", '');
                            end;
                        }

                        trigger OnPreXmlItem()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            if rCompanyInformation."Country/Region Code" <> culTCNEtiquetasCOM.PaisEspF() then
                                currXMLport.Skip();
                        end;
                    }
                    tableelement("2.1.4.1.4.2."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                        XmlName = 'OverseasAddress';
                        textelement("2.1.4.1.4.2.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.2.1." := AjustaLenTextoF(rCompanyInformation.Address);
                            end;
                        }
                        textelement("2.1.4.1.4.2.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCodeAndTown';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.2.2." := AjustaLenTextoF(rCompanyInformation."Post Code" + rCompanyInformation.City);
                            end;
                        }
                        textelement("2.1.4.1.4.2.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.2.3." := RecortaF(rCompanyInformation.County, 20);
                            end;
                        }
                        textelement("2.1.4.1.4.2.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.4.2.4." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais, rCompanyInformation."Country/Region Code", '');
                            end;
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;

                        trigger OnPreXmlItem()
                        begin
                            // IF rCompanyInformation."Country/Region Code" = 'ES' THEN
                            //currXMLport.BREAK;
                        end;
                    }
                    tableelement("2.1.4.1.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ContactDetails';
                        textelement("2.1.4.1.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Telephone';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.5.1." := RecortaF(rCompanyInformation."Phone No.", 15);
                            end;
                        }
                        textelement("2.1.4.1.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TeleFax';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.5.2." := RecortaF(rCompanyInformation."Fax No.", 15);
                            end;
                        }
                        textelement("2.1.4.1.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WebAddress';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.5.3." := AjustaLenTextoF(rCompanyInformation."Home Page");
                            end;
                        }
                        textelement("2.1.4.1.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ElectronicMail';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.1.5.4." := AjustaLenTextoF(rCompanyInformation."E-Mail");
                            end;
                        }
                        textelement("2.1.4.1.5.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ContactPersons';
                        }
                        textelement("2.1.4.1.5.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CnoCnae';

                            trigger OnBeforePassVariable()
                            var
                                clCeros: Label '00000';
                            begin
                                // Completa el formato con ceros por la izqda hasta 5 caracteres totales.
                                "2.1.4.1.5.6." := cuCodeunitsDynamics.RightF(clCeros + rCompanyInformation."Industrial Classification", 5);
                            end;
                        }
                        textelement("2.1.4.1.5.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'INETownCode';
                        }
                        textelement("2.1.4.1.5.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalContactDetails';
                        }
                    }

                    trigger OnAfterGetRecord()
                    var
                        clJ: Label 'J';
                    begin
                        if "2.1.1.1." <> clJ then
                            currXMLport.Break();
                    end;
                }
                tableelement("2.1.4.2."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'Individual';
                    textelement("2.1.4.2.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'Name';

                        trigger OnBeforePassVariable()
                        begin
                            "2.1.4.2.1." := AjustaLenTextoF(rCompanyInformation.Name);
                        end;
                    }
                    textelement("2.1.4.2.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'FirstSurname';
                    }
                    textelement("2.1.4.2.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'SecondSurname';
                    }
                    tableelement("2.1.4.2.4."; Integer)
                    {
                        XmlName = 'AddressInSpain';
                        textelement("2.1.4.2.4.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.1.1." := AjustaLenTextoF(rCompanyInformation.Address);
                            end;
                        }
                        textelement("2.1.4.2.4.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.1.2." := rCompanyInformation."Post Code";
                            end;
                        }
                        textelement("2.1.4.2.4.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Town';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.1.3." := RecortaF(rCompanyInformation.City, 50);
                            end;
                        }
                        textelement("2.1.4.2.4.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.1.4." := RecortaF(rCompanyInformation.County, 20);
                            end;
                        }
                        textelement("2.1.4.2.4.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.1.5." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais,
                                                                        rCompanyInformation."Country/Region Code", '');
                            end;
                        }
                    }
                    tableelement("2.1.4.2.4.2."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'OverseasAddress';
                        textelement("2.1.4.2.4.2.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.2.1." := RecortaF(rCompanyInformation.Address, 80);
                            end;
                        }
                        textelement("2.1.4.2.4.2.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCodeAndTown';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.2.2." := RecortaF(rCompanyInformation."Post Code" + rCompanyInformation.City, 50);
                            end;
                        }
                        textelement("2.1.4.2.4.2.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.2.3." := RecortaF(rCompanyInformation.County, 20);
                            end;
                        }
                        textelement("2.1.4.2.4.2.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.4.2.4." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais,
                                                                        rCompanyInformation."Country/Region Code", '');
                            end;
                        }

                        trigger OnAfterGetRecord()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            if rCompanyInformation."Country/Region Code" = culTCNEtiquetasCOM.PaisEspF() then
                                currXMLport.Skip();
                        end;
                    }
                    tableelement("2.1.4.2.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ContactDetails';
                        textelement("2.1.4.2.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Telephone';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.5.1." := RecortaF(rCompanyInformation."Phone No.", 15);
                            end;
                        }
                        textelement("2.1.4.2.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TeleFax';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.5.2." := RecortaF(rCompanyInformation."Fax No.", 15);
                            end;
                        }
                        textelement("2.1.4.2.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WebAddress';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.5.3." := RecortaF(rCompanyInformation."Home Page", 60);
                            end;
                        }
                        textelement("2.1.4.2.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ElectronicMail';

                            trigger OnBeforePassVariable()
                            begin
                                "2.1.4.2.5.4." := RecortaF(rCompanyInformation."E-Mail", 60);
                            end;
                        }
                        textelement("2.1.4.2.5.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ContactPersons';
                        }
                        textelement("2.1.4.2.5.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CnoCnae';

                            trigger OnBeforePassVariable()
                            var
                                clCeros: Label '00000';
                            begin
                                // Completa el formato con ceros por la izqda hasta 5 caracteres totales.
                                "2.1.4.2.5.6." := cuCodeunitsDynamics.RightF(clCeros + rCompanyInformation."Industrial Classification", 5);
                            end;
                        }
                        textelement("2.1.4.2.5.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'INETownCode';
                        }
                        textelement("2.1.4.2.5.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalContactDetails';
                        }
                    }

                    trigger OnAfterGetRecord()
                    begin
                        currXMLport.Break();
                    end;
                }
            }
            tableelement("2.2."; Integer)
            {
                MinOccurs = Zero;
                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                XmlName = 'BuyerParty';
                tableelement("2.2.1."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TaxIdentification';
                    textelement("2.2.1.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'PersonTypeCode';

                        trigger OnBeforePassVariable()
                        var
                            clF: Label 'F';
                            clJ: Label 'J';
                        begin
                            case rContact.Type of
                                rContact.Type::Company:
                                    "2.2.1.1." := clJ;
                                rContact.Type::Person:
                                    "2.2.1.1." := clF;
                            end;
                        end;
                    }
                    textelement("2.2.1.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'ResidenceTypeCode';

                        trigger OnBeforePassVariable()
                        var
                            culTCNFirmarFacturasFIR: Codeunit TCNFirmarFacturasFIR;
                        begin
                            "2.2.1.2." := culTCNFirmarFacturasFIR.GetResidenceTypeCodeF(rCustLedgerEntry);
                        end;
                    }
                    textelement("2.2.1.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TaxIdentificationNumber';

                        trigger OnBeforePassVariable()
                        var
                            culTCNFuncionesComunes: Codeunit TCN_FuncionesComunes;
                            culTCNErroresFIR: Codeunit TCNErroresFIR;
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            if rDatosFirmarFacturas.Cif = '' then begin
                                culTCNFuncionesComunes.ErrorF(culTCNErroresFIR.CIFCLienteVacioF());
                            end;
                            "2.2.1.3." := RecortaF(rDatosFirmarFacturas."Cod pais centro" + rDatosFirmarFacturas.Cif, 30);
                            if rDatosFirmarFacturas."Cod pais centro" = '' then begin
                                RecortaF(culTCNEtiquetasCOM.PaisEspF() + rDatosFirmarFacturas.Cif, 30);
                            end;
                        end;
                    }
                }
                textelement("2.2.2.")
                {
                    MinOccurs = Zero;
                    XmlName = 'PartyIdentification';
                }
                tableelement("2.2.3."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'AdministrativeCentres';
                    tableelement("2.2.3.1."; Integer)
                    {
                        MaxOccurs = Unbounded;
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending);
                        XmlName = 'AdministrativeCentre';
                        textelement("2.2.3.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CentreCode';

                            trigger OnBeforePassVariable()
                            begin

                                rDatosFirmarFacturas.TestField("Cod ofic contable");
                                rDatosFirmarFacturas.TestField("Cod organo gestor");
                                rDatosFirmarFacturas.TestField("Cod ud tramitadora");

                                if xNCentro = 1 then "2.2.3.1.1." := rDatosFirmarFacturas."Cod ofic contable";
                                if xNCentro = 2 then "2.2.3.1.1." := rDatosFirmarFacturas."Cod organo gestor";
                                if xNCentro = 3 then "2.2.3.1.1." := rDatosFirmarFacturas."Cod ud tramitadora";
                                if xNCentro = 4 then "2.2.3.1.1." := rDatosFirmarFacturas."Cod Proponente";
                            end;
                        }
                        textelement("2.2.3.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'RoleTypeCode';

                            trigger OnBeforePassVariable()
                            var
                                clCero: Label '0';
                            begin
                                "2.2.3.1.2." := clCero + Format(xNCentro);
                                xNCentro += 1;
                            end;
                        }
                        textelement("2.2.3.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Name';

                            trigger OnBeforePassVariable()
                            begin
                                // *** TEC-CENTROS
                                "2.2.3.1.3." := AjustaLenTextoF(rDatosFirmarFacturas."Nombre centro");
                            end;
                        }
                        textelement("2.2.3.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'FirstSurname';
                        }
                        textelement("2.2.3.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'SecondSurname';
                        }
                        tableelement("2.2.3.1.6."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AddressInSpain';
                            textelement("2.2.3.1.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';

                                trigger OnBeforePassVariable()
                                begin
                                    // *** TEC-CENTROS
                                    "2.2.3.1.6.1." := AjustaLenTextoF(rDatosFirmarFacturas."Direccion centro");
                                end;
                            }
                            textelement("2.2.3.1.6.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCode';

                                trigger OnBeforePassVariable()
                                begin
                                    // *** TEC-CENTROS
                                    "2.2.3.1.6.2." := rDatosFirmarFacturas."CP centro"
                                end;
                            }
                            textelement("2.2.3.1.6.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Town';

                                trigger OnBeforePassVariable()
                                begin
                                    "2.2.3.1.6.3." := AjustaLenTextoF(rDatosFirmarFacturas."Poblacion centro")
                                end;
                            }
                            textelement("2.2.3.1.6.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';

                                trigger OnBeforePassVariable()
                                begin
                                    // *** TEC-CENTROS
                                    "2.2.3.1.6.4." := AjustaLenTextoF(rDatosFirmarFacturas."Provincia centro");
                                end;
                            }
                            textelement("2.2.3.1.6.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';

                                trigger OnBeforePassVariable()
                                var
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    // Tecon 08-11-10 DPC. Si el código de país está vacío, rellena 'ESP' por defecto.

                                    if "2.2.3.1.6.5." = '' then "2.2.3.1.6.5." := culTCNEtiquetasFIR.PaisPorDefectoF();
                                end;
                            }
                        }
                        tableelement("2.2.3.1.7."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'OverseasAddress';
                            textelement("2.2.3.1.7.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Address';
                            }
                            textelement("2.2.3.1.7.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'PostCodeAndTown';
                            }
                            textelement("2.2.3.1.7.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Province';
                            }
                            textelement("2.2.3.1.7.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CountryCode';

                                trigger OnBeforePassVariable()
                                var
                                    rlCompanyInformation: Record "Company Information";
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    if "2.2.3.1.6.5." = '' then begin
                                        rlCompanyInformation."Country/Region Code" := CopyStr(culTCNEtiquetasFIR.PaisPorDefectoF(), 1, MaxStrLen(rlCompanyInformation."Country/Region Code"));
                                        "2.2.3.1.6.5." := rlCompanyInformation."Country/Region Code";
                                    end;
                                end;
                            }

                            trigger OnAfterGetRecord()
                            begin
                                // ****
                                currXMLport.Break();
                            end;
                        }
                        tableelement("2.2.3.1.8."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'ContactDetails';
                            textelement("2.2.3.1.8.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'Telephone';

                                trigger OnBeforePassVariable()
                                begin
                                    "2.2.3.1.8.1." := RecortaF(rDatosFirmarFacturas."Telefono centro", 15);
                                end;
                            }
                            textelement("2.2.3.1.8.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TeleFax';

                                trigger OnBeforePassVariable()
                                begin
                                    // *** TEC-CENTROS
                                    "2.2.3.1.8.2." := rDatosFirmarFacturas."Fax centro";
                                end;
                            }
                            textelement("2.2.3.1.8.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'WebAddress';
                            }
                            textelement("2.2.3.1.8.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ElectronicMail';
                            }
                            textelement("2.2.3.1.8.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ContactPersons';

                                trigger OnBeforePassVariable()
                                begin
                                    // *** TEC-CENTROS
                                    "2.2.3.1.8.5." := AjustaLenTextoF(rDatosFirmarFacturas.Contacto);
                                end;
                            }
                            textelement("2.2.3.1.8.6.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'CnoCnae';

                                trigger OnBeforePassVariable()
                                var
                                    clCero: Label '00000';
                                begin
                                    "2.2.3.1.8.6." := cuCodeunitsDynamics.RightF(clCero + rDatosFirmarFacturas."Factura CNAE", 5);
                                end;
                            }
                            textelement("2.2.3.1.8.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'INETownCode';
                            }
                            textelement("2.2.3.1.8.8.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AdditionalContactDetails';
                            }
                        }
                        textelement("2.2.3.1.9.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PhysicalGLN';
                        }
                        textelement("2.2.3.1.10.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'LogicalOperationalPoint';
                        }
                        textelement("2.2.3.1.11.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CentreDescription';
                        }

                        trigger OnPreXmlItem()

                        begin
                            // *** 2.2.3.1. Repetimos 3 veces el código del centro para ogano contable, gestor y unidad tramitadora.
                            // "2.2.3.1.".SetFilter(Number, clFiltro, 1, 3);
                            xNCentro := 1;

                            iF rDatosFirmarFacturas."Cod Proponente" <> '' THEN
                                "2.2.3.1.".SETFILTER(Number, cFiltro, 1, 4)
                            ELSE
                                "2.2.3.1.".SETFILTER(Number, cFiltro, 1, 3);
                        end;
                    }
                }
                tableelement("2.2.4."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'LegalEntity';
                    textelement("2.2.4.1.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'CorporateName';

                        trigger OnBeforePassVariable()
                        begin

                            "2.2.4.1.1." := RecortaF(rDatosFirmarFacturas."Nombre centro", 80);
                        end;
                    }
                    textelement("2.2.4.1.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TradeName';

                        trigger OnBeforePassVariable()
                        begin
                            "2.2.4.1.2." := RecortaF(rDatosFirmarFacturas."Nombre centro", 40);
                        end;
                    }
                    tableelement("2.2.4.1.3."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'RegistrationData';
                        textelement("2.2.4.1.3.1")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Book';
                        }
                        textelement("2.2.4.1.3.2")
                        {
                            MinOccurs = Zero;
                            XmlName = 'RegisterOfCompaniesLocation';
                        }
                        textelement("2.2.4.1.3.3")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Sheet';
                        }
                        textelement("2.2.4.1.3.4")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Folio';
                        }
                        textelement("2.2.4.1.3.5")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Section';
                        }
                        textelement("2.2.4.1.3.6")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Volume';
                        }
                        textelement("2.2.4.1.3.7")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalRegistrationData';
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    tableelement("2.2.4.1.4.1."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AddressInSpain';
                        textelement("2.2.4.1.4.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.4.1.1." := RecortaF(rDatosFirmarFacturas."Direccion centro", 80);
                            end;
                        }
                        textelement("2.2.4.1.4.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.4.1.2." := rDatosFirmarFacturas."CP centro"
                            end;
                        }
                        textelement("2.2.4.1.4.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Town';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.4.1.3." := AjustaLenTextoF(rDatosFirmarFacturas."Poblacion centro");
                            end;
                        }
                        textelement("2.2.4.1.4.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.4.1.4." := AjustaLenTextoF(rDatosFirmarFacturas."Provincia centro");
                            end;
                        }
                        textelement("2.2.4.1.4.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.4.1.5." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais,
                                                                            rDatosFirmarFacturas."Cod pais centro", '');
                            end;
                        }

                        trigger OnAfterGetRecord()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            // *** REVISAR
                            rDatosFirmarFacturas.TestField("Cod pais centro");
                            if UpperCase(rDatosFirmarFacturas."Cod pais centro") <> culTCNEtiquetasCOM.PaisEspF() then begin
                                currXMLport.Break();
                            end
                        end;
                    }
                    tableelement("2.2.4.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'OverseasAddress';
                        textelement("2.2.4.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.5.1." := AjustaLenTextoF(rDatosFirmarFacturas."Direccion centro");
                            end;
                        }
                        textelement("2.2.4.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCodeAndTown';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.5.2." := rDatosFirmarFacturas."CP centro" + rDatosFirmarFacturas."Provincia centro"
                            end;
                        }
                        textelement("2.2.4.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.5.3." := AjustaLenTextoF(rDatosFirmarFacturas."Poblacion centro");
                            end;
                        }
                        textelement("2.2.4.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.5.4." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais,
                                                                        rDatosFirmarFacturas."Cod pais centro", '');
                            end;
                        }

                        trigger OnAfterGetRecord()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            if rDatosFirmarFacturas."Cod pais centro" = culTCNEtiquetasCOM.PaisEspF() then
                                currXMLport.Break();
                        end;
                    }
                    tableelement("2.2.4.1.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ContactDetails';
                        textelement("2.2.4.1.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Telephone';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.5.1." := RecortaF(rDatosFirmarFacturas."Telefono centro", 15);
                            end;
                        }
                        textelement("2.2.4.1.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TeleFax';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.5.2." := rDatosFirmarFacturas."Fax centro"
                            end;
                        }
                        textelement("2.2.4.1.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WebAddress';

                            trigger OnBeforePassVariable()
                            begin
                                // **** "2.2.4.1.5.3." := RecortaF(rCliente."Home Page",60);
                            end;
                        }
                        textelement("2.2.4.1.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ElectronicMail';

                            trigger OnBeforePassVariable()
                            begin
                                // *** "2.2.4.1.5.4." := RecortaF(rCliente."E-Mail",60);
                            end;
                        }
                        textelement("2.2.4.1.5.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ContactPersons';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.1.5.5." := AjustaLenTextoF(rDatosFirmarFacturas.Contacto);
                            end;
                        }
                        textelement("2.2.4.1.5.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CnoCnae';

                            trigger OnBeforePassVariable()
                            var
                                clCeros: Label '00000';
                            begin
                                "2.2.4.1.5.6." := cuCodeunitsDynamics.RightF(clCeros + rDatosFirmarFacturas."Factura CNAE", 5);
                            end;
                        }
                        textelement("2.2.4.1.5.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'INETownCode';
                        }
                        textelement("2.2.4.1.5.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalContactDetails';
                        }
                    }

                    trigger OnPreXmlItem()
                    begin
                        if rContact.Type <> rContact.Type::Company then begin
                            currXMLport.Break();
                        end;
                    end;
                }
                tableelement("2.2.4.2."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'Individual';
                    textelement("2.2.4.2.1")
                    {
                        MinOccurs = Zero;
                        XmlName = 'Name';

                        trigger OnAfterAssignVariable()
                        begin
                            "2.2.4.2.1" := AjustaLenTextoF(rDatosFirmarFacturas."Nombre centro");
                        end;
                    }
                    textelement("2.2.4.2.2")
                    {
                        MinOccurs = Zero;
                        XmlName = 'FirstSurname';
                    }
                    textelement("2.2.4.2.3")
                    {
                        MinOccurs = Zero;
                        XmlName = 'SecondSurname';
                    }
                    tableelement("2.2.4.2.4.1."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AddressInSpain';
                        textelement("2.2.4.2.4.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.1.1." := AjustaLenTextoF(rDatosFirmarFacturas."Direccion centro");
                            end;
                        }
                        textelement("2.2.4.2.4.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.1.2." := rDatosFirmarFacturas."CP centro";
                            end;
                        }
                        textelement("2.2.4.2.4.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Town';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.1.3." := AjustaLenTextoF(rDatosFirmarFacturas."Poblacion centro");
                            end;
                        }
                        textelement("2.2.4.2.4.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.1.4." := AjustaLenTextoF(rDatosFirmarFacturas."Provincia centro");
                            end;
                        }
                        textelement("2.2.4.2.4.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.1.5." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais,
                                                                            rDatosFirmarFacturas."Cod pais centro", '');
                            end;
                        }

                        trigger OnPreXmlItem()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            if rDatosFirmarFacturas."Cod pais centro" <> culTCNEtiquetasCOM.PaisEspF() then begin
                                currXMLport.Break();
                            end;
                        end;
                    }
                    tableelement("2.2.4.2.4.2."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'OverseasAddress';
                        textelement("2.2.4.2.4.2.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Address';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.2.1." := AjustaLenTextoF(rDatosFirmarFacturas."Direccion centro");
                            end;
                        }
                        textelement("2.2.4.2.4.2.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCodeAndTown';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.2.2." := rDatosFirmarFacturas."CP centro" + rDatosFirmarFacturas."Provincia centro"
                            end;
                        }
                        textelement("2.2.4.2.4.2.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Province';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.2.3." := AjustaLenTextoF(rDatosFirmarFacturas."Poblacion centro");
                            end;
                        }
                        textelement("2.2.4.2.4.2.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CountryCode';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.4.2.4." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::CodPais,
                                                                            rDatosFirmarFacturas."Cod pais centro", '');
                            end;
                        }

                        trigger OnPreXmlItem()
                        var
                            culTCNEtiquetasCOM: Codeunit TCNEtiquetasCOM;
                        begin
                            if rDatosFirmarFacturas."Cod pais centro" = culTCNEtiquetasCOM.PaisEspF() then begin
                                currXMLport.Break();
                            end;
                        end;
                    }
                    tableelement("2.2.4.2.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ContactDetails';
                        textelement("2.2.4.2.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Telephone';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.5.1." := RecortaF(rDatosFirmarFacturas."Telefono centro", 15);
                            end;
                        }
                        textelement("2.2.4.2.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TeleFax';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.5.2." := rDatosFirmarFacturas."Fax centro";
                            end;
                        }
                        textelement("2.2.4.2.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WebAddress';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.5.3." := rDatosFirmarFacturas.Web
                            end;
                        }
                        textelement("2.2.4.2.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ElectronicMail';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.5.4." := rDatosFirmarFacturas.Email
                            end;
                        }
                        textelement("2.2.4.2.5.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ContactPersons';

                            trigger OnBeforePassVariable()
                            begin
                                "2.2.4.2.5.5." := AjustaLenTextoF(rDatosFirmarFacturas.Contacto);
                            end;
                        }
                        textelement("2.2.4.2.5.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CnoCnae';
                        }
                        textelement("2.2.4.2.5.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'INETownCode';
                        }
                        textelement("2.2.4.2.5.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalContactDetails';
                        }
                    }

                    trigger OnPreXmlItem()
                    begin
                        if rContact.Type <> rContact.Type::Person then
                            currXMLport.Break();
                    end;
                }
            }
        }
        tableelement("3."; Integer)
        {
            MinOccurs = Zero;
            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
            XmlName = 'Invoices';
            tableelement("3.1."; Integer)
            {
                MinOccurs = Zero;
                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                XmlName = 'Invoice';
                tableelement("3.1.1."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'InvoiceHeader';
                    textelement("3.1.1.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceNumber';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.1.1." := RecortaF(TempTCNCabeceraGenericaVentas."No.", 20);
                        end;
                    }
                    textelement("3.1.1.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceSeriesCode';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.1.2." := RecortaF(TempTCNCabeceraGenericaVentas."No. Series", 20);
                        end;
                    }
                    textelement("3.1.1.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceDocumentType';

                        trigger OnBeforePassVariable()
                        var
                            clFC: Label 'FC';
                        begin
                            // *** Valores posibles
                            // FC - Factura completa
                            // FA - Factura abreviada
                            // AF - Autofactura
                            "3.1.1.3." := clFC;
                        end;
                    }
                    textelement("3.1.1.4.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceClass';

                        trigger OnBeforePassVariable()
                        var
                            clOO: Label 'OO';
                        begin
                            // *** Valores posibles
                            // OO - Original
                            // OR - Original rectificativa
                            // OC - Original recapitulativa
                            // CO - Copia original
                            // CR - Copia rectificativa
                            // CC - Copia recapitulativa
                            "3.1.1.4." := clOO;
                        end;
                    }
                    tableelement("3.1.1.5."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'Corrective';
                        textelement("3.1.1.5.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'InvoiceNumber';
                        }
                        textelement("3.1.1.5.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'InvoiceSeriesCode';
                        }
                        textelement("3.1.1.5.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ReasonCode';
                        }
                        textelement("3.1.1.5.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ReasonDescription';
                        }
                        tableelement("3.1.1.5.5."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxPeriod';
                            textelement("3.1.1.5.5.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'StartDate';
                                trigger OnBeforePassVariable()
                                var
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.1.5.5.1." = '') or ("3.1.1.5.5.1." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                        currXMLport.Skip();
                                    end;
                                end;
                            }
                            textelement("3.1.1.5.5.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EndDate';
                                trigger OnBeforePassVariable()
                                var
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.1.5.5.2." = '') or ("3.1.1.5.5.2." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                        currXMLport.Skip();
                                    end;
                                end;
                            }
                        }
                        textelement("3.1.1.5.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CorrectionMethod';
                        }
                        textelement("3.1.1.5.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CorrectionMethodDescription';
                        }
                        textelement("3.1.1.5.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalReasonDescription';
                        }

                        trigger OnPreXmlItem()
                        begin
                            currXMLport.Break();
                        end;
                    }
                }
                tableelement("3.1.2."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'InvoiceIssueData';
                    textelement("3.1.2.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'IssueDate';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.2.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(TempTCNCabeceraGenericaVentas."Posting Date");
                        end;
                    }
                    textelement("3.1.2.2.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'OperationDate';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.2.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(TempTCNCabeceraGenericaVentas."Shipment Date");
                        end;
                    }
                    tableelement("3.1.2.3."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'PlaceOfIssue';
                        textelement("3.1.2.3.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PostCode';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.2.3.1." := TempTCNCabeceraGenericaVentas."Ship-to Post Code";
                            end;
                        }
                        textelement("3.1.2.3.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PlaceOfIssueDescription';

                            trigger OnBeforePassVariable()
                            begin
                                // Tecon 08-11-10 DPC. Recorta la cadena PlaceOfIssueDescription a 20 para evitar error de longitud
                                "3.1.2.3.2." := RecortaF(DelStr(TempTCNCabeceraGenericaVentas."Ship-to Name", 20, 10), 20);
                            end;
                        }
                    }
                    tableelement("3.1.2.4."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                        XmlName = 'InvoicingPeriod';
                        textelement("3.1.2.4.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'StartDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.2.4.1." = '') or ("3.1.2.4.1." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.2.4.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'EndDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.2.4.2." = '') or ("3.1.2.4.2." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    textelement("3.1.2.5.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceCurrencyCode';

                        trigger OnBeforePassVariable()
                        begin
                            if TempTCNCabeceraGenericaVentas."Currency Code" <> '' then
                                "3.1.2.5." := TempTCNCabeceraGenericaVentas."Currency Code"
                            else
                                "3.1.2.5." := rGeneralLedgerSetup."LCY Code";
                        end;
                    }
                    tableelement("3.1.2.6."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                        XmlName = 'ExchangeRateDetails';
                        textelement("3.1.2.6.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ExchangeRate';
                        }
                        textelement("3.1.2.6.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ExchangeRateDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.2.6.2." = '') or ("3.1.2.6.2." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    textelement("3.1.2.7.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TaxCurrencyCode';

                        trigger OnBeforePassVariable()
                        begin
                            // *** La moneda del impuesto es la misma que la de la factura.
                            if TempTCNCabeceraGenericaVentas."Currency Code" <> '' then
                                "3.1.2.7." := TempTCNCabeceraGenericaVentas."Currency Code"
                            else
                                "3.1.2.7." := rGeneralLedgerSetup."LCY Code";
                        end;
                    }
                    textelement("3.1.2.8.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'LanguageName';

                        trigger OnBeforePassVariable()
                        var
                            culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                        begin
                            "3.1.2.8." := culTCNEtiquetasFIR.IdiomaEsF();
                        end;
                    }
                }
                tableelement("3.1.3."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'TaxesOutputs';
                    tableelement("3.1.3.1."; Integer)
                    {
                        MaxOccurs = Unbounded;
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) WHERE(Number = CONST(1));
                        XmlName = 'Tax';
                        textelement("3.1.3.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TaxTypeCode';
                        }
                        textelement("3.1.3.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TaxRate';
                        }
                        tableelement("3.1.3.1.3."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxableBase';
                            textelement("3.1.3.1.3.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.3.1.3.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }
                        }
                        tableelement("3.1.3.1.4."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxAmount';
                            textelement("3.1.3.1.4.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.3.1.4.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }
                        }
                        tableelement("3.1.3.1.5."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'SpecialTaxableBase';
                            textelement("3.1.3.1.5.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.3.1.5.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }

                            trigger OnPreXmlItem()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        tableelement("3.1.3.1.6."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'SpecialTaxAmount';
                            textelement("3.1.3.1.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.3.1.6.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }

                            trigger OnPreXmlItem()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        textelement("3.1.3.1.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'EquivalenceSurcharge';
                        }
                        tableelement("3.1.3.1.8."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                            XmlName = 'EquivalenceSurchargeAmount';
                            textelement("3.1.3.1.8.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.3.1.8.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;

                            trigger OnPreXmlItem()
                            begin
                                // *** currXMLport.BREAK;
                            end;
                        }

                        trigger OnAfterGetRecord()
                        var
                            clCeroUno: Label '01';
                        begin
                            if "3.1.3.1.".number = 1 then begin
                                TempVatEntry.FindSet(false);
                            end else begin
                                TempVatEntry.Next();
                            end;

                            // *** Establezco los valores siguientes
                            // *** 01 es el código para el IVA.
                            "3.1.3.1.1." := clCeroUno;
                            "3.1.3.1.2." := FormatoNumeroEnteroF(TempVatEntry."VAT %", 2);
                            "3.1.3.1.7." := FormatoNumeroDecimalF(TempVatEntry."EC %", 2);
                            "3.1.3.1.3.1." := FormatoNumeroDecimalF(abs(TempVatEntry.Base), 2);
                            "3.1.3.1.3.2." := FormatoNumeroDecimalF(abs(TempVatEntry.Base), 2);
                            "3.1.3.1.4.1." := FormatoNumeroDecimalF(abs(TempVatEntry.Amount), 2);
                            "3.1.3.1.4.2." := FormatoNumeroDecimalF(abs(TempVatEntry.Amount), 2);
                            "3.1.3.1.8.1." := FormatoNumeroDecimalF(0, 2);
                            "3.1.3.1.8.2." := FormatoNumeroDecimalF(0, 2);
                        end;

                        trigger OnPreXmlItem()
                        var
                            xlPorcIVA: List of [Integer];
                        begin
                            TempVatEntry.DeleteAll(false);
                            rVatEntry.Reset();
                            rVatEntry.SetRange("Document No.", TempTCNCabeceraGenericaVentas."No.");
                            rVatEntry.SetRange("Posting Date", TempTCNCabeceraGenericaVentas."Posting Date");
                            if rVatEntry.FindSet(false) then begin
                                repeat
                                    if xlPorcIVA.Contains(rVatEntry."VAT %") then begin
                                        TempVatEntry.SetRange("VAT %", rVatEntry."VAT %");
                                        TempVatEntry.FindFirst();
                                        TempVatEntry.Base += rVatEntry.Base;
                                        TempVatEntry.Amount += rVatEntry.Amount;
                                        TempVatEntry.Modify(false);
                                    end else begin
                                        xlPorcIVA.Add(rVatEntry."VAT %");
                                        TempVatEntry.Init();
                                        TempVatEntry := rVatEntry;
                                        TempVatEntry.Insert(false);
                                    end
                                until rVatEntry.Next() = 0;
                            end;
                            TempVatEntry.Reset();
                            "3.1.3.1.".setrange(number, 1, TempVatEntry.Count);
                        end;
                    }
                }
                tableelement("3.1.4."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                    XmlName = 'TaxesWithheld';
                    tableelement("3.1.4.1."; Integer)
                    {
                        MaxOccurs = Unbounded;
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'Tax';
                        textelement("3.1.4.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TaxTypeCode';
                        }
                        textelement("3.1.4.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TaxRate';
                        }
                        tableelement("3.1.4.1.3."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxableBase';
                            textelement("3.1.4.1.3.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.4.1.3.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }
                        }
                        tableelement("3.1.4.1.4."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxAmount';
                            textelement("3.1.4.1.4.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'TotalAmount';
                            }
                            textelement("3.1.4.1.4.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EquivalentInEuros';
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;
                        }
                    }

                    trigger OnAfterGetRecord()
                    begin
                        currXMLport.Break();
                    end;

                    trigger OnPreXmlItem()
                    begin
                        // *** TEC
                        // *** pendiente de analizar las retenciones ***
                    end;
                }
                tableelement("3.1.5."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'InvoiceTotals';
                    textelement("3.1.5.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalGrossAmount';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.1." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::Amount) + mDtoFactura[1] + mDtoFactura[2], 2);
                        end;
                    }
                    tableelement("3.1.5.2."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'GeneralDiscounts';
                        tableelement("3.1.5.2.1."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending);
                            XmlName = 'Discount';
                            textelement("3.1.5.2.1.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'DiscountReason';
                            }
                            textelement("3.1.5.2.1.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'DiscountRate';
                            }
                            textelement("3.1.5.2.1.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'DiscountAmount';
                            }

                            trigger OnAfterGetRecord()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin

                                if mDtoFactura["3.1.5.2.1.".Number] <> 0 then begin
                                    "3.1.5.2.1.1." := culTCNEtiquetasFIR.DtoF() + Format("mDto%"["3.1.5.2.1.".Number]) + culTCNEtiquetasFIR.PorcentajeF();
                                    "3.1.5.2.1.2." := FormatoNumeroDecimalF("mDto%"["3.1.5.2.1.".Number], 4);
                                    "3.1.5.2.1.3." := FormatoNumeroDecimalF(mDtoFactura["3.1.5.2.1.".Number], 6);
                                end;
                            end;

                            trigger OnPreXmlItem()
                            begin
                                if (mDtoFactura[1] <> 0) and (mDtoFactura[2] <> 0) then begin
                                    "3.1.5.2.1.".SetRange(Number, 1, 2);
                                end;
                                if (mDtoFactura[1] <> 0) and (mDtoFactura[2] = 0) then begin
                                    "3.1.5.2.1.".SetRange(Number, 1);
                                end;
                                if (mDtoFactura[1] = 0) and (mDtoFactura[2] <> 0) then begin
                                    "3.1.5.2.1.".SetRange(Number, 2);
                                end;

                                // *** NOTA: Filtros aplicados en el OnPreXMLPort.
                            end;
                        }

                        trigger OnAfterGetRecord()
                        begin
                            // *** tec- pendiente de analizar los descuentos
                            if (mDtoFactura[1] = 0) and (mDtoFactura[2] = 0) then begin
                                currXMLport.Break();
                            end;
                        end;
                    }
                    tableelement("3.1.5.3."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(0));
                        XmlName = 'GeneralSurcharges';
                        tableelement("3.1.5.3.1."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'Charge';
                            textelement("3.1.5.3.1.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ChargeReason';
                            }
                            textelement("3.1.5.3.1.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ChargeRate';
                            }
                            textelement("3.1.5.3.1.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ChargeAmount';
                            }
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Skip();
                            "3.1.5.3.1.2." := FormatoNumeroDecimalF(0, 4);
                            "3.1.5.3.1.3." := FormatoNumeroDecimalF(0, 6);
                        end;

                        trigger OnPreXmlItem()
                        begin
                        end;
                    }
                    textelement("3.1.5.4.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalGeneralDiscounts';
                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.4." := FormatoNumeroDecimalF(mDtoFactura[1] + mDtoFactura[2], 2);
                        end;
                    }
                    textelement("3.1.5.5.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalGeneralSurcharges';

                        trigger OnBeforePassVariable()
                        begin
                            currXMLport.Skip();
                            "3.1.5.5." := FormatoNumeroDecimalF(0, 2);
                        end;
                    }
                    textelement("3.1.5.6.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalGrossAmountBeforeTaxes';

                        trigger OnBeforePassVariable()
                        begin

                            "3.1.5.6." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::Amount), 2);
                        end;
                    }
                    textelement("3.1.5.7.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalTaxOutputs';

                        trigger OnBeforePassVariable()

                        begin
                            "3.1.5.7." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT") -
                            CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::Amount), 2);
                        end;
                    }
                    textelement("3.1.5.8.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalTaxesWithheld';

                        trigger OnBeforePassVariable()
                        begin
                            TempTCNCabeceraGenericaVentas.CalcFields(Amount, "Amount Including VAT");
                            // *** "3.1.5.8." := FormatoNumeroDecimalF(rCabeceraGenerica.Amount,2);
                        end;
                    }
                    textelement("3.1.5.9.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceTotal';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.9." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);
                        end;
                    }
                    tableelement("3.1.5.10."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'Subsidies';
                        tableelement("3.1.5.10.1."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'Subsidy';
                            textelement("3.1.5.10.1.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'SubsidyDescription';
                            }
                            textelement("3.1.5.10.1.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'SubsidyRate';
                            }
                            textelement("3.1.5.10.1.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'SubsidyAmount';
                            }
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    tableelement("3.1.5.11."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'PaymentsOnAccount';
                        textelement("3.1.5.11.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentOnAccount';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.5.11.1." = '') or ("3.1.5.11.1." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.5.11.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentOnAccountDate';
                        }
                        textelement("3.1.5.11.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentOnAccountAmount';
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    tableelement("3.1.5.12."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'ReimbursableExpenses';
                        tableelement("3.1.5.12.1."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'ReimbursableExpenses';
                            tableelement("3.1.5.12.1.1."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'ReimbursableExpensesSellerParty';
                                textelement("3.1.5.12.1.1.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PersonTypeCode';
                                }
                                textelement("3.1.5.12.1.1.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'ResidenceTypeCode';
                                }
                                textelement("3.1.5.12.1.1.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'TaxIdentificationNumber';
                                }
                            }
                            tableelement("3.1.5.12.1.2."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'ReimbursableExpensesBuyerParty';
                                textelement("3.1.5.12.1.2.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PersonTypeCode';
                                }
                                textelement("3.1.5.12.1.2.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'ResidenceTypeCode';
                                }
                                textelement("3.1.5.12.1.2.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'TaxIdentificationNumber';
                                }
                            }
                            textelement("3.1.5.12.1.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'IssueDate';
                                trigger OnBeforePassVariable()
                                var
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.5.12.1.3." = '') or ("3.1.5.12.1.3." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                        currXMLport.Skip();
                                    end;
                                end;
                            }
                            textelement("3.1.5.12.1.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'InvoiceNumber';
                            }
                            textelement("3.1.5.12.1.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'InvoiceSeriesCode';
                            }
                            textelement("3.1.5.12.1.6.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'ReimbursableExpensesAmount';
                            }
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    textelement("3.1.5.13.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalFinancialExpenses';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.13." := FormatoNumeroEnteroF(0, 2);
                        end;
                    }
                    textelement("3.1.5.14.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalOutstandingAmount';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.14." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);

                        end;
                    }
                    textelement("3.1.5.15.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalPaymentsOnAccount';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.15." := FormatoNumeroEnteroF(0, 2);
                        end;
                    }
                    tableelement("3.1.5.16."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'AmountsWithheld';
                        textelement("3.1.5.16.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WithholdingReason';
                        }
                        textelement("3.1.5.16.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WithholdingRate';
                        }
                        textelement("3.1.5.16.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'WithholdingAmount';
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    textelement("3.1.5.17.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalExecutableAmount';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.17." := FormatoNumeroDecimalF(CalculaImporteF(TempTCNCabeceraGenericaVentas."No.", TempTCNLinGenericaVentas, cTCNFirmarFacturasFIR.tipoImporteOpc() ::"Amount Including VAT"), 2);

                        end;
                    }
                    textelement("3.1.5.18.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'TotalReimbursableExpenses';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.5.18." := FormatoNumeroEnteroF(0, 2);
                        end;
                    }
                }
                tableelement("3.1.6."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'Items';
                    tableelement("3.1.6.1."; Integer)
                    {
                        MaxOccurs = Unbounded;
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending);
                        XmlName = 'InvoiceLine';
                        textelement("3.1.6.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'IssuerContractReference';
                        }
                        textelement("3.1.6.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'IssuerContractDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.2." = '') or ("3.1.6.1.2." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.6.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'IssuerTransactionReference';
                        }
                        textelement("3.1.6.1.4.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'IssuerTransactionDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.4." = '') or ("3.1.6.1.4." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.6.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ReceiverContractReference';
                        }
                        textelement("3.1.6.1.6.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ReceiverContractDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.6." = '') or ("3.1.6.1.6." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.6.1.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ReceiverTransactionReference';
                        }
                        textelement("3.1.6.1.8.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ReceiverTransactionDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.8." = '') or ("3.1.6.1.8." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.6.1.9.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'FileReference';
                        }
                        textelement("3.1.6.1.10.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'FileDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.10." = '') or ("3.1.6.1.10." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.6.1.11.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'SequenceNumber';
                        }
                        tableelement("3.1.6.1.12."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'DeliveryNotesReferences';
                            tableelement("3.1.6.1.12.1."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'DeliveryNote';
                                textelement("3.1.6.1.12.1.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'DeliveryNoteNumber';
                                }
                                textelement("3.1.6.1.12.1.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'DeliveryNoteDate';
                                    trigger OnBeforePassVariable()
                                    var
                                        culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                    begin
                                        if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.12.1.2." = '') or ("3.1.6.1.12.1.2." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                            currXMLport.Skip();
                                        end;
                                    end;
                                }
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        textelement("3.1.6.1.13.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ItemDescription';

                            trigger OnBeforePassVariable()
                            begin
                                // *** En el documento aparece como longitud 2500 pero es excesivo.
                                "3.1.6.1.13." := RecortaF(TempTCNLinGenericaVentas.Description + TempTCNLinGenericaVentas."Description 2", 250);
                            end;
                        }
                        textelement("3.1.6.1.14.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Quantity';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.6.1.14." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas.Quantity, 2);
                            end;
                        }
                        textelement("3.1.6.1.15.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'UnitOfMeasure';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.6.1.15." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::UdMedida,
                                                                         TempTCNLinGenericaVentas."Unit of Measure Code", '');
                            end;
                        }
                        textelement("3.1.6.1.16.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'UnitPriceWithoutTax';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.6.1.16." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Unit Price", 6);
                            end;
                        }
                        textelement("3.1.6.1.17.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TotalCost';

                            trigger OnBeforePassVariable()
                            begin
                                if TempTCNLinGenericaVentas."Line Discount %" = 100 then
                                    "3.1.6.1.17." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Unit Price", 6)
                                else
                                    // Lo que pone en la norma: Coste Total. Resultado: Quantity x UnitPriceWithoutTax
                                    "3.1.6.1.17." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas.Quantity * TempTCNLinGenericaVentas."Unit Price", 6);
                            end;
                        }
                        tableelement("3.1.6.1.18."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'DiscountsAndRebates';
                            tableelement("3.1.6.1.18.1."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'Discount';
                                textelement("3.1.6.1.18.1.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'DiscountReason';
                                }
                                textelement("3.1.6.1.18.1.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'DiscountRate';
                                }
                                textelement("3.1.6.1.18.1.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'DiscountAmount';
                                }
                            }

                            trigger OnAfterGetRecord()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if TempTCNLinGenericaVentas."Line Discount %" = 0 then
                                    currXMLport.Break()
                                else begin
                                    "3.1.6.1.18.1.1." := culTCNEtiquetasFIR.DtoF() + Format(TempTCNLinGenericaVentas."Line Discount %") + culTCNEtiquetasFIR.PorcentajeF();
                                    "3.1.6.1.18.1.2." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Line Discount %", 4);
                                    if TempTCNLinGenericaVentas."Line Discount %" = 100 then
                                        "3.1.6.1.18.1.3." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Unit Price", 6)
                                    else
                                        "3.1.6.1.18.1.3." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Line Discount Amount", 6);
                                end;
                            end;
                        }
                        tableelement("3.1.6.1.19."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'Charges';
                            tableelement("3.1.6.1.19.1."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'Charge';
                                textelement("3.1.6.1.19.1.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'ChargeReason';
                                }
                                textelement("3.1.6.1.19.1.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'ChargeRate';
                                }
                                textelement("3.1.6.1.19.1.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'ChargeAmount';
                                }
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Skip();
                            end;

                            trigger OnPreXmlItem()
                            begin
                                // *** NOTA: No podemos realizar un break porque sino se salta el campo  GrossAmount que es necesario
                                // *** currXMLport.BREAK;
                            end;
                        }
                        textelement("3.1.6.1.20.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'GrossAmount';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.6.1.20." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Line Amount", 6);
                            end;
                        }
                        tableelement("3.1.6.1.21."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxesWithheld';
                            tableelement("3.1.6.1.21.1."; Integer)
                            {
                                MaxOccurs = Unbounded;
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'Tax';
                                textelement("3.1.6.1.21.1.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'TaxTypeCode';
                                }
                                textelement("3.1.6.1.21.1.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'TaxRate';
                                }
                                tableelement("3.1.6.1.21.1.3."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'TaxableBase';
                                    textelement("3.1.6.1.21.1.3.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.21.1.3.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }
                                }
                                tableelement("3.1.6.1.21.1.4."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'TaxAmount';
                                    textelement("3.1.6.1.21.1.4.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.21.1.4.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }
                                }
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        tableelement("3.1.6.1.22."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'TaxesOutputs';
                            tableelement("3.1.6.1.22.1."; Integer)
                            {
                                MaxOccurs = Unbounded;
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'Tax';
                                textelement("3.1.6.1.22.1.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'TaxTypeCode';
                                }
                                textelement("3.1.6.1.22.1.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'TaxRate';
                                }
                                tableelement("3.1.6.1.22.1.3."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'TaxableBase';
                                    textelement("3.1.6.1.22.1.3.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.22.1.3.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }
                                }
                                tableelement("3.1.6.1.22.1.4."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'TaxAmount';
                                    textelement("3.1.6.1.22.1.4.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.22.1.4.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }
                                }
                                tableelement("3.1.6.1.22.1.5."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'SpecialTaxableBase';
                                    textelement("3.1.6.1.22.1.5.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.22.1.5.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }

                                    trigger OnPreXmlItem()
                                    begin
                                        currXMLport.Break();
                                    end;
                                }
                                tableelement("3.1.6.1.22.1.6."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'SpecialTaxAmount';
                                    textelement("3.1.6.1.22.1.6.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.22.1.6.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }

                                    trigger OnPreXmlItem()
                                    begin
                                        currXMLport.Break()
                                    end;
                                }
                                textelement("3.1.6.1.22.1.7.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'EquivalenceSurcharge';
                                }
                                tableelement("3.1.6.1.22.1.8."; Integer)
                                {
                                    MinOccurs = Zero;
                                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                    XmlName = 'EquivalenceSurchargeAmount';
                                    textelement("3.1.6.1.22.1.8.1.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'TotalAmount';
                                    }
                                    textelement("3.1.6.1.22.1.8.2.")
                                    {
                                        MinOccurs = Zero;
                                        XmlName = 'EquivalentInEuros';
                                    }

                                    trigger OnPreXmlItem()
                                    begin
                                        // *** currXMLport.BREAK;
                                    end;
                                }

                                trigger OnAfterGetRecord()
                                begin
                                    rVATPostingSetup.Reset();
                                    rVATPostingSetup.SetCurrentKey("VAT Bus. Posting Group", "VAT Prod. Posting Group");

                                    if TempTCNLinGenericaVentas.Type <> TempTCNLinGenericaVentas.Type::" " then begin
                                        rVATPostingSetup.Get(TempTCNLinGenericaVentas."VAT Bus. Posting Group", TempTCNLinGenericaVentas."VAT Prod. Posting Group");
                                    end else begin
                                        Clear(rVATPostingSetup);
                                    end;

                                    "3.1.6.1.22.1.1." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::IVA, rVATPostingSetup."VAT Bus. Posting Group", rVATPostingSetup."VAT Prod. Posting Group");
                                    "3.1.6.1.22.1.2." := FormatoNumeroDecimalF(rVATPostingSetup."VAT %", 2);
                                    "3.1.6.1.22.1.3.1." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas.Amount, 2);
                                    "3.1.6.1.22.1.3.2." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas.Amount, 2);
                                    "3.1.6.1.22.1.4.1." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Amount Including VAT" - TempTCNLinGenericaVentas.Amount, 2);
                                    "3.1.6.1.22.1.4.2." := FormatoNumeroDecimalF(TempTCNLinGenericaVentas."Amount Including VAT" - TempTCNLinGenericaVentas.Amount, 2);
                                    "3.1.6.1.22.1.7." := FormatoNumeroDecimalF(rVATPostingSetup."EC %", 2);
                                    "3.1.6.1.22.1.8.1." := FormatoNumeroDecimalF((rVATPostingSetup."EC %" / 100) * TempTCNLinGenericaVentas."VAT Base Amount", 2);
                                    "3.1.6.1.22.1.8.2." := FormatoNumeroDecimalF((rVATPostingSetup."EC %" / 100) * TempTCNLinGenericaVentas."VAT Base Amount", 2);
                                end;
                            }
                        }
                        tableelement("3.1.6.1.23."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'LineItemPeriod';
                            textelement("3.1.6.1.23.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'StartDate';
                                trigger OnBeforePassVariable()
                                var
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.23.1." = '') or ("3.1.6.1.23.1." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                        currXMLport.Skip();
                                    end;
                                end;
                            }
                            textelement("3.1.6.1.23.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'EndDate';
                                trigger OnBeforePassVariable()
                                var
                                    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                                begin
                                    if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.23.2." = '') or ("3.1.6.1.23.2." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                        currXMLport.Skip();
                                    end;
                                end;
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        textelement("3.1.6.1.24.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'TransactionDate';
                            trigger OnBeforePassVariable()
                            var
                                culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
                            begin
                                if (rConfiguracionFirmaFacturas.NoInformarFechasVacias) and ("3.1.6.1.24." = '') or ("3.1.6.1.24." = culTCNEtiquetasFIR.FechaNoValidaF()) then begin
                                    currXMLport.Skip();
                                end;
                            end;
                        }
                        textelement("3.1.6.1.25.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'AdditionalLineItemInformation';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.6.1.25." := DevInfoTipoBlancoF(TempTCNLinGenericaVentas);
                            end;
                        }
                        tableelement("3.1.6.1.26."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'SpecialTaxableEvent';
                            textelement("3.1.6.1.26.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'SpecialTaxableEventCode';
                            }
                            textelement("3.1.6.1.26.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'SpecialTaxableEventReason';
                            }

                            trigger OnAfterGetRecord()
                            begin
                                currXMLport.Break();
                            end;
                        }
                        textelement("3.1.6.1.27.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'ArticleCode';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.6.1.27." := RecortaF(TempTCNLinGenericaVentas."No.", 20);
                            end;
                        }
                        textelement("3.1.6.1.28.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'Extensions';
                            trigger OnBeforePassVariable()
                            begin
                                currXMLport.Skip();
                            end;
                        }

                        trigger OnAfterGetRecord()
                        var
                            clPunto: Label '.';
                        begin
                            if xPrimeraLínea then begin
                                TempTCNLinGenericaVentas.FindSet();
                                xPrimeraLínea := false;
                            end else
                                TempTCNLinGenericaVentas.Next();
                            if TempTCNLinGenericaVentas.Description.Trim() = '' then
                                TempTCNLinGenericaVentas.Description := clPunto;
                        end;

                        trigger OnPreXmlItem()
                        begin
                            FiltraLineasF();
                            "3.1.6.1.".SetRange(Number, 1, TempTCNLinGenericaVentas.Count);
                            xPrimeraLínea := true;
                        end;
                    }
                }
                tableelement("3.1.7."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'PaymentDetails';
                    tableelement("3.1.7.1."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'Installment';
                        textelement("3.1.7.1.1.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'InstallmentDueDate';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.7.1.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(rCustLedgerEntry."Due Date");
                            end;
                        }
                        textelement("3.1.7.1.2.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'InstallmentAmount';

                            trigger OnBeforePassVariable()
                            begin
                                rCustLedgerEntry.CalcFields("Amount (LCY)");
                                "3.1.7.1.2." := FormatoNumeroDecimalF(rCustLedgerEntry."Amount (LCY)", 2);
                            end;
                        }
                        textelement("3.1.7.1.3.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentMeans';

                            trigger OnBeforePassVariable()
                            begin
                                "3.1.7.1.3." := DevolverEquivalenciaF(rEquivalenciaseFacturaSTD.Tipo::FormaPago,
                                                                        TempTCNCabeceraGenericaVentas."Payment Method Code", '');
                            end;
                        }
                        tableelement("3.1.7.1.4."; Integer)
                        {
                            MaxOccurs = Unbounded;
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AccountToBeCredited';
                            textelement("3.1.7.1.4.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'IBAN';

                                trigger OnBeforePassVariable()
                                begin
                                    rCompanyInformation.TestField(IBAN);
                                    "3.1.7.1.4.1." := rCompanyInformation.IBAN;
                                end;
                            }
                            tableelement("3.1.7.1.4.5."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'BranchInSpainAddress';
                                textelement("3.1.7.1.4.5.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("3.1.7.1.4.5.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCode';
                                }
                                textelement("3.1.7.1.4.5.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Town';
                                }
                                textelement("3.1.7.1.4.5.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("3.1.7.1.4.5.5.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }

                                trigger OnAfterGetRecord()
                                begin
                                    currXMLport.Break();
                                end;
                            }
                            tableelement("3.1.7.1.4.6."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'OverseasBranchAddress';
                                textelement("3.1.7.1.4.6.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("3.1.7.1.4.6.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCodeAndTown';
                                }
                                textelement("3.1.7.1.4.6.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("3.1.7.1.4.6.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }

                                trigger OnAfterGetRecord()
                                begin
                                    currXMLport.Break();
                                end;
                            }
                            textelement("3.1.7.1.4.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BIC';

                                trigger OnBeforePassVariable()
                                var
                                    clX: Label 'X';
                                begin
                                    rCompanyInformation.TestField("SWIFT Code");
                                    // *** Si el BIC no viene relleno hasta 11 hay que rellenarlo con X
                                    "3.1.7.1.4.7." := PadStr(CopyStr(rCompanyInformation."SWIFT Code", 1, 11), 11, clX);
                                end;
                            }

                            trigger OnAfterGetRecord()
                            var
                                clCeroCuatro: Label '04';
                            begin
                                if "3.1.7.1.3." <> clCeroCuatro then begin
                                    currXMLport.Break();
                                end;
                            end;
                        }
                        textelement("3.1.7.1.5.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'PaymentReconciliationReference';
                        }
                        tableelement("3.1.7.1.6."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'AccountToBeDebited';
                            textelement("3.1.7.1.6.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'IBAN';

                                trigger OnBeforePassVariable()
                                begin
                                    rCustomerBankAccount.TestField(IBAN);
                                    "3.1.7.1.6.1." := rCustomerBankAccount.IBAN;
                                end;
                            }
                            tableelement("3.1.7.1.6.5."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'BranchInSpainAddress';
                                textelement("3.1.7.1.6.5.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("3.1.7.1.6.5.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCode';
                                }
                                textelement("3.1.7.1.6.5.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Town';
                                }
                                textelement("3.1.7.1.6.5.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("3.1.7.1.6.5.5.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }

                                trigger OnAfterGetRecord()
                                begin
                                    currXMLport.Break();
                                end;
                            }
                            tableelement("3.1.7.1.6.6."; Integer)
                            {
                                MinOccurs = Zero;
                                SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                                XmlName = 'OverseasBranchAddress';
                                textelement("3.1.7.1.6.6.1.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Address';
                                }
                                textelement("3.1.7.1.6.6.2.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'PostCodeAndTown';
                                }
                                textelement("3.1.7.1.6.6.3.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'Province';
                                }
                                textelement("3.1.7.1.6.6.4.")
                                {
                                    MinOccurs = Zero;
                                    XmlName = 'CountryCode';
                                }

                                trigger OnAfterGetRecord()
                                begin
                                    currXMLport.Break();
                                end;
                            }
                            textelement("3.1.7.1.6.7.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'BIC';

                                trigger OnBeforePassVariable()
                                begin
                                    // *** Tec 11-01-2017. Comprobamos que el Swift code esté informadoen el banco del cliente.
                                    rCustomerBankAccount.TestField(rCustomerBankAccount."SWIFT Code");
                                    "3.1.7.1.6.7." := rCustomerBankAccount."SWIFT Code";
                                end;
                            }

                            trigger OnAfterGetRecord()
                            var
                                culTCNFuncionesComunes: Codeunit TCN_FuncionesComunes;
                                culTCNErroresFIR: Codeunit TCNErroresFIR;
                                clCeroDos: Label '02';
                            begin
                                if "3.1.7.1.3." <> clCeroDos then begin
                                    currXMLport.Break();
                                end else begin
                                    if not rCustomerBankAccount.Get(TempTCNCabeceraGenericaVentas."Bill-to Customer No.",
                                                                    TempTCNCabeceraGenericaVentas."Cust. Bank Acc. Code") then begin
                                        if not rCustomerBankAccount.Get(rDatosFirmarFacturas.Cliente, rDatosFirmarFacturas."Cuenta bancaria preferida") then begin
                                            culTCNFuncionesComunes.ErrorF(culTCNErroresFIR.FactNoInfBancoF());
                                        end;
                                    end;
                                end;
                            end;
                        }
                        textelement("3.1.7.1.7.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'CollectionAdditionalInformation';
                        }
                        textelement("3.1.7.1.9.")
                        {
                            MinOccurs = Zero;
                            XmlName = 'DebitReconciliationReference';
                        }

                        trigger OnAfterGetRecord()
                        begin
                            if xPrimerVencimiento then begin
                                rCustLedgerEntry.FindSet();
                                xPrimerVencimiento := false;
                            end else begin
                                rCustLedgerEntry.Next();
                            end;
                        end;

                        trigger OnPreXmlItem()
                        begin
                            xPrimerVencimiento := true;
                        end;
                    }
                }
                tableelement("3.1.8."; Integer)
                {
                    MinOccurs = Zero;
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'LegalLiterals';
                    textelement("3.1.8.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'LegalReference';
                    }

                    trigger OnAfterGetRecord()
                    begin
                        currXMLport.Break();
                    end;
                }
                tableelement("3.1.9."; Integer)
                {
                    SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                    XmlName = 'AdditionalData';
                    textattribute(xmlns)
                    {
                    }
                    textelement("3.1.9.1.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'RelatedInvoice';
                    }
                    tableelement("3.1.9.2."; Integer)
                    {
                        MinOccurs = Zero;
                        SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                        XmlName = 'RelatedDocuments';
                        tableelement("3.1.9.2.1."; Integer)
                        {
                            MinOccurs = Zero;
                            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
                            XmlName = 'Attachment';
                            textelement("3.1.9.2.1.1.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AttachmentCompressionAlgorithm';
                            }
                            textelement("3.1.9.2.1.2.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AttachmentFormat';
                            }
                            textelement("3.1.9.2.1.3.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AttachmentEncoding';
                            }
                            textelement("3.1.9.2.1.4.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AttachmentDescription';
                            }
                            textelement("3.1.9.2.1.5.")
                            {
                                MinOccurs = Zero;
                                XmlName = 'AttachmentData';
                            }
                        }

                        trigger OnAfterGetRecord()
                        begin
                            currXMLport.Break();
                        end;
                    }
                    textelement("3.1.9.3.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'InvoiceAdditionalInformation';

                        trigger OnBeforePassVariable()
                        begin
                            "3.1.9.3." := cuTCNFirmarFacturasFIR.DevInfoCommentCabF(TempTCNCabeceraGenericaVentas);
                        end;
                    }
                    textelement("3.1.9.4.")
                    {
                        MinOccurs = Zero;
                        XmlName = 'Extensions';
                    }

                    trigger OnPreXmlItem()
                    begin
                        if cuTCNFirmarFacturasFIR.DevInfoCommentCabF(TempTCNCabeceraGenericaVentas) = '' then begin
                            currXMLport.Break();
                        end
                    end;
                }
            }
        }
        tableelement("4."; Integer)
        {
            MinOccurs = Zero;
            SourceTableView = SORTING(Number) ORDER(Ascending) WHERE(Number = CONST(1));
            XmlName = 'Extensions';

            trigger OnPreXmlItem()
            begin
                currXMLport.Break();
            end;
        }
    }
}
trigger OnPreXmlPort()
var
    culTCNFuncionesComunes: Codeunit TCN_FuncionesComunes;
    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
    clConcatena: Label '%1%2';
    clDtoNoContemplado: Label 'El cálculo de dto en factrura y dto. por pronto pago no está contemplado actualmente en la EFactura.';
begin
    xRepetirOrganoContable := 3;

    rConfiguracionFirmaFacturas.GetF();
    rCompanyInformation.Get();
    rGeneralLedgerSetup.Get();

    InicializaValoresF();

    TempTCNCabeceraGenericaVentas.Get(TempTCNCabeceraGenericaVentas."Document Type"::Oferta, xFactura, 0);
    FiltraLineasF();
    if TempTCNLinGenericaVentas.FindSet() then begin
        repeat
            rVATPostingSetup.Get(TempTCNCabeceraGenericaVentas."VAT Bus. Posting Group", TempTCNLinGenericaVentas."VAT Prod. Posting Group");
            rVATPostingSetup.Mark(true);
        until TempTCNLinGenericaVentas.Next() = 0;
    end;
    rVATPostingSetup.MarkedOnly(true);
    "3.1.3.1.".SetRange(Number, 1, rVATPostingSetup.Count);

    // Se calcula de dto pp y de factura.
    xContadorDtos := 0;
    Clear(mDtoFactura);
    Clear("mDto%");
    CalculaDescuentosF(mDtoFactura[1], mDtoFactura[2]);
    if (mDtoFactura[1] <> 0) and (mDtoFactura[2] <> 0) then
        culTCNFuncionesComunes.ErrorF(clDtoNoContemplado);

    if mDtoFactura[1] <> 0 then begin
        "mDto%"[1] := PorcDtoF(TempTCNCabeceraGenericaVentas."No.");
        mCodDto[1] := StrSubstNo(clConcatena, culTCNEtiquetasFIR.DtoFacturaF(), "mDto%"[1]);
    end;
    if mDtoFactura[2] <> 0 then begin
        //"mDto%"[2] := rCabeceraGenerica."Payment Discount %";
        "mDto%"[2] := PorcDtoPPF(TempTCNCabeceraGenericaVentas."No.");
        mCodDto[2] := StrSubstNo(clConcatena, culTCNEtiquetasFIR.DtoppF(), "mDto%"[2]);
    end;


    // BUSCAMOS EL Nº DE VENCIMIENTOS DE LA FACTURA.
    FormaDePagoF(TempTCNCabeceraGenericaVentas."Payment Method Code", xTipoDePago);
    xNVencimientos := GetNumVtoFacturaF(TempTCNCabeceraGenericaVentas."No.", xTipoDePago);
    "3.1.7.1.".SetRange(Number, 1, xNVencimientos);

    // 2.2.3.1. Repetimos 3 veces el código del centro para organo contable, gestor y unidad tramitadora.
    "2.2.3.1.".SetRange(Number, 1, xRepetirOrganoContable);
    xNCentro := 1;

    "1.5.".SetRange(Number, 1, 1);
    "2.1.4.".SetRange(Number, 1, 1);
    "2.1.3.1.6.".SetRange(Number, 1, 1);
    "2.1.3.1.7.8.".SetRange(Number, 1, 1);
    "3.1.6.1.".SetRange(Number, 1, TempTCNLinGenericaVentas.Count);
    xPrimeraLínea := true;

    // Cargo los datos del cliente en Datos e-facturaSTD, pueden ser de direccion de envio, pago o cliente.
    DatosClienteF(rDatosFirmarFacturas);

    iF rDatosFirmarFacturas."Cod Proponente" <> '' THEN
        "2.2.3.1.".SETFILTER(Number, cFiltro, 1, 4)
    ELSE
        "2.2.3.1.".SETFILTER(Number, cFiltro, 1, 3);
end;

var
    rCompanyInformation: Record "Company Information";
    rContact: Record Contact;
    rCustLedgerEntry: Record "Cust. Ledger Entry";
    rCustomerBankAccount: Record "Customer Bank Account";
    rGeneralLedgerSetup: Record "General Ledger Setup";
    TempTCNCabeceraGenericaVentas: Record "TCN_CabeceraGenericaVentas" temporary;
    rConfiguracionFirmaFacturas: Record "TCN_ConfiguracionFirmaFacturas";
    rDatosFirmarFacturas: Record "TCN_Datos Firmar Facturas";
    rEquivalenciaseFacturaSTD: Record "TCN_Equivalencias eFacturaSTD";
    TempTCNLinGenericaVentas: Record "TCN_LinGenericaVentas" temporary;
    rVatEntry: Record "VAT Entry";
    TempVatEntry: Record "VAT Entry" temporary;

    rVATPostingSetup: Record "VAT Posting Setup";
    cuCodeunitsDynamics: Codeunit "TCN_FuncionesComunes";

    cTCNFirmarFacturasFIR: Codeunit TCNFirmarFacturasFIR;
    cuTCNFirmarFacturasFIR: Codeunit TCNFirmarFacturasFIR;
    "xPrimeraLínea": Boolean;
    xPrimerVencimiento: Boolean;
    mCodDto: array[2] of Code[20];
    xFactura: Code[250];
    "mDto%": array[2] of Decimal;
    mDtoFactura: array[2] of Decimal;
    xContadorDtos: Integer;
    xNCentro: Integer;
    xNVencimientos: Integer;

    xRepetirOrganoContable: Integer;
    xTipoDePago: Option " ",Payment,Invoice,"Credit Memo","Finance Charge Memo",Reminder,Refund,,,,,,,,,,,,,,,Bill;
    cFiltro: Label '%1..%2';
/// <summary>
/// CalculaDescuentosF.
/// </summary>
/// <param name="pImporteDtoFactura">VAR Decimal.</param>
/// <param name="pImporteDtoPp">VAR Decimal.</param>
procedure CalculaDescuentosF(var pImporteDtoFactura: Decimal; var pImporteDtoPp: Decimal)
begin
    cTCNFirmarFacturasFIR.tipoImporteOpc();
    if TempTCNLinGenericaVentas.FindSet() then begin
        repeat
            if TempTCNCabeceraGenericaVentas."Prices Including VAT" then begin
                pImporteDtoFactura := pImporteDtoFactura + TempTCNLinGenericaVentas."Inv. Discount Amount" / (1 + (TempTCNLinGenericaVentas."VAT %" + TempTCNLinGenericaVentas."EC %") / 100);
                pImporteDtoPp := pImporteDtoPp + TempTCNLinGenericaVentas."Pmt. Disc. Given Amount" / (1 + (TempTCNLinGenericaVentas."VAT %" + TempTCNLinGenericaVentas."EC %") / 100)
            end else begin
                pImporteDtoFactura := pImporteDtoFactura + TempTCNLinGenericaVentas."Inv. Discount Amount";
                pImporteDtoPp := pImporteDtoPp + TempTCNLinGenericaVentas."Pmt. Disc. Given Amount";
            end;
        until TempTCNLinGenericaVentas.Next() = 0;
    end;
end;

/// <summary>
/// DevInfoTipoBlancoF.
/// </summary>
/// <param name="prLinGenerica">Record "TCN_LinGenericaVentas".</param>
/// <returns>Return value of type Text.</returns>
procedure DevInfoTipoBlancoF(prLinGenerica: Record "TCN_LinGenericaVentas"): Text
var
    rlLinGenerica: Record "TCN_LinGenericaVentas";
    culTCNEtiquetasFIR: Codeunit TCNEtiquetasFIR;
    xlSalir: Boolean;
    xlValorExit: Text;
begin
    if prLinGenerica.Type <> prLinGenerica.Type::" " then begin
        xlValorExit := '';
        xlSalir := false;
        rlLinGenerica.Reset();
        rlLinGenerica.SetCurrentKey("Document No.", "Line No.");
        rlLinGenerica.SetRange("Document No.", prLinGenerica."Document No.");
        rlLinGenerica.SetFilter("Line No.", '%1..', prLinGenerica."Line No." + 1);
        repeat
            if (rlLinGenerica.Type <> rlLinGenerica.Type::" ") or
               (CopyStr(rlLinGenerica.Description, 1, 10) = culTCNEtiquetasFIR.NumAlbaranF()) then begin
                xlSalir := true;
            end else begin
                if rlLinGenerica.Description <> '' then begin
                    xlValorExit := CopyStr(xlValorExit + rlLinGenerica.Description + '; ', 1, 1024);
                end;
            end;
        until (rlLinGenerica.Next() = 0) or xlSalir;
        exit(xlValorExit);
    end;
end;

/// <summary>
/// DevolverEquivalenciaF.
/// </summary>
/// <param name="pTipo">Integer.</param>
/// <param name="pCodigo">Code[20].</param>
/// <param name="pCodigo2">Code[20].</param>
/// <returns>Return variable xSalida of type Code[20].</returns>
procedure DevolverEquivalenciaF(pTipo: Integer; pCodigo: Code[20]; pCodigo2: Code[20]) xSalida: Code[20]
var
    rlEquivalenciaseFacturaSTD: Record "TCN_Equivalencias eFacturaSTD";
begin
    // Devuelve la equivalencia del tipo / códigos pasados por parámetro
    rlEquivalenciaseFacturaSTD.SetRange(Tipo, pTipo);
    rlEquivalenciaseFacturaSTD.SetRange(Codigo, pCodigo);
    if pCodigo2 <> '' then begin
        rlEquivalenciaseFacturaSTD.SetRange(Codigo2, pCodigo2);
    end;
    rlEquivalenciaseFacturaSTD.FindFirst();
    xSalida := rlEquivalenciaseFacturaSTD."Codigo para e-Factura";
end;

/// <summary>
/// FormaDePagoF.
/// </summary>
/// <param name="pFormaPago">Code[10].</param>
/// <param name="pTipoDePago">VAR Option " ",Payment,Invoice,"Credit Memo","Finance Charge Memo",Reminder,Refund,,,,,,,,,,,,,,,Bill.</param>
procedure FormaDePagoF(pFormaPago: Code[10]; var pTipoDePago: Option " ",Payment,Invoice,"Credit Memo","Finance Charge Memo",Reminder,Refund,,,,,,,,,,,,,,,Bill)
var
    rlPaymentMethod: Record "Payment Method";
begin
    case TempTCNCabeceraGenericaVentas."Tipo documento impresion" of
        TempTCNCabeceraGenericaVentas."Tipo documento impresion"::"Factura venta", TempTCNCabeceraGenericaVentas."Tipo documento impresion"::"Factura servicio":
            pTipoDePago := xTipoDePago::Invoice;
        TempTCNCabeceraGenericaVentas."Tipo documento impresion"::"Abono venta":
            pTipoDePago := xTipoDePago::"Credit Memo";
    end;
    if rlPaymentMethod.Get(TempTCNCabeceraGenericaVentas."Payment Method Code") then begin
        if rlPaymentMethod."Create Bills" then begin
            pTipoDePago := xTipoDePago::Bill;
        end;
    end;
end;

/// <summary>
/// FormatoNumeroDecimalF.
/// </summary>
/// <param name="pDecimal">Decimal.</param>
/// <param name="pNumeroDecimales">Integer.</param>
/// <returns>Return variable xSalida of type Text[30].</returns>
procedure FormatoNumeroDecimalF(pDecimal: Decimal; pNumeroDecimales: Integer) xSalida: Text[30]
var
    xlRedondeo: Decimal;
    i: Integer;
begin
    xlRedondeo := 1;
    if pNumeroDecimales > 0 then begin
        while i < pNumeroDecimales do begin
            xlRedondeo := xlRedondeo / 10;
            i += 1;
        end;
    end;
    pDecimal := Round(pDecimal, xlRedondeo);
    if pNumeroDecimales = 0 then begin
        xSalida := Format(pDecimal);
    end else begin
        xSalida := Format(pDecimal, 0, '<Precision,' + Format(pNumeroDecimales) + ':' + Format(pNumeroDecimales) + '>' +
                          '<Sign><Integer><Decimals>');
    end;
    xSalida := ConvertStr(xSalida, ',', '.');
end;

/// <summary>
/// FormatoNumeroEnteroF.
/// </summary>
/// <param name="pInteger">Integer.</param>
/// <param name="pNumeroDecimales">Integer.</param>
/// <returns>Return variable xSalida of type Text[30].</returns>
procedure FormatoNumeroEnteroF(pInteger: Integer; pNumeroDecimales: Integer) xSalida: Text[30]
var
    xlDecimal: Decimal;
begin
    xlDecimal := pInteger;
    xSalida := Format(xlDecimal, 0, '<Precision,' + Format(pNumeroDecimales) + ':' + Format(pNumeroDecimales) + '>' +
                      '<Sign><Integer><Decimals>');
    xSalida := ConvertStr(xSalida, ',', '.');
end;

/// <summary>
/// InicializaValoresF.
/// </summary>
procedure InicializaValoresF()
begin
    "1.1." := '';
    "1.2." := '';
    "1.3." := '';
    "1.4.1.1." := '';
    "1.4.1.2." := '';
    "1.4.1.3." := '';
    "1.4.2.1." := '';
    "1.4.2.2." := '';
    "1.4.2.3.1." := '';
    "1.4.2.3.2." := '';
    "1.4.2.3.3." := '';
    "1.4.2.3.4." := '';
    "1.4.2.3.5." := '';
    "1.4.2.3.6." := '';
    "1.4.2.3.7." := '';
    "1.4.2.4.1." := '';
    "1.4.2.4.2." := '';
    "1.4.2.4.3." := '';
    "1.4.2.4.4." := '';
    "1.4.2.4.5." := '';
    "1.4.2.5.1." := '';
    "1.4.2.5.2." := '';
    "1.4.2.5.3." := '';
    "1.4.2.5.4." := '';
    "1.4.2.6.1." := '';
    "1.4.2.6.2." := '';
    "1.4.2.6.3." := '';
    "1.4.2.6.4." := '';
    "1.4.2.6.5." := '';
    "1.4.2.6.6." := '';
    "1.4.2.6.7." := '';
    "1.4.2.6.8." := '';
    "1.4.3.1." := '';
    "1.4.3.2." := '';
    "1.4.3.3." := '';
    "1.4.3.4.1." := '';
    "1.4.3.4.2." := '';
    "1.4.3.4.3." := '';
    "1.4.3.4.4." := '';
    "1.4.3.4.5." := '';
    "1.4.3.5.1." := '';
    "1.4.3.5.2." := '';
    "1.4.3.5.3." := '';
    "1.4.3.5.4." := '';
    "1.4.3.6.1." := '';
    "1.4.3.6.2." := '';
    "1.4.3.6.3." := '';
    "1.4.3.6.4." := '';
    "1.4.3.6.5." := '';
    "1.4.3.6.6." := '';
    "1.4.3.6.7." := '';
    "1.4.3.6.8." := '';
    "1.5.1." := '';
    "1.5.2." := FormatoNumeroEnteroF(0, 2);
    "1.5.3.1." := FormatoNumeroEnteroF(0, 2);
    "1.5.3.2." := FormatoNumeroEnteroF(0, 2);
    "1.5.4.1." := FormatoNumeroEnteroF(0, 2);
    "1.5.4.2." := FormatoNumeroEnteroF(0, 2);
    "1.5.5.1." := FormatoNumeroEnteroF(0, 2);
    "1.5.5.2." := FormatoNumeroEnteroF(0, 2);
    "1.6.1.1.1." := '';
    "1.6.1.1.2." := '';
    "1.6.1.1.3." := '';
    "1.6.1.2.1." := '';
    "1.6.1.2.2." := '';
    "1.6.1.2.3.1." := '';
    "1.6.1.2.3.2." := '';
    "1.6.1.2.3.3." := '';
    "1.6.1.2.3.4." := '';
    "1.6.1.2.3.5." := '';
    "1.6.1.2.3.6." := '';
    "1.6.1.2.3.7." := '';
    "1.6.1.2.4.1." := '';
    "1.6.1.2.4.2." := '';
    "1.6.1.2.4.3." := '';
    "1.6.1.2.4.4." := '';
    "1.6.1.2.4.5." := '';
    "1.6.1.2.5.1." := '';
    "1.6.1.2.5.2." := '';
    "1.6.1.2.5.3." := '';
    "1.6.1.2.5.4." := '';
    "1.6.1.2.6.1." := '';
    "1.6.1.2.6.2." := '';
    "1.6.1.2.6.3." := '';
    "1.6.1.2.6.4." := '';
    "1.6.1.2.6.5." := '';
    "1.6.1.2.6.6." := '';
    "1.6.1.2.6.7." := '';
    "1.6.1.2.6.8." := '';
    "1.6.1.3.1." := '';
    "1.6.1.3.2." := '';
    "1.6.1.3.3." := '';
    "1.6.1.3.4.1." := '';
    "1.6.1.3.4.2." := '';
    "1.6.1.3.4.3." := '';
    "1.6.1.3.4.4." := '';
    "1.6.1.3.4.5." := '';
    "1.6.1.3.5.1." := '';
    "1.6.1.3.5.2." := '';
    "1.6.1.3.5.3." := '';
    "1.6.1.3.5.4." := '';
    "1.6.1.3.6.1." := '';
    "1.6.1.3.6.2." := '';
    "1.6.1.3.6.3." := '';
    "1.6.1.3.6.4." := '';
    "1.6.1.3.6.5." := '';
    "1.6.1.3.6.6." := '';
    "1.6.1.3.6.7." := '';
    "1.6.1.3.6.8." := '';
    "1.6.2.1.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "1.6.2.1.2." := FormatoNumeroEnteroF(0, 2);
    "1.6.2.1.3." := '';
    "1.6.2.1.4.1." := '';
    "1.6.2.1.4.2." := '';
    "1.6.2.1.4.3." := '';
    "1.6.2.1.4.4." := '';
    "1.6.2.1.4.5.1." := '';
    "1.6.2.1.4.5.2." := '';
    "1.6.2.1.4.5.3." := '';
    "1.6.2.1.4.5.4." := '';
    "1.6.2.1.4.5.5." := '';
    "1.6.2.1.4.6.1." := '';
    "1.6.2.1.4.6.2." := '';
    "1.6.2.1.4.6.3." := '';
    "1.6.2.1.4.6.4." := '';
    "1.6.2.1.4.7." := '';
    "1.6.2.1.5." := '';
    "1.6.2.1.6.1." := '';
    "1.6.2.1.6.2." := '';
    "1.6.2.1.6.3." := '';
    "1.6.2.1.6.4." := '';
    "1.6.2.1.6.5.1." := '';
    "1.6.2.1.6.5.2." := '';
    "1.6.2.1.6.5.3." := '';
    "1.6.2.1.6.5.4." := '';
    "1.6.2.1.6.5.5." := '';
    "1.6.2.1.6.6.1." := '';
    "1.6.2.1.6.6.2." := '';
    "1.6.2.1.6.6.3." := '';
    "1.6.2.1.6.6.4." := '';
    "1.6.2.1.6.7." := '';
    "1.6.2.1.7." := '';
    "1.6.2.1.8." := '';
    "1.6.2.1.9." := '';
    "1.6.3." := '';
    "2.1.1.1." := '';
    "2.1.1.2." := '';
    "2.1.1.3." := '';
    "2.1.2." := '';
    "2.1.3.1.1." := '';
    "2.1.3.1.2." := '';
    "2.1.3.1.3." := '';
    "2.1.3.1.4." := '';
    "2.1.3.1.5." := '';
    "2.1.3.1.6.1." := '';
    "2.1.3.1.6.2." := '';
    "2.1.3.1.6.3." := '';
    "2.1.3.1.6.4." := '';
    "2.1.3.1.6.5." := '';
    "2.1.3.1.7.1." := '';
    "2.1.3.1.7.2." := '';
    "2.1.3.1.7.3." := '';
    "2.1.3.1.7.4." := '';
    "2.1.3.1.7.8.1." := '';
    "2.1.3.1.7.8.2." := '';
    "2.1.3.1.7.8.3." := '';
    "2.1.3.1.7.8.4." := '';
    "2.1.3.1.7.8.5." := '';
    "2.1.3.1.7.8.6." := '';
    "2.1.3.1.7.8.7." := '';
    "2.1.3.1.7.8.8." := '';
    "2.1.3.1.9." := '';
    "2.1.3.1.10." := '';
    "2.1.3.1.11." := '';
    "2.1.4.1.1." := '';
    "2.1.4.1.2." := '';
    "2.2.1.1." := '';
    "2.2.1.2." := '';
    "2.2.1.3." := '';
    "2.2.2." := '';
    "2.2.3.1.1." := '';
    "2.2.3.1.2." := '';
    "2.2.3.1.3." := '';
    "2.2.3.1.4." := '';
    "2.2.3.1.5." := '';
    "2.2.3.1.6.1." := '';
    "2.2.3.1.6.2." := '';
    "2.2.3.1.6.3." := '';
    "2.2.3.1.6.4." := '';
    "2.2.3.1.6.5." := '';
    "2.2.3.1.7.1." := '';
    "2.2.3.1.7.2." := '';
    "2.2.3.1.7.3." := '';
    "2.2.3.1.7.4." := '';
    "2.2.3.1.8.1." := '';
    "2.2.3.1.8.2." := '';
    "2.2.3.1.8.3." := '';
    "2.2.3.1.8.4." := '';
    "2.2.3.1.8.5." := '';
    "2.2.3.1.8.6." := '';
    "2.2.3.1.8.7." := '';
    "2.2.3.1.8.8." := '';
    "2.2.3.1.9." := '';
    "2.2.3.1.10." := '';
    "2.2.3.1.11." := '';
    "2.2.4.5.2." := '';
    "2.2.4.5.3." := '';
    "2.2.4.5.4." := '';
    "3.1.1.1." := '';
    "3.1.1.2." := '';
    "3.1.1.3." := '';
    "3.1.1.4." := '';
    "3.1.1.5.1." := '';
    "3.1.1.5.2." := '';
    "3.1.1.5.3." := '';
    "3.1.1.5.4." := '';
    "3.1.1.5.5.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.1.5.5.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.1.5.6." := '';
    "3.1.1.5.7." := '';
    "3.1.1.5.8." := '';
    "3.1.2.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.2.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.2.3.1." := '';
    "3.1.2.3.2." := '';
    "3.1.2.4.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.2.4.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.2.5." := '';
    "3.1.2.6.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.2.6.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.2.7." := '';
    "3.1.2.8." := '';
    "3.1.3.1.1." := '';
    "3.1.3.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.3.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.3.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.4.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.4.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.5.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.5.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.6.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.6.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.7." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.8.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.3.1.8.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.4.1.1." := '';
    "3.1.4.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.4.1.3.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.4.1.3.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.4.1.4.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.4.1.4.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.2.1.1." := '';
    "3.1.5.2.1.2." := '';
    "3.1.5.2.1.3." := '';
    "3.1.5.3.1.1." := '';
    "3.1.5.3.1.2." := '';
    "3.1.5.3.1.3." := '';
    "3.1.5.4." := '';
    "3.1.5.5." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.6." := '';
    "3.1.5.7." := '';
    "3.1.5.8." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.9." := '';
    "3.1.5.10.1.1." := '';
    "3.1.5.10.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.10.1.3." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.11.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.5.11.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.11.3." := '';
    "3.1.5.12.1.1.1." := '';
    "3.1.5.12.1.1.2." := '';
    "3.1.5.12.1.1.3." := '';
    "3.1.5.12.1.2.1." := '';
    "3.1.5.12.1.2.2." := '';
    "3.1.5.12.1.2.3." := '';
    "3.1.5.12.1.3." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.5.12.1.4." := '';
    "3.1.5.12.1.5." := '';
    "3.1.5.12.1.6." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.13." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.14." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.15." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.18." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.16.1." := '';
    "3.1.5.16.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.16.3." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.17." := FormatoNumeroEnteroF(0, 2);
    "3.1.5.18." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.1." := '';
    "3.1.6.1.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.3." := '';
    "3.1.6.1.4." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.5." := '';
    "3.1.6.1.6." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.7." := '';
    "3.1.6.1.8." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.9." := '';
    "3.1.6.1.10." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.11." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.12.1.1." := '';
    "3.1.6.1.12.1.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.13." := '';
    "3.1.6.1.14." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.15." := '';
    "3.1.6.1.16." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.17." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.18.1.1." := '';
    "3.1.6.1.18.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.18.1.3." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.19.1.1." := '';
    "3.1.6.1.19.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.19.1.3." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.20." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.21.1.1." := '';
    "3.1.6.1.21.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.21.1.3.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.21.1.3.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.21.1.4.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.21.1.4.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.1." := '';
    "3.1.6.1.22.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.3.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.3.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.4.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.4.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.5.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.5.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.6.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.6.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.7." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.8.1." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.22.1.8.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.6.1.23.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.23.2." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.24." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.6.1.25." := '';
    "3.1.6.1.26.1." := '';
    "3.1.6.1.26.2." := '';
    "3.1.6.1.27." := '';
    "3.1.7.1.1." := cuTCNFirmarFacturasFIR.FormatoFechaF(0D);
    "3.1.7.1.2." := FormatoNumeroEnteroF(0, 2);
    "3.1.7.1.3." := '';
    "3.1.7.1.4.1." := '';
    "3.1.7.1.4.5.1." := '';
    "3.1.7.1.4.5.2." := '';
    "3.1.7.1.4.5.3." := '';
    "3.1.7.1.4.5.4." := '';
    "3.1.7.1.4.5.5." := '';
    "3.1.7.1.4.6.1." := '';
    "3.1.7.1.4.6.2." := '';
    "3.1.7.1.4.6.3." := '';
    "3.1.7.1.4.6.4." := '';
    "3.1.7.1.4.7." := '';
    "3.1.7.1.5." := '';
    "3.1.7.1.6.1." := '';
    "3.1.7.1.6.5.1." := '';
    "3.1.7.1.6.5.2." := '';
    "3.1.7.1.6.5.3." := '';
    "3.1.7.1.6.5.4." := '';
    "3.1.7.1.6.5.5." := '';
    "3.1.7.1.6.6.1." := '';
    "3.1.7.1.6.6.2." := '';
    "3.1.7.1.6.6.3." := '';
    "3.1.7.1.6.6.4." := '';
    "3.1.7.1.6.7." := '';
    "3.1.7.1.7." := '';
    "3.1.7.1.9." := '';
    "3.1.8.1." := '';
    "3.1.9.1." := '';
    "3.1.9.2.1.1." := '';
    "3.1.9.2.1.2." := '';
    "3.1.9.2.1.3." := '';
    "3.1.9.2.1.4." := '';
    "3.1.9.2.1.5." := '';
    "3.1.9.3." := '';
end;

/// <summary>
/// PorcDtoF.
/// </summary>
/// <param name="pDoc">Code[20].</param>
/// <returns>Return variable xDto of type Decimal.</returns>
procedure PorcDtoF(pDoc: Code[20]) xDto: Decimal
var
    rlCustLedgerEntry: Record "Cust. Ledger Entry";
begin
    xDto := 0;
    rlCustLedgerEntry.Reset();
    rlCustLedgerEntry.SetCurrentKey("Document No.", "Document Type", "Customer No.");
    rlCustLedgerEntry.SetRange("Document No.", pDoc);
    rlCustLedgerEntry.SetFilter("Document Type", '%1', rlCustLedgerEntry."Document Type"::Invoice);
    // *** Debemos sumar a la base los dtos. aplicados.
    if rlCustLedgerEntry.FindFirst() then begin
        xDto := Round((rlCustLedgerEntry."Inv. Discount (LCY)" /
                       (rlCustLedgerEntry."Sales (LCY)" +
                        rlCustLedgerEntry."Inv. Discount (LCY)" +
                        rlCustLedgerEntry."Pmt. Disc. Given (LCY)") * 100), 0.01);
    end;
end;

/// <summary>
/// PorcDtoPPF.
/// </summary>
/// <param name="pDoc">Code[20].</param>
/// <returns>Return variable xDto of type Decimal.</returns>
procedure PorcDtoPPF(pDoc: Code[20]) xDto: Decimal
var
    rlCustLedgerEntry: Record "Cust. Ledger Entry";
begin
    xDto := 0;
    rlCustLedgerEntry.Reset();
    rlCustLedgerEntry.SetCurrentKey("Document No.", "Document Type", "Customer No.");
    rlCustLedgerEntry.SetRange("Document No.", pDoc);
    rlCustLedgerEntry.SetFilter("Document Type", '%1', rlCustLedgerEntry."Document Type"::Invoice);
    // *** Debemos sumar a la base los dtos. aplicados.
    if rlCustLedgerEntry.FindFirst() then begin
        xDto := Round((rlCustLedgerEntry."Pmt. Disc. Given (LCY)" /
                       (rlCustLedgerEntry."Sales (LCY)" +
                        rlCustLedgerEntry."Inv. Discount (LCY)" +
                        rlCustLedgerEntry."Pmt. Disc. Given (LCY)") * 100), 0.01);
    end;
end;

/// <summary>
/// RecortaF.
/// </summary>
/// <param name="pTexto">Text.</param>
/// <param name="pLongitud">Integer.</param>
/// <returns>Return variable xSalida of type Text.</returns>
procedure RecortaF(pTexto: Text; pLongitud: Integer) xSalida: Text
begin
    xsalida := (CopyStr(pTexto, 1, pLongitud));
    // Me aseguro que no supera la longitud configurada
    xsalida := AjustaLenTextoF(xsalida);
end;

/// <summary>
/// SetNumeroFacturaF.
/// </summary>
/// <param name="pNumFac">Code[20].</param>
procedure SetNumeroFacturaF(pNumFac: Code[20])
begin
    xFactura := pNumFac;
end;

local procedure AjustaLenTextoF(pTexto: text) xSalida: Text
var
    culTCN_eFactura: Codeunit TCNeFacturaFIR;
begin
    xSalida := culTCN_eFactura.AjustaTextoLongTextoXMLF(ptexto);
end;

local procedure DatosClienteF(var prDatosFirmarFacturas: Record "TCN_Datos Firmar Facturas")
begin
    if TempTCNCabeceraGenericaVentas."Pay-at Code" <> '' then begin
        if not prDatosFirmarFacturas.Get(prDatosFirmarFacturas.Tipo::DirPago,
                                         TempTCNCabeceraGenericaVentas."Bill-to Customer No.",
                                         TempTCNCabeceraGenericaVentas."Pay-at Code") then begin
            Clear(prDatosFirmarFacturas);
        end;
    end else
        if TempTCNCabeceraGenericaVentas."Ship-to Code" <> '' then begin
            if not prDatosFirmarFacturas.Get(prDatosFirmarFacturas.Tipo::DirEnvio,
                                             TempTCNCabeceraGenericaVentas."Bill-to Customer No.",
                                             TempTCNCabeceraGenericaVentas."Ship-to Code") then begin
                // buscamos sin direccion de envio
                if rConfiguracionFirmaFacturas."Copiar datos cliente dir.env." then begin
                    if not prDatosFirmarFacturas.Get(prDatosFirmarFacturas.Tipo::Cliente,
                                                    TempTCNCabeceraGenericaVentas."Bill-to Customer No.",
                                                    '') then begin
                        Clear(prDatosFirmarFacturas);
                    end;
                end else begin
                    Clear(prDatosFirmarFacturas);
                end;
            end;
        end else begin
            if not prDatosFirmarFacturas.Get(prDatosFirmarFacturas.Tipo::Cliente, TempTCNCabeceraGenericaVentas."Bill-to Customer No.", '') then begin
                Clear(prDatosFirmarFacturas);
            end;
        end;
end;

local procedure GetNumVtoFacturaF(pNumDocumento: Code[20]; pTipoPago: Integer): Integer
var
    xlNumVencimientos: Integer;
begin
    rCustLedgerEntry.Reset();
    rCustLedgerEntry.SetCurrentKey(rCustLedgerEntry."Document No.");
    rCustLedgerEntry.SetRange(rCustLedgerEntry."Document No.", pNumDocumento);
    rCustLedgerEntry.SetRange(rCustLedgerEntry."Document Type", pTipoPago);
    xlNumVencimientos := rCustLedgerEntry.Count;
    exit(xlNumVencimientos);
end;

local procedure FiltraLineasF()
begin
    TempTCNLinGenericaVentas.Reset();
    TempTCNLinGenericaVentas.SetCurrentKey("Document No.");
    TempTCNLinGenericaVentas.SetRange("Document No.", TempTCNCabeceraGenericaVentas."No.");
end;

/// <summary>
/// SetTMPCabeceraGenericaVentas.
/// </summary>
/// <param name="pTCNCabeceraGenericaVentas">Temporary VAR Record TCN_CabeceraGenericaVentas.</param>
procedure SetTMPCabeceraGenericaVentas(var pTCNCabeceraGenericaVentas: Record TCN_CabeceraGenericaVentas temporary)
begin
    TempTCNCabeceraGenericaVentas.Copy(pTCNCabeceraGenericaVentas, true);
end;

/// <summary>
/// SetTMPLineaGenericaVentas.
/// </summary>
/// <param name="pTempLTCNLinGenericaVentas">Temporary VAR Record TCN_LinGenericaVentas.</param>
procedure SetTMPLineaGenericaVentas(var pTempLTCNLinGenericaVentas: Record TCN_LinGenericaVentas temporary)
begin
    TempTCNLinGenericaVentas.Copy(pTempLTCNLinGenericaVentas, true);
end;

/// <summary>
/// CalculaImporteF.
/// </summary>
/// <param name="pNumDoc">Code[20].</param>
/// <param name="TempPTCNLinGenericaVentas">Temporary VAR Record "TCN_LinGenericaVentas".</param>
/// <param name="pOption">Option.</param>
/// <returns>Return value of type Decimal.</returns>
procedure CalculaImporteF(pNumDoc: Code[20]; var TempPTCNLinGenericaVentas: Record "TCN_LinGenericaVentas" temporary; pOption: Option): Decimal
var
    culTCNFirmarFacturasFIR: Codeunit TCNFirmarFacturasFIR;
begin
    exit(culTCNFirmarFacturasFIR.CalculaImportesTablaTemporalFF(pNumDoc, TempPTCNLinGenericaVentas, pOption));
end;

}

@jmadrigalTCN
Copy link
Author

Good morning
FYI:
Keeping investigating this issue, I can see that this happens when the xmlport object is big.

Thank you

@jmadrigalTCN
Copy link
Author

Another clue:

If you change in the settings this property:
al.backgroundCodeAnalysis": "File", from "File" or "Project" to "None", then you get the errors but not the warnings.

Thank you again

@BazookaMusic
Copy link
Contributor

The last one is expected behavior. Setting it to none means you are disabling code analysis.

What I understand is happening in your case is that maybe it's taking a long time for the diagnostics to be calculated. When I try your object, the warnings/errors appear immediately, but I also don't have the related symbols.

Can you also look at the debug console/error log to see if there are crashes?

@jmadrigalTCN
Copy link
Author

The last one is expected behavior. Setting it to none means you are disabling code analysis.

What I understand is happening in your case is that maybe it's taking a long time for the diagnostics to be calculated. When I try your object, the warnings/errors appear immediately, but I also don't have the related symbols.

Can you also look at the debug console/error log to see if there are crashes?

As far as the time is concern, I can confirm that it is not the case. I've left it for hours, and no results either.
And for the debug console/error I don't have any error

@blrobl
Copy link
Contributor

blrobl commented Nov 24, 2024

I also cannot reproduce the issue with the pre-release version of the AL extension and the provided XML port. Is this something new with the latest version? Otherwise, there might be indeed a limitation with the project size to be process. In this case setting al.backgroundCodeAnalysis": "File" (which is also the default case for bigger projects) should solve the issue. An alternative workaround would be to break it down into smaller units.

@jmadrigalTCN
Copy link
Author

I also cannot reproduce the issue with the pre-release version of the AL extension and the provided XML port. Is this something new with the latest version? Otherwise, there might be indeed a limitation with the project size to be process. In this case setting al.backgroundCodeAnalysis": "File" (which is also the default case for bigger projects) should solve the issue. An alternative workaround would be to break it down into smaller units.

Thanks for your reply.

I created a brand new proyect.
Create the very same object, and at it does not give me any error or codecop

And as you suggest, I can not split the objet in two, it is a xmlport and it needs to be al together.

@blrobl blrobl added investigate The issue requires further investigation to determine if this is a product bug no-repro static-code-analysis and removed input-needed labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate The issue requires further investigation to determine if this is a product bug no-repro static-code-analysis
Projects
None yet
Development

No branches or pull requests

3 participants