#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] };