Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 25-01-2015
lithium76 lithium76 is offline
Miembro
 
Registrado: ene 2015
Posts: 33
Poder: 0
lithium76 Va por buen camino
Sería de gran utilidad, muchas gracias.. aquí está una parte del mío (la de los nodos principales, todo no me deja por excesivamente largo) tal como salen del Data Binding por si queda más claro lo que quería decir

Código Delphi [-]
const
  TargetNamespace = 'http:....Facturae';

implementation

{ Global Functions }

function GetFacturae(Doc: IXMLDocument): IXMLFacturae;
begin
  Result := Doc.GetDocBinding('Facturae', TXMLFacturae, TargetNamespace) as IXMLFacturae;
end;

function LoadFacturae(const FileName: string): IXMLFacturae;
begin
  Result:= LoadXMLDocument(FileName).GetDocBinding('Facturae', TXMLFacturae, TargetNamespace) as IXMLFacturae;
end;

function NewFacturae: IXMLFacturae;
begin
  Result := NewXMLDocument.GetDocBinding('Facturae', TXMLFacturae, TargetNamespace) as IXMLFacturae;
end;

{ TXMLFacturae }

procedure TXMLFacturae.AfterConstruction;
begin
  RegisterChildNode('FileHeader', TXMLFileHeaderType);
  RegisterChildNode('Parties', TXMLPartiesType);
  RegisterChildNode('Invoices', TXMLInvoicesType);
  RegisterChildNode('Extensions', TXMLExtensionsType);
  RegisterChildNode('Signature', TXMLSignatureType_ds);
  inherited;
end;
Responder Con Cita
  #2  
Antiguo 26-01-2015
iMia iMia is offline
Miembro
 
Registrado: jul 2010
Posts: 147
Poder: 16
iMia Va por buen camino
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...
Responder Con Cita
  #3  
Antiguo 26-01-2015
lithium76 lithium76 is offline
Miembro
 
Registrado: ene 2015
Posts: 33
Poder: 0
lithium76 Va por buen camino
Perdón pero he andado liado y no he podido responder antes... Pues es un gran trabajo, interesante la aproximación que has hecho al problema y la manera que has encontrado de resolverlo.. Me lo miraré más a fondo a ver si consigo rehacer mi código también . una lástima que el binding no consiga hacerlo directamente ¡Muchísimas gracias!
Responder Con Cita
  #4  
Antiguo 27-01-2015
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 688
Poder: 21
olbeup Va camino a la fama
Yo tenía el mismo problema y lo resolví aquí, con la ayuda de Al González

Un saludo.
__________________
Al hacer una consulta SQL, haz que los demás te entiendan y disfruten de ella, será tú reflejo de tú saber.
Responder Con Cita
  #5  
Antiguo 27-01-2015
lithium76 lithium76 is offline
Miembro
 
Registrado: ene 2015
Posts: 33
Poder: 0
lithium76 Va por buen camino
¡Muchas gracias, olbeup! ¡Muy amable! Gran aporte este post que has puesto.. Una pregunta, si me permites, tu no trabajas a partir de la interface del Data Binding, no? ¿ Son todo IXMLNode's, que vas colocando según correspndo no?
Responder Con Cita
  #6  
Antiguo 28-01-2015
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 688
Poder: 21
olbeup Va camino a la fama
Cita:
Empezado por lithium76 Ver Mensaje
¡Muchas gracias, olbeup! ¡Muy amable! Gran aporte este post que has puesto.. Una pregunta, si me permites, tu no trabajas a partir de la interface del Data Binding, no? ¿ Son todo IXMLNode's, que vas colocando según correspndo no?
Si, desde el IXMLDocument que es el principal y los IXMLNotes el resto.

Un saludo.
__________________
Al hacer una consulta SQL, haz que los demás te entiendan y disfruten de ella, será tú reflejo de tú saber.
Responder Con Cita
  #7  
Antiguo 04-02-2015
Kribbeling Kribbeling is offline
Registrado
NULL
 
Registrado: feb 2011
Posts: 5
Poder: 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
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Mexico - Como crear sellos en FACTURA ELECTRONICA.. pcicom API de Windows 12 10-11-2012 18:46:55
Factura Electrónica aig Varios 13 10-12-2010 17:12:44
factura electronica spia Varios 2 22-02-2009 21:30:06
Factura electronica AUNA Aprendiz Varios 5 01-09-2005 10:44:15
programa para validar formato de archivo de texto n3mohack Varios 4 21-04-2005 00:27:00


La franja horaria es GMT +2. Ahora son las 11:02:05.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi