You are on page 1of 3

strbuilder.

Append(" spRptTaxInvoiceALLNEWSales

" & vbCrLf)

strbuilder.Append(" ALTER Procedure [dbo].[spRptTaxInvoiceALLNEWSales](@ strEICode nvarchar(15), @strDCCodes nvarchar(500)) as begin declare @strSo nva rchar ") strbuilder.Append(" select @strSO = strSOCOde from tblExInvoiceHd where strEICode = @strEICode declare @dblCentVat decimal(18,2) declare @dblSed decima l(18,2) ") strbuilder.Append(" declare @dblTaxVal decimal(18,2) declare @FinAmt dec imal(18,2) declare @dblEduCess decimal(18,2) declare @dblSHECess decimal(18,2) declare") strbuilder.Append(" @dblVat decimal(18,2) declare @dblCST decimal(18,2 ) declare @Freight decimal(18,2) declare @insurance decimal(18,2) declare @tot al ") strbuilder.Append(" decimal(18,2) declare @Total1 decimal(18,2) declare @Total2 decimal(18,2) declare @Total3 decimal(18,2) declare @TotalEx decimal( 18,2)") strbuilder.Append(" declare @grandTotal decimal(18,2) declare @dynamicSq l nvarchar(1000) declare @strDCNos nvarchar(100) declare @strDCNo nvarchar(100) ") strbuilder.Append(" declare @strAgainst nvarchar(20) set @strDCNos='' de clare dcno cursor for select isnull(strdcno,'') from tblDeliveryChallanHd ") strbuilder.Append(" where @strDCCodes like '%'+strDCCode +'%' print(@st rDCNos) open dcno fetch next from dcno into @strDCNo WHILE @@FETCH_STATUS = 0 " ) strbuilder.Append(" BEGIN set @strDCNos=@strDCNos+@strDCNo+',' fetch nex t from dcno into @strDCNo End Close dcno deallocate dcno set @strDCNos= left(@st rDCNos,") strbuilder.Append(" len(@strDCNos)-1) declare @dtDCDate smalldatetime p rint(@strDCNos) select @dtDCDate=max(dtDCDate) from tblDeliveryChallanHd ") strbuilder.Append(" where @strDCCodes like '%'+strDCCode +'%' declare @Trmode nvarchar(100) declare @TrDktNo nvarchar(100) declare @Trvehno nvarchar( 100)") strbuilder.Append(" declare @dblCentVatVal decimal(18,2) declare @dblSed Val decimal(18,2) declare @dblEduCessVal decimal(18,2) declare @dblSHECessVa l decimal(18,2)") strbuilder.Append(" declare @dblVatVal decimal(18,2) declare @dblCSTVal decimal(18,2)") strbuilder.Append(" select top 1 @Trmode= strMinBy ,@TrDktNo=strDktNo, @Trvehno=strvehno from tblDeliveryChallanHd where @strDCCodes like '%'+strDCCo de +'%' ") strbuilder.Append(" SET @dynamicSQL = 'select @total = sum(dc.dblQty * dc.dblUnitPrice) from tblExInvoiceDtl dc where dc.strEICode ='''+ @strEICod e +'''' ") strbuilder.Append(" EXEC sp_executesql @dynamicSQL,N'@total decimal(18, 2) out', @total out select @strAgainst=strAgainst,@total1=dblTaxableAmt ,") strbuilder.Append(" @dblCentVatVal=(select isnull((select dblTaxAmt from tbltransTaxDtl where strTaxcode=(select strSCENVAT from dbinvsystem_cabinet.. tbltaxsetup) ") strbuilder.Append(" and strTransCode=@strEICode),0)), ") strbuilder.Append(" @dblSedVal=0.00, @dblTaxVal = dblTaxAmt,@FinAmt=dbl FinAmount,") strbuilder.Append(" @dblEduCessVal = (select isnull((select dblTaxAmt") strbuilder.Append(" from tbltransTaxDtl where strTaxcode=(select strSE Cess from dbinvsystem_cabinet..tbltaxsetup) and strTransCode=@strEICode),0)), " ) strbuilder.Append(" @dblSHECessVal=(select isnull((select dblTaxAmt from

tbltransTaxDtl where strTaxcode=(select strSSHECess from dbinvsystem_cabinet. .tbltaxsetup) ") strbuilder.Append(" and strTransCode=@strEICode),0)),") strbuilder.Append(" @dblVatVal=(select isnull((select dblTaxAmt from tbl transTaxDtl where strTaxcode=(select strSVAT from dbinvsystem_cabinet..tbltaxs etup) ") strbuilder.Append(" and strTransCode=@strEICode),0)),") strbuilder.Append(" @dblCSTVal= (select isnull((select dblTaxAmt from tb ltransTaxDtl where strTaxcode=(select strSCST from dbinvsystem_cabinet..tbltax setup) ") strbuilder.Append(" and strTransCode=@strEICode),0)) ") strbuilder.Append(" , @Freight = strFreight, @Insurance = strInsurance ,") strbuilder.Append(" @dblCentVat=(select isnull((select dblTaxRate from t bltransTaxDtl where strTaxcode=(select strSCENVAT from dbinvsystem_cabinet..tblt axsetup) and strTransCode=@strEICode),0)),") strbuilder.Append(" @dblSed=0.00,") strbuilder.Append(" @dblEduCess = (select isnull((select dblTaxRate fro m tbltransTaxDtl where strTaxcode=(select strSECess from dbinvsystem_cabinet.. tbltaxsetup) and strTransCode=@strEICode),0)), ") strbuilder.Append(" @dblSHECess=(select isnull((select dblTaxRate from t bltransTaxDtl where strTaxcode=(select strSSHECess from dbinvsystem_cabinet..t bltaxsetup) and strTransCode=@strEICode),0)),") strbuilder.Append(" @dblVAT=(select isnull((select dblTaxRate from tbltr ansTaxDtl where strTaxcode=(select strSVAT from dbinvsystem_cabinet..tbltaxset up) and strTransCode=@strEICode),0)),") strbuilder.Append(" @dblCST=(select isnull((select dblTaxRate from tbltr ansTaxDtl where strTaxcode=(select strSCST from dbinvsystem_cabinet..tbltaxset up) and strTransCode=@strEICode),0))") strbuilder.Append(" from tblExInvoiceHd th left outer join tblExInvoic eTaxDtl td on th.strEICode=td.strEICode where th.strEICode =") strbuilder.Append(" @strEICode set @Total2 = @total1+@dblCentVatVal + @dblSedVal + @dblEduCessVal + @dblSHECessVal ") strbuilder.Append(" set @Total3 = @FinAmt set @grandTotal = @Total3 + @Freight + @insurance set @TotalEx= @dblTaxVal") strbuilder.Append(" if (@strAgainst = 'Direct') begin select ti.strEICod e, ti.dtEIDate, pm.strPName, pm.strMAdd1, pm.strMAdd2, pm.strMCity,pm.strMstate, pm.strMPin,") strbuilder.Append(" pm.strMCountry, pm.strVAT, pm.strCST, pm.strExcise, ti.strCustPONo as PoNo, dchd.strDCCode as DCCode, dchd.strDCNo as DCNo, dchd.d tDCDate as ") strbuilder.Append(" DCDate, '' as systemModel, ti.strTariffNo, ti.dblTa riffRate,ti.dtIssueDate, ti.dtIssueTime, dbo.udf_Num_ToWords(day(ti.dtRemovalDa te))+'/'") strbuilder.Append(" +dbo.udf_Num_ToWords(month(ti.dtRemovalDate))+'/'+db o.udf_Num_ToWords(year(ti.dtRemovalDate))as dtRemWords,") strbuilder.Append(" ti.dtRemovalDate, dbo.udf_Num_ToWords(datepart(hh,ti .dtRemovalTime))+' HRS ' +dbo.udf_Num_ToWords") strbuilder.Append(" (datepart(n,ti.dtRemovalTime))+' MIN' as tmRemWords ,ti.dtRemovalTime, ti.strAdd, ti.dblAddVal, ") strbuilder.Append(" ti.strDeduct,ti.dblDeductVal, ti.dblTaxAmt, @total1 Total1, @dblCentVatVal CenVatValue, @dblSedVal SedValue, @dblTaxVal") strbuilder.Append(" TaxValue, @dblEduCessVal EduCessValue, @dblSHECessV al SHECessValue, @Total2 Total2,@dblVat VatValue, @dblCST CSTValue, ") strbuilder.Append(" @Total3 Total3, @grandTotal GrandTotal, dbo.Currenc y_ToWords(round(@grandTotal,2)) as Amtinwords, ti.strCurrency,") strbuilder.Append(" PM.STREXCISE,PM.STRREGISTRATION, PM.STRRANGE,PM.STRD IVISION,PM.STRCOMMISSIONERATE,ti.strGRNCode,pm.strManualCode as ") strbuilder.Append(" strInsType,ti.strNameofCom,ti.strTerms ,@TotalEx tot alExcise, dbo.Currency_ToWords(round(@TotalEx,2)) as Excinwords,")

