服务热线:

400-665-0027

知识资讯
联系我们

电话:400-665-0027


您当前位置:首页 > 知识资讯  > 知识学习 > 正文知识学习
如何在K3WISE版本中,如何实现发票号码重复的提示
服务热线:400-665-0027 新购有特价、金蝶老客户升级金蝶云产品可以享受5折优惠,送手机、送话费,好礼不断!

如何在K3WISE版本中,如何实现当发票号码已经在系统中存在时,新做的发票如果发票号码与之前系统中发票号码一样时,新做的发票不允许保存。

可以通过以下代码实现此功能。



1 将所有发票号码导入一个库中(要注意发票号码是在单据头还是单据体)


create table ffphm

(fdjlx    varchar(200),

fdjbh    varchar(200),

fdjhm    varchar(200))


insert into ffphm

(fdjlx,fdhbh,fdjhm)

select '采购发票',t1.fbillno,t2.ftext from icpurchase t1, icpurchaseentry t2

where t1.finterid=t2.finterid

group by t1.fbillno,t2.ftext


insert into ffphm

(fdjlx,fdjbh,fdjhm)

select '其他应付单',t2.fnumber,t1.ftext from t_rp_arpbillentry t1, t_rp_arpbill t2

where t1.fbillid=t2.fbillid

group by t1.ftext,t2.fnumber


insert into ffphm

(fdjlx,fdhbh,fdjhm)

select '差旅费报销单',t1.fbillno,t2.ftext from t_BM_TravelExp t1, t_BM_TravelExpentry t2

where t1.fid=t2.fid

group by t1.fbillno, t2.ftext


insert into ffphm

(fdjlx,fdhbh,fdjhm)

select '费用报销单',t1.fbillno,t2.ftext from t_BM_ExpReimbursement t1,t_BM_ExpReimbursemententry t2

where t1.fid=t2.fid

group by t1.fbillno, t2.ftext





---2 执行下面的控制程序


----其他应付单

create trigger [dbo].[easy_210602_fphm] on [dbo].[t_RP_ARPBill]

for update,delete,insert

as



insert into ffphm

(fdjlx,fdjbh,fdjhm)

select '其他应付单',t1.fnumber,t2.ftext from t_rp_arpbill t1, t_rp_arpbillentry t2

where t1.fbillid=t2.fbillid and t1.fnumber not in (select fdjbh from ffphm)



if exists(select fdjhm from ffphm where fdjhm<>'' group by fdjhm having count(*)>='1')


begin raiserror ('发票号码重复',18,10)


end




----采购发票

create trigger [dbo].[easy_210602_fphm1] on [dbo].[icpurchase]

for update,delete,insert

as



insert into ffphm

(fdjlx,fdjbh,fdjhm)

select '采购发票',t1.fbillno,t2.ftext from icpurchase  t1, icpurchaseentry t2

where t1.finterid=t2.finterid and t1.fbillno not in (select fdjbh from ffphm)



if exists(select fdjhm from ffphm where fdjhm<>'' group by fdjhm having count(*)>='1')


begin raiserror ('发票号码重复',18,10)


end




----费用报销

create trigger [dbo].[easy_210602_fphm1] on [dbo].[icpurchase]

for update,delete,insert

as



insert into ffphm

(fdjlx,fdjbh,fdjhm)

select '费用报销',t1.fbillno,t2.ftext from t_BM_ExpReimbursement  t1, t_BM_ExpReimbursemententry t2

where t1.fid=t2.fid and t1.fbillno not in (select fdjbh from ffphm)



if exists(select fdjhm from ffphm where fdjhm<>'' group by fdjhm having count(*)>='1')


begin raiserror ('发票号码重复',18,10)


end



----差旅费报销

create trigger [dbo].[easy_210602_fphm1] on [dbo].[icpurchase]

for update,delete,insert

as



insert into ffphm

(fdjlx,fdjbh,fdjhm)

select '差旅费报销',t1.fbillno,t2.ftext from t_BM_TravelExp  t1, t_BM_TravelExpentry t2

where t1.fid=t2.fid and t1.fbillno not in (select fdjbh from ffphm)



if exists(select fdjhm from ffphm where fdjhm<>'' group by fdjhm having count(*)>='1')


begin raiserror ('发票号码重复',18,10)


end