diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-22 19:52:19 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-22 19:52:19 +0200 |
| commit | 6e0e96cfc74b129950002456e21d401dd07e10fd (patch) | |
| tree | cce5c4b86150f6b28abe6d6d558b30d34e621be7 /src/reports.h | |
| parent | 4dee87e83257c81413b29ccb33989e4df109a61c (diff) | |
| download | bokf-6e0e96cfc74b129950002456e21d401dd07e10fd.tar.gz bokf-6e0e96cfc74b129950002456e21d401dd07e10fd.zip | |
reports, sie: carry earlier IB vouchers, restart P&L at year start
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/reports.h')
| -rw-r--r-- | src/reports.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/reports.h b/src/reports.h index c4a6e4e..82c29e5 100644 --- a/src/reports.h +++ b/src/reports.h @@ -6,6 +6,21 @@ #include "yyjson.h" +/* SQL condition: voucher row `r` of voucher `v` on account `a` belongs to the + opening balance of fiscal year ?4 (org ?1) for a period starting ?2; ?5 is + the configured IB series. Balance accounts carry all earlier history, + including earlier years' IB vouchers; P&L accounts restart at the year + start, so only this year's IB vouchers and movements before ?2 count. */ +#define REPORT_IB_ROW_SQL \ + "((v.series = 'IB' OR v.series = ?5) AND (v.fiscal_year_id = ?4" \ + " OR (v.date < (SELECT f.start_date FROM fiscal_years f" \ + " WHERE f.org_id = ?1 AND f.id = ?4)" \ + " AND a.type NOT IN ('revenue','expense'))))" \ + " OR (v.series <> 'IB' AND v.series <> ?5 AND v.date < ?2" \ + " AND (a.type NOT IN ('revenue','expense') OR v.date >=" \ + " (SELECT f.start_date FROM fiscal_years f" \ + " WHERE f.org_id = ?1 AND f.id = ?4)))" + yyjson_mut_val *report_trial_balance(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, int64_t fy_id, const char *from, const char *to, |
