支持三人台账、库存更正审批与每日人数增量
This commit is contained in:
1 parent
8d9039aacf
commit
f6bdfcf10d
57 files changed
+2536
-564
No files matched your search
@@ -1,12 +1,13 @@
|
||||
'use strict';
|
||||
// 模板只保存表单预设;金额仍用元、重量仍用克,不继承订单或流水身份。
|
||||
(function(root,factory){
|
||||
const api=factory(typeof module==='object'&&module.exports?require('./fee-estimates'):root.FeeEstimates);
|
||||
const api=factory(typeof module==='object'&&module.exports?require('./fee-estimates'):root.FeeEstimates,typeof module==='object'&&module.exports?require('./credit-card-fees'):root.CreditCardFees);
|
||||
if(typeof module==='object'&&module.exports)module.exports=api;else root.OrderTemplates=api;
|
||||
})(typeof globalThis==='object'?globalThis:this,function(Fees){
|
||||
})(typeof globalThis==='object'?globalThis:this,function(Fees,Cards){
|
||||
const products=['足金999','足银999','纯银925'],charges=['编绳','证书','包装','快递','附加费'];
|
||||
const pockets=['','现货','金料','找金','回收旧料','君宝汇'];
|
||||
const accounts=['助理微信','助理支付宝','助理现金','助理信用卡','麦麦微信','麦麦支付宝','麦麦现金','麦麦信用卡'];
|
||||
const accounts=['助理2微信','助理2支付宝','助理2现金','助理2信用卡','助理微信','助理支付宝','助理现金','助理信用卡','麦麦微信','麦麦支付宝','麦麦现金','麦麦信用卡'];
|
||||
const normalizeAccount=account=>Cards?.normalizeAccount?Cards.normalizeAccount(account):(['助理信用卡','助理1信用卡','助理2信用卡','麦麦信用卡'].includes(account)?'麦麦信用卡':account);
|
||||
const cardFee=item=>item?.system==='credit_card'||String(item?.key||'').startsWith('card_fee:');
|
||||
const uuid=/^[a-f0-9-]{36}$/;
|
||||
function object(value,name){if(!value||typeof value!=='object'||Array.isArray(value))throw new Error(name+'格式无效');return value;}
|
||||
@@ -21,7 +22,7 @@
|
||||
const [whole,fraction='']=result.split('.');if(BigInt(whole)*10n**BigInt(places)+BigInt(fraction.padEnd(places,'0'))>100000000000n)throw new Error(name+'超出支持范围');return result;
|
||||
}
|
||||
function count(value,name){const result=string(value,name,12);if(result&&!/^\d+$/.test(result))throw new Error(name+'须为非负整数');if(Number(result)>1000000000)throw new Error(name+'超出支持范围');return result;}
|
||||
function payer(value,fallback='owner'){return pick(value,['owner','assistant',''],'成本付款人',fallback);}
|
||||
function payer(value,fallback='owner'){return pick(value,['owner','assistant','assistant2',''],'成本付款人',fallback);}
|
||||
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')};
|
||||
}
|
||||
@@ -35,7 +36,7 @@
|
||||
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'?'现货':''),
|
||||
payer:pick(line.payer,['owner','assistant'],'货品成本付款人','owner'),pricingMode:unit==='件'?'manual':pick(line.pricingMode,['auto','manual'],'计价方式',line.sale!=null?'manual':'auto'),
|
||||
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,'商品基础金额')};
|
||||
result.name=nameType==='其他'?result.customName:nameType;
|
||||
@@ -73,9 +74,9 @@
|
||||
if(!['shipping','box','certificate','braiding','sticker','other'].includes(old)&&! /^(charge|manual):[a-f0-9-]{36}$/.test(old))throw new Error('模板费用项目无效');
|
||||
if(keys.has(old))throw new Error('模板费用项目不能重复');keys.add(old);
|
||||
const linked=old.startsWith('charge:')?ids.get(old.slice(7)):null;if(old.startsWith('charge:')&&!linked)return null;
|
||||
return {key:linked?'charge:'+linked:old==='shipping'?'shipping':'manual:'+newId(),note:string(fee.note,'费用名称',150),amount:numeric(fee.amount,'实际费用'),payer:pick(fee.payer,['owner','assistant'],'费用付款人','assistant'),status:'estimated',edited:fee.edited!==false,...(linked?{sourceName:string(fee.sourceName||fee.note,'附加项目名称',40)}:{})};
|
||||
return {key:linked?'charge:'+linked:old==='shipping'?'shipping':'manual:'+newId(),note:string(fee.note,'费用名称',150),amount:numeric(fee.amount,'实际费用'),payer:pick(fee.payer,['owner','assistant','assistant2'],'费用付款人','assistant'),status:'estimated',edited:fee.edited!==false,...(linked?{sourceName:string(fee.sourceName||fee.note,'附加项目名称',40)}:{})};
|
||||
}).filter(Boolean);
|
||||
const preset={salesperson:string(draft.salesperson,'开单人',30),payment_account:pick(draft.payment_account,accounts,'收款账户','助理微信'),credit_card_fee_payer:pick(draft.credit_card_fee_payer,['owner','assistant'],'信用卡手续费付款人','owner'),discount:numeric(draft.discount??'0','整单优惠'),note:string(draft.note,'客户单备注',240),fee_auto_initialized:true,lines,fee_items:Fees.sync(items,lines)};
|
||||
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}={}){
|
||||
|
||||
Reference in new issue
Block a user