壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4269|回复: 2

[二次开发] AP 暂挂过帐发票的删除(SQL)

[复制链接]
发表于 2005/7/30 12:15:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
现象:预付款发票有税码,但把税行删掉了,做费用发票与预付款核销时,暂挂。

解决方法
将有问题的发票彻底删掉重做。
一。用APPS将预付款发票的税码删除,重新审批。

二。对标准发票操作如下:
从FORM可知发票的INVOICE_ID='25494',因已有部分行入帐

1 删除会计行
SELECT * FROM AP_AE_LINES_ALL AAL WHERE AAL.REFERENCE2='25494'
DELETE FROM AP_AE_LINES_ALL AAL WHERE AAL.REFERENCE2='25494'
DESC AP_AE_LINES_ALL AAL

2?删除会计行头
SELECT * FROM AP_AE_HEADERS_ALL AAH WHERE AAH.AE_HEADER_ID IN (36406,36407)
DESC AP_AE_HEADERS_ALL

3 删除发票事件表
SELECT * FROM AP_ACCOUNTING_EVENTS_ALL AEA WHERE AEA.SOURCE_ID='25494'
DESC AP_ACCOUNTING_EVENTS_ALL

4 删除发票分配行
SELECT * FROM AP_INVOICE_DISTRIBUTIONS_ALL APDA WHERE APDA.INVOICE_ID='25494'
DESC AP_INVOICE_DISTRIBUTIONS_ALL

5 删除发票头
SELECT * FROM AP_INVOICES_ALL AI WHERE AI.INVOICE_ID='25494'
DESC AP_INVOICES_ALL

6.删除发票暂挂表
SELECT * FROM AP_HOLDS_ALL AH WHERE AH.INVOICE_ID ='25494'
DESC AP_HOLDS_ALL
发表于 2013/1/5 14:03:03 | 显示全部楼层
呵呵 我之前做过几个AP 删除的SQL 一直删除到 总帐日记账相关SQL分享给出来

--发票
create table bak.AP_INVOICES_ALL_110707 as
select * from AP_INVOICES_ALL aia
where aia.invoice_id in (90490,90333)
--发票行
create table bak.AP_INVOICE_LINES_110707 as
select * from AP_INVOICE_LINES_ALL ala
where ala.invoice_id in (90490,90333);
--分配
create table bak.Ap_Invoice_Dist_110707 as
select *
  from Ap_Invoice_Distributions_All aid
where aid.invoice_id = 90490;
--计划付款
create table bak.AP_PAYMENT_SCHEDULES_110707 as
select * from AP_PAYMENT_SCHEDULES_ALL p
where p.invoice_id in (90490,90333);
--暂挂
create table bak.AP_HOLDS_110707 as
select * from AP_HOLDS_ALL h
where h.invoice_id = 90490;
--付款行
create table bak.AP_INVOICE_PAYMENTS_110707 as
select * from AP_INVOICE_PAYMENTS_all aip
where aip.invoice_id = 90333;
--付款头
create table bak.AP_CHECKS_110707 as
select * from AP_CHECKS_ALL ac where ac.check_id = 64863;
--分录事件
create table bak.xla_trans_entities_110707 as
select *
  from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (90490, 90333)
   and xte.security_id_int_1 = 81
   and application_id = 200;
insert into bak.xla_trans_entities_110707
select  * from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (64863)
   and xte.security_id_int_1 = 81
   and application_id = 200;
   
--分录头
create table bak.xla_ae_headers_110707 as
select *
  from xla.xla_ae_headers xah
where xah.entity_id in (9556541, 9554363);
insert into bak.xla_ae_headers_110707
select * from xla.xla_ae_headers xah where xah.entity_id in (9554366);

--会计事件
create table bak.xla_events_110707 as
select *
  from xla_events xe
where xe.event_id in
       (select event_id
          from xla.xla_ae_headers xah
         where xah.entity_id in (9556541, 9554363));
insert into bak.xla_events_110707
select * from xla_events xe
where xe.event_id in
       (select event_id
          from bak.xla_ae_headers_110707 xah
         where xah.entity_id in (9554366));
--分录行
create table bak.xla_ae_lines_110707 as
select *
  from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824);

insert into bak.xla_ae_lines_110707
select *
  from xla.xla_ae_lines xal
where xal.ae_header_id=14101322;

--日记账导入参考
create table bak.gl_import_references_110707 as
select *
  from gl.gl_import_references gr
where gr.gl_sl_link_id in
       (select gl_sl_link_id
          from xla.xla_ae_lines xal
         where xal.ae_header_id in (14101317, 14103708, 14299824));
insert into bak.gl_import_references_110707
select *
  from gl.gl_import_references gr
where gr.gl_sl_link_id in (25174221,25174222);  
--日记账头
create table bak.gl_je_headers_110707 as
select *
  from gl_je_headers gjh
