专业版付款单选择源单采购发票保存时提示:付款单中包含核销金额大于未核销金额的采购发票,不允许保存!
【问题描述】
专业版付款单选择源单采购发票保存时提示:付款单中包含核销金额大于未核销金额的采购发票,不允许保存!
【原因分析】
原因:所选采购发票表头的已核销金额及未核销金额与发票的实际核销金额不符,系统判定单据不允许保存;
【解决方案】
可参考以下脚本执行处理:
update ICPurchase set FPayAmountFor = rp.ftotal
from ICPurchase icc inner join
(
select ic.FInterID,ic.fbillno,ic.FPayAmountFor,isnull(ftotal,0) ftotal --,FPayAmountFor-FTotal '差异'
--ic.FInterID '发票内码',ic.fbillno '发票编码',ic.FPayAmountFor '账面已付金额',FTotal '实际发生付款金额'
from ICPurchase ic
left join (
Select FInterID, sum(FAmount) as FTotal From (
Select e.FInterID as FInterID,ISNull(e.FBillSettleAmountFor,0) as FAmount --'付款单'
from t_RP_PBill t Inner Join t_RP_PBillEntry e On t.FBillID=e.FBillID
Left Join t_Account a ON a.FAccountID=t.FAcctId
Left Join t_Currency c ON e.FBillCurrencyID=c.FCurrencyID
Where e.FClassID_SRC IN (1000003,1000004)
Union All
Select u.FInterID as FInterID,-1*isnull(e.FBillSettleAmountFor,0) as FAmount --'退款单'
from t_RP_PBill t
inner join t_RP_PBillEntry e On t.FBillID=e.FBillID
inner join (Select * from t_RP_PBillEntry Where FClassID_SRC IN (1000003,1000004)) u On e.FEntryID_SRC=u.FEntryID and u.FBillID=e.FInterID
Left Join t_Currency c ON e.FBillCurrencyID=c.FCurrencyID
Inner Join t_Account a ON a.FAccountID=t.FAcctId
Where t.FPayTypeid = 1010
Union All
select FContactID as FInterID,isnull(e.FCheckAmountFor,0) as FAmount --'核销单'
from T_RP_CheckInfo t Inner Join T_RP_CheckInfoEntry e ON t.FInterID=e.FInterID
Left Join t_Currency c ON e.FCurrencyID=c.FCurrencyID
Where ((t.FCheckType = 0 And e.FEntryType = 1) Or (t.FCheckType = 1 And e.FEntryType = 0) Or (t.FCheckType = 3 And e.FEntryType = 1))
And FContactType IN (75,76)
Union All
Select v1.FInvoiceID as FInterID,isnull(e.FBillSettleAmountFor,0) as FAmount --'付款单'
from t_RP_PBill t Inner Join t_RP_PBillEntry e On t.FBillID=e.FBillID
Left Join t_RP_CheckInfoEntry v1 on v1.FInterID=e.FInterID and v1.FNo=e.FEntryID_HXD_SRC
Left Join t_RP_CheckInfo v2 on v1.FInterID=v2.FInterID
Left Join t_Currency c ON e.FBillCurrencyID=c.FCurrencyID
Inner Join t_Account a ON a.FAccountID=t.FAcctId
Where e.FClassID_SRC = 1000093 and v1.FInvoiceType IN (75,76) And v2.FCheckType=5
Union All
Select v1.FInvoiceID as FInterID,-1*isnull(e.FBillSettleAmountFor,0) as FAmount --'退款单'
from t_RP_PBill t Inner Join t_RP_PBillEntry e On t.FBillID=e.FBillID
Inner Join t_RP_PBillEntry u On e.FEntryID_SRC=u.FEntryID
Left Join t_RP_CheckInfoEntry v1 on v1.FInterID=u.FInterID and v1.FNo=u.FEntryID_HXD_SRC
Left Join t_RP_CheckInfo v2 on v1.FInterID=v2.FInterID
Left Join t_Currency c ON e.FBillCurrencyID=c.FCurrencyID
Inner Join t_Account a ON a.FAccountID=t.FAcctId
Where t.FPayTypeid =1010 AND u.FClassID_SRC=1000093 AND v1.FInvoiceType IN (75,76) And v2.FCheckType=5
Union All
select v1.FInvoiceID as FInterID,isnull(v1.FCheckAmountFor,0) as FAmount --'核销单'
from T_RP_CheckInfo t Inner Join T_RP_CheckInfoEntry e ON t.FInterID=e.FInterID
Inner Join T_RP_CheckInfoEntry v1 on v1.FContactID=e.FInterID and v1.FHeIndex=e.FNo
Inner Join T_RP_CheckInfo v2 on v2.FInterID=v1.FInterID
Inner Join t_Currency c ON e.FCurrencyID=c.FCurrencyID
Where ((v2.FCheckType = 0 And v1.FEntryType = 1) Or (v2.FCheckType = 1 And v1.FEntryType = 0) Or (v2.FCheckType = 3 And v1.FEntryType = 1))
And v1.FInvoiceType IN (75,76) And v1.FContactType=1006 AND t.FCheckType=5
Union All
SELECT b.FInvoiceID as FInterID,isnull(b.FCheckAmountFor, 0) - isnull(b.FMeCheckAmountFor, 0) as FAmount --应付转应付(未核销金额不为0的)上面没有包含未核销金额
FROM T_RP_CheckInfo a LEFT JOIN
T_RP_CheckInfoEntry b ON a.FInterID = b.FInterID
WHERE a.FCheckType = 5 AND b.FInvoiceType IN (75,76) and isnull(b.FCheckAmountFor, 0) - isnull(b.FMeCheckAmountFor, 0) <> 0
) as pp
group by FInterID ) t on t.FInterID=ic.FInterID
where ic.FPayAmountFor-isnull(t.ftotal,0)<>0
) rp on rp.FInterId=icc.FInterId
where rp.FPayAmountFor-isnull(rp.ftotal,0)<>0 and icc.FPOStyle<>251
go
update ICPurchase set FUnPayAmountFor = FPurchaseAmountFor - FPayAmountFor
go
【注意事项】
正式账套执行脚本前请先做好备份,建议待在测试账套中核实无误后再在正式账套中执行。
专业版付款单选择源单采购发票保存时提示:付款单中包含核销金额大于未核销金额的采购发票,不允许保存!
本文2024-09-22 15:54:47发表“kis知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-kis-84521.html