1.
增加科目
7001
供应商付款差额
,
核算项目为
‘
供应商
’;
2.
把确认后的差额以凭证的形式录入
;
3.
在系统工具
—
单据自定义中增加字段
’
是否提示
’
;
如图
4.
在数据库中执行脚本。
go
create trigger icpurchase_jade01 on icpurchase
for insert,update
as
declare @ftrantype int,@finterid int,@fisprompt as bit,@fsupplyid int,@fstatus int
declare @fleftamountfor decimal(18,2),@fdiffamount decimal(18,2)
declare @fleftamountfor decimal(18,2),@fdiffamount decimal(18,2)
select @ftrantype = ftrantype,@finterid = finterid,@fisprompt = case when isnull(FHeadSelfI0245,0) = 1 then 1 else 0 end,@fsupplyid = fsupplyid,@fstatus = fstatus
from inserted
from inserted
--采购专用发票,未审核,
if @ftrantype <> 75 or @fstatus = 1 or @fisprompt = 0 goto ext
if @ftrantype <> 75 or @fstatus = 1 or @fisprompt = 0 goto ext
select @fleftamountfor = isnull(sum(famountfor),0)
from t_voucher a,t_voucherentry b,t_account c,t_itemdetailv d
where a.fvoucherid = b.fvoucherid and b.faccountid = c.faccountid and b.fdetailid = d.fdetailid
and d.fitemclassid = 8 and c.fnumber= '7001' and b.fdc = 0
and d.fitemid = @fsupplyid
from t_voucher a,t_voucherentry b,t_account c,t_itemdetailv d
where a.fvoucherid = b.fvoucherid and b.faccountid = c.faccountid and b.fdetailid = d.fdetailid
and d.fitemclassid = 8 and c.fnumber= '7001' and b.fdc = 0
and d.fitemid = @fsupplyid
select @fdiffamount = sum((b.fauxtaxprice - c. fauxtaxprice) * b.fqty * a.fexchangerate)
from icpurchase a
inner join icpurchaseentry b on a.finterid = b.finterid
left join poorderentry c on b.forderinterid = c.finterid and b.forderentryid = c.fentryid
where a.finterid = @finterid
from icpurchase a
inner join icpurchaseentry b on a.finterid = b.finterid
left join poorderentry c on b.forderinterid = c.finterid and b.forderentryid = c.fentryid
where a.finterid = @finterid
if @fleftamountfor < @fdiffamount
begin
declare @errmsg varchar(200)
select @errmsg = '已经确认的差额为:' + convert(varchar(20),@fleftamountfor) + char(10) +
'本张发票的差额为:' + convert(varchar(20),@fdiffamount) + char(10)
raiserror (@errmsg,16,1)
end
ext:
/*
alter table icpurchase disable trigger icpurchase_jade01
alter table icpurchase enable trigger icpurchase_jade01
*/
本文转自redking51CTO博客,原文链接:
http://blog.51cto.com/redking/25136
,如需转载请自行联系原作者