#ifndef BOKF_REPORTS_H #define BOKF_REPORTS_H #include #include #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, int include_zero, char **err); yyjson_mut_val *report_income_statement(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, int64_t fy_id, const char *from, const char *to, char **err); yyjson_mut_val *report_balance_sheet(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, int64_t fy_id, const char *to, char **err); yyjson_mut_val *report_vat(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, const char *from, const char *to, char **err); yyjson_mut_val *report_general_ledger(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, int64_t fy_id, const char *from, const char *to, yyjson_val *accounts, char **err); yyjson_mut_val *report_voucher_list(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, int64_t fy_id, const char *series, char **err); yyjson_mut_val *report_vat_eskd(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, const char *from, const char *to, const char *upplysning, char **err); #endif