ci/woodpecker/pr/db Pipeline was successful
ci/woodpecker/pr/hledger Pipeline was successful
ci/woodpecker/pr/jobs Pipeline was successful
ci/woodpecker/pr/snapshots Pipeline was successful
ci/woodpecker/pr/web Pipeline was successful
ci/woodpecker/pr/worker Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/hledger Pipeline was successful
ci/woodpecker/push/jobs Pipeline was successful
ci/woodpecker/push/snapshots Pipeline was successful
ci/woodpecker/push/web Pipeline was successful
ci/woodpecker/push/worker Pipeline was successful
71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { journalMetadata } from './src/journal-stats.js';
|
|
import { planOverviewReports, type OverviewReports } from './src/overview/batch.js';
|
|
import { parseBalanceSheet } from './src/overview/balance-sheet.js';
|
|
import { parseIncomeStatement } from './src/overview/income-statement.js';
|
|
import { organizeOverviewData } from './src/overview/report.js';
|
|
import { planIncomeRanges } from './src/overview/ranges.js';
|
|
|
|
// Compose only pure production parsers/planners/organizers; never execute native jobs.
|
|
export function decodeOverviewFixture(
|
|
discoveryStats: string,
|
|
reports: { incomeStatements: string[]; snapshots: string[] },
|
|
transactionCounts: readonly number[] = [1, 3, 6, 12]
|
|
) {
|
|
const metadata = journalMetadata(discoveryStats);
|
|
const plan = planOverviewReports(metadata);
|
|
const overview: OverviewReports = {
|
|
...metadata,
|
|
incomeStatements: plan.incomeRanges.map((range, index) => ({
|
|
...range,
|
|
transactionCount: transactionCounts[index],
|
|
report: parseIncomeStatement(reports.incomeStatements[index])
|
|
})),
|
|
snapshots: plan.snapshotPeriods.map((period, index) => ({
|
|
...period,
|
|
report: parseBalanceSheet(reports.snapshots[index])
|
|
}))
|
|
};
|
|
return organizeOverviewData(overview);
|
|
}
|
|
|
|
// Owned native JSON documents shared by the dashboard adapter tests only.
|
|
export function balanceReports(asOf = '2026-04-16'): string[] {
|
|
const date = new Date(`${asOf}T00:00:00Z`);
|
|
date.setUTCDate(1);
|
|
date.setUTCMonth(date.getUTCMonth() - 11);
|
|
return Array.from({ length: 12 }, (_, index) => {
|
|
const begin = date.toISOString().slice(0, 10);
|
|
date.setUTCMonth(date.getUTCMonth() + 1);
|
|
const end = index === 11 ? new Date(`${asOf}T00:00:00Z`) : new Date(date);
|
|
if (index === 11) end.setUTCDate(end.getUTCDate() + 1);
|
|
const report = {
|
|
cbrDates: [
|
|
[begin, end.toISOString().slice(0, 10)].map((contents) => ({ tag: 'Exact', contents }))
|
|
],
|
|
cbrTotals: { prrAmounts: [[]] },
|
|
cbrSubreports: [
|
|
['Assets', { prTotals: { prrAmounts: [[]] } }, true],
|
|
['Liabilities', { prTotals: { prrAmounts: [[]] } }, false]
|
|
]
|
|
};
|
|
return JSON.stringify(report);
|
|
});
|
|
}
|
|
|
|
export function incomeReports(asOf = '2026-04-16'): string[] {
|
|
return planIncomeRanges(asOf).map((range) => {
|
|
const totals = () => ({ prrAmounts: range.periods.map(() => []), prrTotal: [] });
|
|
const report = {
|
|
cbrDates: range.periods.map(({ begin, endExclusive }) =>
|
|
[begin, endExclusive].map((contents) => ({ tag: 'Exact', contents }))
|
|
),
|
|
cbrTotals: { prrTotal: [] },
|
|
cbrSubreports: [
|
|
['Revenues', { prTotals: totals(), prRows: [] }, true],
|
|
['Expenses', { prTotals: totals(), prRows: [] }, false]
|
|
]
|
|
};
|
|
return JSON.stringify(report);
|
|
});
|
|
}
|