置换余料支持寄存暂不结算及修改取消联动
This commit is contained in:
1 parent
1f1e6dd402
commit
b070da1e3d
9 files changed
+110
-36
No files matched your search
@@ -9,7 +9,7 @@ function quote(l,input,actor,env,options,R){
|
||||
const parts=items.map((item,i)=>{
|
||||
if(!item||typeof item!=='object'||!item.exchange||item.exchange.items||item.exchange.products||(item.old_source!=='deposit'&&(!Array.isArray(item.old_lines)||item.old_lines.length!==1)))env.fail('第'+(i+1)+'件置换资料无效');
|
||||
// 内部单件预览不产生收付款,信用卡手续费只按整单实收计算。
|
||||
return R.quote(l,{...input,...item,old_source:item.old_source,deposit_id:item.deposit_id,deposit_weight:item.deposit_weight,old_lines:item.old_lines,old_pocket:item.old_pocket??'回收旧料',old_stock_count:item.old_stock_count,buy_rate:item.buy_rate,buy_total:item.buy_total,mode:'exchange',date:input.date,customer:input.customer,salesperson:input.salesperson,member:input.member,note:input.note,payer:input.payer,payment_account:input.payment_account?.endsWith('信用卡')?'麦麦微信':input.payment_account,exchange:{...item.exchange,charges:[],fee_items:[],discount:'0',rounding_mode:'cent'}},actor,env,{...options,creating:false,existingRecovery:options.existingRecovery?.exchangeItems?.[i]??null});
|
||||
return R.quote(l,{...input,...item,old_source:item.old_source,deposit_id:item.deposit_id,deposit_weight:item.deposit_weight,old_lines:item.old_lines,old_pocket:item.old_pocket??'回收旧料',old_stock_count:item.old_stock_count,buy_rate:item.buy_rate,buy_total:item.buy_total,surplus_mode:item.surplus_mode,surplus_memo:item.surplus_memo,mode:'exchange',date:input.date,customer:input.customer,salesperson:input.salesperson,member:input.member,note:input.note,payer:input.payer,payment_account:input.payment_account?.endsWith('信用卡')?'麦麦微信':input.payment_account,exchange:{...item.exchange,charges:[],fee_items:[],discount:'0',rounding_mode:'cent'}},actor,env,{...options,creating:false,existingRecovery:options.existingRecovery?.exchangeItems?.[i]??null});
|
||||
});
|
||||
if(options.creating&&parts.some(p=>p.laborCost===null||p.differenceMg&&!p.exchange.costMaterial.rate&&p.exchange.costMaterial.mode!=='pool'))env.fail('请逐件补齐进货工费和差重料费');
|
||||
// 必须一次试算所有用料,避免多件分别试算时重复使用同一笔剩料。
|
||||
@@ -20,7 +20,8 @@ function quote(l,input,actor,env,options,R){
|
||||
if(probes[i].materialPool?.materialSources)p.exchange.costMaterial.materialSources=probes[i].materialPool.materialSources;
|
||||
}
|
||||
const first=parts[0],q={...first,exchangeItems:parts,newProducts:parts.map(p=>({...p.newProduct,laborMode:p.laborMode,laborRate:p.laborRate,laborAmount:p.laborAmount,costLabor:p.exchange.costLabor,laborCost:p.laborCost,laborPayer:p.exchange.costPayers.labor})),old_lines:parts.flatMap(p=>p.old_lines),payment_account:input.payment_account??first.payment_account};
|
||||
delete q.customerDeposit;
|
||||
delete q.customerDeposit;delete q.surplusMode;delete q.surplusMemo;
|
||||
if(parts.some(p=>p.depositMg))q.depositMg=parts.reduce((n,p)=>n+(p.depositMg||0),0);else delete q.depositMg;
|
||||
for(const key of ['oldMg','newMg','matchedMg','differenceMg','surplusMg','depreciationMg','goldAmount','laborAmount','depreciationAmount','purchaseMg','purchaseAmount','calculatedPurchaseAmount'])q[key]=sum(parts,key);
|
||||
for(const key of ['materialCost','laborCost','goodsCost'])q[key]=parts.some(p=>p[key]===null)?null:sum(parts,key);
|
||||
q.charges=Calc.charges(input.exchange.charges??[]).items;if(q.charges.some(p=>p.amount===null))env.fail('请补齐其他收费');q.chargesAmount=sum(q.charges,'amount');
|
||||
@@ -38,5 +39,5 @@ function quote(l,input,actor,env,options,R){
|
||||
require('./customer-materials').validate(l,q,env,{orderId:options.orderId});
|
||||
return q;
|
||||
}
|
||||
function publicItems(q){const fields=['old_lines','oldMg','newMg','matchedMg','differenceMg','surplusMg','goldRate','laborRate','laborMode','depreciationMg','depreciationRate','buyRate','goldAmount','laborAmount','depreciationAmount','calculatedPurchaseAmount','purchaseAmount'];return q.exchangeItems.map(p=>({...Object.fromEntries(fields.map(k=>[k,p[k]])),newProduct:{name:p.newProduct.name,quantity:p.newMg}}));}
|
||||
function publicItems(q){const fields=['old_lines','oldMg','newMg','matchedMg','differenceMg','surplusMg','depositMg','surplusMode','goldRate','laborRate','laborMode','depreciationMg','depreciationRate','buyRate','goldAmount','laborAmount','depreciationAmount','calculatedPurchaseAmount','purchaseAmount'];return q.exchangeItems.map(p=>({...Object.fromEntries(fields.map(k=>[k,p[k]])),newProduct:{name:p.newProduct.name,quantity:p.newMg}}));}
|
||||
module.exports={quote,publicItems};
|
||||
Reference in new issue
Block a user