El siguiente código trae la facturación neta del día. Contempla facturas y notas crédito.
Select T0.SlpName, sum(TBL0.LineTotal) as Total from OSLP T0
Left join
(select TB0.SlpCode, sum(TB0.LineTotal) as LineTotal from INV1 TB0 where year(TB0.DocDate) = year(getdate()) and month(TB0.DocDate) = month(getdate()) and day(TB0.DocDate) = day(getdate()) group by TB0.SlpCode
UNION ALL select TB1.SlpCode, sum(TB1.LineTotal*-1) from RIN1 TB1 where year(TB1.DocDate) = year(getdate()) and month(TB1.DocDate) = month(getdate()) and day(TB1.DocDate) = day(getdate()) group by TB1.SlpCode) TBL0
ON TBL0.SlpCode = T0.SlpCode
Where T0.Active = 'Y'
group by T0.SlpName
Solo es necesario modificar el WHERE de las 2 consultas TB0 y TB1 para identificar el día para el cual uno quiere la consulta. O si prefiere una tabla con la facturación por día del mes en curso:
Select T0.SlpName,
sum (case when day(TBL0.DocDate) = 1 then TBL0.LineTotal else 0 end) as '1',
sum (case when day(TBL0.DocDate) = 2 then TBL0.LineTotal else 0 end) as '2',
sum (case when day(TBL0.DocDate) = 3 then TBL0.LineTotal else 0 end) as '3',
sum (case when day(TBL0.DocDate) = 4 then TBL0.LineTotal else 0 end) as '4',
sum (case when day(TBL0.DocDate) = 5 then TBL0.LineTotal else 0 end) as '5',
sum (case when day(TBL0.DocDate) = 6 then TBL0.LineTotal else 0 end) as '6',
sum (case when day(TBL0.DocDate) = 7 then TBL0.LineTotal else 0 end) as '7',
sum (case when day(TBL0.DocDate) = 8 then TBL0.LineTotal else 0 end) as '8',
sum (case when day(TBL0.DocDate) = 9 then TBL0.LineTotal else 0 end) as '9',
sum (case when day(TBL0.DocDate) = 10 then TBL0.LineTotal else 0 end) as '10',
sum (case when day(TBL0.DocDate) = 11 then TBL0.LineTotal else 0 end) as '11',
sum (case when day(TBL0.DocDate) = 12 then TBL0.LineTotal else 0 end) as '12',
sum (case when day(TBL0.DocDate) = 13 then TBL0.LineTotal else 0 end) as '13',
sum (case when day(TBL0.DocDate) = 14 then TBL0.LineTotal else 0 end) as '14',
sum (case when day(TBL0.DocDate) = 15 then TBL0.LineTotal else 0 end) as '15',
sum (case when day(TBL0.DocDate) = 16 then TBL0.LineTotal else 0 end) as '16',
sum (case when day(TBL0.DocDate) = 17 then TBL0.LineTotal else 0 end) as '17',
sum (case when day(TBL0.DocDate) = 18 then TBL0.LineTotal else 0 end) as '18',
sum (case when day(TBL0.DocDate) = 19 then TBL0.LineTotal else 0 end) as '19',
sum (case when day(TBL0.DocDate) = 20 then TBL0.LineTotal else 0 end) as '20',
sum (case when day(TBL0.DocDate) = 21 then TBL0.LineTotal else 0 end) as '21',
sum (case when day(TBL0.DocDate) = 22 then TBL0.LineTotal else 0 end) as '22',
sum (case when day(TBL0.DocDate) = 23 then TBL0.LineTotal else 0 end) as '23',
sum (case when day(TBL0.DocDate) = 24 then TBL0.LineTotal else 0 end) as '24',
sum (case when day(TBL0.DocDate) = 25 then TBL0.LineTotal else 0 end) as '25',
sum (case when day(TBL0.DocDate) = 26 then TBL0.LineTotal else 0 end) as '26',
sum (case when day(TBL0.DocDate) = 27 then TBL0.LineTotal else 0 end) as '27',
sum (case when day(TBL0.DocDate) = 28 then TBL0.LineTotal else 0 end) as '28',
sum (case when day(TBL0.DocDate) = 29 then TBL0.LineTotal else 0 end) as '29',
sum (case when day(TBL0.DocDate) = 30 then TBL0.LineTotal else 0 end) as '30',
sum (case when day(TBL0.DocDate) = 31 then TBL0.LineTotal else 0 end) as '31',
sum (isnull(TBL0.LineTotal,0)) as Total
from OSLP T0
Left join
(select TB0.DocDate, TB0.SlpCode, sum(TB0.LineTotal) as LineTotal from INV1 TB0 where year(TB0.DocDate) = year(getdate()) and month(TB0.DocDate) = month(getdate()) group by TB0.SlpCode, TB0.DocDate
UNION ALL select TB1.DocDate, TB1.SlpCode, sum(TB1.LineTotal*-1) as LineTotal from RIN1 TB1 where year(TB1.DocDate) = year(getdate()) and month(TB1.DocDate) = month(getdate()) group by TB1.SlpCode, TB1.DocDate) AS TBL0
ON TBL0.SlpCode = T0.SlpCode
Where T0.Active = 'Y'
group by T0.SlpName