fix: resolve critical SQL and display bugs across 5 financial reports

- Fix systemic LEFT JOIN date filter bug in Balance Sheet, Income Statement,
  and Cash Flow Statement by using parenthesized INNER JOIN pattern so
  SUM(jel.debit/credit) respects date parameters
- Add Current Year Net Income synthetic equity line to Balance Sheet to
  satisfy the accounting equation (A = L + E) during open fiscal periods
- Add investment_accounts balances to Balance Sheet assets and corresponding
  equity lines for reserve/operating investment holdings
- Fix Cash Flow Statement beginning/ending cash always showing $0 by
  replacing LIKE '%Cash%' filter with account_type = 'asset'
- Fix Year-End Package HTTP 500 by replacing broken invoices.vendor_id
  query with journal-entry-based vendor payment lookup
- Fix Quarterly Report defaulting to previous quarter instead of current
- Fix Quarterly Report date subtitle off-by-one day from UTC parsing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 14:15:01 -05:00
parent 3790a3bd9e
commit a0b366e94a
2 changed files with 105 additions and 31 deletions

View File

@@ -46,8 +46,8 @@ interface QuarterlyData {
export function QuarterlyReportPage() {
const now = new Date();
const currentQuarter = Math.ceil((now.getMonth() + 1) / 3);
const defaultQuarter = currentQuarter > 1 ? currentQuarter - 1 : 4;
const defaultYear = currentQuarter > 1 ? now.getFullYear() : now.getFullYear() - 1;
const defaultQuarter = currentQuarter;
const defaultYear = now.getFullYear();
const [year, setYear] = useState(String(defaultYear));
const [quarter, setQuarter] = useState(String(defaultQuarter));
@@ -102,7 +102,7 @@ export function QuarterlyReportPage() {
{data && (
<Text size="sm" c="dimmed">
{data.quarter_label} &middot; {new Date(data.date_range.from).toLocaleDateString()} {new Date(data.date_range.to).toLocaleDateString()}
{data.quarter_label} &middot; {new Date(data.date_range.from + 'T00:00:00').toLocaleDateString()} {new Date(data.date_range.to + 'T00:00:00').toLocaleDateString()}
</Text>
)}