summaryrefslogtreecommitdiff
path: root/src/cmd_sru.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd_sru.c')
-rw-r--r--src/cmd_sru.c50
1 files changed, 50 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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]
+};