//Crea la fachada para comprobantes de la versión 3.3
FacadeCFD33 fachada = new FacadeCFD33();
//Agrega los datos generales de la factura
fachada.p01DatosGenerales(“A”, “12345”, “2018-10-29T07:00:00”, “01”, “Contado”, 100.00, 0, “MXN”, 1, 105.34, “I”, “PUE”, “85040”, “”);
//Agrega los datos del emisor
fachada.p03Emisor(“MAG041126GT8”, “EMPRESA PRUEBA”, “601”);
fachada.p04Receptor(“USO110603I26”, “UMBRALL SOFTWARE SA DE CV”, “”, “”, “G01”);
Comprobante.Conceptos.Concepto concepto = fachada.p05ConceptoAgregar(“01010101”, “998877660011”, 1.0, “H87”, “Pieza”, “CABLE NUMERO 5”, 100, 100, 0);
fachada.p05ConceptoAgregarImpuestoTraslado(100.0, “002”, “Tasa”, 0.16, 16.0, concepto);
fachada.p05ConceptoAgregarImpuestoRetencion(100.0, “002”, “Tasa”, 0.106600, 10.66, concepto);
fachada.p06ImpuestosCrearResumenPorConceptos();
fachada.p08DatosCertificado(“C:USLibcertificadosCSD_Pruebas_CFDI_MAG041126GT8CSD_Pruebas_CFDI_MAG041126GT8.cer”);
fachada.p09GenerarCadenaOriginal();
fachada.p10GenerarSelloDigital(“C:USLibcertificadosCSD_Pruebas_CFDI_MAG041126GT8CSD_Pruebas_CFDI_MAG041126GT8.key”, “12345678a”);
//fachada.p12TimbrarDocumento(true, “”);
RespuestaTFD respuesta = fachada.p12TimbrarDocumento(true, “”);//fachada.p11TimbrarDocumento(true, “”);
//Si el comprobante no fue timbrado lee el mensaje de error
if (!respuesta.isOperacionExitosa()) {
System.out.println(fachada.getXmlError());
System.out.println(respuesta.getMensajeError());
} else {
//Si el comprobante fue timbrado
//Se lee el resumen del timbre fiscal
ResumenCfd33 resumen = fachada.getResumenCfd33();
//Guarda el archivo xml
try (FileOutputStream file = new FileOutputStream(String.format(“C:USLibtest%s.xml”, resumen.getTfdUUID()))) {
file.write(respuesta.getXmlFile());
}
}