增加货盘新增改名与启停管理,保留历史库存关联

This commit is contained in:
summer committed 2026-11-08 03:30:58 +08:00
1 parent 337b2a709f
commit ba15795f0a
29 files changed
+748 -218

No files matched your search

+3 -2
View File
@@ -44,8 +44,9 @@ function orderTotal(subtotal,discount,mode,env){
if(subtotal===discount)return {total:0,rounding_adjustment:0};
return Calc.orderTotal([subtotal],discount,mode);
}
function quote(ledger,input,actor,env,{creating=false,orderId=null}={}){
function quote(ledger,input,actor,env,{creating=false,orderId=null,existingRecovery=null}={}){
active(actor,env);if(!input||typeof input!=='object'||Array.isArray(input))env.fail('回收/置换记录格式无效');
if(!existingRecovery&&!ledger.pocket('回收旧料')?.active)env.fail('回收旧料货盘已停用,请先启用后再登记新的回收或置换');
const mode=env.pick(input.mode,['direct','exchange'],'回收方式'),date=env.day(input.date||env.today()),member=ledger.selectedMember(input,actor);
const old_lines=normalizeOld(input.old_lines,env),oldMg=safe(sum(old_lines,'foldedMg'),env,'旧料折后总重量');
const customer=creating?product(input.customer,'客户称呼/代号',60,env):env.text(input.customer,'客户称呼/代号',60,true);
@@ -59,7 +60,7 @@ function quote(ledger,input,actor,env,{creating=false,orderId=null}={}){
if(mode==='exchange'){
const e=input.exchange;if(!e||typeof e!=='object'||Array.isArray(e))env.fail('请填写换出的新货');
const newMg=env.weight(e.quantity,'新货克重');if(newMg<=0)env.fail('新货克重须大于0');
const newProduct={name:env.text(e.name??'足金','新货名称',60),quantity:newMg,pocket:env.pick(e.pocket,env.pockets,'新货货盘')};
const newProduct={name:env.text(e.name??'足金','新货名称',60),quantity:newMg,pocket:ledger.validatePocket(e.pocket,{original:existingRecovery?.newProduct?.pocket,name:'新货货盘'})};
if(Calc.isSilver(newProduct.name))env.fail('黄金置换暂只支持按克黄金商品');
const matchedMg=Math.min(newMg,oldMg),differenceMg=Math.max(newMg-oldMg,0),surplusMg=Math.max(oldMg-newMg,0);
const goldRate=env.money(e.gold_price??'0','销售金价'),laborRate=env.money(e.labor_rate??'0','销售工费'),laborMode=env.pick(e.labor_mode??'gram',['gram','total'],'销售工费方式');