SELECT Factura.Mn_Cve_Moneda, Moneda.Mn_Decimales_SAT, Moneda.Mn_Variacion_SAT, Factura.Fc_Tipo_Cambio as Tipo_Cambio, Factura.Fc_Serie as Serie, Factura.Fc_Serie_Folio as Folio, Factura.Fecha_Alta as Fecha, isnull(Cv_Tipo_Condicion,'01') as TipoCondicion, isnull(Condicion_Venta.Cv_Pago_Parcial,'NO') as Pago_Parcial, isnull(Condicion_Venta.Cv_Codigo_SAT,'') as Leyenda_Fiscal, isnull(Condicion_Venta.Cv_Descripcion,'') as CondicionesPago, Cliente.Cl_Complemento_Fiscal as Complemento_Fiscal, 'I' as TipoComprobante, isnull(Condicion_Venta.Cv_Uso_CFDI,'') as UsoCFDI, Empresa.Em_Cve_Empresa, Empresa.Em_Razon_Social, Empresa.Em_R_F_C, Empresa.Em_Cve_Regimen_Fiscal AS Em_Regimen_Fiscal, Cliente.Cl_R_F_C, Cliente.Cl_Razon_Social, ISNULL( PaisCl.Ps_Iso_3166_1_Alpha_3, Cliente.Cl_Pais) AS Cl_Pais, ISNULL(Direccion_Entrega.De_Pais,'') AS De_Pais, Cliente.Cl_Tax_Id as NumRegIdTrib, ISNULL( CpScExp.Cp_Descripcion, ISNULL(CpEm.Cp_Descripcion,Sucursal.Sc_Codigo_Postal)) as LugarExpedicion, Factura_Serie.Fs_Ruta_Certificado_Digital, Factura_Serie.Fs_Ruta_Llave_Privada, Factura_Serie.Fs_Password_Certificado_Digital as Password, Factura_Serie.Fs_Timbra_Test, Factura_Serie.Fs_Usuario_WS, Factura_Serie.Fs_Password_WS, Factura_Serie.Fs_Cve_Factura_Serie, Factura_Serie.Fs_Tipo, Factura_Serie.Fs_NCer, round((Factura.Fc_Precio_Lista_Importe),6) as Subtotal, round((Factura.Fc_Descuento_Importe + Factura.Fc_Descuento_Global_Importe),6) as Descuento, round((Factura.Fc_Precio_Neto_Importe),6) As Total FROM Factura_Encabezado Factura LEFT JOIN Entrega_Documento ON Entrega_Documento.Ed_Documento = Factura.Fc_Folio and Entrega_Documento.Ed_Tabla = 'FACTURA' LEFT JOIN Direccion_Entrega ON Direccion_Entrega.De_Id = Entrega_Documento.De_Id and Direccion_Entrega.De_Documento = Entrega_Documento.De_Documento And Direccion_Entrega.De_Tabla = Entrega_Documento.De_Tabla LEFT JOIN Condicion_Venta on Condicion_Venta.Cv_Cve_Condicion_Venta = Factura.Fc_Condicion_Venta INNER JOIN Moneda ON Moneda.Mn_Cve_Moneda = Factura.Mn_Cve_Moneda INNER JOIN Cliente ON Factura.Cl_Cve_Cliente = Cliente.Cl_Cve_Cliente INNER JOIN Sucursal ON Sucursal.Sc_Cve_Sucursal = Factura.Sc_Cve_Sucursal INNER JOIN Empresa ON Empresa.Em_Cve_Empresa = Sucursal.Em_Cve_Empresa INNER JOIN Factura_Serie ON Factura.Fc_Serie = Factura_Serie.Fs_Cve_Factura_Serie AND Factura_Serie.Es_Cve_Estado <> 'BA' AND Factura_Serie.Fs_Tipo = '04' LEFT JOIN Pais PaisCl ON PaisCl.Ps_Cve_Pais = Cliente.Cl_Cve_Pais LEFT JOIN Codigo_Postal CpScExp ON CpScExp.Cp_Cve_Codigo_Postal = Sucursal.Sc_Cve_Codigo_Postal_Expedicion LEFT JOIN Codigo_Postal CpEm ON CpEm.Cp_Cve_Codigo_Postal = Empresa.Em_Cve_Codigo_Postal WHERE Factura.Fc_Folio = '01-0000227' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_CONDICION_PAGO_DEFAULT_CFDI33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_COMPLEMENTO_PAGO_CFDI33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'NO_NOMINA_CONCEPTO_ISR' SELECT * FROM Comprobante_Digital WHERE Cd_Tabla = 'FACTURA' AND Cd_Documento = '01-0000227' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_MOSTRAR_UNIDAD_CFDI33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVAR_CFDI_V33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVAR_NOMINA_12' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVAR_CFD_V2' SELECT Factura.Fc_Fecha as Fecha, Factura.Fc_Serie as Serie, Factura_Serie.Fs_Tipo, (CASE WHEN Factura.Fecha_Alta > Factura_Serie.Fs_Vigencia_Finaliza THEN -1 ELSE DATEDIFF(DAY,Factura.Fecha_Alta,Factura_Serie.Fs_Vigencia_Finaliza) END) DIAS, Factura_Serie.Fs_Vigencia_Finaliza AS VENCIMIENTO, Cliente.Cl_Complemento_Fiscal FROM Factura_Encabezado Factura INNER JOIN Factura_Serie Factura_Serie ON Factura.Fc_Serie = Factura_Serie.Fs_Cve_Factura_Serie AND Factura_Serie.Es_Cve_Estado <> 'BA' INNER JOIN CLiente ON Cliente.Cl_Cve_Cliente = Factura.Cl_Cve_Cliente WHERE Factura.Fc_Folio = '01-0000227' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_PRODUCTO_CUENTA_PREDIAL' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_CAMPO_NUM_CUENTA_PREDIAL' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_METODO_PAGO_CLAVE_DEFAULT' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVA_METODO_PAGO_CLAVE' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_DIAS_VENCIMIENTO_CERTIFICADO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'VEN_PRODUCTO_ANTICIPO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_IMPUESTO_IEPS_TASA' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_IMPUESTO_IEPS_CONCEPTO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_DIRECCION_RECEPTOR_CON_CRUZAMIENTO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_DESCRIPCION_AMPLIADA' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_DIRECCION_FISCAL' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_CANTIDAD_NOMINA12' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_IMPORTE_NOMINA12' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_IMPUESTO_LOCAL_CFDI' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_CANTIDAD_CFDI' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_PRECIO_CFDI' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_IMPUESTO_CFDI' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_FORMATO_IMPORTE_CFDI' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_DIRECCION_RECEPTOR_CON_CRUZAMIENTO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_URL_SERVIDOR_TIMBRADO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_DESCRIPCION_AMPLIADA' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_DIRECCION_FISCAL' SELECT Factura.Mn_Cve_Moneda, Moneda.Mn_Decimales_SAT, Moneda.Mn_Variacion_SAT, Factura.Fc_Tipo_Cambio as Tipo_Cambio, Factura.Fc_Serie as Serie, Factura.Fc_Serie_Folio as Folio, Factura.Fecha_Alta as Fecha, isnull(Cv_Tipo_Condicion,'01') as TipoCondicion, isnull(Condicion_Venta.Cv_Pago_Parcial,'NO') as Pago_Parcial, isnull(Condicion_Venta.Cv_Codigo_SAT,'') as Leyenda_Fiscal, isnull(Condicion_Venta.Cv_Descripcion,'') as CondicionesPago, Cliente.Cl_Complemento_Fiscal as Complemento_Fiscal, 'I' as TipoComprobante, isnull(Condicion_Venta.Cv_Uso_CFDI,'') as UsoCFDI, Empresa.Em_Cve_Empresa, Empresa.Em_Razon_Social, Empresa.Em_R_F_C, Empresa.Em_Cve_Regimen_Fiscal AS Em_Regimen_Fiscal, Cliente.Cl_R_F_C, Cliente.Cl_Razon_Social, ISNULL( PaisCl.Ps_Iso_3166_1_Alpha_3, Cliente.Cl_Pais) AS Cl_Pais, ISNULL(Direccion_Entrega.De_Pais,'') AS De_Pais, Cliente.Cl_Tax_Id as NumRegIdTrib, ISNULL( CpScExp.Cp_Descripcion, ISNULL(CpEm.Cp_Descripcion,Sucursal.Sc_Codigo_Postal)) as LugarExpedicion, Factura_Serie.Fs_Ruta_Certificado_Digital, Factura_Serie.Fs_Ruta_Llave_Privada, Factura_Serie.Fs_Password_Certificado_Digital as Password, Factura_Serie.Fs_Timbra_Test, Factura_Serie.Fs_Usuario_WS, Factura_Serie.Fs_Password_WS, Factura_Serie.Fs_Cve_Factura_Serie, Factura_Serie.Fs_Tipo, Factura_Serie.Fs_NCer, round((Factura.Fc_Precio_Lista_Importe),6) as Subtotal, round((Factura.Fc_Descuento_Importe + Factura.Fc_Descuento_Global_Importe),6) as Descuento, round((Factura.Fc_Precio_Neto_Importe),6) As Total FROM Factura_Encabezado Factura LEFT JOIN Entrega_Documento ON Entrega_Documento.Ed_Documento = Factura.Fc_Folio and Entrega_Documento.Ed_Tabla = 'FACTURA' LEFT JOIN Direccion_Entrega ON Direccion_Entrega.De_Id = Entrega_Documento.De_Id and Direccion_Entrega.De_Documento = Entrega_Documento.De_Documento And Direccion_Entrega.De_Tabla = Entrega_Documento.De_Tabla LEFT JOIN Condicion_Venta on Condicion_Venta.Cv_Cve_Condicion_Venta = Factura.Fc_Condicion_Venta INNER JOIN Moneda ON Moneda.Mn_Cve_Moneda = Factura.Mn_Cve_Moneda INNER JOIN Cliente ON Factura.Cl_Cve_Cliente = Cliente.Cl_Cve_Cliente INNER JOIN Sucursal ON Sucursal.Sc_Cve_Sucursal = Factura.Sc_Cve_Sucursal INNER JOIN Empresa ON Empresa.Em_Cve_Empresa = Sucursal.Em_Cve_Empresa INNER JOIN Factura_Serie ON Factura.Fc_Serie = Factura_Serie.Fs_Cve_Factura_Serie AND Factura_Serie.Es_Cve_Estado <> 'BA' AND Factura_Serie.Fs_Tipo = '04' LEFT JOIN Pais PaisCl ON PaisCl.Ps_Cve_Pais = Cliente.Cl_Cve_Pais LEFT JOIN Codigo_Postal CpScExp ON CpScExp.Cp_Cve_Codigo_Postal = Sucursal.Sc_Cve_Codigo_Postal_Expedicion LEFT JOIN Codigo_Postal CpEm ON CpEm.Cp_Cve_Codigo_Postal = Empresa.Em_Cve_Codigo_Postal WHERE Factura.Fc_Folio = '01-0000227' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_CONDICION_PAGO_DEFAULT_CFDI33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_COMPLEMENTO_PAGO_CFDI33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'NO_NOMINA_CONCEPTO_ISR' SELECT * FROM Comprobante_Digital WHERE Cd_Tabla = 'FACTURA' AND Cd_Documento = '01-0000227' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_MOSTRAR_UNIDAD_CFDI33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVAR_CFDI_V33' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVAR_NOMINA_12' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVAR_CFD_V2' SELECT Factura.Fc_Fecha as Fecha, Factura.Fc_Serie as Serie, Factura_Serie.Fs_Tipo, (CASE WHEN Factura.Fecha_Alta > Factura_Serie.Fs_Vigencia_Finaliza THEN -1 ELSE DATEDIFF(DAY,Factura.Fecha_Alta,Factura_Serie.Fs_Vigencia_Finaliza) END) DIAS, Factura_Serie.Fs_Vigencia_Finaliza AS VENCIMIENTO, Cliente.Cl_Complemento_Fiscal FROM Factura_Encabezado Factura INNER JOIN Factura_Serie Factura_Serie ON Factura.Fc_Serie = Factura_Serie.Fs_Cve_Factura_Serie AND Factura_Serie.Es_Cve_Estado <> 'BA' INNER JOIN CLiente ON Cliente.Cl_Cve_Cliente = Factura.Cl_Cve_Cliente WHERE Factura.Fc_Folio = '01-0000227' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_PRODUCTO_CUENTA_PREDIAL' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_CAMPO_NUM_CUENTA_PREDIAL' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_METODO_PAGO_CLAVE_DEFAULT' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_ACTIVA_METODO_PAGO_CLAVE' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'GEN_DIAS_VENCIMIENTO_CERTIFICADO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'VEN_PRODUCTO_ANTICIPO' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_IMPUESTO_IEPS_TASA' SELECT Cf_Tipo, Cf_Descripcion, Cf_Valor FROM Configuracion WHERE Cf_Variable = 'FAC_IMPUESTO_IEPS_CONCEPTO'