置换余料支持寄存暂不结算及修改取消联动
This commit is contained in:
1 parent
1f1e6dd402
commit
b070da1e3d
9 files changed
+110
-36
No files matched your search
@@ -67,6 +67,7 @@ function snapshot(l,row){
|
||||
tables.usages=row.order_id?l.rows('SELECT * FROM material_pool_usages WHERE order_id=? ORDER BY rowid',row.order_id):[];
|
||||
tables.purchase=row.purchase_id?l.one('SELECT * FROM material_purchases WHERE id=?',row.purchase_id):null;
|
||||
tables.purchaseSource=row.purchase_id?l.one('SELECT * FROM recovery_purchase_sources WHERE purchase_id=?',row.purchase_id):null;
|
||||
const customerMaterialOrigin=l.one('SELECT * FROM customer_material_origins WHERE recovery_id=?',row.id);if(customerMaterialOrigin)tables.customerMaterialOrigin=customerMaterialOrigin;
|
||||
const customerMaterialEvents=l.rows('SELECT * FROM customer_material_events WHERE recovery_id=? ORDER BY rowid',row.id);if(customerMaterialEvents.length)tables.customerMaterialEvents=customerMaterialEvents;
|
||||
return {record:row,order,...tables};
|
||||
}
|
||||
@@ -220,6 +221,7 @@ function change(l,id,action,input,actor,env){return atomic(l,()=>{
|
||||
if(!Number.isSafeInteger(input.revision)||input.revision!==row.revision)env.fail('回收记录版本已有变动,请刷新核对',409);if(pending(l,id))env.fail('本单已有待审批更正,请先由麦麦处理',409);
|
||||
if(input.verified!==true)env.fail('请核实关联收付、购料和库存后确认');const reason=env.text(input.reason,'回收更正原因',200),after=action==='cancel'?null:normalized(l,row,input,actor,env),date=after?.date??env.day(input.date??env.today());
|
||||
verifyLegacyCount(l,row,after,input,env);
|
||||
require('./customer-materials').validateSurplus(l,row.id,after,env);
|
||||
const affected=blocking(l,row,after,actor,env);validateInventory(l,movements(l,row,after),env);
|
||||
const before=Recoveries.inputFor(JSON.parse(row.data)),next=after?Recoveries.inputFor(after):null,requestId=randomUUID(),created=env.now(),direct=actor.role==='owner'||row.date===env.today()&&date===env.today();
|
||||
const summary={before:compact(Recoveries.detail(l,id,actor,env)),after:compact(after),affectedDates:[...new Set([row.date,date])].sort(),blockedUsages:affected,...legacyCountInfo(l,row),legacyCountVerified:input.legacyCountVerified===true};
|
||||
|
||||
Reference in new issue
Block a user