USE [Clinica]
GO
/****** Object:  View [Caja].[VWMovimientoCaja]    Script Date: 18-08-2025 21:38:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




CREATE view [Caja].[VWMovimientoCaja]
as
SELECT 
    mc.IdMovimientoCaja,
    CASE 
        WHEN mc.NroTransaccionTBK IS NULL OR mc.NroTransaccionTBK = '' OR mc.NroTransaccionTBK = '0' 
        THEN '' 
        ELSE mc.NroTransaccionTBK
    END AS NroTransaccionTBK,
	isnull(NroBoleta, '') as NroBoleta,
    isnull(mc.NroBono, '') as NroBono,
    c.IdCaja,
    c.Descripcion AS Caja,
    mp.Descripcion AS ModalidadPago,
    tc.Descripcion AS TipoCopago,
    mc.Monto,
    mc.FechaMovimiento,
    contacto.IdContacto AS IdCajero,
    contacto.Nombre AS Cajero,
    cc.IdCicloCaja,
    cc.FechaApertura
FROM Caja.MovimientoCaja mc
INNER JOIN Caja.Caja c ON mc.IdCaja = c.IdCaja
INNER JOIN Caja.CicloCaja cc ON mc.IdCicloCaja = cc.IdCicloCaja
INNER JOIN Caja.TipoModalidadPago mp ON mc.IdTipoModalidadPago = mp.IdTipoModalidadPago
INNER JOIN Caja.TipoCopago tc ON mc.IdTipoCopago = tc.IdTipoCopago
JOIN Core.Usuario u ON u.IdUsuario = cc.IdUsuarioCajero
JOIN Core.Contacto contacto ON contacto.IdContacto = u.IdContacto;


GO
