Advertisement
orezalucard

CorteZFactura

Nov 4th, 2024
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.31 KB | Source Code | 0 0
  1. DECLARE @TdaInicial BIGINT = 1
  2. DECLARE @TdaFinal BIGINT = 2
  3. DECLARE @FechaInicial DATETIME = ''
  4. DECLARE @FechaFinal DATETIME = ''
  5.  
  6. SELECT
  7. T.Tda_Codigo, T.Tda_Alias,
  8. CZ.CZ_Fecha, CZ.FolTda_Codigo, CZ.FolEst_Codigo, CZ.FolDoc_Codigo, CZ.FolConsecutivo,
  9. CONCAT(CZ.FolTda_Codigo, '-', CZ.FolEst_Codigo, '-', CZ.FolDoc_Codigo, '-', CZ.FolConsecutivo) AS FolioCZ,
  10. F.F_ImporteTotal, F.F_Fecha,
  11. F.FolTda_Codigo, F.FolEst_Codigo, F.FolDoc_Codigo, F.FolConsecutivo,
  12. CONCAT(F.FolTda_Codigo, '-', F.FolEst_Codigo, '-', F.FolDoc_Codigo, '-', F.FolConsecutivo) AS FolioF,
  13. FCFD.UUID
  14. FROM CortesZ CZ
  15. LEFT JOIN Facturas F ON F.CZTda_Codigo = CZ.FolTda_Codigo AND F.CZEst_Codigo = CZ.FolEst_Codigo AND F.CZDoc_Codigo = CZ.FolDoc_Codigo AND F.CZConsecutivo = CZ.FolConsecutivo
  16. LEFT JOIN FacturaCFD FCFD ON FCFD.FaTda_Codigo = F.FolTda_Codigo AND FCFD.FaEst_Codigo = F.FolEst_Codigo AND FCFD.FaDoc_Codigo = F.FolDoc_Codigo AND FCFD.FaConsecutivo = F.FolConsecutivo
  17. INNER JOIN Tiendas T ON T.Tda_Codigo = CZ.FolTda_Codigo
  18. WHERE T.Tda_Codigo BETWEEN @TdaInicial AND @TdaFinal AND CZ.CZ_Fecha BETWEEN @FechaInicial AND @FechaFinal
  19. --LEFT JOIN FacturasGlobalesCortesZ FGCZ ON FGCZ.FolTdaCodigo_CZ = CZ.FolTda_Codigo AND FGCZ.FolEstCodigo_CZ = CZ.FolEst_Codigo AND FGCZ.FolDocCodigo_CZ = CZ.FolDoc_Codigo AND FGCZ.FolConsecutivo_CZ=CZ.FolConsecutivo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement