取消已用回收单时将关联用料转入公共料池
This commit is contained in:
1 parent
19b1b0263c
commit
dec01a3dca
18 files changed
+380
-56
No files matched your search
@@ -40,8 +40,20 @@ test('助理仅本人,原日与新日均今天为直改,其余显示申请
|
||||
const h=harness('assistant');await h.open();const {fields,submit}=h.editForm();h.run('syncRecoveryEditMode()');assert.equal(submit.textContent,'保存修改');fields.date.value=OLD;h.run('syncRecoveryEditMode()');assert.equal(submit.textContent,'提交修改申请');assert.match(h.nodes.get('#recovery-edit-mode').textContent,/审批前.*不变/);const denied=harness('assistant2');await assert.rejects(denied.open(),/不属于当前成员/);const pending=harness();await assert.rejects(pending.open({pending:request(),permissions:{canEdit:false,canCancel:false,canDirect:false,requiresApproval:true,reason:'待麦麦复核'}}),/待麦麦复核/);assert.equal(pending.run('recoveryEditEntry'),null);
|
||||
});
|
||||
|
||||
test('已有用料显示授权订单或匿名提示,取消入口关闭但允许核对修改',()=>{
|
||||
const h=harness();h.context.__detail=detail('owner',{permissions:{canEdit:true,canCancel:false,canDirect:true,requiresApproval:false,reason:'已有用料'},blockedUsages:[{orderId:'own-order',number:'XS可见',mg:1000},{mg:2000,anonymous:true}]});h.run('recoveryDetailEdit=__detail');const actions=h.run('recoveryDetailChangeActionsHTML(__detail.record)'),panel=h.run('recoveryEditPanelHTML(__detail)');assert.match(actions,/recovery-edit-open/);assert.ok(!actions.includes('recovery-edit-cancel'));assert.match(panel,/XS可见/);assert.match(panel,/其他成员用料/);assert.equal((panel.match(/recovery-change-open-order/g)||[]).length,1);
|
||||
test('已有用料仍能取消,展示订单锁价与匿名用量,修改约束保留',async()=>{
|
||||
const usages=[{orderId:'own-order',number:'XS<可见>',mg:1000},{priceLockId:'own-lock',number:'锁价可见',mg:500},{orderId:'hidden-order',number:'不可泄露订单',mg:2000,anonymous:true}];
|
||||
for(const member of ['owner','assistant']){
|
||||
const h=harness(member);h.context.__detail=detail(h.user.role,{blockedUsages:usages});h.run('recoveryDetailEdit=__detail');const actions=h.run('recoveryDetailChangeActionsHTML(__detail.record)'),panel=h.run('recoveryEditPanelHTML(__detail)');
|
||||
assert.match(actions,/recovery-edit-open/);assert.match(actions,/recovery-edit-cancel/);assert.match(panel,/修改时不能更换金料日期,也不能将金料减至低于已用/预留量/);assert.match(panel,/公共料按可用量补足/);assert.match(panel,/公共料不足仍可取消/);assert.match(panel,/料费待补/);assert.doesNotMatch(panel,/不能取消|不可泄露订单|hidden-order|XS<可见>/);assert.match(panel,/XS<可见>/);assert.match(panel,/其他成员用料 · 2\.000g/);assert.equal((panel.match(/recovery-change-open-order/g)||[]).length,1);assert.equal((panel.match(/recovery-change-open-lock/g)||[]).length,1);
|
||||
await h.run(`openRecoveryCancel('${ID}')`);const html=h.nodes.get('#recovery-change-dialog').innerHTML;for(const text of ['XS<可见>','锁价可见','1.000g','0.500g','其他成员用料','公共料不足仍可取消','料费待补','关联用料自动重算'])assert.ok(html.includes(text),text);assert.doesNotMatch(html,/不能取消|修改时不能|不可泄露订单|hidden-order/);
|
||||
h.smallForm('recovery-cancel-form',{reason:'录入重复,核对后取消',verified:true});h.run('finishRecoveryChangeSave=async function(url,input,result){__finished={url,input,result};};');h.calls.length=0;await h.run('submitRecoveryCancel(__form)');assert.equal(h.calls[0].url,'/api/recoveries/'+ID+'/cancel');assert.deepEqual(JSON.parse(JSON.stringify(h.calls[0].data)),{revision:3,reason:'录入重复,核对后取消',verified:true});
|
||||
}
|
||||
});
|
||||
|
||||
test('取消仍遵守服务端权限和待审状态,不能用已有用料放开重复申请',async()=>{
|
||||
for(const extra of [{status:'cancelled',permissions:{canEdit:false,canCancel:false,canDirect:false,requiresApproval:false,reason:'本单已经取消'}},{pending:request({action:'cancel',after:null}),permissions:{canEdit:false,canCancel:false,canDirect:false,requiresApproval:true,reason:'本单有待审批更正'}}]){
|
||||
const h=harness();h.context.__detail=detail('owner',{blockedUsages:[{number:'XS已用',orderId:'own-order',mg:1000}],...extra});h.run('recoveryDetailEdit=__detail');assert.doesNotMatch(h.run('recoveryDetailChangeActionsHTML(__detail.record)'),/recovery-edit-cancel/);await h.run(`openRecoveryCancel('${ID}')`);assert.equal(h.run('recoveryReviewEntry'),null);assert.match(h.nodes.get('#recovery-change-dialog').innerHTML,/暂不能取消/);assert.equal(h.calls.filter(call=>call.data).length,0);
|
||||
}
|
||||
});
|
||||
|
||||
test('取消须原因与确认,历史助理自动申请,取消响应不会重建新单',async()=>{
|
||||
@@ -53,7 +65,7 @@ test('审批显示完整前后旧料、费用付款人与实际净额,同意
|
||||
});
|
||||
|
||||
test('过期申请只能驳回,助理不能审批;取消对照显示冲正且不把未提供利润当0',async()=>{
|
||||
const h=harness();await h.review({stale:true,canApprove:false});assert.ok(!h.nodes.get('#recovery-change-dialog').innerHTML.includes('data-kind="approve"'));assert.throws(()=>h.run("showRecoveryDecision('approve')"),/已有变动/);const assistant=harness('assistant');await assistant.review({canApprove:false});assert.throws(()=>assistant.run("showRecoveryDecision('reject')"),/麦麦账号/);h.context.__request=request({action:'cancel',after:null});const html=h.run('recoveryChangeComparisonHTML(__request)');assert.match(html,/取消后/);assert.match(html,/冲正原库存及关联购料/);assert.ok(!html.includes('undefined'));assert.ok(!html.includes('NaN'));
|
||||
const h=harness();await h.review({stale:true,canApprove:false});assert.ok(!h.nodes.get('#recovery-change-dialog').innerHTML.includes('data-kind="approve"'));assert.throws(()=>h.run("showRecoveryDecision('approve')"),/已有变动/);const assistant=harness('assistant');await assistant.review({canApprove:false});assert.throws(()=>assistant.run("showRecoveryDecision('reject')"),/麦麦账号/);h.context.__request=request({action:'cancel',after:null,summary:{...request().summary,blockedUsages:[{orderId:'visible-order',number:'XS<已用>',mg:3000},{number:'不应展示',orderId:'private-order',anonymous:true,mg:500}]}});const html=h.run('recoveryChangeComparisonHTML(__request)');assert.match(html,/取消后/);assert.match(html,/冲正原库存及关联购料/);assert.match(html,/公共料不足仍可取消/);assert.match(html,/料费待补/);assert.match(html,/XS<已用> · 3\.000g/);assert.match(html,/其他成员用料 · 0\.500g/);assert.doesNotMatch(html,/不应展示|private-order|不能取消|undefined|NaN/);
|
||||
});
|
||||
|
||||
test('409保留修改草稿并禁旧版本,重新读取与核对前不允许重交',async()=>{
|
||||
|
||||
Reference in new issue
Block a user