Professional Documents
Culture Documents
GRN Orgi
GRN Orgi
GRN Orgi
(select distinct m.[Item Category Code] from dbo.[O2I-O2 Power Pvt_ Ltd_-
India$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[O2I-O2 Power Pvt_ Ltd_-
India$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
(select distinct [HSN_SAC Code] from dbo.[O2I-O2 Power Pvt_ Ltd_- India$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[O2I-O2 Power Pvt_ Ltd_-
India$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [O2I-O2 Power Pvt_ Ltd_- India$Detailed GST
Ledger Entry] g inner join [O2I-O2 Power Pvt_ Ltd_- India$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [O2I-O2 Power Pvt_ Ltd_- India$Detailed GST
Ledger Entry] g inner join [O2I-O2 Power Pvt_ Ltd_- India$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [O2I-O2 Power Pvt_ Ltd_- India$Detailed GST
Ledger Entry] g inner join [O2I-O2 Power Pvt_ Ltd_- India$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [O2I-O2 Power Pvt_ Ltd_- India$Detailed GST
Ledger Entry] g inner join [O2I-O2 Power Pvt_ Ltd_- India$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [O2I-O2 Power Pvt_ Ltd_- India$Detailed
GST Ledger Entry] g inner join [O2I-O2 Power Pvt_ Ltd_- India$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [O2I-O2 Power Pvt_ Ltd_- India$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount],
(select distinct Top 1 pl.[Document No_] from [O2I-O2 Power Pvt_ Ltd_-
India$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[O2I-O2 Power Pvt_ Ltd_- India$Purch_ Rcpt_ Header] h inner join dbo.[O2I-
O2 Power Pvt_ Ltd_- India$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[O2I-O2 Power Pvt_ Ltd_- India$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [GLO-Glowsun Powergen Pvt_ Ltd_$Company Information])
Company, h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity, cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[GLO-Glowsun Powergen Pvt_ Ltd_$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[GLO-Glowsun Powergen Pvt_
Ltd_$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct top 1 [GST Registration No_] from dbo.[GLO-Glowsun Powergen Pvt_
Ltd_$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [GLO-Glowsun Powergen Pvt_ Ltd_$Detailed GST
Ledger Entry] g inner join [GLO-Glowsun Powergen Pvt_ Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
from dbo.[GLO-Glowsun Powergen Pvt_ Ltd_$Purch_ Rcpt_ Header] h inner join dbo.
[GLO-Glowsun Powergen Pvt_ Ltd_$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[GLO-Glowsun Powergen Pvt_ Ltd_$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [CYC-Cyclic Energy Pwr Pvt Ltd_$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[CYC-Cyclic Energy Pwr Pvt Ltd_$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[CYC-Cyclic Energy Pwr Pvt
Ltd_$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[CYC-Cyclic Energy Pwr Pvt
Ltd_$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[CYC-Cyclic Energy Pwr Pvt Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[CYC-Cyclic Energy Pwr Pvt
Ltd_$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value],
(select distinct [HSN_SAC Code] from dbo.[CYC-Cyclic Energy Pwr Pvt Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[CYC-Cyclic Energy Pwr Pvt
Ltd_$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [CYC-Cyclic Energy Pwr Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [CYC-Cyclic Energy Pwr Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [CYC-Cyclic Energy Pwr Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [CYC-Cyclic Energy Pwr Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [CYC-Cyclic Energy Pwr Pvt Ltd_$Detailed
GST Ledger Entry] g inner join [CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [CYC-Cyclic Energy Pwr Pvt
Ltd_$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Rcpt_ Header] h inner join dbo.
[CYC-Cyclic Energy Pwr Pvt Ltd_$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[CYC-Cyclic Energy Pwr Pvt Ltd_$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [CSP-Clean Solar Pwr-Bhainsada)$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[CSP-Clean Solar Pwr-Bhainsada)$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[CSP-Clean Solar Pwr-Bhainsada)
$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct top 1 [GST Registration No_] from dbo.[CSP-Clean Solar Pwr-
Bhainsada)$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [CSP-Clean Solar Pwr-Bhainsada)$Detailed GST
Ledger Entry] g inner join [CSP-Clean Solar Pwr-Bhainsada)$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
UNION ALL
select (select Name from [ALT-Altra Xergi Power Pvt Ltd_$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ALT-Altra Xergi Power Pvt Ltd_$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ALT-Altra Xergi Power Pvt
Ltd_$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[ALT-Altra Xergi Power Pvt
Ltd_$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[ALT-Altra Xergi Power Pvt Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[ALT-Altra Xergi Power Pvt
Ltd_$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,
(select distinct [HSN_SAC Code] from dbo.[ALT-Altra Xergi Power Pvt Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[ALT-Altra Xergi Power Pvt
Ltd_$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [ALT-Altra Xergi Power Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [ALT-Altra Xergi Power Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [ALT-Altra Xergi Power Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [ALT-Altra Xergi Power Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [ALT-Altra Xergi Power Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [ALT-Altra Xergi Power Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [ALT-Altra Xergi Power Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [ALT-Altra Xergi Power Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [ALT-Altra Xergi Power Pvt Ltd_$Detailed
GST Ledger Entry] g inner join [ALT-Altra Xergi Power Pvt Ltd_$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [ALT-Altra Xergi Power Pvt Ltd_$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [ALT-Altra Xergi Power Pvt
Ltd_$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[ALT-Altra Xergi Power Pvt Ltd_$Purch_ Rcpt_ Header] h inner join dbo.
[ALT-Altra Xergi Power Pvt Ltd_$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ALT-Altra Xergi Power Pvt Ltd_$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [XLX-XL Xergi Power Pv_ Ltd_$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[XLX-XL Xergi Power Pv_ Ltd_$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[XLX-XL Xergi Power Pv_
Ltd_$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[XLX-XL Xergi Power Pv_
Ltd_$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[XLX-XL Xergi Power Pv_ Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[XLX-XL Xergi Power Pv_
Ltd_$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,
(select distinct [HSN_SAC Code] from dbo.[XLX-XL Xergi Power Pv_ Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[XLX-XL Xergi Power Pv_
Ltd_$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [XLX-XL Xergi Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [XLX-XL Xergi Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [XLX-XL Xergi Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [XLX-XL Xergi Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [XLX-XL Xergi Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [XLX-XL Xergi Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [XLX-XL Xergi Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [XLX-XL Xergi Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [XLX-XL Xergi Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [XLX-XL Xergi Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [XLX-XL Xergi Power Pv_ Ltd_$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [XLX-XL Xergi Power Pv_ Ltd_$Purch_
Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.
[Line No_]) [PI No]
from dbo.[XLX-XL Xergi Power Pv_ Ltd_$Purch_ Rcpt_ Header] h inner join dbo.[XLX-
XL Xergi Power Pv_ Ltd_$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[XLX-XL Xergi Power Pv_ Ltd_$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [TEQ-Teq Green Power Pv_ Ltd_$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[TEQ-Teq Green Power Pv_ Ltd_$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[TEQ-Teq Green Power Pv_
Ltd_$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[TEQ-Teq Green Power Pv_
Ltd_$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[TEQ-Teq Green Power Pv_ Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[TEQ-Teq Green Power Pv_
Ltd_$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value],
(select distinct [HSN_SAC Code] from dbo.[TEQ-Teq Green Power Pv_ Ltd_$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[TEQ-Teq Green Power Pv_
Ltd_$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [TEQ-Teq Green Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [TEQ-Teq Green Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [TEQ-Teq Green Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [TEQ-Teq Green Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [TEQ-Teq Green Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [TEQ-Teq Green Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [TEQ-Teq Green Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [TEQ-Teq Green Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [TEQ-Teq Green Power Pv_ Ltd_$Detailed GST
Ledger Entry] g inner join [TEQ-Teq Green Power Pv_ Ltd_$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [TEQ-Teq Green Power Pv_ Ltd_$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [TEQ-Teq Green Power Pv_
Ltd_$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[TEQ-Teq Green Power Pv_ Ltd_$Purch_ Rcpt_ Header] h inner join dbo.[TEQ-
Teq Green Power Pv_ Ltd_$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[TEQ-Teq Green Power Pv_ Ltd_$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [SOL-Solalite Power Private Ltd$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[SOL-Solalite Power Private Ltd$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[SOL-Solalite Power Private
Ltd$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct top 1 [GST Registration No_] from dbo.[SOL-Solalite Power Private
Ltd$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [SOL-Solalite Power Private Ltd$Detailed GST
Ledger Entry] g inner join [SOL-Solalite Power Private Ltd$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
from dbo.[SOL-Solalite Power Private Ltd$Purch_ Rcpt_ Header] h inner join dbo.
[SOL-Solalite Power Private Ltd$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[SOL-Solalite Power Private Ltd$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [ENE-Energizent Power Pvt Ltd_$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ENE-Energizent Power Pvt Ltd_$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ENE-Energizent Power Pvt
Ltd_$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct top 1 [GST Registration No_] from dbo.[ENE-Energizent Power Pvt
Ltd_$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [ENE-Energizent Power Pvt Ltd_$Detailed GST
Ledger Entry] g inner join [ENE-Energizent Power Pvt Ltd_$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
from dbo.[ENE-Energizent Power Pvt Ltd_$Purch_ Rcpt_ Header] h inner join dbo.[ENE-
Energizent Power Pvt Ltd_$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ENE-Energizent Power Pvt Ltd_$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [BEP-Beempow Energy Private Ltd$Company Information])
Company, h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[BEP-Beempow Energy Private Ltd$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[BEP-Beempow Energy Private
Ltd$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct top 1 [GST Registration No_] from dbo.[BEP-Beempow Energy Private
Ltd$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [BEP-Beempow Energy Private Ltd$Detailed GST
Ledger Entry] g inner join [BEP-Beempow Energy Private Ltd$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
from dbo.[BEP-Beempow Energy Private Ltd$Purch_ Rcpt_ Header] h inner join dbo.
[BEP-Beempow Energy Private Ltd$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[BEP-Beempow Energy Private Ltd$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [TXI-TEQ GREEN POWER XI PVT LTD$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[TXI-TEQ GREEN POWER XI PVT LTD$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[TXI-TEQ GREEN POWER XI PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[TXI-TEQ GREEN POWER XI PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[TXI-TEQ GREEN POWER XI PVT LTD$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[TXI-TEQ GREEN POWER XI PVT
LTD$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,
(select distinct [HSN_SAC Code] from dbo.[TXI-TEQ GREEN POWER XI PVT LTD$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[TXI-TEQ GREEN POWER XI PVT
LTD$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [TXI-TEQ GREEN POWER XI PVT LTD$Detailed GST
Ledger Entry] g inner join [TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [TXI-TEQ GREEN POWER XI PVT LTD$Detailed GST
Ledger Entry] g inner join [TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [TXI-TEQ GREEN POWER XI PVT LTD$Detailed GST
Ledger Entry] g inner join [TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [TXI-TEQ GREEN POWER XI PVT LTD$Detailed GST
Ledger Entry] g inner join [TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [TXI-TEQ GREEN POWER XI PVT LTD$Detailed
GST Ledger Entry] g inner join [TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [TXI-TEQ GREEN POWER XI PVT
LTD$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.
[TXI-TEQ GREEN POWER XI PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[TXI-TEQ GREEN POWER XI PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [TGX-TEQ GREEN POWER X PVT LTD$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[TGX-TEQ GREEN POWER X PVT LTD$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code Item],
(select distinct m.[Item Category Code] from dbo.[TGX-TEQ GREEN POWER X PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[TGX-TEQ GREEN POWER X PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
(select distinct top 1 [GST Registration No_] from dbo.[TGX-TEQ GREEN POWER X PVT
LTD$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [TGX-TEQ GREEN POWER X PVT LTD$Detailed GST
Ledger Entry] g inner join [TGX-TEQ GREEN POWER X PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [TGX-TEQ GREEN POWER X PVT LTD$Detailed GST
Ledger Entry] g inner join [TGX-TEQ GREEN POWER X PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [TGX-TEQ GREEN POWER X PVT LTD$Detailed GST
Ledger Entry] g inner join [TGX-TEQ GREEN POWER X PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [TGX-TEQ GREEN POWER X PVT LTD$Detailed GST
Ledger Entry] g inner join [TGX-TEQ GREEN POWER X PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [TGX-TEQ GREEN POWER X PVT LTD$Detailed
GST Ledger Entry] g inner join [TGX-TEQ GREEN POWER X PVT LTD$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [TGX-TEQ GREEN POWER X PVT LTD$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [TGX-TEQ GREEN POWER X PVT
LTD$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[TGX-TEQ GREEN POWER X PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[TGX-
TEQ GREEN POWER X PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[TGX-TEQ GREEN POWER X PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [TG9-TEQ GREEN POWER IX PVT LTD$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[TG9-TEQ GREEN POWER IX PVT LTD$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[TG9-TEQ GREEN POWER IX PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[TG9-TEQ GREEN POWER IX PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[TG9-TEQ GREEN POWER IX PVT LTD$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[TG9-TEQ GREEN POWER IX PVT
LTD$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,(select distinct [HSN_SAC Code] from dbo.[TG9-TEQ GREEN POWER IX PVT LTD$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[TG9-TEQ GREEN POWER IX PVT
LTD$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [TG9-TEQ GREEN POWER IX PVT LTD$Detailed GST
Ledger Entry] g inner join [TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [TG9-TEQ GREEN POWER IX PVT LTD$Detailed GST
Ledger Entry] g inner join [TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [TG9-TEQ GREEN POWER IX PVT LTD$Detailed GST
Ledger Entry] g inner join [TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [TG9-TEQ GREEN POWER IX PVT LTD$Detailed GST
Ledger Entry] g inner join [TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [TG9-TEQ GREEN POWER IX PVT LTD$Detailed
GST Ledger Entry] g inner join [TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [TG9-TEQ GREEN POWER IX PVT
LTD$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.
[TG9-TEQ GREEN POWER IX PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[TG9-TEQ GREEN POWER IX PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [ESE-ES ENERGY PRIVATE LIMITED$Company Information])
Company, h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ESE-ES ENERGY PRIVATE LIMITED$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ESE-ES ENERGY PRIVATE
LIMITED$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
from dbo.[ESE-ES ENERGY PRIVATE LIMITED$Purch_ Rcpt_ Header] h inner join dbo.[ESE-
ES ENERGY PRIVATE LIMITED$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ESE-ES ENERGY PRIVATE LIMITED$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [ESP-ES SUN POWER PVT LIMITED$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ESP-ES SUN POWER PVT LIMITED$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ESP-ES SUN POWER PVT
LIMITED$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[ESP-ES SUN POWER PVT
LIMITED$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[ESP-ES SUN POWER PVT LIMITED$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[ESP-ES SUN POWER PVT
LIMITED$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line
No_]=l.[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,(select distinct [HSN_SAC Code] from dbo.[ESP-ES SUN POWER PVT LIMITED$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[ESP-ES SUN POWER PVT
LIMITED$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [ESP-ES SUN POWER PVT LIMITED$Detailed GST
Ledger Entry] g inner join [ESP-ES SUN POWER PVT LIMITED$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [ESP-ES SUN POWER PVT LIMITED$Detailed GST
Ledger Entry] g inner join [ESP-ES SUN POWER PVT LIMITED$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [ESP-ES SUN POWER PVT LIMITED$Detailed GST
Ledger Entry] g inner join [ESP-ES SUN POWER PVT LIMITED$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [ESP-ES SUN POWER PVT LIMITED$Detailed GST
Ledger Entry] g inner join [ESP-ES SUN POWER PVT LIMITED$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [ESP-ES SUN POWER PVT LIMITED$Detailed GST
Ledger Entry] g inner join [ESP-ES SUN POWER PVT LIMITED$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [ESP-ES SUN POWER PVT LIMITED$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [ESP-ES SUN POWER PVT
LIMITED$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.
[Receipt Line No_]=l.[Line No_]) [PI No]
from dbo.[ESP-ES SUN POWER PVT LIMITED$Purch_ Rcpt_ Header] h inner join dbo.[ESP-
ES SUN POWER PVT LIMITED$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ESP-ES SUN POWER PVT LIMITED$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [ESS-ES SOLAR PRIVATE LIMITED$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ESS-ES SOLAR PRIVATE
LIMITED$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Header] h inner join dbo.[ESS-
ES SOLAR PRIVATE LIMITED$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [DRE-DRES ENERGY PVT LTD$Company Information]) Company,h.
[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor Name]
[Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[DRE-DRES ENERGY PVT LTD$Item] m where m.
[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[DRE-DRES ENERGY PVT LTD$Item] m
where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[DRE-DRES ENERGY PVT LTD$Item] m
where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[DRE-DRES ENERGY PVT LTD$Purchase Line] pl
where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]) as
NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[DRE-DRES ENERGY PVT
LTD$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,(select distinct [HSN_SAC Code] from dbo.[DRE-DRES ENERGY PVT LTD$Purchase Line]
pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_] ) [PO
HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[DRE-DRES ENERGY PVT
LTD$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [DRE-DRES ENERGY PVT LTD$Detailed GST Ledger
Entry] g inner join [DRE-DRES ENERGY PVT LTD$Purch_ Inv_ Line] pl on g.[Document
No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [DRE-DRES ENERGY PVT LTD$Detailed GST Ledger
Entry] g inner join [DRE-DRES ENERGY PVT LTD$Purch_ Inv_ Line] pl on g.[Document
No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [DRE-DRES ENERGY PVT LTD$Detailed GST Ledger
Entry] g inner join [DRE-DRES ENERGY PVT LTD$Purch_ Inv_ Line] pl on g.[Document
No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [DRE-DRES ENERGY PVT LTD$Detailed GST Ledger
Entry] g inner join [DRE-DRES ENERGY PVT LTD$Purch_ Inv_ Line] pl on g.[Document
No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [DRE-DRES ENERGY PVT LTD$Detailed GST
Ledger Entry] g inner join [DRE-DRES ENERGY PVT LTD$Purch_ Inv_ Line] pl on g.
[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [DRE-DRES ENERGY PVT LTD$Purch_ Inv_ Line] pl
where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [DRE-DRES ENERGY PVT LTD$Purch_
Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.
[Line No_]) [PI No]
from dbo.[DRE-DRES ENERGY PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[DRE-DRES
ENERGY PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[DRE-DRES ENERGY PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.[Document
No_]
UNION ALL
select (select Name from [ESS-ES SOLAR PRIVATE LIMITED$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ESS-ES SOLAR PRIVATE
LIMITED$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Header] h inner join dbo.[ESS-
ES SOLAR PRIVATE LIMITED$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
UNION ALL
select (select Name from [ESS-ES SOLAR PRIVATE LIMITED$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ESS-ES SOLAR PRIVATE
LIMITED$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Header] h inner join dbo.[ESS-
ES SOLAR PRIVATE LIMITED$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[OR1-O2 RENEWABLE E I PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[OR1-
O2 RENEWABLE E I PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[OR1-O2 RENEWABLE E I PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
select (select Name from [ESS-ES SOLAR PRIVATE LIMITED$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[ESS-ES SOLAR PRIVATE
LIMITED$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
from dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Header] h inner join dbo.[ESS-
ES SOLAR PRIVATE LIMITED$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[ESS-ES SOLAR PRIVATE LIMITED$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[OR2-O2 RENEWABLE E II PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[OR2-
O2 RENEWABLE E II PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[OR2-O2 RENEWABLE E II PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[OR3-O2RENEWABLE E III PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[OR3-
O2RENEWABLE E III PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[OR3-O2RENEWABLE E III PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[OR4-O2RENEWABLE ENE IV PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.
[OR4-O2RENEWABLE ENE IV PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[OR4-O2RENEWABLE ENE IV PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
UNION ALL
select (select Name from [TX2-TEQ GREEN PWR XII PVT LTD$Company Information])
Company,h.[No_] as [GRN No],h.[Buy-from Vendor No_] [Vendor No],h.[Buy-from Vendor
Name] [Vendor Name], h.[Posting Date], gh.[Gate Entry No_],gh.[Gate Entry Date],
h.[Location Code],gh.Remarks, h.[Document Date], h.[Dimension Set ID],h.[Shortcut
Dimension 1 Code],
h.[Shortcut Dimension 2 Code],gh.[Purchase Category], gh.[Vendor Invoice No_],gh.
[Vendor Invoice Date],
---=====
l.[Line No_],l.[No_] [Item No], l.Description [Item Desc], l.[Description 2] [Item
Desc 2], l.[Unit of Measure Code], l.[Order No_] [Purchase Order No_],
l.[Order Line No_],cast(l.Quantity as Numeric(35,2)) Quantity,cast(l.[Direct Unit
Cost] as Numeric(35,2)) [Direct Unit Cost],cast(l.[Unit Cost] as Numeric(35,2))
[Unit Cost],cast(l.[Quantity Invoiced] as Numeric(35,2)) [Quantity Invoiced],l.
[Qty_ Rcd_ Not Invoiced],--[Pending Order Quantity],
[GRN Qty(Posted)],cast([Accepted Quantity] as Numeric(35,2)) [Accepted Quantity],
cast([Rejected Quantity] as Numeric(35,2)) [Rejected Quantity], l.[Return Reason
Code],
l.[Indent No_],[Indent Line No_],l.[Job No_],
[Line Remarks],
Case when gh.Status =0 then 'Open' else 'Closed' end Status,
gh.[CN_RR_LR No_] as [CN_RR_LR No],gh.[CN_RR_LR Date],
gh.[Way Bill No_] as [Way Bill No] ,
(select distinct [HSN_SAC Code] from dbo.[TX2-TEQ GREEN PWR XII PVT LTD$Item] m
where m.[No_]=l.[No_] ) [HSN / SEC Code],
(select distinct m.[Item Category Code] from dbo.[TX2-TEQ GREEN PWR XII PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Item Category Code],
(select distinct m.[Product Group Code] from dbo.[TX2-TEQ GREEN PWR XII PVT
LTD$Item] m where m.[No_]=l.[No_] ) [Product Sub Group Code],
COALESCE(case h.[Workflow Sub Document Type] when 1 Then 'FA' When 2 then
'Regular' When 3 Then 'Direct' When 4 Then 'Work Order' when 5 then 'Inward'
when 6 then 'Outward' when 7 then 'Indent' end,'') as [Workflow Sub Document
Type],
cast((select sum(pl.Quantity) from dbo.[TX2-TEQ GREEN PWR XII PVT LTD$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line
No_]) as NUMERIC(35,2)) [PO QTY],
cast((select sum([Amount Including Tax]) from dbo.[TX2-TEQ GREEN PWR XII PVT
LTD$Purchase Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.
[Order Line No_]) as NUMERIC(35,2)) [PO Value]
,(select distinct [HSN_SAC Code] from dbo.[TX2-TEQ GREEN PWR XII PVT LTD$Purchase
Line] pl where pl.[Document No_]=l.[Order No_] and pl.[Line No_]=l.[Order Line No_]
) [PO HSN/SEC Code],
(select distinct top 1 [GST Registration No_] from dbo.[TX2-TEQ GREEN PWR XII PVT
LTD$Vendor] v where v.No_=h.[Buy-from Vendor No_]) [Vendor GST REg No],
cast((select sum([GST Amount]) from [TX2-TEQ GREEN PWR XII PVT LTD$Detailed GST
Ledger Entry] g inner join [TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='SGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [SGST Amount],
cast((select sum([GST Amount]) from [TX2-TEQ GREEN PWR XII PVT LTD$Detailed GST
Ledger Entry] g inner join [TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CGST Amount],
cast((select sum([GST Amount]) from [TX2-TEQ GREEN PWR XII PVT LTD$Detailed GST
Ledger Entry] g inner join [TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='IGST' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [IGST Amount],
cast((select sum([GST Amount]) from [TX2-TEQ GREEN PWR XII PVT LTD$Detailed GST
Ledger Entry] g inner join [TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Inv_ Line] pl on
g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] and g.[GST Component Code]='CESS' where
pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line No_]) as
NUMERIC(35,2)) [CESS Amount]
,
(select distinct g.[HSN_SAC Code] from [TX2-TEQ GREEN PWR XII PVT LTD$Detailed
GST Ledger Entry] g inner join [TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Inv_ Line] pl
on g.[Document No_]=pl.[Document No_]
and g.[Document Line No_]=pl.[Line No_] where pl.[Receipt No_]=l.[Document No_]
and pl.[Receipt Line No_]=l.[Line No_]) [HSN Sec Code],
cast((select sum([TDS Amount]) from [TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Inv_
Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt Line No_]=l.[Line
No_]) as NUMERIC(35,2)) [TDS Amount]
,
(select distinct Top 1 pl.[Document No_] from [TX2-TEQ GREEN PWR XII PVT
LTD$Purch_ Inv_ Line] pl where pl.[Receipt No_]=l.[Document No_] and pl.[Receipt
Line No_]=l.[Line No_]) [PI No]
from dbo.[TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[TX2-
TEQ GREEN PWR XII PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[TX2-TEQ GREEN PWR XII PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[PWG-PANAMA WIND E G PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[PWG-
PANAMA WIND E G PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[PWG-PANAMA WIND E G PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[PWS-PANAMA WIND E S PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[PWS-
PANAMA WIND E S PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[PWS-PANAMA WIND E S PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
UNION ALL
UNION ALL
UNION ALL
from dbo.[O21-O2RENEWABLE E XXI PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.[O21-
O2RENEWABLE E XXI PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[O21-O2RENEWABLE E XXI PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[O22-O2RENEWABLE E XXII PVT LTD$Purch_ Rcpt_ Header] h inner join dbo.
[O22-O2RENEWABLE E XXII PVT LTD$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[O22-O2RENEWABLE E XXII PVT LTD$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL
from dbo.[O23-O2RENEWABLE E XXIII PVT L$Purch_ Rcpt_ Header] h inner join dbo.[O23-
O2RENEWABLE E XXIII PVT L$Goods Receipt Header] gh on h.No_=gh.No_
inner join dbo.[O23-O2RENEWABLE E XXIII PVT L$Purch_ Rcpt_ Line] l on h.No_=l.
[Document No_]
UNION ALL