where gjh.je_header_id in
       (select je_header_id
          from gl.gl_import_references gr
         where gr.gl_sl_link_id in
               (select gl_sl_link_id
                  from xla.xla_ae_lines xal
                 where xal.ae_header_id in (14101317, 14103708, 14299824)));
insert into bak.gl_je_headers_110707
select * from gl_je_headers gjh
where gjh.je_header_id =5553330;

--日记账行
create table bak.gl_je_lines_110707 as
select *
  from gl_je_lines gjl
where gjl.je_header_id in
       (select je_header_id
          from gl.gl_import_references gr
         where gr.gl_sl_link_id in
               (select gl_sl_link_id
                  from xla.xla_ae_lines xal
                 where xal.ae_header_id in (14101317, 14103708, 14299824)));
insert into bak.gl_je_lines_110707
select *
  from gl_je_lines gjl
where gjl.je_header_id=5553330;
--日记帐批   
create table bak.gl_je_batches_110707 as
select *
  from gl_je_batches gjb
where gjb.je_batch_id in
       (select je_batch_id
          from gl.gl_import_references gr
         where gr.gl_sl_link_id in
               (select gl_sl_link_id
                  from xla.xla_ae_lines xal
                 where xal.ae_header_id in (14101317, 14103708, 14299824)));
                 

--发票
delete from AP_INVOICES_ALL aia
where aia.invoice_id in (90490,90333)
--发票行
delete from AP_INVOICE_LINES_ALL ala
where ala.invoice_id in (90490,90333);
--分配
delete from Ap_Invoice_Distributions_All aid
where aid.invoice_id = 90490;
--计划付款
delete from AP_PAYMENT_SCHEDULES_ALL p
where p.invoice_id in (90490,90333);
--暂挂
delete from AP_HOLDS_ALL h
where h.invoice_id = 90490;
--付款行
delete from AP_INVOICE_PAYMENTS_all aip
where aip.invoice_id = 90333;
--付款头
delete from AP_CHECKS_ALL ac where ac.check_id = 64863;
--分录事件
delete from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (90490, 90333)
   and xte.security_id_int_1 = 81
   and application_id = 200;
delete from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (64863)
   and xte.security_id_int_1 = 81
   and application_id = 200;
   
--分录头
delete from xla.xla_ae_headers xah
where xah.entity_id in (9556541, 9554363);

delete from xla.xla_ae_headers xah where xah.entity_id in (9554366);
--会计事件
delete from xla_events xe
where xe.event_id in
       (select event_id
          from bak.xla_ae_headers_110707 xah
         where xah.entity_id in (9556541, 9554363));
delete from xla_events xe
where xe.event_id in
       (select event_id
          from bak.xla_ae_headers_110707 xah
         where xah.entity_id in (9554366));         
--分录行
delete from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824);

delete from xla.xla_ae_lines xal
where xal.ae_header_id=14101322;
--日记账导入参考
delete from gl.gl_import_references gr
where gr.gl_sl_link_id in
       (select gl_sl_link_id
          from bak.xla_ae_lines_110707 xal
         where xal.ae_header_id in (14101317, 14103708, 14299824));
delete from gl.gl_import_references gr
where gr.gl_sl_link_id in (25174221,25174222);  
--日记账头
delete from gl_je_headers gjh
where gjh.je_header_id in
       (select je_header_id
          from bak.gl_import_references_110707 gr
         where gr.gl_sl_link_id in
               (select gl_sl_link_id
                  from bak.xla_ae_lines_110707 xal
                 where xal.ae_header_id in (14101317, 14103708, 14299824)));
delete from gl_je_headers gjh
where gjh.je_header_id =5553330;
--日记账行
delete from gl_je_lines gjl
where gjl.je_header_id in
       (select je_header_id
          from bak.gl_import_references_110707 gr
         where gr.gl_sl_link_id in
               (select gl_sl_link_id
                  from bak.xla_ae_lines_110707 xal
                 where xal.ae_header_id in (14101317, 14103708, 14299824)));
delete from gl_je_lines gjl
where gjl.je_header_id=5553330;

--日记帐批   
delete from gl_je_batches gjb where gjb.je_batch_id=5007897
select rowid,gjb.*
  from gl_je_batches gjb
where gjb.je_batch_id in
       (select je_batch_id
          from bak.gl_import_references_110707 gr
         where gr.gl_sl_link_id in
               (select gl_sl_link_id
                  from bak.xla_ae_lines_110707 xal
                 where xal.ae_header_id in (14101317, 14103708, 14299824)));
                 
                 
                 

评分

参与人数 1努力值 +50 收起 理由
纵横四海 + 50 赞一个!

查看全部评分

发表于 2013/6/25 12:44:45 | 显示全部楼层
学习了,删除的很完整啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 15:39 , Processed in 0.019018 second(s), 22 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表