Ver Mensaje Individual
  #10  
Antiguo 21-05-2019
wilcg wilcg is offline
Miembro
 
Registrado: abr 2014
Posts: 107
Reputación: 10
wilcg Va por buen camino
Un poco mas resumido para poder analizar el código y la informacion que se crea en el xml.
Código Delphi [-]
Var
  tDocXmlNombre: string;
  Xml: IXMLDOCUMENT;
  nMaster, nPrimero, nSegundo, nTercero, nCuarto, nQuinto, nAtributo, nItem,
    nItemSub, nCDATA: IXMLNODE;
begin
  Xml := NewXMLDocument;
  Xml.Version := '1.0';
  Xml.Encoding := 'UTF-8';
  // XML.StandAlone := 'yes';
  Xml.Options := [doNodeAutoIndent];

  nMaster := Xml.AddChild('Invoice');
  nMaster.Attributes['xmlns'] :=
    'urnasis:names:specification:ubl:schema:xsd:Invoice-2';
  nMaster.Attributes['xmlns:cac'] :=
    'urnasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2';
  nMaster.Attributes['xmlns:cbc'] :=
    'urnasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2';
  nMaster.Attributes['xmlns:ccts'] := 'urn:un:unece:uncefact:documentation:2';
  nMaster.Attributes['xmlns:ds'] := 'http://www.w3.org/2000/09/xmldsig#';
  nMaster.Attributes['xmlns:ext'] :=
    'urnasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2';
  nMaster.Attributes['xmlns:qdt'] :=
    'urnasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2';
  nMaster.Attributes['xmlns:udt'] :=
    'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2';
  nMaster.Attributes['xmlns:xsi'] :=
    'http://www.w3.org/2001/XMLSchema-instance';

  { Encabezado de Firma digital }
  nPrimero := nMaster.AddChild('ext:UBLExtensions');

  { Firma DIGITAL }
  nSegundo := nPrimero.AddChild('ext:UBLExtension');
  nSegundo.AddChild('ext:ExtensionContent').Text := '';

  { Ubl versión }
  nPrimero := nMaster.AddChild('cbc:UBLVersionID');
  nPrimero.Text := '2.1';
  { Cuztom }
  nPrimero := nMaster.AddChild('cbc:CustomizationID');
  nPrimero.Text := '2.0';

  // Información de COMPROBANTE
  { numeracion de factura }
  nPrimero := nMaster.AddChild('cbc:ID');
  nPrimero.Text := '12345678900-01-F001-0000001';

  { fecha y hora de emisión }
  nPrimero := nMaster.AddChild('cbc:IssueDate');
  nPrimero.Text := FormatDateTime('yyyy-mm-dd', Date);
   nPrimero     := nMaster.AddChild('cbc:IssueTime');
    nPrimero.Text := FormatDateTime('hh-mm-ss',Time);

   { fecha de vencimiento }
    nPrimero     := nMaster.AddChild('cbcueDate');
    nPrimero.Text := FormatDateTime('yyyy-mm-dd',Date);


  { Información de EMPRESA remitente }
  nPrimero := nMaster.AddChild('cac:Signature');
  nPrimero.AddChild('cbc:ID').Text := 'tRucEmisor';
  nSegundo := nPrimero.AddChild('cac:SignatoryParty');
  nTercero := nSegundo.AddChild('cac:PartyIdentification');
  nTercero.AddChild('cbc:ID').Text := 'tRucEmisor';
  nCuarto := nSegundo.AddChild('cac:PartyName');
  nCuarto.AddChild('cbc:Name').DOMNode.appendChild
    (Xml.DOMDocument.createCDATASection('tRazonEmisor'));
  nSegundo := nPrimero.AddChild('cacigitalSignatureAttachment');
  nTercero := nSegundo.AddChild('cac:ExternalReference');
  nTercero.AddChild('cbc:URI').Text := 'tRucEmisor';

  { Datos del EMISOR }
  nPrimero := nMaster.AddChild('cac:AccountingSupplierParty');
  nItem := nPrimero.AddChild('cbc:CustomerAssignedAccountID');
  nItem.Text := 'tRucEmisor'; // NUMERO DOC del Emisor
  nItem := nPrimero.AddChild('cbc:AdditionalAccountID');
  nItem.Text := 'FE_CodigoTipoDoc(tRucEmisor)';
  // ID del DOC del Receptor     ( 1 = DNI; 6 = RUC )   Códigos de Tipos de Documentos de Identidad

  Xml.SaveToFile(ExtractFilePath(Application.ExeName) + '12345678900-01-F001-0000001.xml');
Responder Con Cita