Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 19-05-2019
manelb manelb is offline
Miembro
 
Registrado: mar 2017
Posts: 281
Poder: 8
manelb Va por buen camino
Saludos a todos…

Hola oscarac, intentaré explicar nuestra experiencia sobre el tema por si te puede orientar…

Cuando en nuestro ERP desarrollamos la generación de facturas en formato xml, optamos por la generación “a pelo”, en formato texto, tal y como comenta el compañero dec.
Y así lo tenemos en la actualidad.

De todas formas, más tarde, investigamos sobre de qué forma los ficheros xsd que definen la estructura del xml podían utilizarse para simplificar el proceso y descubrimos el XML Data Binding.
Utilizando esta herramienta conseguimos generar una interface que permite generar y guardar de una forma más encapsulada la factura en formato xml.

En nuestro caso, la unidad que contiene la interface creada por el XML Data Binding a partir del xsd , contiene más de 6 mil líneas y esta es una muestra del código generado
Código Delphi [-]
{****************************************************************************************}
{                                                                                        }
{                                    XML Data Binding                                    }
{                                                                                        }
{         Generated on: 25/02/2017 16:38:47                                              }
{       Generated from: G:\DropBoxMBel\Dropbox\Facturacio Electronica\Facturaev3_2.xsd   }
{   Settings stored in: G:\DropBoxMBel\Dropbox\Facturacio Electronica\Facturaev3_2.xdb   }
{                                                                                        }
{****************************************************************************************}

unit Facturaev3_2;

interface

uses xmldom, XMLDoc, XMLIntf;

type

{ Forward Decls }

  IXMLFacturae = interface;
  IXMLFileHeaderType = interface;
  IXMLThirdPartyType = interface;
  IXMLTaxIdentificationType = interface;
  IXMLLegalEntityType = interface;
.
.
.
.
.
{ IXMLFacturae }

  IXMLFacturae = interface(IXMLNode)
    ['{4180325F-7A60-46DE-9C54-055114275527}']
    { Property Accessors }
    function Get_FileHeader: IXMLFileHeaderType;
    function Get_Parties: IXMLPartiesType;
    function Get_Invoices: IXMLInvoicesType;
    function Get_Extensions: IXMLExtensionsType;
    function Get_Signature: IXMLSignatureType_ds;
    { Methods & Properties }
    property FileHeader: IXMLFileHeaderType read Get_FileHeader;
    property Parties: IXMLPartiesType read Get_Parties;
    property Invoices: IXMLInvoicesType read Get_Invoices;
    property Extensions: IXMLExtensionsType read Get_Extensions;
    property Signature: IXMLSignatureType_ds read Get_Signature;
  end;
.
.
.
{ Global Functions }

function GetFacturae(Doc: IXMLDocument): IXMLFacturae;
function LoadFacturae(const FileName: string): IXMLFacturae;
function NewFacturae: IXMLFacturae;
.
.
.


Y un ejemplo de su llamada e inicio de construcción del xml
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  Factura: IXMLFacturae;
begin
  Factura:= GetFacturae(xml); {xml es un TXMLDocument}
  Factura.FileHeader.SchemaVersion:='3.2';
  Factura.FileHeader.Modality:='I';
  Factura.FileHeader.InvoiceIssuerType:='EM';
.
.
.
end;

Saludos
Responder Con Cita
  #2  
Antiguo 20-05-2019
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
es exactamente lo que estoy haciendo
tambien investigue y llegue a la conclusion que los xsd son cono "una base"

asi que estoy en pleno analisis para generar el XML

quiza podamos apoyarnos mutuamente...

saludos
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita
  #3  
Antiguo 20-05-2019
manelb manelb is offline
Miembro
 
Registrado: mar 2017
Posts: 281
Poder: 8
manelb Va por buen camino
Pero que problema tienes exactamente??
Responder Con Cita
  #4  
Antiguo 20-05-2019
wilcg wilcg is offline
Miembro
 
Registrado: abr 2014
Posts: 107
Poder: 11
wilcg Va por buen camino
No soy experto en delphi, pero empiricamente he estado trabajando en un proyecto.
El XML lo he estado resolviendo de este modo, a ver si te es útil. OJO que la extructura del xml aún falta corregir.

