
update  tp set tp.NoLowerDedReason = case when isnull( atd.reason,'') ='-' then '' else  ISNULL( atd.Reason,'')  end 
from TDSPayments  tp inner join AccountTDSDetails  as atd on tp.Branch = atd.branch  and tp.code = atd.Party 
where tp.DocDate between '01 Apr 2021' and '30 Jun 2021' and isnull ( tp.CertificatetoDeduct ,0)=1


--update  tdc set tdc.Reason  = atd.reason
--from TaxDepositChild  tdc inner join AccountTDSDetails  as atd on tdc.Branch = atd.branch  and tdc.Partycode = atd.Party 
--where tdc.PaidDate  between '01 Apr 2021' and '30 Jun 2021'


--update TDSPayments  set NoLowerDedReason ='' where  NoLowerDedReason='A'  AND DeductionNotApp =1


----SELECT NEWREASON =case when isnull ( tp.DeductionNotApp,0) =1   and atd.Reason ='A'  THEN '' WHEN ATD.Reason ='-' THEN '' ELSE ATD.Reason  END 
----,tp.DeductionNotApp ,atd.Reason
----,TDC.*
--update  tdc set tdc.Reason  = case when isnull ( tp.DeductionNotApp,0) =1   and atd.Reason ='A'  THEN '' WHEN ATD.Reason ='-' THEN '' ELSE ATD.Reason  END 
--from TaxDepositChild  tdc inner join TDSPayments  as tp on tdc.Branch = tp.branch  and tdc.RefType  = tp.type  and tdc.refprefix = tp.prefix and  tdc.RefSrl = tp.srl  
--LEFT join AccountTDSDetails  as atd on tdc.Branch = atd.branch  and tdc.PartyCode = atd.Party 
--where tdc.PaidDate  between '01 Apr 2021' and '30 Jun 2021'


update  tdc set tdc.Reason  = tp.NoLowerDedReason 
from TaxDepositChild  tdc inner join TDSPayments  as tp on tdc.Branch = tp.branch  and tdc.RefType  = tp.type  and tdc.refprefix = tp.prefix and  tdc.RefSrl = tp.srl  
where tdc.PaidDate  between '01 Apr 2021' and '30 Jun 2021'


--select * from master where name ='Dachser India Pvt. ltd.'
--155111883
--update  tdspayments set NoLowerDedReason='',AssessingCertiRefNo =''
--where code ='155111883' and docdate >='01 Apr 2022'
