移入店铺配置,保留原账号与历史账务口径

This commit is contained in:
summer committed 2026-11-16 23:03:36 +08:00
1 parent 8d68111479
commit 90bdc75150
22 files changed
+535 -62

No files matched your search

+2
View File
@@ -2,6 +2,7 @@
// 回收专用更正:身份不变、原流水保留;旧账冲正与新账补记和审批在同一事务中。
const {randomUUID,createHash}=require('node:crypto');
const Recoveries=require('./recoveries'),Material=require('./material-pools'),Rolling=require('./rolling-material-pools'),TeamFunds=require('./team-funds'),Counts=require('./inventory-counts');
const CreditCardRates=require('./credit-card-rates');
const hash=value=>createHash('sha256').update(JSON.stringify(value)).digest('hex');
const yuan=value=>(value/100).toFixed(2),sum=(rows,key)=>rows.reduce((n,row)=>n+(row[key]??0),0);
function atomic(l,fn){l.db.exec('SAVEPOINT recovery_change');try{const r=fn();l.db.exec('RELEASE recovery_change');return r;}catch(e){l.db.exec('ROLLBACK TO recovery_change');l.db.exec('RELEASE recovery_change');throw e;}}
@@ -143,6 +144,7 @@ function purchaseChange(l,row,after,actor,env){
function appendOrder(l,row,after,actor,reason,env){
if(!row.order_id)return;
const id=row.order_id;
if(after)CreditCardRates.capture(l,'order',id,after.credit_card_rate_permille);
reverseRows(l,id,'payments',actor,reason,env);reverseRows(l,id,'expenses',actor,reason,env);
if(!after){l.run("UPDATE orders SET status='cancelled',fee_items='[]',reviewed_revision=0 WHERE id=?",id);Material.release(l,l.rawOrder(id),row.date,actor,env,{kind:'回收记录取消释放'});return;}
const input=Recoveries.orderInput(after),previous=l.rawOrder(id),lines=l.validateLines(input.lines,previous.lines,after.date,{orderId:id,member:row.member}),line=lines[0];