补齐固定旧版的浏览器逐笔写入对照并记录账务差异
This commit is contained in:
1 parent
e77588b337
commit
7d2007955f
39 files changed
+3653
-41
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
export async function exerciseDeliveredLocks({ day, yesterday, session, post, open, field, action, submit, route }) {
|
||||
// 一张昨日按料池锁价、今日交付的单行单,及一张当日手填进价的多行单。
|
||||
for (const multi of [false, true]) {
|
||||
const date = multi ? day : yesterday;
|
||||
await session.day(date);
|
||||
let pool;
|
||||
if (!multi) {
|
||||
await post('owner', '/api/material-purchases', {
|
||||
date,
|
||||
grams: '4',
|
||||
total: '3600',
|
||||
payer: 'owner',
|
||||
allocations: [{ member: 'owner', amount: '3600' }],
|
||||
note: '锁价单料池',
|
||||
});
|
||||
const preview = await session.get('owner', '/api/material-pools/rolling-preview');
|
||||
await post('owner', '/api/material-pools/rolling-enable', { date, revision: preview.revision, verified: true });
|
||||
pool = await session.get('owner', '/api/material-pools/' + date);
|
||||
}
|
||||
const line = i => ({
|
||||
name: '锁价商品' + i,
|
||||
unit: 'g',
|
||||
quantity: '1',
|
||||
goldPrice: '1000',
|
||||
laborMode: 'gram',
|
||||
laborRate: '0',
|
||||
material: pool
|
||||
? { source: 'pool', poolId: date, revision: pool.revision }
|
||||
: { source: 'manual', rate: '850', payer: 'owner', verified: true },
|
||||
});
|
||||
const { id } = await post('assistant', '/api/price-locks', {
|
||||
date,
|
||||
member: 'assistant',
|
||||
customer: '锁价编辑' + (multi ? '多行' : '单行'),
|
||||
salesperson: '娜娜',
|
||||
customer_type: 'new',
|
||||
internal_note: '#锁价',
|
||||
lines: multi ? [line(1), line(2)] : [line(1)],
|
||||
payment: { amount: multi ? '2000' : '1000', account: '助理微信', verified: true },
|
||||
});
|
||||
await session.day(day);
|
||||
const lock = await session.get('assistant', '/api/price-locks/' + id);
|
||||
const lines = lock.lines.map(row => ({
|
||||
lineId: row.id,
|
||||
quantity: (row.locked_mg / 1000).toFixed(3),
|
||||
laborRate: '0',
|
||||
laborMode: 'gram',
|
||||
payer: 'assistant',
|
||||
costPayers: { material: row.buy_payer, labor: 'assistant' },
|
||||
costParts: { labor: '20', accessories: '2', other: '1' },
|
||||
inventory: { pocket: '现货', original: row.material_source === 'pool' ? 'stocked' : 'receive', extra: 'receive' },
|
||||
extraMaterial: { rate: '900', payer: 'assistant', verified: true },
|
||||
}));
|
||||
const delivered = await post('assistant', '/api/price-locks/' + id + '/deliver', {
|
||||
date: day,
|
||||
revision: lock.revision,
|
||||
verified: true,
|
||||
lines,
|
||||
fee_items: [{ key: 'shipping', amount: '6', payer: 'assistant', note: '快递费' }],
|
||||
});
|
||||
const page = await open(multi ? 'owner' : 'assistant', delivered.id);
|
||||
await action(page, 'edit-order').click();
|
||||
const form = page.locator('#order-edit-meta-form');
|
||||
await form.waitFor();
|
||||
if (!multi) {
|
||||
await field(form, 'lock_material_source').selectOption('manual');
|
||||
await field(form, 'lock_material_rate').fill('880');
|
||||
await field(form, 'lock_material_payer').selectOption('owner');
|
||||
await field(form, 'lock_material_verified').check();
|
||||
}
|
||||
const modes = form.locator('[name=lock_cost_labor_mode]');
|
||||
assert.equal(await modes.count(), multi ? 2 : 1);
|
||||
await modes.last().selectOption('gram');
|
||||
await form.locator('[name=lock_cost_labor_rate]').last().fill('12.50');
|
||||
await field(form, 'internal_note').fill('改正锁价进货资料');
|
||||
await field(form, 'edit_reason').fill('更正锁价工费');
|
||||
await field(form, 'cost_box').check();
|
||||
await field(form, 'edit_verified').check();
|
||||
await submit(
|
||||
multi ? '店主直接修改多行已交付锁价单' : '助理申请修改跨日已交付料池锁价单',
|
||||
page,
|
||||
form,
|
||||
route(delivered.id) + '/' + (multi ? 'edit' : 'change'),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user