0% found this document useful (0 votes)
64 views4 pages

New Text Document

Uploaded by

Soumya Swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views4 pages

New Text Document

Uploaded by

Soumya Swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

create or replace view tdsdetailfromvoucher as

select

x."TNO",x."VOUCHERNO",x."VOUCHERDATE",x."PARTYCODE",x."PARTYNAME",x."PANNO",x."TDSM
ASTERCODE",x."AMOUNT",x."TDSAMOUNT",x."SURCHARGEONTDSAMOUNT",x."CESSONTDSAMOUNT",x.
"HANDSCESSONTDSAMOUNT",
z.TaxSectionName
from (
select
a.TNo,
a.VoucherNO,
a.VoucherDate,
b.PartyCode,
b.PartyName,
getPartyAttributeValue(b.PartyCode, 'PANNO') as PANNo,
GetTDSMasterCode(b.PartyCode, a.VoucherDate) as TDSMasterCode,
b.Amount as Amount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'TDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as TDSAmount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'SURCHARGEONTDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as SurchargeOnTDSAmount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'CESSONTDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as CessOnTDSAmount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'HANDSCESSONTDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as HAndSCessOnTDSAmount
from Voucher a, (
select
aa.TNo,
aa.AccountCode,
bb.PartyCode,
bb.PartyName,
sum(aa.Amount) as Amount
from VoucherDetail aa, Party bb
where 1=1
------------------------------------
-- dated 12 feb 2015
-- and aa.Amount > 0
------------------------------------
-- above condition is added bellow again on dated 5 mar 2015
and aa.Amount > 0
--
and aa.AccountCode = bb.PartyCode
and bb.PartyTypeCode != 'ACCOUNT'
group by aa.TNO, aa.AccountCode, bb.PartyCode, bb.PartyName
) b
where a.TNo = b.TNo
and exists(
select
bb.TNo
from MyAccountInclude aa, VoucherDetail bb
where aa.AccountCode = 'TDSALLPAYABLE'
and aa.ChildCode = bb.AccountCode
and bb.TNO = A.TNO
)
---------------------------------------------
-- added on 5 mar 2015
and exists(
select
a1.TNo
from VoucherDetail a1, VoucherDetail b1
where a1.TNo = b1.TNo
and a1.TNO = b.TNo
and a1.AccountCode = b.AccountCode
and b1.TNo = b.tNo
and b1.AccountCode = b.AccountCode
and a1.Amount > 0
and b1.Amount < 0
)
) x, TDSMaster y, TaxSection z
where x.TDSMasterCode = y.TDSMasterCode(+)
and y.TaxSectionCode = z.TaxSectionCode(+)
--------------------------------------------
---------------------------------------------
-- added on 5 mar 2015
union all
select

x."TNO",x."VOUCHERNO",x."VOUCHERDATE",x."PARTYCODE",x."PARTYNAME",x."PANNO",x."TDSM
ASTERCODE",x."AMOUNT",x."TDSAMOUNT",x."SURCHARGEONTDSAMOUNT",x."CESSONTDSAMOUNT",x.
"HANDSCESSONTDSAMOUNT",
z.TaxSectionName
from (
select
a.TNo,
a.VoucherNO,
a.VoucherDate,
b.PartyCode,
b.PartyName,
getPartyAttributeValue(b.PartyCode, 'PANNO') as PANNo,
GetTDSMasterCode(b.PartyCode, a.VoucherDate) as TDSMasterCode,
b.Amount as Amount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'TDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as TDSAmount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'SURCHARGEONTDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as SurchargeOnTDSAmount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'CESSONTDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as CessOnTDSAmount,
(
select
sum(aa.Amount)
from VoucherDetail aa
where aa.TNO = a.TNo
and exists(
select
aaa.AccountCode
from MyAccountInclude aaa
where aaa.AccountCode = 'HANDSCESSONTDSPAYABLE'
and aaa.ChildCode = aa.AccountCode
)
) as HAndSCessOnTDSAmount
from Voucher a, (
select
aa.TNo,
aa.AccountCode,
bb.PartyCode,
bb.PartyName,
sum(aa.Amount) as Amount
from VoucherDetail aa, Party bb
where 1=1
------------------------------------
-- dated 12 feb 2015
-- aa.Amount > 0
and aa.AccountCode = bb.PartyCode
and bb.PartyTypeCode != 'ACCOUNT'
group by aa.TNO, aa.AccountCode, bb.PartyCode, bb.PartyName
) b
where a.TNo = b.TNo
and exists(
select
bb.TNo
from MyAccountInclude aa, VoucherDetail bb
where aa.AccountCode = 'TDSALLPAYABLE'
and aa.ChildCode = bb.AccountCode
and bb.TNO = A.TNO
)
---------------------------------------------
-- added on 5 mar 2015
and not exists(
select
a1.TNo
from VoucherDetail a1, VoucherDetail b1
where a1.TNo = b1.TNo
and a1.TNO = b.TNo
and a1.AccountCode = b.AccountCode
and b1.TNo = b.tNo
and b1.AccountCode = b.AccountCode
and a1.Amount > 0
and b1.Amount < 0
)
) x, TDSMaster y, TaxSection z
where x.TDSMasterCode = y.TDSMasterCode(+)
and y.TaxSectionCode = z.TaxSectionCode(+)
;

You might also like