补齐固定旧版的浏览器逐笔写入对照并记录账务差异
This commit is contained in:
1 parent
e77588b337
commit
7d2007955f
39 files changed
+3653
-41
No files matched your search
@@ -0,0 +1,80 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { ui } from './funds-ui.mjs';
|
||||
|
||||
export async function material(context, { owner, assistant, yesterday }) {
|
||||
const { day } = context;
|
||||
const { action, field, fill, navigate, write, submit } = ui(context);
|
||||
async function buy(page, label, date, grams, total, note) {
|
||||
await navigate(page, 'material-pools');
|
||||
const form = page.locator('#material-purchase-form');
|
||||
await fill(form, { date, grams, total, note });
|
||||
await write(label, page, '/api/material-purchases', () => submit(form));
|
||||
await page.locator('.material-purchase-table').getByText(note, { exact: true }).waitFor();
|
||||
}
|
||||
async function openPurchase(page, date, note, actionName) {
|
||||
const toggle = page.locator('[data-action="toggle-material-pool"][data-id="' + date + '"]');
|
||||
if ((await toggle.getAttribute('aria-expanded')) !== 'true') await toggle.click();
|
||||
const row = page.locator('.material-purchase-table tr').filter({ hasText: note });
|
||||
await action(row, actionName).click();
|
||||
}
|
||||
await buy(assistant, '店员登记前日购料', yesterday, '8.125', '6906.25', '前日原始凭据');
|
||||
await buy(owner, '店主登记当日购料', day, '10', '8500.00', '本日采购');
|
||||
await buy(owner, '店主登记待更正购料', day, '1', '800', '待更正采购');
|
||||
await openPurchase(owner, day, '待更正采购', 'edit-material-purchase');
|
||||
const edit = owner.locator('#material-purchase-edit-form');
|
||||
await fill(edit, { grams: '1.250', total: '1023.40', note: '当天凭据更正' });
|
||||
await write('当天直接更正购料', owner, /\/material-purchases\/[^/]+\/edit$/, () => submit(edit));
|
||||
await openPurchase(owner, day, '当天凭据更正', 'delete-material-purchase');
|
||||
await write('当天直接删除购料', owner, /\/material-purchases\/[^/]+\/delete$/, () =>
|
||||
submit(owner.locator('#material-purchase-delete-form')),
|
||||
);
|
||||
const rolling = owner.locator('#material-rolling-enable-form');
|
||||
const preview = await context.step('店主只读预览材料结转与关联订单影响', async () => {
|
||||
const [response] = await Promise.all([
|
||||
owner.waitForResponse(
|
||||
r => r.request().method() === 'GET' && r.url().endsWith('/api/material-pools/rolling-preview'),
|
||||
),
|
||||
action(owner, 'material-rolling-enable-preview').click(),
|
||||
]);
|
||||
assert.equal(response.status(), 200);
|
||||
const data = await response.json();
|
||||
assert.equal(data.canEnable, true);
|
||||
assert.ok(Array.isArray(data.relatedOrders));
|
||||
await rolling.waitFor();
|
||||
return data;
|
||||
});
|
||||
await field(rolling, 'verified').check();
|
||||
await write('店主核对并启用跨日材料结转', owner, '/api/material-pools/rolling-enable', () => submit(rolling));
|
||||
for (const [operation, reviewKind] of [
|
||||
['edit', 'approve'],
|
||||
['delete', 'reject'],
|
||||
]) {
|
||||
await assistant.reload();
|
||||
await navigate(assistant, 'material-pools');
|
||||
await openPurchase(assistant, yesterday, '前日原始凭据', operation + '-material-purchase');
|
||||
const form = assistant.locator('#material-purchase-' + operation + '-form');
|
||||
if (operation === 'edit') await field(form, 'total').fill('6950.50');
|
||||
await fill(form, { change_reason: '按原始付款凭据核对' });
|
||||
await field(form, 'change_verified').check();
|
||||
const verb = operation === 'edit' ? '更正' : '删除';
|
||||
await write('店员申请' + verb + '历史购料', assistant, /\/material-purchases\/[^/]+\/change$/, () => submit(form));
|
||||
await owner.reload();
|
||||
await navigate(owner, 'material-pools');
|
||||
await action(owner, 'material-change-open').click();
|
||||
const review = owner.locator('#material-change-review-form');
|
||||
await fill(review, { note: reviewKind === 'approve' ? '付款凭据相符' : '原料确已购入' });
|
||||
if (reviewKind === 'approve') await field(review, 'verified').check();
|
||||
await write(
|
||||
'店主' + (reviewKind === 'approve' ? '批准' : '驳回') + verb + '购料申请',
|
||||
owner,
|
||||
new RegExp('/material-purchase-changes/[^/]+/' + reviewKind + '$'),
|
||||
() => (reviewKind === 'approve' ? submit(review) : action(review, 'material-change-reject').click()),
|
||||
);
|
||||
}
|
||||
await navigate(owner, 'material-pools');
|
||||
const toggle = owner.locator('[data-action="toggle-material-pool"][data-id="' + day + '"]');
|
||||
if ((await toggle.getAttribute('aria-expanded')) !== 'true') await toggle.click();
|
||||
// 三成员账本的网页仅显示旧式料款结算历史,不能新登记两人料款结算。
|
||||
assert.equal(await owner.getByRole('button', { name: '登记实际交款/返款' }).count(), 0);
|
||||
return { 材料结转预览: preview };
|
||||
}
|
||||
Reference in new issue
Block a user