51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
import legacyPools from './funds-legacy-pools.mjs';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { material } from './funds-material.mjs';
|
||
|
|
import { locks } from './funds-locks.mjs';
|
||
|
|
import { afterSales } from './funds-after-sales.mjs';
|
||
|
|
export async function seedFunds({ day, session }) {
|
||
|
|
const yesterday = new Date(Date.parse(day + 'T12:00:00Z') - 86400000).toISOString().slice(0, 10);
|
||
|
|
await session.post('owner', '/api/stock', {
|
||
|
|
date: yesterday,
|
||
|
|
kind: 'opening',
|
||
|
|
pocket: '现货',
|
||
|
|
grams: '100',
|
||
|
|
note: '锁价交付期初库存',
|
||
|
|
});
|
||
|
|
await session.post('assistant', '/api/orders/issue', {
|
||
|
|
date: day,
|
||
|
|
customer: '店主代收经营款的夹具',
|
||
|
|
customer_type: 'new',
|
||
|
|
salesperson: '娜娜',
|
||
|
|
internal_note: '代收款凭据',
|
||
|
|
member: 'assistant',
|
||
|
|
payment_account: '麦麦微信',
|
||
|
|
rounding_mode: 'cent',
|
||
|
|
lines: [
|
||
|
|
{
|
||
|
|
name: '足金999',
|
||
|
|
unit: 'g',
|
||
|
|
quantity: '1',
|
||
|
|
pocket: '现货',
|
||
|
|
payer: 'assistant',
|
||
|
|
sale: '1000',
|
||
|
|
costParts: { material: '800', labor: '50', accessories: '0', other: '0' },
|
||
|
|
costPayers: { material: 'assistant', labor: 'assistant' },
|
||
|
|
},
|
||
|
|
],
|
||
|
|
fee_items: [],
|
||
|
|
});
|
||
|
|
assert.deepEqual(session.problems, []);
|
||
|
|
return yesterday;
|
||
|
|
}
|
||
|
|
|
||
|
|
export default async function fundsCore(context) {
|
||
|
|
const { pageFor } = context;
|
||
|
|
const yesterday = await seedFunds(context);
|
||
|
|
const participants = { owner: await pageFor('owner'), assistant: await pageFor('assistant'), yesterday };
|
||
|
|
await legacyPools(context);
|
||
|
|
const preview = await material(context, participants);
|
||
|
|
const quotes = await locks(context, participants);
|
||
|
|
await afterSales(context, participants);
|
||
|
|
return { ...preview, ...quotes };
|
||
|
|
}
|