完善订单审批、每日对账与信用卡手续费

加入助理订单变更复核、收款人汇总、每日报销和应转金额;优化库存筛选、订单明细与连续浏览。开单身份必填,信用卡手续费按实收4‰自动计算并默认由麦麦承担,打印优惠显示在人民币大写旁。

验证:484项测试通过;独立HTTP与浏览器覆盖普通订单、锁价、修改审批、断线恢复和打印隔离。旧报表兼容,本机升级原29表295行数据保持一致。
This commit is contained in:
summer committed 2026-10-23 09:49:36 +08:00
1 parent 27a11e9b35
commit a506fb1228
68 files changed
+3591 -259

No files matched your search

+7 -7
View File
@@ -70,13 +70,13 @@ test('费用更正后的有效支出只复制一次,冲回与旧模板不回
assert.equal(draft.fee_items.find(item=>item.note==='证书').amount,'0.00');assert.equal(draft.fee_items.find(item=>item.note==='包装').amount,'0.00');
assert.equal(draft.fee_items.find(item=>item.note==='更正补记:再次核对').amount,'9.25');assert.ok(!draft.fee_items.some(item=>item.note.startsWith('更正冲回:')));
assert.ok(!draft.fee_items.some(item=>['8.80','5.25','4.50'].includes(item.amount)));assert.deepEqual(Fees.sync(draft.fee_items,draft.lines),draft.fee_items);
const saved=l.detail(issue(draft));assert.equal(saved.directCost,current.directCost);assert.deepEqual(l.detail(id),current);
draft.customer='复制新客户';const saved=l.detail(issue(draft));assert.equal(saved.directCost,current.directCost);assert.deepEqual(l.detail(id),current);
});
test('同名同额多项费用及额外费用逐笔保留,150字额外费用名称可以再次保存',t=>{
const {l,issue,act}=fixture(t),input=rich();input.fee_items.push({key:'manual:'+randomUUID(),note:'手工处理',amount:'18.80',payer:'assistant',status:'estimated'});
const id=issue(input);act(id,'expense',{amount:'18.80',payer:'assistant',note:'手工处理'});act(id,'expense',{amount:'3.20',payer:'owner',note:'长'.repeat(150)});
const source=l.detail(id),draft=Copy.fromOrder(source,{today:NEXT});assert.equal(draft.fee_items.filter(item=>item.note==='手工处理').length,3);assert.equal(draft.fee_items.find(item=>item.note.length===150).amount,'3.20');
assert.equal(l.detail(issue(draft)).directCost,source.directCost);
draft.customer='复制新客户';assert.equal(l.detail(issue(draft)).directCost,source.directCost);
});
test('旧单没有费用模板时采用实际支出,已完成且没有花费的附加项明确保留0',t=>{
const {l,issue,act}=fixture(t),id=issue(rich());l.run('UPDATE orders SET fee_items=? WHERE id=?','[]',id);const source=l.detail(id),draft=Copy.fromOrder(source,{today:NEXT});
@@ -90,26 +90,26 @@ test('未完成旧草稿的空费用、手填0、付款人和原总成本保持
const id=run(input,()=>l.saveOrder(input,owner)).id,source=l.detail(id),draft=Copy.fromOrder(source,{today:NEXT});
assert.equal(draft.fee_items.find(item=>item.note==='证书').amount,'');assert.equal(draft.fee_items.find(item=>item.note==='包装').amount,'0.00');assert.equal(draft.lines[0].cost,'30.00');assert.equal(draft.lines[0].payer,'assistant');
});
function pooled(poolId){return {date:D,customer:'日购料原单',payment_account:'助理微信',discount:'0',fee_items:[],lines:[{name:'足金999',unit:'g',quantity:'2',pocket:'',payer:'owner',pricingMode:'auto',goldPrice:'980',laborRate:'20',laborMode:'gram',pieces:'1',costParts:{material:'',labor:'20',accessories:'0',other:'0'},costMaterial:{mode:'pool',poolId},costLabor:{mode:'gram',rate:'10'},costPayers:{material:'owner',labor:'assistant'}}]};}
function pooled(poolId){return {date:D,customer:'日购料原单',salesperson:'合成开单人',payment_account:'助理微信',discount:'0',fee_items:[],lines:[{name:'足金999',unit:'g',quantity:'2',pocket:'',payer:'owner',pricingMode:'auto',goldPrice:'980',laborRate:'20',laborMode:'gram',pieces:'1',costParts:{material:'',labor:'20',accessories:'0',other:'0'},costMaterial:{mode:'pool',poolId},costLabor:{mode:'gram',rate:'10'},costPayers:{material:'owner',labor:'assistant'}}]};}
test('原当日池随新日期切换并重新核算,不继承耗用分摊或旧快照,不提前占料',t=>{
const {l,issue,buy}=fixture(t);buy(D,'9000','owner');buy(NEXT,'9500','assistant');const id=issue(pooled(D)),source=l.detail(id),before=snapshot(l),draft=Copy.fromOrder(source,{today:NEXT}),line=draft.lines[0];
assert.equal(snapshot(l),before);assert.deepEqual(line.costMaterial,{mode:'pool',poolId:NEXT});assert.equal(line.materialPoolDraft.defaultDate,true);assert.equal(line.costParts.material,'');assert.ok(!Object.hasOwn(line,'materialPool'));assert.ok(!Object.hasOwn(line,'materialAllocations'));
assert.equal(Calc.purchaseCosts(line).parts.material,null);line.quantity='3';const result=l.detail(issue(draft));assert.equal(result.lines[0].costParts.material,285000);assert.deepEqual(result.lines[0].materialPool.allocations,[{payer:'assistant',amount:285000}]);
assert.equal(Calc.purchaseCosts(line).parts.material,null);line.quantity='3';draft.customer='复制新客户';const result=l.detail(issue(draft));assert.equal(result.lines[0].costParts.material,285000);assert.deepEqual(result.lines[0].materialPool.allocations,[{payer:'assistant',amount:285000}]);
assert.equal(l.materialPoolDetail(D).usedMg,2000);assert.equal(l.materialPoolDetail(NEXT).usedMg,3000);assert.deepEqual(l.detail(id),source);
});
test('原来手选以前日期的池保留选择,使用当前池余额,新耗用只新增一份',t=>{
const {l,issue,buy}=fixture(t),old='2026-10-16';buy(old,'8800');const id=issue(pooled(old)),source=l.detail(id),before=snapshot(l),draft=Copy.fromOrder(source,{today:NEXT});
assert.equal(snapshot(l),before);assert.equal(draft.lines[0].costMaterial.poolId,old);assert.equal(draft.lines[0].materialPoolDraft.defaultDate,false);draft.lines[0].quantity='3';
const result=l.detail(issue(draft));assert.equal(result.lines[0].costParts.material,264000);assert.equal(l.materialPoolDetail(old).usedMg,5000);assert.equal(l.rows('SELECT * FROM material_pool_usages').length,2);assert.equal(l.rows('SELECT * FROM material_purchases').length,1);
draft.customer='复制新客户';const result=l.detail(issue(draft));assert.equal(result.lines[0].costParts.material,264000);assert.equal(l.materialPoolDetail(old).usedMg,5000);assert.equal(l.rows('SELECT * FROM material_pool_usages').length,2);assert.equal(l.rows('SELECT * FROM material_purchases').length,1);
});
test('锁价交付只复制普通报价,清掉旧关联与锁价备注,必须补料费及付款人,保存不再造锁价入库',t=>{
const {l,run,issue}=fixture(t),creation={date:D,customer:'原锁价客户',note:'原客户备注',line:{name:'足金999',quantity:'2',goldPrice:'980',laborRate:'20',laborMode:'gram',pieces:'1',charges:[]},discount:'0',payment:{amount:'2000',account:'助理微信',verified:true},material:{rate:'900',payer:'owner',verified:true}};
const {l,run,issue}=fixture(t),creation={date:D,customer:'原锁价客户',salesperson:'合成开单人',note:'原客户备注',line:{name:'足金999',quantity:'2',goldPrice:'980',laborRate:'20',laborMode:'gram',pieces:'1',charges:[]},discount:'0',payment:{amount:'2000',account:'助理微信',verified:true},material:{rate:'900',payer:'owner',verified:true}};
const lock=run(creation,()=>l.createPriceLock(creation,owner));
const delivery={date:NEXT,revision:1,verified:true,line:{quantity:'2',laborRate:'20',laborMode:'gram',pieces:'1',charges:[],payer:'owner',costParts:{labor:'20',accessories:'0',other:'0'},costLabor:{mode:'total'},costPayers:{material:'owner',labor:'assistant'}},discount:'0',inventory:{pocket:'现货',original:'receive'},fee_items:[]};
const result=run(delivery,()=>l.deliverPriceLock(lock.id,delivery,owner)),original=l.detail(result.id),before=snapshot(l),draft=Copy.fromOrder(original,{today:NEXT});
assert.equal(snapshot(l),before);assert.equal(draft.copy_kind,'price-lock');assert.equal(draft.note,'原客户备注');assert.equal(draft.lines[0].goldPrice,'980.00');assert.equal(draft.lines[0].costParts.material,'');assert.equal(draft.lines[0].costPayers.material,'');assert.ok(!Object.hasOwn(draft,'price_lock_id'));assert.ok(!Object.hasOwn(draft.lines[0],'materialAllocations'));
assert.throws(()=>issue(draft),/付款人|料费成本/);assert.equal(snapshot(l),before);
draft.lines[0].costParts.material='1700';draft.lines[0].costPayers.material='assistant';draft.lines[0].pocket='';const copy=l.detail(issue(draft));
draft.customer='复制新客户';draft.lines[0].costParts.material='1700';draft.lines[0].costPayers.material='assistant';draft.lines[0].pocket='';const copy=l.detail(issue(draft));
assert.ok(!copy.price_lock_id);assert.equal(l.rows('SELECT * FROM price_locks').length,1);assert.equal(l.rows('SELECT * FROM price_lock_events').length,2);assert.equal(l.rows('SELECT * FROM movements').length,2);assert.deepEqual(l.detail(original.id),original);
});
test('空白自动草稿无需覆盖提示;填写0、添加项目、改收款人或已有复制草稿都须保护',()=>{