Ver Mensaje Individual
  #28  
Antiguo 04-02-2015
Kribbeling Kribbeling is offline
Registrado
NULL
 
Registrado: feb 2011
Posts: 5
Reputación: 0
Kribbeling Va por buen camino
Cita:
Empezado por iMia Ver Mensaje
Como verás lo he simplificado al máximo. y escribo el xml casi de forma literal

Código:
/// Tipo TFacturae
type
  TFacturae = class
  private
    fFileHeader:  TFileHeader;
    fParties:     TParties;
    fInvoices:    TInvoices;
//    fExtensions:  TExtensions;
  public
    constructor Create;
    ///
    function ToXml: IXMLDOMElement;
    ///
    property FileHeader: TFileHeader  read fFileHeader  write fFileHeader;
    property Parties:    TParties     read fParties     write fParties;
    property Invoices:   TInvoices    read fInvoices    write fInvoices;
//    property fExtensions: TExtensions  read fExtensions  write fExtensions;
  end;

{ TFacturae }

  XMLNode_eFact_32_Facturae                                     = 'fe:Facturae';
    XMLNode_eFact_32_FileHeader                                   = 'FileHeader';
    XMLNode_eFact_32_SchemaVersion                                  = 'SchemaVersion';
    XMLNode_eFact_32_Modality                                     = 'Modality';
    XMLNode_eFact_32_InvoiceIssuerType                            = 'InvoiceIssuerType';

constructor TFacturae.Create;
begin
  fFileHeader := TFileHeader.Create;
  fParties    := TParties.Create;
  fInvoices   := TInvoices.Create;
end;

function TFacturae.ToXml: IXMLDOMElement;
var
  XMLDoc: IXMLDOMDocument;
  XMLElement: IXMLDOMElement;
begin
  XMLDoc := CoFreeThreadedDOMDocument30.Create;
  try
    XMLElement := XMLDoc.createElement( XMLNode_eFact_32_Facturae );
    if XMLElement <> nil then
    begin
      XMLElement.AppendChild(Self.fFileHeader.ToXml);
      XMLElement.AppendChild(Self.fParties.ToXml);
      XMLElement.AppendChild(Self.fInvoices.ToXml);
    end;
    result := XMLElement;
  finally
  end;
end;


type
  TFileHeader = class
  private
    fSchemaVersion:     string; // (E)
    fModality:          string; // (E)
    fInvoiceIssuerType: string; // (E)
//    fThirdParty:              TThirdParty;
    fBatch:             TBatch;
//    fFactoringAssignmentData: TFactoringAssignmentData;
  public
    constructor Create;

    function ToXml: IXMLDOMNode;

    property SchemaVersion:     string read fSchemaVersion      write fSchemaVersion;
    property Modality:               string read fModality           write fModality;
    property InvoiceIssuerType: string read fInvoiceIssuerType  write fInvoiceIssuerType;
    property Batch:                  TBatch read fBatch              write fBatch;
  end;

{ FFileHeaderType }

  C_SchemaVersion_3_2 = '3.2';

  C_Modality_Individual = 'I';

  C_PersonTypeCode_Fisica   = 'F';
  C_PersonTypeCode_Juridica = 'J';

  C_ResidenceTypeCodeType_R = 'R';  /// - Residente en España
  C_ResidenceTypeCodeType_U = 'U';  /// - Residente en la UE

  C_InvoiceIssuerType_Emisor        = 'EM';

constructor TFileHeader.Create;
begin
  fSchemaVersion      := C_SchemaVersion_3_2_1;
  fModality           := C_Modality_Individual;
  fInvoiceIssuerType  := C_InvoiceIssuerType_Emisor;
  fBatch              := TBatch.Create;
end;

function TFileHeader.ToXml: IXMLDOMNode;
var
  XMLElement: IXMLDOMElement;
begin
  XMLElement := NewElementNode( nil, XMLNode_eFact_32_FileHeader );
  if XMLElement <> nil then
  begin
    XMLElement.appendChild(NewTextNode(XMLElement, XMLNode_eFact_32_SchemaVersion, Self.fSchemaVersion, 0));
    XMLElement.appendChild(NewTextNode(XMLElement, XMLNode_eFact_32_Modality, Self.fModality, 0));
    XMLElement.appendChild(NewTextNode(XMLElement, XMLNode_eFact_32_InvoiceIssuerType, Self.fInvoiceIssuerType, 0));
    XMLElement.appendChild(Self.fBatch.ToXml);
  end;
  result := XMLElement;
end;

...
p.d.: Està hecho para Delphi5...
Muy Buenas ,

Esta es mi primera (bueno segunda) vez , no se si lo hago correctamente, en cualquier caso gracias.

Veo que has implementado codigo para la facturae, podrias pasarme algun ejemplo o las clases, muchas gracias .
Responder Con Cita