Dear Sir Please Add BOM Price in this Sales Report.

2 days ago 1

SELECT T0.DocEntry,t0.docnum arsenic 'Invoice No', --T0.[U_CustomersGRNNo],T0.[U_GRDate],


M.[BeginStr] arsenic 'Prerflix',T0.[NumAtCard],
(SELECT Top 1 X.[County] FROM CRD1 X Where T0.CardCode = X.CardCode)as'County',
T0.[DocDate],T0.[CANCELED], T0.[TaxDate], T0.[CardName], a.[ItmsGrpCod], a.[U_ItemSubGroup], a.[SalUnitMsr],
(case erstwhile t0.gsttrantyp='GA' past 'GST Tax Invoice'
when t0.gsttrantyp='GD' past 'GST Debit Memo'
else 'Bill Of Supply' extremity ) arsenic 'Document Type',
--(Select N.[U_BPSubGroup] From OCRD N Where T0.CardCode = N.CardCode)as'BP Sub Group',
t3.bpgstn, t0.paytocode arsenic 'Bill To', t0.shiptocode arsenic 'Ship To', T1.[OcrCode],
(Select apical 1 T.[Location] from OLCT T wherever T.Code=t1.LocCode ) arsenic 'Location',
T3.[BpGSTN] arsenic 'BP GSTIN',

(SELECT Top 1 S.[Name] FROM CRD1 R INNER JOIN OCST S ON R.[State] = S.[Code] Where T0.CardCode = R.CardCode )as'State',
T1.[ItemCode], T1.[Dscription],A.[FrgnName],T1.[Quantity],T1.[U_NoOfPkgs], T1.[U_DNo], T1.[U_QtyInKG], l.ItmsGrpNam, T1.[Weight1],T1.[LineTotal]-(T1.LineTotal*T0.[DiscPrcnt]/100) 'Basic Value',

T1.[PriceBefDi],T1.[Price], T0.[RoundDif],T1.[DiscPrcnt],T0.[DocTotal],-- A.[U_ProductGroup], A.[U_SubGroup],
t2.chapterid,---T8.[DistNumber],T8.[MnfDate], T8.[ExpDate],

--(SELECT X.[U_GST] FROM [@UOM] X wherever X.[Name] = T1.[unitMsr])as'Unit1', T1.[PackQty],
--(SELECT X.[U_GST] FROM [@UOM] X wherever X.[Name] = a.[SalPackMsr])as'Unit2',T1.[Quantity], t1.price, T1.[LineTotal]-(T1.LineTotal*T0.[DiscPrcnt]/100) 'Basic Value',

(SELECT apical 1 ISNULL(T7.stccode,0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType=-120 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum)'IGSTRate%',
(SELECT ISNULL(sum(T7.TaxSUm),0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType=-120 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum and t7.expnscode=-1 )IGSTAmt,

(SELECT apical 1 ISNULL(T7.stccode,0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType= 8 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum)'TCSRate%',
(SELECT ISNULL(sum(T7.TaxSUm),0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType= 8 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum and t7.expnscode=-1 )TCSAmt,

(SELECT apical 1 ISNULL(T7.stccode,0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType=-100 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum)'CGSTRate%',
(SELECT ISNULL(sum(T7.TaxSUm),0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType=-100 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum and t7.expnscode=-1 )CGSTAmt,

(SELECT apical 1 ISNULL(T7.stccode,0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType=-110 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum)'SGSTRate%',
(SELECT ISNULL(sum(T7.TaxSUm),0) FROM OINV T5 INNER JOIN INV1 T6 ON T5.DocEntry=T6.DocEntry INNER JOIN INV4 T7 ON T5.DocEntry=T7.DocEntry Where T7.StaType=-110 AND T6.LineNum=T1.LineNum AND T5.DocEntry=T0.DocEntry AND T6.ItemCode=T1.ItemCode AND T6.LineNum=T7.LineNum and t7.expnscode=-1 )SGSTAmt,

(case erstwhile t1.VisOrder=0 then
(select sum(distinct t.basesum) from inv4 t wherever t.expnscode successful (1,2,3,4) and t.docentry=t0.docentry)
when t1.VisOrder>=1 past 0 end) arsenic 'Freight Amt',

(case erstwhile t1.VisOrder=0 then
(select sum( t.taxsum) from inv4 t wherever t.expnscode successful (1,2,3,4) and t.docentry=t0.docentry)
when t1.VisOrder>=1 past 0 end) arsenic 'Freight Tax Amt',

(case erstwhile t1.VisOrder=0 then
(select apical 1 t.stccode from inv4 t wherever t.expnscode successful (1,2,3,4) and t.docentry=t0.docentry)
when t1.VisOrder>=1 past '' end) arsenic 'Freight Tax Rate',


T1.[LineTotal],H.[SlpName],T1.[AcctCode],T0.[U_VehicleNo], T0.[U_Destination],T0.[U_Transporter],T0.[U_LRNo], T0.[U_LRDate], T0.[U_Ewaybill], T0.[U_TransporterGST]


FROM dbo.OINV T0
INNER JOIN dbo.INV1 T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN NNM1 M ON T0.[Series] = M.[Series]
LEFT JOIN dbo.OITM a ON T1.[ItemCode] = a.[ItemCode]
LEFT JOIN dbo.OITB l connected a.ItmsGrpCod = l.ItmsGrpCod
LEFT JOIN dbo.OCHP T2 ON T1.HsnEntry = T2.[AbsEntry]
LEFT JOIN dbo.inv12 t3 connected t0.docentry=t3.docentry
INNER JOIN dbo.OLCT T4 ON T1.[LocCode] = T4.[Code]
LEFT JOIN DLN1 T5 ON T1.BaseEntry = T5.DocEntry And T5.BaseLine = T1.LineNum AND T1.WhsCode=T5.WhsCode AND T1.ItemCode=T5.ItemCode
LEFT JOIN ODLN T6 ON T5.DocEntry = T6.DocEntry
INNER JOIN OSLP H ON T0.[SlpCode] = H.[SlpCode]
--left outer articulation IBT1 I1 connected T1.ItemCode=I1.ItemCode and (T5.DocEntry=I1.BaseEntry and T5.ObjType=I1.BaseType)
--left outer articulation OBTN T8 connected T8.ItemCode=I1.ItemCode and I1.BatchNum=T8.DistNumber
LEFT JOIN WTR1 T16 On T16.DocEntry=T1.BaseEntry and T16.LineNum=T1.BaseLine
--left outer articulation IBT1 I11 connected T1.ItemCode=I11.ItemCode and (T16.DocEntry=I11.BaseEntry and T16.ObjType=I11.BaseType)
--left outer articulation OBTN T18 connected T18.ItemCode=I11.ItemCode and I11.BatchNum=T18.DistNumber


WHERE T4.[GSTRegnNo] =[%2] and T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1] and T0.Canceled = 'N' AND T0.GSTTranTyp NOT IN('GD')

ORDER BY T0.[DocDate],T0.[DocNum]

Read Entire Article