开单成本改为勾选并支持按账号配置默认开单人
This commit is contained in:
1 parent
8cac61deb3
commit
6047cc360b
17 files changed
+278
-40
No files matched your search
@@ -59,7 +59,30 @@ test('首次只调整打印位置保留原品牌,配置持久化且不同账
|
||||
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'shop-settings-database-')),filename=path.join(dir,'shop-a.sqlite'),first=new Ledger(filename),other=new Ledger(':memory:'),actors=accounts(first);t.after(()=>{other.close();fs.rmSync(dir,{recursive:true,force:true});});
|
||||
first.setMeta('printing',{...Printing.defaults,store:'唯光原店',subtitle:'唯光原票',contact:'原联系'});const before=Settings.read(other);
|
||||
Settings.updatePrinting(first,{offsetY:7},actors.owner);assert.equal(Settings.read(first).storeName,'唯光原店');assert.equal(Settings.printingSettings(first).contact,'原联系');
|
||||
const current=Settings.read(first);Settings.update(first,{revision:current.revision,storeName:'另一店',creditCardRatePermille:0,profitSharePercent:45,profitShareEffectiveMonth:today().slice(0,7)},actors.owner);const saved=Settings.read(first);first.close();
|
||||
const current=Settings.read(first);Settings.update(first,{revision:current.revision,storeName:'另一店',creditCardRatePermille:0,profitSharePercent:45,profitShareEffectiveMonth:today().slice(0,7),salespersonDefaults:{assistant:'张'}},actors.owner);const saved=Settings.read(first);first.close();
|
||||
const reopened=new Ledger(filename);try{assert.deepEqual(Settings.read(reopened),saved);assert.equal(Settings.printingSettings(reopened).offsetY,7);}finally{reopened.close();}
|
||||
assert.deepEqual(Settings.read(other),before);
|
||||
});
|
||||
test('账号默认开单人兼容实际登录名,老板按账号配置且不改账号、历史订单、模板或打印经办人',async t=>{
|
||||
const f=await fixture(t),initial=(await f.call('/api/shop-settings')).body;
|
||||
assert.deepEqual(initial.salespersonDefaults,{owner:'麦麦',assistant:'助理',assistant2:'助理2'});
|
||||
const oldConfig={...initial};delete oldConfig.salespersonDefaults;f.ledger.setMeta(Settings.KEY,oldConfig);
|
||||
assert.deepEqual(Settings.read(f.ledger).salespersonDefaults,initial.salespersonDefaults);
|
||||
const date=today(),issued=await f.call('/api/orders/issue',{date,customer:'合成历史客户',salesperson:'原自由开单人',payment_account:'麦麦微信',lines:[{name:'合成配件',unit:'件',quantity:'1',pocket:'',payer:'owner',sale:'100',cost:'40'}],fee_items:[]});assert.equal(issued.status,200);
|
||||
const template=await f.call('/api/order-templates',{name:'合成原经办模板',preset:{lines:[{}],salesperson:'模板原开单人'}});assert.equal(template.status,200);
|
||||
const before=tableSnapshot(f.ledger),input={revision:0,salespersonDefaults:{owner:'店主经办',assistant:' 张 ',assistant2:'李'}},key=randomUUID();
|
||||
const first=await f.call('/api/shop-settings',input,'owner',key),again=await f.call('/api/shop-settings',input,'owner',key);assert.equal(first.status,200);assert.deepEqual(first.body,again.body);
|
||||
const expected={owner:'店主经办',assistant:'张',assistant2:'李'};assert.deepEqual(first.body.shopSettings.salespersonDefaults,expected);
|
||||
for(const member of ['assistant','assistant2']){
|
||||
assert.deepEqual((await f.call('/api/state',undefined,member)).body.shopSettings.salespersonDefaults,expected);
|
||||
assert.equal((await f.call('/api/shop-settings',{revision:1,salespersonDefaults:{[member]:'越权姓名'}},member)).status,403);
|
||||
}
|
||||
for(const value of [null,[],{other:'新员工'},{assistant:''},{assistant:' '},{assistant:42},{assistant:'字'.repeat(31)},{assistant:'张\n李'}]){
|
||||
const result=await f.call('/api/shop-settings',{revision:1,salespersonDefaults:value});
|
||||
assert.equal(result.status,400,JSON.stringify(value));
|
||||
}
|
||||
assert.deepEqual(tableSnapshot(f.ledger),before);
|
||||
assert.equal((await f.call('/api/orders/'+issued.body.id)).body.salesperson,'原自由开单人');
|
||||
assert.equal((await f.call('/api/order-templates/'+template.body.id)).body.preset.salesperson,'模板原开单人');
|
||||
const printed=await f.call('/print/'+issued.body.id);assert.equal(printed.status,200);assert.match(printed.body,/原自由开单人/);assert.doesNotMatch(printed.body,/店主经办/);
|
||||
});
|
||||
Reference in new issue
Block a user