test: 調動月份拆分與合併
CI / build (push) Successful in 27s
CI / build (pull_request) Successful in 26s

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VDJVpPiGiWjJP1yVvvGhzQ
This commit is contained in:
2026-11-04 07:47:56 +00:00
co-authored by Claude Opus 5.5
parent 32e594a0f0
commit 52f0154bb3
+15
View File
@@ -99,3 +99,18 @@ test('change list, peak reset with restore, and undoing the latest anchor', asyn
await store.anchor(m, { year: 2027, half: 'H1', note: 'again', by: 't' });
assert.equal((await store.evaluate(m, 2027)).active.version, 2);
});
test('actual CODA split by transfer month; snapshots and change lists merge the two parts back', async () => {
const { splitTransfers, mergedPeople } = await import('../anchor-calc.js');
const p = { employeeNumber: 'b', name: 'b', dept: 'Y', group: 'h1', role: 'A - 藝術家', h1Start: 1, h1End: 6, h2Start: 7, h2End: 12, row: 'b', monthlyCost: months(100), totalCost: 1200 };
const parts = splitTransfers([p], [{ key: 'hr:b', from: { dept: 'X', group: 'g2' }, month: 4 }]);
assert.equal(parts.length, 2);
assert.deepEqual([parts[0].dept, parts[0].h1Start, parts[0].h1End, parts[0].h2Start], ['X', 1, 3, '']);
assert.deepEqual([parts[1].dept, parts[1].h1Start, parts[1].h1End, parts[1].h2Start, parts[1].h2End], ['Y', 4, 6, 7, 12]);
const merged = mergedPeople([{ ...parts[0], monthlyCost: [100, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0], totalCost: 300 }, { ...parts[1], monthlyCost: [0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100], totalCost: 900 }]);
const e = merged.get('hr:b');
assert.equal(e.person.dept, 'Y');
assert.equal(e.pa.reduce((a, b) => a + b, 0), 1200);
const people = [p];
assert.equal(splitTransfers(people, []), people);
});