保存同行基础版:店铺配置与员工管理
This commit is contained in:
1 parent
ecb8d6dec0
commit
b7b987064b
84 files changed
+1884
-573
No files matched your search
@@ -22,7 +22,7 @@ test('取消定金单释放占用、不造入库,退款从原账户',t=>{const
|
||||
test('转款超过余额、重复开账、未来业务、旧版草稿冲突均阻止',t=>{const {stock,save,act,fulfill,l}=fixture(t);stock();assert.throws(()=>stock(),/重复登记/);const id=save();assert.throws(()=>l.saveOrder({...l.rawOrder(id),revision:0,lines:[{name:'x',unit:'g',quantity:'1',pocket:'现货',payer:'owner',cost:'1',sale:'2'}]},actor),/已被更新/);fulfill(id);assert.throws(()=>act(id,'settlement',{amount:'1201',bucket:'cost',direction:'toOwner',note:'超额',verified:true}),/超过/);assert.throws(()=>act(id,'expense',{date:'2099-01-01',amount:'1',payer:'owner',note:'未来'}),/业务日期/);});
|
||||
test('客户投影和HTML中没有成本、利润、垫资和日志字段,文本转义',t=>{const {l,stock,save}=fixture(t);stock();const id=save({customer:'<script>alert(1)</script>',note:'<img onerror=evil()>',lines:[{name:'足金<script>',unit:'g',quantity:'1',pocket:'现货',payer:'owner',cost:'987.65',sale:'1200'}]});const p=l.publicOrder(id),serialized=JSON.stringify(p);for(const key of ['cost','payer','profit','audit','settlement','pocket'])assert.ok(!serialized.includes('"'+key+'"'));const html=receipt(p);assert.ok(!html.includes('987.65'));assert.ok(!html.includes('<img onerror'));assert.ok(html.includes('<img'));assert.ok(html.includes('草稿'));});
|
||||
test('多行单据全部保留在一张纸,仅显示纸单号与一次合计',t=>{const {l,save}=fixture(t);const id=save({lines:Array.from({length:17},(_,i)=>({name:'外配'+i,unit:'件',quantity:'1',pocket:'',payer:'assistant',cost:'1',sale:'2'}))});const html=receipt(l.publicOrder(id));assert.equal((html.match(/<section class="sheet /g)||[]).length,1);assert.equal((html.match(/合计金额/g)||[]).length,1);assert.equal((html.match(/纸单号:/g)||[]).length,1);assert.ok(html.includes('外配16'));assert.ok(!html.includes('系统单号'));assert.ok(receipt(l.publicOrder(id),{},'overlay').includes('sheet overlay'));});
|
||||
test('助理不可开账、调整、复核;有新动作复核重新待办',t=>{const {l,stock,save,act,fulfill}=fixture(t);assert.throws(()=>stock({},assistant),/麦麦账号/);stock();const id=save();fulfill(id);assert.throws(()=>act(id,'review',{revision:l.detail(id).revision},assistant),/麦麦账号/);act(id,'review',{revision:l.detail(id).revision});assert.equal(l.detail(id).reviewed_revision,l.detail(id).revision);act(id,'expense',{amount:'1',payer:'assistant',note:'售后'});assert.notEqual(l.detail(id).reviewed_revision,l.detail(id).revision);});
|
||||
test('助理不可开账、调整、复核;有新动作复核重新待办',t=>{const {l,stock,save,act,fulfill}=fixture(t);assert.throws(()=>stock({},assistant),/店主账号/);stock();const id=save();fulfill(id);assert.throws(()=>act(id,'review',{revision:l.detail(id).revision},assistant),/店主账号/);act(id,'review',{revision:l.detail(id).revision});assert.equal(l.detail(id).reviewed_revision,l.detail(id).revision);act(id,'expense',{amount:'1',payer:'assistant',note:'售后'});assert.notEqual(l.detail(id).reviewed_revision,l.detail(id).revision);});
|
||||
test('旧快照遇补录会过期,不把原记录标成已封账',t=>{const {l,stock,save,act,fulfill,run}=fixture(t);stock();const id=save();fulfill(id);run({},()=>l.closeDay(D,actor));assert.equal(l.report(D).close.stale,false);act(id,'expense',{amount:'1',payer:'assistant',note:'售后'});assert.equal(l.report(D).close.stale,true);});
|
||||
test('数据库重新打开、备份恢复后账单及操作号完整',async t=>{const {l,dir,stock,save,fulfill}=fixture(t);stock();const id=save();fulfill(id);const before=l.detail(id),dest=path.join(dir,'backup.sqlite');await l.backupTo(dest);const copy=new Ledger(dest);assert.equal(copy.detail(id).profit,before.profit);assert.equal(copy.inventory()[0].mg,8800);assert.ok(copy.rows('SELECT * FROM operations').length>=4);copy.close();l.close();const reopened=new Ledger(path.join(dir,'ledger.sqlite'));assert.equal(reopened.detail(id).number,before.number);reopened.close();});
|
||||
test('麦麦直接收款从总待结金额扣除,不重复要求助理上交',t=>{const {l,stock,save,act}=fixture(t);stock();const id=save();act(id,'confirm');act(id,'receipt',{amount:'1200',account:'麦麦微信',verified:true});act(id,'deliver',{verified:true});assert.equal(l.detail(id).settlementDue,0);assert.ok(l.report(D).warnings.some(w=>w.message.includes('直接收客户款')));});
|
||||
|
||||
Reference in new issue
Block a user