strbuilder.Append(" @Trmode Trmode,@TrDktNo TrDktNo,@Trvehno Trvehno, dc hd.dtDCDate as PODate, pm.strcategory ,dbo.Currency_ToWords(round") strbuilder.Append(" (@dblCentVat,2)) as CentVatInWord,'' as strAddTax,@d blCentVat as dblCenVat,@dblSed as dblSed,@dblEduCess as dblEduCess,@dblSHECess a s dblSHECess,") strbuilder.Append(" @dblVatVal as VATValue ,@dblVAT as dblVATRate,@dblCS T as CSTValue,@dblCSTVal as dblCSTRate,@Freight as Freight, @Insurance as Insura nce") strbuilder.Append(" from tblExInvoiceHd ti, tblDeliveryChallanHd dchd, dbinvsystem_cabinet..tblPartyMaster pm ") strbuilder.Append(" where (ti.strEICode = @strEICode) and (ti.strDCCode= dchd.strDCCode) and (dchd.strCustCode = pm.strPCode) End else ") strbuilder.Append(" if (@strAgainst = 'Sales Order' ) begin select ti.s trEICode, ti.dtEIDate, pm.strPName, pm.strMAdd1, pm.strMAdd2,pm.strMCity,pm.st rMstate,") strbuilder.Append(" pm.strMPin, pm.strMCountry, pm.strVAT, pm.strCST, p m.strExcise, so.strCustPONo as PoNo, '' as DCCode , case when @strDCNos='' ") strbuilder.Append(" then replace(@strDCCodes,'''','') else @strDCNos e nd as DCNo,@dtDCDate as DCDate ,so.strSysModel as systemModel, ti.strTariffNo, ") strbuilder.Append(" ti.dblTariffRate, ti.dtIssueDate, ti.dtIssueTime, d bo.udf_Num_ToWords(day(ti.dtRemovalDate))+'/'+dbo.udf_Num_ToWords(month(ti.dtRem ovalDate))") strbuilder.Append(" +'/'+dbo.udf_Num_ToWords(year(ti.dtRemovalDate))as d tRemWords,ti.dtRemovalDate, dbo.udf_Num_ToWords(datepart(hh,ti.dtRemovalTime))+' HRS '") strbuilder.Append(" +dbo.udf_Num_ToWords(datepart(n,ti.dtRemovalTime))+' MIN' as tmRemWords,ti.dtRemovalTime, ti.strAdd, ti.dblAddVal, ti.strDeduct, ") strbuilder.Append(" ti.dblDeductVal, ti.dblTaxAmt, @total1 Total1, @dblC entVatVal CenVatValue, @dblSedVal SedValue, @dblTaxVal TaxValue, @dblEduCessVal EduCessValue,") strbuilder.Append(" @dblSHECessVal SHECessValue, @Total2 Total2, @dblVa t VatValue, @dblCST CSTValue, @Total3 Total3, @grandTotal GrandTotal, ") strbuilder.Append(" dbo.Currency_ToWords(round(@grandTotal,2)) as Amtinw ords, ti.strCurrency, PM.STREXCISE, PM.STRREGISTRATION, PM.STRRANGE, PM.STRDIVIS ION, ") strbuilder.Append(" PM.STRCOMMISSIONERATE, ti.strGRNCode,pm.strManualCod e as strInsType,sd.strRemarks as strNameofCom,ti.strTerms,")

You might also like