-----------/*修正了由于删除重复凭证导致的科目余额不平的问题*/---------
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='供应商编号'