import fs from 'node:fs'; import {carryCase} from '../tests/frontend/helpers/irpc-carry-case.mjs'; import {internationalCase} from '../tests/frontend/helpers/irpc-international-case.mjs'; import {recordAnnual, saveAnnualBook} from '../resources/js/lib/irpc-annual-settlement.ts'; const cases = {}; for (const name of ['payable', 'expired', 'missing-use', 'overallocated', 'fractional', 'recoverable']) { const c = carryCase(), previous = internationalCase(); const frozen = recordAnnual(previous.d, previous.b, '2026-10-27T17:00:00+02:00').result; c.b.history = [frozen]; const l = c.b.creditCarry.lots[0]; if (name === 'expired') l.year = '2020'; if (name === 'missing-use') l.usesState = ''; if (name === 'overallocated') {l.eligible = '5000'; l.selected = '1400';} if (name === 'fractional') { Object.assign(l, {eligible: '2/3', originDeducted: '1/3', selected: '1/3', usesState: 'absent', uses: []}); c.b.creditCarry.currentInternational = '1/3'; } if (name === 'recoverable') {l.eligible = '2000'; l.selected = '1300'; c.b.creditCarry.currentPec = '0';} c.d.modelo_a_snapshot = saveAnnualBook(c.d, recordAnnual(c.d, c.b, '2026-10-28T12:00:00+02:00')); cases[name] = c.d; } fs.writeFileSync(new URL('../tests/frontend/fixtures/irpc-carry-preserved.json', import.meta.url), JSON.stringify({synthetic: true, actualBalances: false, cases})); console.log('Prepared six synthetic carry API cases with frozen international-credit history.');