From 8351fa7752bb8341ef405a37ff7c73142715e981 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Sun, 20 Sep 2026 20:11:19 +0200 Subject: commands: split the command table by domain --- src/cmd_sru.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/cmd_sru.c (limited to 'src/cmd_sru.c') diff --git a/src/cmd_sru.c b/src/cmd_sru.c new file mode 100644 index 0000000..337ef69 --- /dev/null +++ b/src/cmd_sru.c @@ -0,0 +1,50 @@ +#include "commands.h" +#include "cmd_util.h" + +#include +#include +#include + +#include "db.h" +#include "sru.h" +#include "util.h" + +static yyjson_mut_val *h_sru_export(struct req *r) +{ + int64_t fy = 0; + if (req_fy(r, &fy) != 0) + return NULL; + char *err = NULL; + yyjson_mut_val *res = + sru_export(r->rdoc, r->db, r->org_id, fy, r->args, &err); + if (!res) { + yyjson_mut_val *e = + fail(r, "INVALID_ARGS", err ? err : "could not build the SRU files"); + free(err); + return e; + } + return res; +} + + +static const struct cmd_arg args_sru_export[] = { + { "fiscal_year", ARG_INT, 0, NULL, NULL, + "Fiscal year id; defaults to the latest" }, + { "adjustments", ARG_JSON, 0, NULL, NULL, + "Array of {code,amount_ore} tax adjustments" }, + { "submitter", ARG_JSON, 0, NULL, NULL, + "Object overriding the INFO.SRU submitter" }, + { "assisted", ARG_BOOL, 0, NULL, NULL, "Assisted declaration" }, + { "audited", ARG_BOOL, 0, NULL, NULL, "Audited declaration" }, + { "ignore_unmapped", ARG_BOOL, 0, "false", NULL, + "Proceed despite unmapped accounts" }, +}; + +const struct command g_cmd_sru[] = { + { "sru.export", "INK2 SRU files (INFO.SRU + BLANKETTER.SRU)", + PERM_READ, 1, 0, 0, h_sru_export, CMD_ARGS(args_sru_export) }, +}; + +const struct cmd_table g_cmd_table_sru = { + g_cmd_sru, sizeof g_cmd_sru / sizeof g_cmd_sru[0] +}; -- cgit v1.3