专业版付款单选择源单采购发票保存时提示:付款单中包含核销金额大于未核销金额的采购发票,不允许保存!

【问题描述】
专业版付款单选择源单采购发票保存时提示:付款单中包含核销金额大于未核销金额的采购发票,不允许保存!

【原因分析】
原因:所选采购发票表头的已核销金额及未核销金额与发票的实际核销金额不符,系统判定单据不允许保存;
【解决方案】
可参考以下脚本执行处理:
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.FInter
专业版付款单选择源单采购发票保存时提示:付款单中包含核销金额大于未核销金额的采购发票,不允许保存!
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



