📄 gl_enter_credencearh.pas
字号:
+' InvInBill.CurrencyCode, '
+' Currency.CurrencyName, '
+' InvInBill.CurrencyCode+'' ''+Currency.CurrencyName as CurrencyFlag, '
+' InvInBill.ExchRate, '
+' InvInBill.VendorCode, '
+' InvInBill.DeptCode, '
+' InvInBill.BillType2Code, '
+' Vendor.NoInvoiceApKmCode, '
+' InvInBillLine.ItemCode, '
+' Item.AssetKmCode, '
+' InvInBillLine.InvBillQty, '
+' InvInBillLine.Cost, '
+' InvInBillLine.InvBillPrice, '
+' InvInBillLIne.InvBillPriceC, '
+' InvInBillLine.InvBillNoTaxPrice, '
+' InvInBillLIne.InvBillNoTaxPriceC, '
+' InvInBillLIne.InvBillAmount, '
+' InvInBillLine.InvBillAmountC, '
+' InvInBillLIne.InvBillNoTaxAmount, '
+' InvInBillLine.InvBillNoTaxAmountC '
+' Into #TmpInvInBillLine '
+' from InvInBillLine '
+' join InvInBill on InvInBillLIne.InvBillId = InvInBill.InvBillId '
+' left join Vendor on InvInBill.VendorCode = Vendor.VendorCode '
+' left join Currency on InvInBill.CurrencyCode=Currency.CurrencyCode '
+' left join Item on InvInBillLine.ItemCode = Item.ItemCode '
+' where InvInBill.ISCredence = 0 '
+' and IsHistoryBill=1 '
+' ';
SqlText := SqlText
+' select ApInvoice.ApInvoiceId, '
+' ApInvoice.ApInvoiceNo, '
+' ApInvoice.VendorCode, '
+' ApInvoice.CurrencyCode, '
+' Currency.CurrencyName, '
+' ApInvoice.CurrencyCode+'' ''+Currency.CurrencyName as CurrencyFlag, '
+' ApInvoice.ExchRate, '
+' ApInvoice.ApInvoiceTax, '
+' ApInvoice.ApInvoiceTaxC, '
+' ApInvoice.ApInvoiceAmount, '
+' ApInvoice.ApInvoiceAmountC, '
+' Vendor.InvoiceApKmCode, '
+' Vendor.NoInvoiceApKmCode, '
+' ApInvoiceLine.InvBillId, '
+' InvInBillLine.InvBillQty, '
+' InvInBillLine.InvBillNoTaxPrice, '
+' InvInBillLine.InvBillNoTaxPriceC '
+' into #TmpApInvoiceLine '
+' from ApInvoiceLine '
+' join ApInvoice on ApInvoiceLine.ApInvoiceId = ApInvoice.ApInvoiceId '
+' and ApInvoice.ISCredence=0 '
+' and DatePArt(yy,ApInvoice.ApInvoiceInputDate)=@AccountYear '
+' and DatePArt(mm,ApInvoice.ApInvoiceInputDate)=@AccountMonth '
+' left join Vendor on ApInvoice.VendorCode=Vendor.VendorCode '
+' left join Currency on ApInvoice.CurrencyCode=Currency.CurrencyCode '
+' join InvInBillLine on ApInvoiceLine.InvBillId = InvInBillLine.InvBillId '
+' '
+' select PayJournal.PayBillNo, '
+' PayJournal.VendorCode, '
+' PayJournal.CurrencyCode, '
+' Currency.CurrencyName , '
+' PayJournal.CurrencyCode+'' ''+Currency.CurrencyName as CurrencyFlag, '
+' PayJournal.ExchRate, '
+' Vendor.InvoiceApKmCode, '
+' Vendor.NoInvoiceApKmCode, '
+' PayMode.PayModeKmCode, '
+' PayJournal.PayAmount, '
+' PayJournal.PayAmountC '
+' into #TmpPayJournal '
+' from PayJournal '
+' left join PayMode on PayJournal.PayModeCode=PayMode.PayModeCode '
+' left join Currency on PayJournal.CurrencyCode=Currency.CurrencyCode '
+' left join Vendor on PayJournal.VendorCode=Vendor.VendorCode '
+' where ISCredence=0 '
+' and DatePArt(yy,PayInputDate)=@AccountYear '
+' and DatePArt(mm,PayInPutDate)=@AccountMonth '
+' '
+' Create Table #TempCredence '
+' ( CredenceId Integer Identity ,'
+' CheckFlag Integer null default 0, '
+' InvoiceNo varchAr(50) null, '
+' KmCode varchAr(30) null, '
+' CurrencyCode varchAr(10) null, '
+' CurrencyName varchAr(20) null, '
+' CurrencyFlag varchAr(30) null, '
+' ExchRate Decimal(20,8) null, '
// +' KmName varchAr(100) Null,'
+' FDebitAmount decimal(20,2) null, '
+' FCreditAmount decimal(20,2) null, '
+' DebitAmount decimal(20,2) null, '
+' CreditAmount decimal(20,2) null, '
+' CredenceClass varchAr(20) null, '
+' CredenceType Integer null, '
+' Flag SmallInt null default 0 , '
+' RemArk varchAr(150) null ) '
+' Insert Into #TempCredence(InvoiceNo,KmCode,CurrencyCode,CurrencyName,CurrencyFlag, ExchRate,'
+' FDebitAmount,FCreditAmount, '
+' DebitAmount,CreditAmount, '
+' CredenceClass,CredenceType, '
+' RemArk) '
+' /********************************************************************************************/ '
+' '//一、 录入历史未匹配入库单 (InvInBill ISHistoryBill=1表) '
+' '
+' ';
SqlText := SqlTExt
+' select InvBillNo, '//入库单号 '
+' NoInvoiceApKmCode as KmCode, '//应付帐款科目代码 '
+' CurrencyCode, '
+' CurrencyName, '
+' CurrencyFlag, '
+' ExchRate, '
{ +' Case when Sum(InvBillQty*InvBillNoTaxPrice)>0 then Sum(InvBillQty*InvBillNoTaxPrice) '
+' else 0 '
+' end as FDebitAmount,'//原币借方金额 '
+' Case when Sum(InvBillQty*InvBillNoTaxPrice)<0 then -Sum(InvBillQty*InvBillNoTaxPrice) '
+' else 0 '
+' end as FCreditAmount, '//原币贷方金额 '
+' case when Sum(InvBillQty*InvBillNoTaxPriceC)>0 then Sum(InvBillQty*InvBillNoTaxPriceC)'
+' else 0 '
+' end as DebitAmount,'//本位币借方金额 '
+' case when Sum(InvBillQty*InvBillNoTaxPriceC)<0 then -Sum(InvBillQty*InvBillNoTaxPrice)'
+' else 0 '
+' end as CreditAmount, '//本位币贷方金额 '
}
+' Sum(InvBillQty*InvBillNoTaxPrice) as FDebitAmount,'//原币借方金额 '
+' 0.0 as FCreditAmount, '//原币贷方金额 '
+' Sum(InvBillQty*InvBillNoTaxPriceC) as DebitAmount,'//本位币借方金额 '
+' 0.0 as CreditAmount, '//本位币贷方金额 '
+' ''录入历史未匹配入库单'' ,'
+' 0,'
+' ''供应商:''+VendorCode+'' 入库单号:''+InvBillNo as RemArk'//备注 '
+' from #TmpInvInBillLine '
+' where InvBillNoTaxPrice>0 '
+' group by InvBillNo,CurrencyCode,CurrencyName,CurrencyFlag,ExchRate,NoInvoiceApKmCode,VendorCode '
+' '
+' union all '
+' select InvBillNo, '//入库单号 '
+' NoInvoiceApKmCode as KmCode, '//应付帐款科目代码 '
+' CurrencyCode, '
+' CurrencyName, '
+' CurrencyFlag, '
+' ExchRate, '
{ +' Case when Sum(InvBillQty*InvBillNoTaxPrice)<0 then -Sum(InvBillQty*InvBillNoTaxPrice) '
+' else 0 '
+' end as FDebitAmount,'//原币借方金额 '
+' Case when Sum(InvBillQty*InvBillNoTaxPrice)>0 then Sum(InvBillQty*InvBillNoTaxPrice) '
+' else 0 '
+' end as FCreditAmount, '//原币贷方金额 '
+' case when Sum(InvBillQty*InvBillNoTaxPriceC)<0 then -Sum(InvBillQty*InvBillNoTaxPriceC) '
+' else 0 '
+' end as DebitAmount,'//本位币借方金额 '
+' case when Sum(InvBillQty*InvBillNoTaxPriceC)>0 then Sum(InvBillQty*InvBillNoTaxPrice) '
+' else 0 '
+' end as CreditAmount, '//本位币贷方金额 '
}
+' 0.0 as FDebitAmount,'//原币借方金额 '
+' Sum(InvBillQty*InvBillNoTaxPrice) as FCreditAmount, '//原币贷方金额 '
+' 0.0 as DebitAmount,'//本位币借方金额 '
+' Sum(InvBillQty*InvBillNoTaxPriceC) as CreditAmount, '//本位币贷方金额 '
+' ''录入历史未匹配入库单'' ,'
+' 0,'
+' ''供应商:''+VendorCode+'' 入库单号:''+InvBillNo as RemArk'//备注 '
+' from #TmpInvInBillLine '
+' where InvBillNoTaxPrice>0 '
+' group by InvBillNo,CurrencyCode,CurrencyName,CurrencyFlag,ExchRate,NoInvoiceApKmCode,VendorCode '
+' '
+' /*********************************************************************************************/'
+' ';//二、采购发票: '
SqlText := SqlText
+' union all '
+' select ApInvoiceNo, '//发票号 '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -