增加货盘新增改名与启停管理,保留历史库存关联
This commit is contained in:
1 parent
337b2a709f
commit
ba15795f0a
29 files changed
+748
-218
No files matched your search
@@ -26,7 +26,7 @@
|
||||
function manualMaterial(value={},fallback={}){
|
||||
object(value,'备用料费');return {mode:pick(value.mode,['gram','total'],'备用料费方式',fallback.mode||'gram'),rate:numeric(value.rate??fallback.rate,'备用进货料价'),total:numeric(value.total??fallback.total,'备用料费合计'),originalTotal:'',payer:payer(value.payer,fallback.payer??'owner')};
|
||||
}
|
||||
function fromDraft(draft,{newId=()=>globalThis.crypto.randomUUID()}={}){
|
||||
function fromDraft(draft,{newId=()=>globalThis.crypto.randomUUID(),pocketKeys=pockets}={}){
|
||||
object(draft,'开单预设');
|
||||
if(!Array.isArray(draft.lines)||!draft.lines.length||draft.lines.length>60)throw new Error('模板需要1~60行商品');
|
||||
const ids=new Map(),seen=new Set();
|
||||
@@ -35,7 +35,7 @@
|
||||
const name=string(line.name,'商品名称',60),nameType=pick(line.nameType,[...products,'其他'],'商品名称',products.includes(name)?name:name?'其他':'足金999');
|
||||
const result={nameType,customName:string(line.customName??(nameType==='其他'?name:''),'其他商品名称',60),unit,
|
||||
quantity:unit==='g'?numeric(line.quantity,'商品克重',3):count(line.quantity,'商品件数'),
|
||||
pocket:unit==='件'||['足银999','纯银925'].includes(nameType)?'':pick(line.pocket,pockets,'出库货盘',nameType==='足金999'?'现货':''),
|
||||
pocket:unit==='件'||['足银999','纯银925'].includes(nameType)?'':pick(line.pocket,['',...pocketKeys],'出库货盘',nameType==='足金999'?'现货':''),
|
||||
payer:pick(line.payer,['owner','assistant','assistant2'],'货品成本付款人','owner'),pricingMode:unit==='件'?'manual':pick(line.pricingMode,['auto','manual'],'计价方式',line.sale!=null?'manual':'auto'),
|
||||
goldPrice:numeric(line.goldPrice,'销售金价'),laborMode:pick(line.laborMode,['gram','piece'],'销售工费方式','gram'),laborRate:numeric(line.laborRate,'销售工费'),pieces:count(line.pieces??'1','计工费件数'),
|
||||
priceNote:string(line.priceNote,'销售单价说明',100),sale:numeric(line.sale,'本行销售额'),baseSale:numeric(line.baseSale??line.sale,'商品基础金额')};
|
||||
@@ -79,9 +79,9 @@
|
||||
const preset={salesperson:string(draft.salesperson,'开单人',30),payment_account:pick(normalizeAccount(draft.payment_account),accounts,'收款账户','助理微信'),credit_card_fee_payer:pick(draft.credit_card_fee_payer,['owner','assistant','assistant2'],'信用卡手续费付款人','owner'),discount:numeric(draft.discount??'0','整单优惠'),note:string(draft.note,'客户单备注',240),fee_auto_initialized:true,lines,fee_items:Fees.sync(items,lines)};
|
||||
if(JSON.stringify(preset).length>240000)throw new Error('模板内容过大,请减少商品或附加项目');return preset;
|
||||
}
|
||||
function apply(preset,{today,salesperson='',newId}={}){
|
||||
function apply(preset,{today,salesperson='',newId,pocketKeys}={}){
|
||||
if(!/^\d{4}-\d{2}-\d{2}$/.test(today||'')||!Number.isFinite(Date.parse(today+'T00:00:00Z'))||new Date(today+'T00:00:00Z').toISOString().slice(0,10)!==today)throw new Error('未取得有效系统日期,请刷新后再套用模板。');
|
||||
const draft=fromDraft(preset,{newId});
|
||||
const draft=fromDraft(preset,{newId,pocketKeys});
|
||||
for(const line of draft.lines)if(line.costMaterial?.mode==='pool'){line.costMaterial={mode:'pool',poolId:today};line.materialPoolDraft={...line.materialPoolDraft,poolId:today,defaultDate:true};}
|
||||
return {...draft,date:today,fees_date:today,customer:'',salesperson:draft.salesperson||salesperson,rounding_mode:'yuan'};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user