HI.
Tu codigo tiene varios detalles,. Lo que hace referencia a campos de usuario los deje comentados, ya que no tengo esos campos creados en mi BD. el segundo select lo deje comentado para que lo corrigas segun como esta el primero.
slds
SELECT T2.SeriesName 'Oficina', T1.DocDate 'Fecha',
iif(T1.DocSubType = '–','Factura','Abono') 'Tipo de Documento', T1.DocNum 'No de Documento',T0.BaseDocNum " No de Remision", NULL 'Desc. de Devolucion', (SELECT BaseDocNum FROM DLN1 WHERE DocEntry = T0.BaseEntry AND LineNum = T0.BaseLine) 'Doc. de Ventas',
(SELECT NumAtCard FROM ORDR A0 INNER JOIN RDR1 A1 ON A0.DocEntry = A1.DocEntry WHERE A0.DocEntry = T0.BaseEntry AND A1.LineNum = T0.BaseLine AND A0.DocDate >= '[%0]' AND A0.DocDate <= '[%1]') 'Orden de Compra',
--(SELECT Comments FROM ORDR WHERE DocEntry = T0.BaseEntry AND LineNum = T0.BaseLine) 'Descripcion',
T1.CardCode 'Codigo Cliente', T1.CardName 'Nombre Cliente', T3.SlpName 'Agente', T0.WhsCode 'Almacen',T0.ItemCode 'Codigo de Material',T0.Dscription 'Descripcion de Material',
--CASE T1.DocSubType
--WHEN 'DN' THEN - T0.U_SalesQty
--WHEN '–' THEN T0.U_SalesQty
--END AS 'Ctd. Facturada',
--T0.U_SalesUoM 'Un. Medida Venta',T0.U_Largo 'Largo', T0.U_Ancho 'Ancho', T0.U_Altura 'Espesor', T0.U_Densidad 'Densidad',
CASE T1.DocSubType
WHEN 'DN' THEN 0
WHEN '–' THEN T0.Quantity
END AS 'Peso Neto Kg',
--T0.U_PriceSal 'Precio Lista',
--CASE T1.DocSubType
--WHEN 'DN' THEN -((T0.U_PriceSalT0.U_SalesQty)/T0.Quantity)
--WHEN '–' THEN ((T0.U_PriceSalT0.U_SalesQty)/T0.Quantity)
--END AS 'Precio Facturado',
--CASE T1.DocSubType
--WHEN 'DN' THEN -T0.U_PriceSalT0.U_SalesQty
--WHEN '–' THEN T0.U_PriceSalT0.U_SalesQty
--END AS 'Importe Facturado',
T0.Currency 'Moneda',
--CASE T1.DocSubType
--WHEN 'DN' THEN -T0.TotalFrgn
--WHEN '–' THEN T0.TotalFrgn
--END AS 'Monto USD',
--CASE T1.DocSubType
--WHEN 'DN' THEN -T0.LineTotal
--WHEN '–' THEN T0.LineTotal
--END AS 'Monto Pesos',
--CASE T1.DocSubType
--WHEN 'DN' THEN -iif(T0.Currency = 'USD', T0.LineTotal, T0.LineTotal)
--WHEN '–' THEN iif(T0.Currency = 'USD', T0.LineTotal, T0.LineTotal)
--END AS 'USD a Pesos',
T0.GrossBuyPr 'Costo MN', /*T0.GrossBuyPr*T0.Quantity 'Costo Total',*/ T1.DocRate,/*T0.GrossBuyPr*T0.Quantity 'Costo Total USD' ,*/ T1.DocRate 'Tipo de Cambio', T5.GroupName 'Segmento'
--,T6.U_Linea_de_Producto 'Linea de Producto', T6.U_Tipo_de_Corte 'Tipo de Corte',
--CASE T1.U_SaleType
--WHEN 'VG' THEN 'Venta general'
--WHEN 'EX' THEN 'Extraordinario'
--END AS 'Tipo de Venta'
FROM INV1 T0
INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN NNM1 T2 ON T1.Series = T2.Series
INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode
INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode
INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode
INNER JOIN OITM T6 ON T0.ItemCode = T6.ItemCode
WHERE T1.DocDate >= '[%0]' AND T1.DocDate <= '[%1]'