diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-21 21:43:44 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-21 21:43:44 +0200 |
| commit | 62a92f0af0442c78277c3c97c9efe6fef8145625 (patch) | |
| tree | 3802a62904880da22bf84a44e9ece3cdff9cd8aa /src/sie.c | |
| parent | f1eeb15781a044a9451ee08b91c63feb395b4767 (diff) | |
| download | bokf-0.1.60.tar.gz bokf-0.1.60.zip | |
settings: per-feature voucher series and console invoice number; tui: F9 hintsv0.1.60
Diffstat (limited to 'src/sie.c')
| -rw-r--r-- | src/sie.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -8,6 +8,7 @@ #include <string.h> #include <time.h> +#include "db.h" #include "ledger.h" #include "log.h" #include "util.h" @@ -135,18 +136,22 @@ int sie_export_file(sqlite3 *db, int64_t org_id, int64_t fy_id, put_date(f, end); put(f, "\n"); - /* accounts and balances: IB = this year's series "IB" voucher(s) plus - all non-IB history before the year; UB = everything through the end; + /* accounts and balances: IB = this year's IB-series voucher(s) plus all + non-IB history before the year; UB = everything through the end; RES = the year's non-IB movements. */ + char ib_series[16]; + db_setting_copy(db, org_id, "series_ib", "IB", ib_series, + sizeof ib_series); if (sqlite3_prepare_v2( db, "SELECT a.number,a.name," - " COALESCE(SUM(CASE WHEN (v.series = 'IB'" + " COALESCE(SUM(CASE WHEN ((v.series = 'IB' OR v.series = ?5)" " AND v.fiscal_year_id = ?4) OR (v.series <> 'IB'" - " AND v.date < ?2) THEN r.debit_ore - r.credit_ore END),0)," + " AND v.series <> ?5 AND v.date < ?2)" + " THEN r.debit_ore - r.credit_ore END),0)," " COALESCE(SUM(CASE WHEN v.date <= ?3" " THEN r.debit_ore - r.credit_ore END),0)," - " COALESCE(SUM(CASE WHEN v.series <> 'IB'" + " COALESCE(SUM(CASE WHEN v.series <> 'IB' AND v.series <> ?5" " AND v.date >= ?2 AND v.date <= ?3" " THEN r.debit_ore - r.credit_ore END),0)" " FROM accounts a LEFT JOIN (voucher_rows r JOIN vouchers v" @@ -163,6 +168,7 @@ int sie_export_file(sqlite3 *db, int64_t org_id, int64_t fy_id, sqlite3_bind_text(st, 2, start, -1, SQLITE_TRANSIENT); sqlite3_bind_text(st, 3, end, -1, SQLITE_TRANSIENT); sqlite3_bind_int64(st, 4, fy_id); + sqlite3_bind_text(st, 5, ib_series, -1, SQLITE_TRANSIENT); while (sqlite3_step(st) == SQLITE_ROW) { const char *number = (const char *)sqlite3_column_text(st, 0); const char *name = (const char *)sqlite3_column_text(st, 1); |
