
/****** Object:  View [dbo].[VArticulosCC]    Script Date: 09/21/2015 13:46:34 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



ALTER VIEW [dbo].[VArticulosCC]
AS
SELECT --CONVERT(varchar(8), folio.num_tarj) + '-' + RTRIM(folio.nombre_titular)
       RTRIM(folio.titular) AS Credito, 
       hfac.id_mone, pvta.id_pvta, pvta.cod_pvta, 
       pvta.desc_pvta, '' AS id_fami, 
       '' AS desc_fami, lfac.id_arti, 
       arti.cod_arti, arti.desc_arti, 
       mone.cod_mone AS cod_mone, '' AS desc_mone, 
       lfac.cantidad, 
       hfac.Nro_Cheque AS id_cta_con1, '' AS conc_ingres, 
       hfac.tasa AS tasa_inv, 
       lfac.importe_bruto * lfac.cantidad AS vbrutas,
       lfac.importe_neto * lfac.cantidad AS vnetas, 
       lfac.dcto_neto * lfac.cantidad dcto_neto,
       lfac.recargo_neto * lfac.cantidad recargo_neto, 
       lfac.precio_costo * lfac.cantidad precio_costo, 
       hfac.fecha_cier AS fecha_factura,
       hfac.estado, hfac.id_fact, 
       tco.id_fpag, tco.cuenta_casa, 
       Turn.id_turn, Turn.fecha_ini
FROM       VRESTHFAC AS hfac 
INNER JOIN RESTCRED  AS folio ON hfac.id_refer = folio.id_cred 
INNER JOIN RESTHFCO  AS hfaco ON hfac.id_fact = hfaco.id_fact 
INNER JOIN RESTTCOB  AS tco ON hfaco.id_tcob = tco.id_tcob 
INNER JOIN RESTPVTA  AS pvta ON hfac.id_pvta = pvta.id_pvta 
INNER JOIN VRESTHFAL AS lfac ON hfac.id_fact = lfac.id_fact 
INNER JOIN RESTARTI  AS arti ON lfac.id_arti = arti.id_arti 
INNER JOIN RestTurn     Turn ON hfac.id_turn = turn.id_turn
LEFT JOIN  SICLAMON     mone ON hfac.id_mone = mone.id_mone, 
           RestTabl     Tabl
WHERE (lfac.cantidad > 0) 
  AND (tco.cuenta_casa = 1)



GO


