【脚本】删除重复建立的应付、现付单及其凭证单据
2018-08-23    易林江
2134 0
由于系统环境异常,极地概率下会导致建立审核外协单、物流单、入库单等单据时,产生多笔应付或现付单及其凭证单据,若有,则可利用此脚本查询并删除重复项
  • 查询指令

    -----------/*查询相关单据跟凭证*/-------------

    SELECT * from SRM_ChargeUpPaymentBill  where code='应付单号'

    SELECT * FROM  FAM_CredenceBill WHERE BUSINESSBILLCODE='应付单号'
    SELECT * FROM  FAM_CredenceBill WHERE CODE='凭证单号'

    SELECT * FROM  FAM_CredenceBillDetail WHERE ParentBillCode='凭证单号'

    SELECT * FROM FAM_AccountHistory  WHERE CODE='科目编号' ORDER BY ACCPID

  • 删除指令

    ---------/*删除重复凭证记录、凭证明细、应付单*/--------------

    DELETE FAM_CredenceBillDetail WHERE ParentBillCode='凭证单号'

    DELETE FAM_CredenceBill WHERE CODE='凭证单号'

    DELETE SRM_ChargeUpPaymentBill  where code='应付单号'

  • 调整科目余额指令

    -----------/*修正了由于删除重复凭证导致的科目余额不平的问题*/---------

    update FAM_AccountHistory  set credit=credit-数值,pebalance=pebalance-数值,credit4year=credit4year-数值 where Code='科目编号' and shopcode='门店编号' and AccPid='会计期间'
    update FAM_AccountHistory  set psbalance=psbalance-数值,pebalance=pebalance-数值,credit4year=credit4year-数值 where Code='科目编号' and shopcode='门店编号' and AccPid='会计期间'
    update FAM_AccountHistory  set psbalance=psbalance-数值,pebalance=pebalance-数值,credit4year=credit4year-数值 where Code='科目编号' and shopcode='门店编号' and AccPid='会计期间'

    ---------------------------------------
    /*查询应付单中已结为0的单据*/
    select * from SRM_ChargeUpPaymentBill where suppliercode='供应商编号' and settledamount=0 order by  sys4createtime

    select * from  SRM_SettlePaymentBillDetail where chargeuppayableaccountcode='科目编号' order by chargeuppaymentbillcode

    select * from SRM_Supplier where code='供应商编号'

    select * from SRM_ChargeUpPaymentBill where exists (select * from  SRM_SettlePaymentBillDetail where chargeuppayableaccountcode='科目编号')

    /*查询结付单和应付单编号一致的供应商并且已结付的单据是哪些*/
    select * from SRM_ChargeUpPaymentBill where code not in (select chargeuppaymentbillcode from  SRM_SettlePaymentBillDetail where chargeuppayableaccountcode='科目编号') and suppliercode='供应商编号' 

    /*更新满足条件的供应商的已结金额为 0*/
    update  SRM_ChargeUpPaymentBill set settledamount=0 where code not in (select chargeuppaymentbillcode from  SRM_SettlePaymentBillDetail where chargeuppayableaccountcode='科目编号') and suppliercode='供应商编号' 

    /*汇总供应商已结金额总数*/
    select sum(settledamount) from SRM_ChargeUpPaymentBill where code not in (select chargeuppaymentbillcode from  SRM_SettlePaymentBillDetail where chargeuppayableaccountcode='科目编号') and suppliercode='供应商编号'

该文章对您有用吗?

非常感谢,您的反馈对我们很有价值!

客服电话

4006757966

微信公众号

联系我们

印特3系演示版

申请

印特5系演示版

申请

免费试用

印特软件标准演示版下载申请

请您填写您的一些信息,提交您的申请后,我们会在两个工作日内进行处理,并回复您一封邮件,内附下载链接,请您注意查收。
*
请输入正确的公司名称
*
请输入正确的联络人员
*
请输入正确的联络电话
提交申请
关闭