Código Delphi [-]
Var
  FirmarXML: TCFXML;
  Zip: TZipFile;
  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 := edtSerie.Text + '-' +
    FEnumCBT(FloatToStr(edtNumeracion.Value), 7, '0', False);

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

  { Código del comprobante }
  nPrimero := nMaster.AddChild('cbc:InvoiceTypeCode');
  nPrimero.Attributes['listID'] := '0101';
  nPrimero.Attributes['listAgencyName'] := 'PE:SUNAT';
  nPrimero.Attributes['listName'] := 'SUNAT:Identificador de Tipo de Documento';
  nPrimero.Attributes['listURI'] :=
    'urne:gob:sunat:cpe:see:gem:catalogos:catalogo01';
  nPrimero.Text := FEObCodCBT(FEObIntLookup(edtComprobante));

  { Leyendo a letras el valor }
  nPrimero := nMaster.AddChild('cbc:Note');
  nPrimero.Attributes['languageLocaleID'] := '1000';
  nPrimero.Text := 'SON: ' + UpperCase(FELeyendoNUM(txtTotal.Value)) +
    ' Y 00/100 ' + ObDatoStrInt('monedas', 'id_moneda', 'descripcion',
    FEObIntLookup(edtMoneda));

  { Obteniendo el código de MONEDA }
  nPrimero := nMaster.AddChild('cbcocumentCurrencyCode');
  nPrimero.Attributes['listID'] := 'ISO 4217 Alpha';
  nPrimero.Attributes['listName'] := 'Currency';
  nPrimero.Attributes['listAgencyName'] :=
    'United Nations Economic Commission for Europe';
  nPrimero.Text := ObDatoStrInt('monedas', 'id_moneda', 'codigo',
    FEObIntLookup(edtMoneda));

  { 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

  nSegundo := nPrimero.AddChild('cac:Party');
  nTercero := nSegundo.AddChild('cac:PartyIdentification');
  nAtributo := nTercero.AddChild('cbc:ID');
  nAtributo.Attributes['schemeID'] := '6';
  nAtributo.Attributes['schemeName'] :=
    'SUNAT:Identificador de Documento de Identidad';
  nAtributo.Attributes['schemeAgencyName'] := 'PE:SUNAT';
  nAtributo.Attributes['schemeURI'] :=
    'urne:gob:sunat:cpe:see:gem:catalogos:catalogo06';
  nAtributo.Text := tRucEmisor;
  nTercero := nSegundo.AddChild('cac:PartyName');
  nTercero.AddChild('cbc:Name').DOMNode.appendChild
    (Xml.DOMDocument.createCDATASection(tRazonEmisor));
  nTercero := nSegundo.AddChild('cac:PartyLegalEntity');
  nTercero.AddChild('cbc:RegistrationName').DOMNode.appendChild
    (Xml.DOMDocument.createCDATASection(tRazonEmisor));
  nItem := nTercero.AddChild('cac:RegistrationAddress');
  nItem.AddChild('cbc:AddressTypeCode').Text := IntToStr(tUbiGeoEmisor);
  // Código del domicilio fiscal o de local anexo del emisor

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

  nSegundo := nPrimero.AddChild('cac:Party');
  nTercero := nSegundo.AddChild('cac:PartyIdentification');
  nAtributo := nTercero.AddChild('cbc:ID');
  nAtributo.Attributes['schemeID'] := FE_CodigoTipoDoc(edtDni.Text);
  nAtributo.Attributes['schemeName'] :=
    'SUNAT:Identificador de Documento de Identidad';
  nAtributo.Attributes['schemeAgencyName'] := 'PE:SUNAT';
  nAtributo.Attributes['schemeURI'] :=
    'urne:gob:sunat:cpe:see:gem:catalogos:catalogo06';
  nAtributo.Text := edtDni.Text;
  nTercero := nSegundo.AddChild('cac:PartyLegalEntity');
  nTercero.AddChild('cbc:RegistrationName').DOMNode.appendChild
    (Xml.DOMDocument.createCDATASection(edtNombre.Text));

  nPrimero := nMaster.AddChild('cac:TaxTotal');
  nSegundo := nPrimero.AddChild('cbc:TaxAmount');
  nSegundo.Attributes['currencyID'] := ObDatoStrInt('monedas', 'id_moneda',
    'codigo', FEObIntLookup(edtMoneda));
  nSegundo.Text := FormatFloat('0.00', txtIgv.Value); // corregir
  nSegundo := nPrimero.AddChild('cac:TaxSubtotal');
  nItem := nSegundo.AddChild('cbc:TaxableAmount');
  nItem.Attributes['currencyID'] := ObDatoStrInt('monedas', 'id_moneda',
    'codigo', FEObIntLookup(edtMoneda));
  nItem.Text := FormatFloat('0.00', txtTotal.Value);
  nTercero := nSegundo.AddChild('cbc:TaxAmount');
  nTercero.Attributes['currencyID'] := ObDatoStrInt('monedas', 'id_moneda',
    'codigo', FEObIntLookup(edtMoneda));
  nTercero.Text := FormatFloat('0.00', txtSubTotal.Value); // corregir
  nTercero := nSegundo.AddChild('cac:TaxCategory');
  nItem := nTercero.AddChild('cbc:ID');
  nItem.Attributes['schemeID'] := 'UN/ECE 5305';
  nItem.Attributes['schemeName'] := 'Tax Category Identifier';
  nItem.Attributes['schemeAgencyName'] :=
    'United Nations Economic Commission for Europe';
  nItem.Text := 'S';

  nCuarto := nTercero.AddChild('cac:TaxScheme');
  nQuinto := nCuarto.AddChild('cbc:ID');
  nQuinto.Attributes['schemeID'] := 'UN/ECE 5153';
  nQuinto.Attributes['schemeAgencyID'] := '6';
  nQuinto.Text := IntToStr(IgvObCodigoIntInt(ObIntLookup(edtImpuesto)));
  // Codigo Internacional del IGV

  nQuinto := nCuarto.AddChild('cbc:Name');
  nQuinto.Text := 'IGV'; // Corregir  ---- OJO ---- PENDIENTE
  nQuinto := nCuarto.AddChild('cbc:TaxTypeCode');
  nQuinto.Text := IgvObCntitStrInt(ObIntLookup(edtImpuesto));
  // CODIGO DEL TRIBUTO valor 3 igv (VAT, EXC, OTH)

  nPrimero := nMaster.AddChild('cac:LegalMonetaryTotal');
  nSegundo := nPrimero.AddChild('cbc:AllowanceTotalAmount');
  nSegundo.Attributes['currencyID'] := ObDatoStrInt('monedas', 'id_moneda',
    'codigo', FEObIntLookup(edtMoneda));
  nSegundo.Text := FloatToStr(txtDescuento.Value);
  nSegundo := nPrimero.AddChild('cbc:PayableAmount');
  nSegundo.Attributes['currencyID'] := ObDatoStrInt('monedas', 'id_moneda',
    'codigo', FEObIntLookup(edtMoneda));
  nSegundo.Text := FloatToStr(txtTotal.Value);
Responder Con Cita
  #5  
Antiguo 21-05-2019
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
Cita:
Empezado por manelb Ver Mensaje
Pero que problema tienes exactamente??
que no se como empezar a crear el XML
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita
  #6  
Antiguo 21-05-2019
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
wilcg estoy tomando como ejemplo tu codigo y me esta fucionando bien, pero me sale error en este codigo

Código Delphi [-]
nCuarto.AddChild('cbc:Name').DOMNode.appendChild (Xml.DOMDocument.createCDATASection(tRazonEmisor));

error : [dcc32 Error] frmEmisionFactura_f.pas(933): E2242 'DOMDocument' is not the name of a unit
acaso se encuentra en alguna otra unidad?
__________________
Dulce Regalo que Satanas manda para mi.....

Última edición por oscarac fecha: 21-05-2019 a las 05:49:48.
Responder Con Cita
  #7  
Antiguo 21-05-2019
wilcg wilcg is offline
Miembro
 
Registrado: abr 2014
Posts: 107
Poder: 11
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
  #8  
Antiguo 05-03-2020
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
Cita:
Empezado por manelb Ver Mensaje
Saludos a todos…

Hola oscarac, intentaré explicar nuestra experiencia sobre el tema por si te puede orientar…

Cuando en nuestro ERP desarrollamos la generación de facturas en formato xml, optamos por la generación “a pelo”, en formato texto, tal y como comenta el compañero dec.
Y así lo tenemos en la actualidad.

De todas formas, más tarde, investigamos sobre de qué forma los ficheros xsd que definen la estructura del xml podían utilizarse para simplificar el proceso y descubrimos el XML Data Binding.
Utilizando esta herramienta conseguimos generar una interface que permite generar y guardar de una forma más encapsulada la factura en formato xml.

En nuestro caso, la unidad que contiene la interface creada por el XML Data Binding a partir del xsd , contiene más de 6 mil líneas y esta es una muestra del código generado
Código Delphi [-]
{****************************************************************************************}
{                                                                                        }
{                                    XML Data Binding                                    }
{                                                                                        }
{         Generated on: 25/02/2017 16:38:47                                              }
{       Generated from: G:\DropBoxMBel\Dropbox\Facturacio Electronica\Facturaev3_2.xsd   }
{   Settings stored in: G:\DropBoxMBel\Dropbox\Facturacio Electronica\Facturaev3_2.xdb   }
{                                                                                        }
{****************************************************************************************}

unit Facturaev3_2;

interface

uses xmldom, XMLDoc, XMLIntf;

type

{ Forward Decls }

  IXMLFacturae = interface;
  IXMLFileHeaderType = interface;
  IXMLThirdPartyType = interface;
  IXMLTaxIdentificationType = interface;
  IXMLLegalEntityType = interface;
.
.
.
.
.
{ IXMLFacturae }

  IXMLFacturae = interface(IXMLNode)
    ['{4180325F-7A60-46DE-9C54-055114275527}']
    { Property Accessors }
    function Get_FileHeader: IXMLFileHeaderType;
    function Get_Parties: IXMLPartiesType;
    function Get_Invoices: IXMLInvoicesType;
    function Get_Extensions: IXMLExtensionsType;
    function Get_Signature: IXMLSignatureType_ds;
    { Methods & Properties }
    property FileHeader: IXMLFileHeaderType read Get_FileHeader;
    property Parties: IXMLPartiesType read Get_Parties;
    property Invoices: IXMLInvoicesType read Get_Invoices;
    property Extensions: IXMLExtensionsType read Get_Extensions;
    property Signature: IXMLSignatureType_ds read Get_Signature;
  end;
.
.
.
{ Global Functions }

function GetFacturae(Doc: IXMLDocument): IXMLFacturae;
function LoadFacturae(const FileName: string): IXMLFacturae;
function NewFacturae: IXMLFacturae;
.
.
.


Y un ejemplo de su llamada e inicio de construcción del xml
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  Factura: IXMLFacturae;
begin
  Factura:= GetFacturae(xml); {xml es un TXMLDocument}
  Factura.FileHeader.SchemaVersion:='3.2';
  Factura.FileHeader.Modality:='I';
  Factura.FileHeader.InvoiceIssuerType:='EM';
.
.
.
end;

Saludos
estoy retomando este tema de nuevo, voy a probar este metodo, me parece mas simple, si tu lo has probado, genera tambien los subniveles en el armado del XML?
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita
  #9  
Antiguo 06-03-2020
manelb manelb is offline
Miembro
 
Registrado: mar 2017
Posts: 281
Poder: 8
manelb Va por buen camino
Si, este proceso genera la estructura completa de la factura.

Si lo necesitas, este fin de semana te puedo preparar un pequeño ejemplo con el xsd de la factura electrónica de España y te lo mando...

Saludos
Responder Con Cita
  #10  
Antiguo 06-03-2020
manelb manelb is offline
Miembro
 
Registrado: mar 2017
Posts: 281
Poder: 8
manelb Va por buen camino
De forma muy rápida...

Me he descargado la documentación des de los enlaces que has puesto, he importado el xsd y he generado este pequeño ejemplo:

Metes un memo, un botón y un XMLDocument en un formulario, y en el botón pones lo siguiente:

Código Delphi [-]
var
  factura: IXMLInvoiceType;
  AccountID: IXMLAdditionalAccountIDType_cbc;
  PartyName: IXMLPartyNameType_cac;
begin
  factura:= GetInvoice(XMLDocument1);
  factura.IssueDate.NodeValue:='2011-06-28';
  factura.AccountingSupplierParty.CustomerAssignedAccountID.NodeValue:= '20100113612';

  AccountID:= factura.AccountingSupplierParty.AdditionalAccountID.Add;
  AccountID.nodevalue:='6';

  PartyName:= factura.AccountingSupplierParty.Party.PartyName.Add;
  PartyName.Name.NodeValue:='K&G Laboratorios';


  memoxml.lines.Text:= XMLDocument1.XML.Text;

end;

He cogido como ejemplo la factura que incluye en el documento
"Guia+XML+Boleta+version+2+0.pdf" que he descargado con la documentación.

Espero te sirva para comenzar....

Saludos
Responder Con Cita
  #11  
Antiguo 06-03-2020
manelb manelb is offline
Miembro
 
Registrado: mar 2017
Posts: 281
Poder: 8
manelb Va por buen camino
Ah!!

Al componente XMLDocument le pones la propiedad Options.doNodeAutoIndent a true para que el texto quede mas estructurado
Responder Con Cita
  #12  
Antiguo 08-03-2020
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
ok voy entediendo mas

pero hay algo que me tiene en duda

para que instancias

Código Delphi [-]
  AccountID: IXMLAdditionalAccountIDType_cbc;
  PartyName: IXMLPartyNameType_cac;

todo no se podria hacer desde

Código Delphi [-]
factura: IXMLInvoiceType;
???
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita
  #13  
Antiguo 08-03-2020
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Poder: 20
oscarac Va por buen camino
o al menos explicame por favor como identifico

Raíz, Nodo, Atributo, DATO y asi sucesivamente
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita
Respuesta



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
Facturación electrónica Perú SUNAT wilcg Internet 5 29-10-2018 18:46:01
Facturacion Electrónica México kapcomx Varios 3 15-09-2017 18:23:18
Qué se sabe de la facturación electrónica en Colombia ? rolandoj Varios 9 11-01-2017 22:30:58
facturacion electronica anubis Debates 5 09-11-2010 06:33:59
facturacion electronica pmfras Internet 1 04-11-2008 14:09:35


La franja horaria es GMT +2. Ahora son las 02:59:27.


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