内部备注必填并支持快捷标签,置换结算可带入当日加权料价

This commit is contained in:
summer committed 2026-11-30 15:40:40 +08:00
1 parent 6fe7504e52
commit ac9073471d
30 files changed
+194 -72

No files matched your search

@@ -33,7 +33,7 @@ test('旧6账户或helper未加载时不开放卡选项,信用卡统一锁定
const h=harness();assert.match(h.run('accountFields("麦麦信用卡")'),/<option value="信用卡" selected>/);
h.run('state.accounts=state.accounts.filter(account=>!account.endsWith("信用卡"))');assert.doesNotMatch(h.run('accountFields()'),/<option value="信用卡"/);
h.context.__accounts=accounts;h.run('state.accounts=__accounts;delete globalThis.CreditCardFees');assert.doesNotMatch(h.run('accountFields()'),/<option value="信用卡"/);
h.context.__draft={customer:'客户',salesperson:'麦麦',payment_account:'麦麦信用卡'};assert.throws(()=>h.run('validateIssueDraft(__draft)'),/信用卡收款暂未准备好/);
h.context.__draft={customer:'客户',internal_note:'测试内部备注',salesperson:'麦麦',payment_account:'麦麦信用卡'};assert.throws(()=>h.run('validateIssueDraft(__draft)'),/信用卡收款暂未准备好/);
const index=fs.readFileSync(path.join(__dirname,'../public/index.html'),'utf8');assert.equal((index.match(/src="\/credit-card-fees.js"/g)||[]).length,1);assert.ok(index.indexOf('/credit-card-fees.js')<index.indexOf('/app.js'));
});
@@ -69,7 +69,7 @@ test('旧自动卡费元数据、金额和日期原样回传,只允许付款
});
test('普通新单提交保留人工费用与付款人,自动预览不写入fee_items',()=>{
const h=harness(),values={orderId:'',revision:'',rounding_mode:'yuan',date:D,customer:'客户',salesperson:'麦麦',payment_recipient:'助理',payment_method:'信用卡',fees_date:D,discount:'0',note:'',credit_card_fee_payer:'assistant'};
const h=harness(),values={orderId:'',revision:'',rounding_mode:'yuan',date:D,customer:'客户',internal_note:'测试内部备注',salesperson:'麦麦',payment_recipient:'助理',payment_method:'信用卡',fees_date:D,discount:'0',note:'',credit_card_fee_payer:'assistant'};
const form=fieldsForm(values,{querySelectorAll:()=>[]});h.nodes.set('#order-form',form);const rows=[feeRow(shipping),feeRow(autoFee())];h.nodes.set('#fee-rows',{querySelectorAll:()=>rows});
const result=h.json('collectDraft()');assert.equal(result.payment_account,'麦麦信用卡');assert.equal(result.credit_card_fee_payer,'assistant');assert.equal(result.fee_items.length,1);assert.equal(result.fee_items[0].key,'shipping');assert.equal(result.fee_items[0].amount,'6.00');assert.equal(JSON.stringify(result).includes('card_fee:'),false);
});
@@ -83,7 +83,7 @@ test('补收与正向收款更正展示6‰,退款和费用更正不新增卡
});
test('锁价首收按实际付款预览而非预计报价,付款人进入payment,原卡费只读留存',()=>{
const h=harness(),root=preview(),form=fieldsForm({date:D,customer:'合成客户',salesperson:'麦麦',note:'',discount:'0',name:'足金999',quantity:'1.000',goldPrice:'1000',laborRate:'0',laborMode:'gram',pieces:'1',received_amount:'500',payment_recipient:'助理',payment_method:'信用卡',credit_card_fee_payer:'assistant',material_rate:'800',material_payer:'owner',payment_verified:input('on',{checked:true}),material_verified:input('on',{checked:true})});
const h=harness(),root=preview(),form=fieldsForm({date:D,customer:'合成客户',internal_note:'测试内部备注',salesperson:'麦麦',note:'',discount:'0',name:'足金999',quantity:'1.000',goldPrice:'1000',laborRate:'0',laborMode:'gram',pieces:'1',received_amount:'500',payment_recipient:'助理',payment_method:'信用卡',credit_card_fee_payer:'assistant',material_rate:'800',material_payer:'owner',payment_verified:input('on',{checked:true}),material_verified:input('on',{checked:true})});
h.nodes.set('#price-lock-create-form',form);h.nodes.set('#lock-create-card-fee',root);for(const id of ['#lock-create-total','#lock-sale-estimate','#lock-material-estimate'])h.nodes.set(id,{textContent:''});h.run('syncPriceLockCreate()');assert.equal(root.fields['[data-credit-card-amount]'].value,'3.00');assert.equal(h.json('collectPriceLockCreate().payment').credit_card_fee_payer,'assistant');assert.equal(h.nodes.get('#lock-create-total').textContent,'¥1,000');
h.context.__lock={credit_card_fees:[{date:'2026-10-21',amount:200,payer:'owner'},{date:D,amount:80,payer:'assistant'}],credit_card_fee_total:280};const html=h.run('priceLockCardFeesHTML(__lock)');for(const text of ['2.80','2.00','0.80','麦麦支付','娜娜支付','交付时沿用,不重复'])assert.ok(html.includes(text));assert.doesNotMatch(html,/<input|<select|remove-/);
});
@@ -96,7 +96,7 @@ test('交付仅正补收产生新费,已付卡费和其他费用始终留在
});
test('模板和复制保留信用卡渠道、剔除旧费,改额后仅按新金额重算',()=>{
const fee=autoFee({amount:'3.02'}),line={name:'定制珠宝',nameType:'其他',customName:'定制珠宝',unit:'件',quantity:'1',pocket:'',payer:'owner',pricingMode:'manual',baseSale:'753',sale:'753',charges:[],cost:'400'},draft={date:D,customer:'旧客户',salesperson:'麦麦',payment_account:'麦麦信用卡',credit_card_fee_payer:'assistant',discount:'0',lines:[line],fee_items:[fee,shipping]};
const fee=autoFee({amount:'3.02'}),line={name:'定制珠宝',nameType:'其他',customName:'定制珠宝',unit:'件',quantity:'1',pocket:'',payer:'owner',pricingMode:'manual',baseSale:'753',sale:'753',charges:[],cost:'400'},draft={date:D,customer:'旧客户',internal_note:'测试内部备注',salesperson:'麦麦',payment_account:'麦麦信用卡',credit_card_fee_payer:'assistant',discount:'0',lines:[line],fee_items:[fee,shipping]};
const preset=Templates.fromDraft(draft),applied=Templates.apply(preset,{today:D});assert.equal(applied.customer,'');assert.equal(applied.payment_account,'麦麦信用卡');assert.equal(applied.credit_card_fee_payer,'assistant');assert.equal(applied.fee_items.length,1);assert.equal(applied.fee_items[0].key,'shipping');assert.ok(!JSON.stringify(applied).includes(PAYMENT));applied.lines[0].baseSale='1000';const total=Calc.orderTotal([Calc.sale(applied.lines[0]).sale],0,'yuan').total;assert.equal(Cards.amount(total),600);
const source={...draft,discount:0,status:'delivered',pendingFees:[],corrections:[],fee_items:[{...fee,amount:302}],expenses:[{id:EXPENSE,date:D,note:fee.note,amount:302,payer:'owner'}],lines:[{...line,quantity:1,baseSale:75300,sale:75300,cost:40000}]};const copied=Copy.fromOrder(source,{today:D});assert.equal(copied.payment_account,'麦麦信用卡');assert.equal(copied.fee_items.length,0);assert.equal(copied.customer,'');copied.lines[0].baseSale='100';assert.equal(Cards.amount(Calc.orderTotal([Calc.sale(copied.lines[0]).sale],0,'yuan').total),60);
});