锁价交付补重支持当日料池,内部备注移至客户名旁
This commit is contained in:
1 parent
ac9073471d
commit
c5883351c1
20 files changed
+196
-66
No files matched your search
@@ -175,11 +175,11 @@ function prepareLines(l,lines,businessDate,env,{orderId=null,member=null}={}){
|
||||
usages.sort((a,b)=>a.created<b.created?-1:a.created>b.created?1:a.fifo_sequence-b.fifo_sequence);for(const u of allocations(pool,usages,l))if(u.preview_index!==undefined)applyLine(lines[u.preview_index],u,pool);return lines;
|
||||
}
|
||||
function reconcile(l,...args){return l.scope(null,()=>reconcileInternal(l,...args),null);}
|
||||
function reconcileInternal(l,date,actor,env,{skipJournalOrder=null,preservePriceLockIds=[]}={}){
|
||||
function reconcileInternal(l,date,actor,env,{skipJournalOrder=null,preservePriceLockIds=[],repriceExtraPriceLockIds=[]}={}){
|
||||
assertDate(l,date,env);ensureDay(l,date,env);const pool=readSources(l,date,env),updates=new Map();
|
||||
const preserved=new Set(preservePriceLockIds);
|
||||
for(const u of allocations(pool,pool.usages.filter(u=>consumed(l,u,date)||u.kind==='priceLock'&&u.reservedPublicSubstitutionMg>0),l)){
|
||||
if(u.kind==='priceLock'){if(!preserved.has(u.price_lock_id))LockPools.update(l,u,pool,actor,env,{skipJournalOrder});continue;}
|
||||
if(u.kind==='priceLock'){if(!preserved.has(u.price_lock_id)||u.line_index<0&&repriceExtraPriceLockIds.includes(u.price_lock_id))LockPools.update(l,u,pool,actor,env,{skipJournalOrder});continue;}
|
||||
if(require('./order-after-sales').read(l,u.order_id))continue;
|
||||
if(!updates.has(u.order_id))updates.set(u.order_id,{order:l.rawOrder(u.order_id),delta:0,changed:false});const v=updates.get(u.order_id),line=v.order.lines[u.line_index];
|
||||
if(!line||line.costMaterial?.poolId!==date)env.fail('滚动料池与商品来源不一致',409);
|
||||
@@ -242,7 +242,7 @@ function repriceLegacyReturns(l,actor,env){
|
||||
}syncReturnSources(l,origin);
|
||||
}
|
||||
}
|
||||
function rebuild(l,actor,env,{fromDate=null,skipJournalOrder=null,preservePriceLockIds=[],ensureDates=[]}={}){return withHistorical(l,()=>{
|
||||
function rebuild(l,actor,env,{fromDate=null,skipJournalOrder=null,preservePriceLockIds=[],repriceExtraPriceLockIds=[],ensureDates=[]}={}){return withHistorical(l,()=>{
|
||||
const previous=l.rollingRebuilding;l.rollingRebuilding=true;try{
|
||||
const c=config(l);if(!c?.enabled)return;
|
||||
if(!fromDate||fromDate<=c.cutover){
|
||||
@@ -257,7 +257,7 @@ function rebuild(l,actor,env,{fromDate=null,skipJournalOrder=null,preservePriceL
|
||||
for(let i=0;i<days.length;i++){
|
||||
const d=days[i];if(fromDate&&d.date<fromDate)continue;
|
||||
if(i){const prev=readPool(l,days[i-1].date,env,{internal:true,live:!fromDate||days[i-1].date>=fromDate});l.run('UPDATE material_rolling_days SET opening=? WHERE date=?',JSON.stringify({mg:prev.remainingMg,amount:prev.remainingCost,allocations:prev.remainingAllocations,pending:prev.status==='pending',...(prev.remainingMaterialGroups?{materialGroups:prev.remainingMaterialGroups}:{})}),d.date);}
|
||||
reconcile(l,d.date,actor,env,{skipJournalOrder,preservePriceLockIds});syncReturnSources(l,d.date);
|
||||
reconcile(l,d.date,actor,env,{skipJournalOrder,preservePriceLockIds,repriceExtraPriceLockIds});syncReturnSources(l,d.date);
|
||||
}
|
||||
}finally{l.rollingRebuilding=previous;}
|
||||
});}
|
||||
|
||||
Reference in new issue
Block a user