fizko-cli 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -0
- package/dist/index.js +1561 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1561 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
|
|
29
|
+
// src/config.ts
|
|
30
|
+
var import_fs = __toESM(require("fs"));
|
|
31
|
+
var import_os = __toESM(require("os"));
|
|
32
|
+
var import_path = __toESM(require("path"));
|
|
33
|
+
function configDir() {
|
|
34
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
35
|
+
const base = xdg ? xdg : import_path.default.join(import_os.default.homedir(), ".config");
|
|
36
|
+
const dir = import_path.default.join(base, "fizko");
|
|
37
|
+
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
38
|
+
return dir;
|
|
39
|
+
}
|
|
40
|
+
function configPath() {
|
|
41
|
+
return import_path.default.join(configDir(), "credentials.json");
|
|
42
|
+
}
|
|
43
|
+
function save(creds) {
|
|
44
|
+
const p = configPath();
|
|
45
|
+
import_fs.default.writeFileSync(p, JSON.stringify(creds, null, 2), { encoding: "utf8", mode: 384 });
|
|
46
|
+
return p;
|
|
47
|
+
}
|
|
48
|
+
function load() {
|
|
49
|
+
const p = configPath();
|
|
50
|
+
if (!import_fs.default.existsSync(p)) return null;
|
|
51
|
+
try {
|
|
52
|
+
return JSON.parse(import_fs.default.readFileSync(p, "utf8"));
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function clear() {
|
|
58
|
+
const p = configPath();
|
|
59
|
+
if (import_fs.default.existsSync(p)) import_fs.default.unlinkSync(p);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/client.ts
|
|
63
|
+
var DEFAULT_BASE_URL = "https://api.fizko.ai";
|
|
64
|
+
var compact = false;
|
|
65
|
+
function setCompact(value) {
|
|
66
|
+
compact = value;
|
|
67
|
+
}
|
|
68
|
+
function getCredentials() {
|
|
69
|
+
const envKey = process.env.FIZKO_API_KEY ?? "";
|
|
70
|
+
const envUrl = process.env.FIZKO_API_URL ?? "";
|
|
71
|
+
if (envKey) {
|
|
72
|
+
return { apiKey: envKey, baseUrl: (envUrl || DEFAULT_BASE_URL).replace(/\/$/, "") };
|
|
73
|
+
}
|
|
74
|
+
const saved = load();
|
|
75
|
+
if (saved?.api_key) {
|
|
76
|
+
const url = envUrl || saved.base_url || DEFAULT_BASE_URL;
|
|
77
|
+
return { apiKey: saved.api_key, baseUrl: url.replace(/\/$/, "") };
|
|
78
|
+
}
|
|
79
|
+
process.stderr.write(JSON.stringify({ error: "Not authenticated. Run: fizko login" }) + "\n");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
function handleError(status, body) {
|
|
83
|
+
let err;
|
|
84
|
+
try {
|
|
85
|
+
err = JSON.parse(body);
|
|
86
|
+
} catch {
|
|
87
|
+
err = { error: body, status_code: status };
|
|
88
|
+
}
|
|
89
|
+
process.stderr.write(JSON.stringify(err) + "\n");
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
function buildUrl(base, path2, params) {
|
|
93
|
+
const url = new URL(`${base}${path2}`);
|
|
94
|
+
if (params) {
|
|
95
|
+
for (const [k, v] of Object.entries(params)) {
|
|
96
|
+
if (v !== void 0 && v !== null) url.searchParams.set(k, String(v));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return url.toString();
|
|
100
|
+
}
|
|
101
|
+
async function get(path2, params) {
|
|
102
|
+
const { apiKey, baseUrl } = getCredentials();
|
|
103
|
+
const url = buildUrl(baseUrl, path2, params);
|
|
104
|
+
const res = await fetch(url, { headers: { "X-API-Key": apiKey } });
|
|
105
|
+
const text = await res.text();
|
|
106
|
+
if (res.status >= 400) handleError(res.status, text);
|
|
107
|
+
return JSON.parse(text);
|
|
108
|
+
}
|
|
109
|
+
async function post(path2, data, overrideKey, overrideUrl) {
|
|
110
|
+
let apiKey;
|
|
111
|
+
let baseUrl;
|
|
112
|
+
if (overrideKey) {
|
|
113
|
+
apiKey = overrideKey;
|
|
114
|
+
baseUrl = (overrideUrl ?? process.env.FIZKO_API_URL ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
115
|
+
} else {
|
|
116
|
+
({ apiKey, baseUrl } = getCredentials());
|
|
117
|
+
}
|
|
118
|
+
const url = `${baseUrl}${path2}`;
|
|
119
|
+
const headers = { "Content-Type": "application/json" };
|
|
120
|
+
if (apiKey) headers["X-API-Key"] = apiKey;
|
|
121
|
+
const res = await fetch(url, { method: "POST", headers, body: JSON.stringify(data ?? {}) });
|
|
122
|
+
const text = await res.text();
|
|
123
|
+
if (res.status >= 400) handleError(res.status, text);
|
|
124
|
+
if (res.status === 204) return { status: "deleted" };
|
|
125
|
+
try {
|
|
126
|
+
return JSON.parse(text);
|
|
127
|
+
} catch {
|
|
128
|
+
return { status: "ok" };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function patch(path2, data) {
|
|
132
|
+
const { apiKey, baseUrl } = getCredentials();
|
|
133
|
+
const url = `${baseUrl}${path2}`;
|
|
134
|
+
const res = await fetch(url, {
|
|
135
|
+
method: "PATCH",
|
|
136
|
+
headers: { "Content-Type": "application/json", "X-API-Key": apiKey },
|
|
137
|
+
body: JSON.stringify(data ?? {})
|
|
138
|
+
});
|
|
139
|
+
const text = await res.text();
|
|
140
|
+
if (res.status >= 400) handleError(res.status, text);
|
|
141
|
+
try {
|
|
142
|
+
return JSON.parse(text);
|
|
143
|
+
} catch {
|
|
144
|
+
return { status: "ok" };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function rawGet(url, params) {
|
|
148
|
+
const fullUrl = buildUrl(url, "", params).replace(/\/$/, "") || url;
|
|
149
|
+
const u = new URL(url);
|
|
150
|
+
if (params) {
|
|
151
|
+
for (const [k, v] of Object.entries(params)) {
|
|
152
|
+
if (v !== void 0 && v !== null) u.searchParams.set(k, String(v));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const res = await fetch(u.toString());
|
|
156
|
+
const text = await res.text();
|
|
157
|
+
if (res.status >= 400) handleError(res.status, text);
|
|
158
|
+
return JSON.parse(text);
|
|
159
|
+
}
|
|
160
|
+
async function rawPost(url, data) {
|
|
161
|
+
const res = await fetch(url, {
|
|
162
|
+
method: "POST",
|
|
163
|
+
headers: { "Content-Type": "application/json" },
|
|
164
|
+
body: JSON.stringify(data ?? {})
|
|
165
|
+
});
|
|
166
|
+
const text = await res.text();
|
|
167
|
+
if (res.status >= 400) handleError(res.status, text);
|
|
168
|
+
return JSON.parse(text);
|
|
169
|
+
}
|
|
170
|
+
function output(data) {
|
|
171
|
+
console.log(JSON.stringify(data, null, compact ? void 0 : 2));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/commands/auth.ts
|
|
175
|
+
var DEFAULT_BASE_URL2 = "https://api.fizko.ai";
|
|
176
|
+
var DEFAULT_WEB_URL = "https://admin.fizko.ai";
|
|
177
|
+
function registerAuth(program2) {
|
|
178
|
+
program2.command("login").description("Iniciar sesi\xF3n con tu cuenta Fizko.").option("--api-url <url>", "URL de la API", process.env.FIZKO_API_URL ?? DEFAULT_BASE_URL2).option("--web-url <url>", "URL del dashboard", process.env.FIZKO_WEB_URL ?? DEFAULT_WEB_URL).option("--no-browser", "No abrir el navegador autom\xE1ticamente").action(async (opts) => {
|
|
179
|
+
const baseUrl = opts.apiUrl.replace(/\/$/, "");
|
|
180
|
+
const dashboardUrl = opts.webUrl.replace(/\/$/, "");
|
|
181
|
+
const saved = load();
|
|
182
|
+
if (saved?.api_key) {
|
|
183
|
+
process.stderr.write(`Ya autenticado como ${saved.email}.
|
|
184
|
+
`);
|
|
185
|
+
process.stderr.write("Usa 'fizko logout' para cerrar sesi\xF3n primero.\n");
|
|
186
|
+
process.exit(0);
|
|
187
|
+
}
|
|
188
|
+
process.stderr.write("Iniciando autenticaci\xF3n...\n\n");
|
|
189
|
+
const resp = await rawPost(`${baseUrl}/api/auth/cli/initiate`);
|
|
190
|
+
const deviceCode = resp.device_code;
|
|
191
|
+
const userCode = resp.user_code;
|
|
192
|
+
const pollInterval = (resp.poll_interval ?? 2) * 1e3;
|
|
193
|
+
const expiresIn = (resp.expires_in ?? 600) * 1e3;
|
|
194
|
+
const authUrl = `${dashboardUrl}/cli-auth?code=${userCode}`;
|
|
195
|
+
process.stderr.write(`Tu c\xF3digo de verificaci\xF3n: ${userCode}
|
|
196
|
+
|
|
197
|
+
`);
|
|
198
|
+
process.stderr.write(`Abre este link en tu navegador: ${authUrl}
|
|
199
|
+
|
|
200
|
+
`);
|
|
201
|
+
if (opts.browser !== false) {
|
|
202
|
+
const { execSync } = await import("child_process");
|
|
203
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
204
|
+
try {
|
|
205
|
+
execSync(`${cmd} "${authUrl}"`);
|
|
206
|
+
} catch {
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
process.stderr.write("Esperando autorizaci\xF3n");
|
|
210
|
+
const deadline = Date.now() + expiresIn;
|
|
211
|
+
while (Date.now() < deadline) {
|
|
212
|
+
await new Promise((r) => setTimeout(r, pollInterval));
|
|
213
|
+
const poll = await rawGet(`${baseUrl}/api/auth/cli/poll`, { device_code: deviceCode });
|
|
214
|
+
if (poll.status === "authorized") {
|
|
215
|
+
const apiKey = poll.api_key;
|
|
216
|
+
const email = poll.user_email ?? "";
|
|
217
|
+
const path2 = save({ api_key: apiKey, email, base_url: baseUrl });
|
|
218
|
+
process.stderr.write(`
|
|
219
|
+
|
|
220
|
+
Autenticado como ${email}
|
|
221
|
+
`);
|
|
222
|
+
process.stderr.write(`Credenciales guardadas en ${path2}
|
|
223
|
+
`);
|
|
224
|
+
process.exit(0);
|
|
225
|
+
}
|
|
226
|
+
if (poll.status === "expired") {
|
|
227
|
+
process.stderr.write("\n\nC\xF3digo expirado. Intenta de nuevo con: fizko login\n");
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
process.stderr.write(".");
|
|
231
|
+
}
|
|
232
|
+
process.stderr.write("\n\nTiempo agotado. Intenta de nuevo con: fizko login\n");
|
|
233
|
+
process.exit(1);
|
|
234
|
+
});
|
|
235
|
+
program2.command("logout").description("Cerrar sesi\xF3n y eliminar credenciales guardadas.").action(() => {
|
|
236
|
+
const saved = load();
|
|
237
|
+
if (!saved) {
|
|
238
|
+
process.stderr.write("No hay sesi\xF3n activa.\n");
|
|
239
|
+
process.exit(0);
|
|
240
|
+
}
|
|
241
|
+
clear();
|
|
242
|
+
process.stderr.write(`Sesi\xF3n de ${saved.email} cerrada.
|
|
243
|
+
`);
|
|
244
|
+
});
|
|
245
|
+
program2.command("status").description("Mostrar estado de autenticaci\xF3n.").action(() => {
|
|
246
|
+
const envKey = process.env.FIZKO_API_KEY;
|
|
247
|
+
const saved = load();
|
|
248
|
+
if (envKey) {
|
|
249
|
+
process.stderr.write("Autenticado via FIZKO_API_KEY (env var)\n");
|
|
250
|
+
} else if (saved?.api_key) {
|
|
251
|
+
process.stderr.write(`Autenticado como ${saved.email}
|
|
252
|
+
`);
|
|
253
|
+
process.stderr.write(`API: ${saved.base_url ?? DEFAULT_BASE_URL}
|
|
254
|
+
`);
|
|
255
|
+
} else {
|
|
256
|
+
process.stderr.write("No autenticado. Ejecuta: fizko login\n");
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/commands/companies.ts
|
|
262
|
+
function registerCompanies(program2) {
|
|
263
|
+
const cmd = program2.command("companies").description("Listar y consultar empresas.");
|
|
264
|
+
cmd.command("list").description("Listar empresas del usuario.").option("--page <n>", "N\xFAmero de p\xE1gina", (v) => parseInt(v)).action(async (opts) => {
|
|
265
|
+
output(await get("/api/companies", { page: opts.page }));
|
|
266
|
+
});
|
|
267
|
+
cmd.command("get <company_id>").description("Obtener detalle de una empresa.").action(async (companyId) => {
|
|
268
|
+
output(await get(`/api/companies/${companyId}`));
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// src/commands/tax.ts
|
|
273
|
+
function registerTax(program2) {
|
|
274
|
+
const cmd = program2.command("tax").description("Documentos tributarios, F29, res\xFAmenes e indicadores.");
|
|
275
|
+
cmd.command("purchases").description("Listar documentos de compra.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period-year <n>", "A\xF1o (ej: 2026)", (v) => parseInt(v)).option("--period-month <n>", "Mes (1-12)", (v) => parseInt(v)).option("--document-type <type>", "Tipo de documento (ej: 33, 34)").option("--page <n>", "N\xFAmero de p\xE1gina", (v) => parseInt(v)).action(async (opts) => {
|
|
276
|
+
output(await get("/api/tax/purchases", {
|
|
277
|
+
company: opts.company,
|
|
278
|
+
period_year: opts.periodYear,
|
|
279
|
+
period_month: opts.periodMonth,
|
|
280
|
+
document_type: opts.documentType,
|
|
281
|
+
page: opts.page
|
|
282
|
+
}));
|
|
283
|
+
});
|
|
284
|
+
cmd.command("purchase <purchase_id>").description("Obtener detalle de un documento de compra.").action(async (id) => {
|
|
285
|
+
output(await get(`/api/tax/purchases/${id}`));
|
|
286
|
+
});
|
|
287
|
+
cmd.command("sales").description("Listar documentos de venta.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period-year <n>", "A\xF1o (ej: 2026)", (v) => parseInt(v)).option("--period-month <n>", "Mes (1-12)", (v) => parseInt(v)).option("--document-type <type>", "Tipo de documento").option("--page <n>", "N\xFAmero de p\xE1gina", (v) => parseInt(v)).action(async (opts) => {
|
|
288
|
+
output(await get("/api/tax/sales", {
|
|
289
|
+
company: opts.company,
|
|
290
|
+
period_year: opts.periodYear,
|
|
291
|
+
period_month: opts.periodMonth,
|
|
292
|
+
document_type: opts.documentType,
|
|
293
|
+
page: opts.page
|
|
294
|
+
}));
|
|
295
|
+
});
|
|
296
|
+
cmd.command("sale <sale_id>").description("Obtener detalle de un documento de venta.").action(async (id) => {
|
|
297
|
+
output(await get(`/api/tax/sales/${id}`));
|
|
298
|
+
});
|
|
299
|
+
cmd.command("contacts").description("Listar contactos tributarios (proveedores/clientes).").requiredOption("--company <uuid>", "UUID de la empresa").option("--page <n>", "N\xFAmero de p\xE1gina", (v) => parseInt(v)).action(async (opts) => {
|
|
300
|
+
output(await get("/api/tax/contacts", { company: opts.company, page: opts.page }));
|
|
301
|
+
});
|
|
302
|
+
cmd.command("documents").description("Listar todos los documentos tributarios (compras + ventas + honorarios).").requiredOption("--company <uuid>", "UUID de la empresa").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").option("--start-date <date>", "Fecha inicio YYYY-MM-DD").option("--end-date <date>", "Fecha fin YYYY-MM-DD").option("--limit <n>", "Documentos por p\xE1gina", (v) => parseInt(v)).option("--offset <n>", "Offset de paginaci\xF3n", (v) => parseInt(v)).action(async (opts) => {
|
|
303
|
+
output(await get("/api/tax/documents", {
|
|
304
|
+
company_id: opts.company,
|
|
305
|
+
period: opts.period,
|
|
306
|
+
start_date: opts.startDate,
|
|
307
|
+
end_date: opts.endDate,
|
|
308
|
+
limit: opts.limit,
|
|
309
|
+
offset: opts.offset
|
|
310
|
+
}));
|
|
311
|
+
});
|
|
312
|
+
cmd.command("document <document_id>").description("Obtener detalle de un documento tributario.").action(async (id) => {
|
|
313
|
+
output(await get(`/api/tax/documents/${id}`));
|
|
314
|
+
});
|
|
315
|
+
cmd.command("documents-summary").description("Resumen de transacciones por tipo de documento (\xFAltimos 3 meses).").requiredOption("--company <uuid>", "UUID de la empresa").action(async (opts) => {
|
|
316
|
+
output(await get("/api/tax/documents/summary", { company_id: opts.company }));
|
|
317
|
+
});
|
|
318
|
+
cmd.command("f29").description("Listar declaraciones F29 agrupadas por per\xEDodo.").requiredOption("--company <uuid>", "UUID de la empresa").option("--year <n>", "A\xF1o", (v) => parseInt(v)).option("--page <n>", "N\xFAmero de p\xE1gina", (v) => parseInt(v)).action(async (opts) => {
|
|
319
|
+
output(await get("/api/tax/form29", {
|
|
320
|
+
company_id: opts.company,
|
|
321
|
+
year: opts.year,
|
|
322
|
+
page: opts.page
|
|
323
|
+
}));
|
|
324
|
+
});
|
|
325
|
+
cmd.command("f29-export").description("Exportar documentos de un c\xF3digo F29 espec\xEDfico.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--code <code>", "C\xF3digo F29 a exportar").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
326
|
+
output(await get("/api/tax/f29/export-csv", {
|
|
327
|
+
company_id: opts.company,
|
|
328
|
+
code: opts.code,
|
|
329
|
+
period: opts.period
|
|
330
|
+
}));
|
|
331
|
+
});
|
|
332
|
+
cmd.command("f29-codes").description("Listar c\xF3digos F29 exportables para un per\xEDodo.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
333
|
+
output(await get("/api/tax/f29/exportable-codes", {
|
|
334
|
+
company_id: opts.company,
|
|
335
|
+
period: opts.period
|
|
336
|
+
}));
|
|
337
|
+
});
|
|
338
|
+
cmd.command("summary").description("Resumen tributario para un per\xEDodo (desde F29).").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
339
|
+
output(await get("/api/tax/summary", { company_id: opts.company, period: opts.period }));
|
|
340
|
+
});
|
|
341
|
+
cmd.command("iva").description("Resumen de IVA para un per\xEDodo.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
342
|
+
output(await get("/api/tax/summary/iva", { company_id: opts.company, period: opts.period }));
|
|
343
|
+
});
|
|
344
|
+
cmd.command("timeline").description("L\xEDnea de tiempo tributaria (\xFAltimos 12 meses).").requiredOption("--company <uuid>", "UUID de la empresa").action(async (opts) => {
|
|
345
|
+
output(await get("/api/tax/summary/timeline", { company_id: opts.company }));
|
|
346
|
+
});
|
|
347
|
+
cmd.command("honorarios").description("Listar boletas de honorarios.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period-year <n>", "A\xF1o", (v) => parseInt(v)).option("--period-month <n>", "Mes (1-12)", (v) => parseInt(v)).action(async (opts) => {
|
|
348
|
+
output(await get("/api/tax/honorarios", {
|
|
349
|
+
company: opts.company,
|
|
350
|
+
period_year: opts.periodYear,
|
|
351
|
+
period_month: opts.periodMonth
|
|
352
|
+
}));
|
|
353
|
+
});
|
|
354
|
+
cmd.command("ddjj").description("Listar declaraciones juradas.").requiredOption("--company <uuid>", "UUID de la empresa").option("--year <n>", "A\xF1o tributario", (v) => parseInt(v)).action(async (opts) => {
|
|
355
|
+
output(await get("/api/tax/ddjj", { company_id: opts.company, year: opts.year }));
|
|
356
|
+
});
|
|
357
|
+
cmd.command("checker-tributario").description("Comparar libro SII vs documentos contabilizados en Fizko.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
358
|
+
output(await get("/api/tax/checker-tributario", {
|
|
359
|
+
company_id: opts.company,
|
|
360
|
+
period: opts.period
|
|
361
|
+
}));
|
|
362
|
+
});
|
|
363
|
+
cmd.command("checker-impuestos").description("Comparar impuestos declarados en F29 vs contabilizados en Fizko.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
364
|
+
output(await get("/api/tax/checker-impuestos-mensuales", {
|
|
365
|
+
company_id: opts.company,
|
|
366
|
+
period: opts.period
|
|
367
|
+
}));
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// src/commands/accounting.ts
|
|
372
|
+
function registerAccounting(program2) {
|
|
373
|
+
const cmd = program2.command("accounting").description("Contabilidad: plan de cuentas, asientos, reportes, obligaciones.");
|
|
374
|
+
cmd.command("accounts").description("Listar plan de cuentas.").requiredOption("--company <uuid>", "UUID de la empresa").option("--tree", "Devolver en estructura de \xE1rbol").action(async (opts) => {
|
|
375
|
+
const params = { company: opts.company };
|
|
376
|
+
if (opts.tree) params["tree"] = "1";
|
|
377
|
+
output(await get("/api/accounting/accounts", params));
|
|
378
|
+
});
|
|
379
|
+
cmd.command("journal-entries").description("Listar asientos contables.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").option("--limit <n>", "L\xEDmite de resultados", (v) => parseInt(v)).option("--offset <n>", "Offset de paginaci\xF3n", (v) => parseInt(v)).action(async (opts) => {
|
|
380
|
+
output(await get("/api/accounting/journal-entries", {
|
|
381
|
+
company: opts.company,
|
|
382
|
+
period: opts.period,
|
|
383
|
+
limit: opts.limit,
|
|
384
|
+
offset: opts.offset
|
|
385
|
+
}));
|
|
386
|
+
});
|
|
387
|
+
cmd.command("journal-entry <entry_id>").description("Obtener detalle de un asiento contable.").action(async (id) => {
|
|
388
|
+
output(await get(`/api/accounting/journal-entries/${id}`));
|
|
389
|
+
});
|
|
390
|
+
cmd.command("balance-report").description("Balance de 8 columnas.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period-from <yyyy-mm>", "Per\xEDodo inicio YYYY-MM").requiredOption("--period-to <yyyy-mm>", "Per\xEDodo fin YYYY-MM").option("--cost-center-id <uuid>", "UUID centro de costo").action(async (opts) => {
|
|
391
|
+
output(await get("/api/accounting/balance-report", {
|
|
392
|
+
company_id: opts.company,
|
|
393
|
+
period_from: opts.periodFrom,
|
|
394
|
+
period_to: opts.periodTo,
|
|
395
|
+
cost_center_id: opts.costCenterId
|
|
396
|
+
}));
|
|
397
|
+
});
|
|
398
|
+
cmd.command("income-statement").description("Estado de resultados (EERR).").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period-from <yyyy-mm>", "Per\xEDodo inicio YYYY-MM").requiredOption("--period-to <yyyy-mm>", "Per\xEDodo fin YYYY-MM").option("--cost-center-id <uuid>", "UUID centro de costo").action(async (opts) => {
|
|
399
|
+
output(await get("/api/accounting/reports/income-statement", {
|
|
400
|
+
company_id: opts.company,
|
|
401
|
+
period_from: opts.periodFrom,
|
|
402
|
+
period_to: opts.periodTo,
|
|
403
|
+
cost_center_id: opts.costCenterId
|
|
404
|
+
}));
|
|
405
|
+
});
|
|
406
|
+
cmd.command("general-journal").description("Libro diario.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").option("--page <n>", "N\xFAmero de p\xE1gina", (v) => parseInt(v)).option("--page-size <n>", "Tama\xF1o de p\xE1gina", (v) => parseInt(v)).action(async (opts) => {
|
|
407
|
+
output(await get("/api/accounting/reports/general-journal", {
|
|
408
|
+
company_id: opts.company,
|
|
409
|
+
period: opts.period,
|
|
410
|
+
page: opts.page,
|
|
411
|
+
page_size: opts.pageSize
|
|
412
|
+
}));
|
|
413
|
+
});
|
|
414
|
+
cmd.command("general-ledger").description("Libro mayor.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period-from <yyyy-mm>", "Per\xEDodo inicio YYYY-MM").requiredOption("--period-to <yyyy-mm>", "Per\xEDodo fin YYYY-MM").option("--account-id <uuid>", "UUID de cuenta espec\xEDfica").action(async (opts) => {
|
|
415
|
+
output(await get("/api/accounting/reports/general-ledger", {
|
|
416
|
+
company_id: opts.company,
|
|
417
|
+
period_from: opts.periodFrom,
|
|
418
|
+
period_to: opts.periodTo,
|
|
419
|
+
account_id: opts.accountId
|
|
420
|
+
}));
|
|
421
|
+
});
|
|
422
|
+
cmd.command("classified-balance").description("Balance clasificado.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").option("--period-from <yyyy-mm>", "Per\xEDodo inicio YYYY-MM").option("--period-to <yyyy-mm>", "Per\xEDodo fin YYYY-MM").option("--cost-center-id <uuid>", "UUID centro de costo").action(async (opts) => {
|
|
423
|
+
output(await get("/api/accounting/reports/classified-balance", {
|
|
424
|
+
company_id: opts.company,
|
|
425
|
+
period: opts.period,
|
|
426
|
+
period_from: opts.periodFrom,
|
|
427
|
+
period_to: opts.periodTo,
|
|
428
|
+
cost_center_id: opts.costCenterId
|
|
429
|
+
}));
|
|
430
|
+
});
|
|
431
|
+
cmd.command("rli-balance").description("Balance RLI (Renta L\xEDquida Imponible).").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--period-from <yyyy-mm>", "Per\xEDodo inicio YYYY-MM").requiredOption("--period-to <yyyy-mm>", "Per\xEDodo fin YYYY-MM").action(async (opts) => {
|
|
432
|
+
output(await get("/api/accounting/reports/rli-balance", {
|
|
433
|
+
company_id: opts.company,
|
|
434
|
+
period_from: opts.periodFrom,
|
|
435
|
+
period_to: opts.periodTo
|
|
436
|
+
}));
|
|
437
|
+
});
|
|
438
|
+
cmd.command("progress").description("Avance contable de la empresa.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
439
|
+
output(await get("/api/accounting/progress", {
|
|
440
|
+
company_id: opts.company,
|
|
441
|
+
period: opts.period
|
|
442
|
+
}));
|
|
443
|
+
});
|
|
444
|
+
cmd.command("obligations").description("Listar obligaciones contables (cuentas por pagar/cobrar).").requiredOption("--company <uuid>", "UUID de la empresa").option("--obligation-type <type>", "Tipo: payable o receivable").option("--status <status>", "Estado: pending, partial, paid, overdue").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").option("--limit <n>", "L\xEDmite de resultados", (v) => parseInt(v), 30).option("--offset <n>", "Offset de paginaci\xF3n", (v) => parseInt(v), 0).action(async (opts) => {
|
|
445
|
+
output(await get("/api/accounting/obligations/", {
|
|
446
|
+
company: opts.company,
|
|
447
|
+
obligation_type: opts.obligationType,
|
|
448
|
+
status: opts.status,
|
|
449
|
+
period: opts.period,
|
|
450
|
+
limit: opts.limit,
|
|
451
|
+
offset: opts.offset
|
|
452
|
+
}));
|
|
453
|
+
});
|
|
454
|
+
cmd.command("obligation <obligation_id>").description("Obtener detalle de una obligaci\xF3n.").action(async (id) => {
|
|
455
|
+
output(await get(`/api/accounting/obligations/${id}/`));
|
|
456
|
+
});
|
|
457
|
+
cmd.command("contabilizar <obligation_id>").description("Contabilizar una obligaci\xF3n. Sin --lines, auto-genera el asiento.").option("--lines <json>", 'L\xEDneas del asiento JSON: [{"account_code":"5101","debit":1000,"credit":0}]').option("--account-code <code>", "C\xF3digo de cuenta (modo legacy)").option("--description <text>", "Descripci\xF3n del asiento").action(async (id, opts) => {
|
|
458
|
+
const body = {};
|
|
459
|
+
if (opts.lines) body["lines"] = JSON.parse(opts.lines);
|
|
460
|
+
if (opts.accountCode) body["account_code"] = opts.accountCode;
|
|
461
|
+
if (opts.description) body["description"] = opts.description;
|
|
462
|
+
output(await post(`/api/accounting/obligations/${id}/contabilizar/`, body));
|
|
463
|
+
});
|
|
464
|
+
cmd.command("descontabilizar <obligation_id>").description("Eliminar el asiento contable de una obligaci\xF3n.").action(async (id) => {
|
|
465
|
+
output(await post(`/api/accounting/obligations/${id}/descontabilizar/`));
|
|
466
|
+
});
|
|
467
|
+
cmd.command("abonar <obligation_id>").description("Registrar un pago (abono) en una obligaci\xF3n.").requiredOption("--amount <n>", "Monto del abono", parseFloat).requiredOption("--payment-type <type>", "Tipo: cash, check, third_party, international, factoring, bad_debt").option("--notes <text>", "Notas opcionales", "").option("--no-contabilizar", "No auto-contabilizar el pago").action(async (id, opts) => {
|
|
468
|
+
output(await post(`/api/accounting/obligations/${id}/abonar/`, {
|
|
469
|
+
amount: opts.amount,
|
|
470
|
+
payment_type: opts.paymentType,
|
|
471
|
+
notes: opts.notes,
|
|
472
|
+
contabilizar: opts.contabilizar !== false
|
|
473
|
+
}));
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// src/commands/banking.ts
|
|
478
|
+
function registerBanking(program2) {
|
|
479
|
+
const cmd = program2.command("banking").description("Movimientos bancarios, clasificaci\xF3n y conciliaci\xF3n.");
|
|
480
|
+
cmd.command("movements").description("Listar movimientos bancarios.").requiredOption("--company <uuid>", "UUID de la empresa").option("--status <status>", "Estado: pending, reconciled, matched, split").option("--classification <text>", "Filtrar por clasificaci\xF3n").option("--period <yyyy-mm>", "Filtrar por mes (prefijo YYYY-MM)").option("--limit <n>", "L\xEDmite de resultados", (v) => parseInt(v), 30).option("--offset <n>", "Offset de paginaci\xF3n", (v) => parseInt(v), 0).action(async (opts) => {
|
|
481
|
+
const params = {
|
|
482
|
+
company: opts.company,
|
|
483
|
+
status: opts.status,
|
|
484
|
+
limit: opts.limit,
|
|
485
|
+
offset: opts.offset
|
|
486
|
+
};
|
|
487
|
+
if (opts.classification) params["classification__icontains"] = opts.classification;
|
|
488
|
+
if (opts.period) params["date__gte"] = `${opts.period}-01`;
|
|
489
|
+
output(await get("/api/accounting/bank-movements/", params));
|
|
490
|
+
});
|
|
491
|
+
cmd.command("movement <movement_id>").description("Obtener detalle de un movimiento bancario.").action(async (id) => {
|
|
492
|
+
output(await get(`/api/accounting/bank-movements/${id}/`));
|
|
493
|
+
});
|
|
494
|
+
cmd.command("classify <movement_id>").description("Clasificar un movimiento bancario.").requiredOption("--classification <text>", "Clasificaci\xF3n (ej: 'Gasto Operacional')").option("--document-type <type>", "Tipo documento (ej: 'Factura')").option("--comment <text>", "Comentario").action(async (id, opts) => {
|
|
495
|
+
const body = { classification: opts.classification };
|
|
496
|
+
if (opts.documentType) body["document_type"] = opts.documentType;
|
|
497
|
+
if (opts.comment) body["comment"] = opts.comment;
|
|
498
|
+
output(await patch(`/api/accounting/bank-movements/${id}/classify/`, body));
|
|
499
|
+
});
|
|
500
|
+
cmd.command("contabilizar <movement_id>").description("Crear asiento contable para un movimiento bancario.").requiredOption("--account-code <code>", "C\xF3digo de cuenta contrapartida (ej: '5101')").option("--description <text>", "Descripci\xF3n del asiento").action(async (id, opts) => {
|
|
501
|
+
const body = { account_code: opts.accountCode };
|
|
502
|
+
if (opts.description) body["description"] = opts.description;
|
|
503
|
+
output(await post(`/api/accounting/bank-movements/${id}/contabilizar/`, body));
|
|
504
|
+
});
|
|
505
|
+
cmd.command("contabilizar-reconciliaciones <movement_id>").description("Crear un asiento por cada reconciliaci\xF3n del movimiento.").requiredOption(
|
|
506
|
+
"--entries <json>",
|
|
507
|
+
'Array JSON: [{"reconciliation_id":"UUID","lines":[{"account_code":"5101","debit":1000,"credit":0}],"description":"opcional"}]'
|
|
508
|
+
).action(async (id, opts) => {
|
|
509
|
+
output(await post(
|
|
510
|
+
`/api/accounting/bank-movements/${id}/contabilizar-reconciliaciones/`,
|
|
511
|
+
{ entries: JSON.parse(opts.entries) }
|
|
512
|
+
));
|
|
513
|
+
});
|
|
514
|
+
cmd.command("descontabilizar <movement_id>").description("Eliminar el asiento contable de un movimiento bancario.").action(async (id) => {
|
|
515
|
+
output(await post(`/api/accounting/bank-movements/${id}/descontabilizar/`, {}));
|
|
516
|
+
});
|
|
517
|
+
cmd.command("reconcile").description("Conciliar un movimiento con una obligaci\xF3n.").requiredOption("--movement-id <uuid>", "UUID del movimiento bancario").requiredOption("--obligation-id <uuid>", "UUID de la obligaci\xF3n").option("--amount <n>", "Monto (auto-detecta si no se proporciona)", parseFloat).option("--notes <text>", "Notas", "").action(async (opts) => {
|
|
518
|
+
const body = {
|
|
519
|
+
movement_id: opts.movementId,
|
|
520
|
+
obligation_id: opts.obligationId,
|
|
521
|
+
notes: opts.notes
|
|
522
|
+
};
|
|
523
|
+
if (opts.amount !== void 0) body["amount"] = opts.amount;
|
|
524
|
+
output(await post("/api/accounting/reconciliation/match", body));
|
|
525
|
+
});
|
|
526
|
+
cmd.command("reconcile-multi").description("Conciliar un movimiento con m\xFAltiples obligaciones (divide el monto autom\xE1ticamente).").requiredOption("--movement-id <uuid>", "UUID del movimiento bancario").requiredOption("--obligation-ids <uuids>", "UUIDs de obligaciones separados por coma").option("--notes <text>", "Notas", "").action(async (opts) => {
|
|
527
|
+
const ids = opts.obligationIds.split(",").map((s) => s.trim());
|
|
528
|
+
output(await post("/api/accounting/reconciliation/match-multi", {
|
|
529
|
+
movement_id: opts.movementId,
|
|
530
|
+
obligation_ids: ids,
|
|
531
|
+
notes: opts.notes
|
|
532
|
+
}));
|
|
533
|
+
});
|
|
534
|
+
cmd.command("unmatch <reconciliation_id>").description("Deshacer una conciliaci\xF3n (unmatch).").action(async (id) => {
|
|
535
|
+
output(await post("/api/accounting/reconciliation/unmatch", { reconciliation_id: id }));
|
|
536
|
+
});
|
|
537
|
+
cmd.command("list-reconciliations").description("Listar conciliaciones completadas.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").option("--limit <n>", "L\xEDmite de resultados", (v) => parseInt(v), 30).option("--offset <n>", "Offset de paginaci\xF3n", (v) => parseInt(v), 0).action(async (opts) => {
|
|
538
|
+
output(await get("/api/accounting/reconciliation/list", {
|
|
539
|
+
company_id: opts.company,
|
|
540
|
+
period: opts.period,
|
|
541
|
+
limit: opts.limit,
|
|
542
|
+
offset: opts.offset
|
|
543
|
+
}));
|
|
544
|
+
});
|
|
545
|
+
cmd.command("suggestions").description("Obtener sugerencias de conciliaci\xF3n para un movimiento.").requiredOption("--company <uuid>", "UUID de la empresa").requiredOption("--movement-id <uuid>", "UUID del movimiento").action(async (opts) => {
|
|
546
|
+
output(await get("/api/accounting/reconciliation/suggestions", {
|
|
547
|
+
company_id: opts.company,
|
|
548
|
+
movement_id: opts.movementId
|
|
549
|
+
}));
|
|
550
|
+
});
|
|
551
|
+
cmd.command("status").description("Estado de conciliaci\xF3n de la empresa.").requiredOption("--company <uuid>", "UUID de la empresa").option("--period <yyyy-mm>", "Per\xEDodo YYYY-MM").action(async (opts) => {
|
|
552
|
+
output(await get("/api/accounting/reconciliation/status", {
|
|
553
|
+
company_id: opts.company,
|
|
554
|
+
period: opts.period
|
|
555
|
+
}));
|
|
556
|
+
});
|
|
557
|
+
cmd.command("obligation-from-movement <movement_id>").description("Crear obligaci\xF3n desde un movimiento bancario y auto-conciliar.").option("--classification <text>", "Clasificaci\xF3n del movimiento (si no tiene)").option("--obligation-type <type>", "Tipo: payable o receivable (auto-detecta)").option("--notes <text>", "Notas", "").action(async (id, opts) => {
|
|
558
|
+
const body = { bank_movement_id: id, notes: opts.notes };
|
|
559
|
+
if (opts.classification) body["classification"] = opts.classification;
|
|
560
|
+
if (opts.obligationType) body["obligation_type_override"] = opts.obligationType;
|
|
561
|
+
output(await post("/api/accounting/obligations/create-from-movement/", body));
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// src/schema.ts
|
|
566
|
+
var SCHEMA = {
|
|
567
|
+
"name": "fizko",
|
|
568
|
+
"description": "CLI for the Fizko API. Query tax documents, accounting reports, and company data for Chilean businesses. All commands output JSON to stdout. Errors go to stderr as JSON with exit code 1.",
|
|
569
|
+
"auth": "Run 'fizko login' to authenticate, or set FIZKO_API_KEY env var. Credentials are stored in ~/.config/fizko/credentials.json.",
|
|
570
|
+
"global_flags": {
|
|
571
|
+
"--compact": "Output JSON without indentation (smaller output for programmatic use)"
|
|
572
|
+
},
|
|
573
|
+
"tip": "Start with 'fizko companies list' to get company UUIDs, then use those UUIDs in other commands.",
|
|
574
|
+
"commands": {
|
|
575
|
+
"companies list": {
|
|
576
|
+
"description": "List all companies the authenticated user has access to. Returns array of companies with id, rut, business_name, tax_info.",
|
|
577
|
+
"options": {
|
|
578
|
+
"--page": {
|
|
579
|
+
"type": "int",
|
|
580
|
+
"required": false,
|
|
581
|
+
"description": "Page number for pagination"
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
"example": "fizko companies list"
|
|
585
|
+
},
|
|
586
|
+
"companies get": {
|
|
587
|
+
"description": "Get full detail of a single company including tax_info, settings, and representatives.",
|
|
588
|
+
"args": {
|
|
589
|
+
"company_id": {
|
|
590
|
+
"type": "UUID",
|
|
591
|
+
"required": true,
|
|
592
|
+
"description": "Company UUID"
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
"example": "fizko companies get 550e8400-e29b-41d4-a716-446655440000"
|
|
596
|
+
},
|
|
597
|
+
"tax purchases": {
|
|
598
|
+
"description": "List purchase documents (facturas de compra). Returns paginated list with supplier info, amounts, IVA, document type, and period.",
|
|
599
|
+
"options": {
|
|
600
|
+
"--company": {
|
|
601
|
+
"type": "UUID",
|
|
602
|
+
"required": true,
|
|
603
|
+
"description": "Company UUID"
|
|
604
|
+
},
|
|
605
|
+
"--period-year": {
|
|
606
|
+
"type": "int",
|
|
607
|
+
"required": false,
|
|
608
|
+
"description": "Filter by year (e.g. 2026)"
|
|
609
|
+
},
|
|
610
|
+
"--period-month": {
|
|
611
|
+
"type": "int",
|
|
612
|
+
"required": false,
|
|
613
|
+
"description": "Filter by month (1-12)"
|
|
614
|
+
},
|
|
615
|
+
"--document-type": {
|
|
616
|
+
"type": "str",
|
|
617
|
+
"required": false,
|
|
618
|
+
"description": "DTE type code (33=factura, 34=exenta, 61=nota credito)"
|
|
619
|
+
},
|
|
620
|
+
"--page": {
|
|
621
|
+
"type": "int",
|
|
622
|
+
"required": false,
|
|
623
|
+
"description": "Page number"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
"example": "fizko tax purchases --company UUID --period-year 2026 --period-month 1"
|
|
627
|
+
},
|
|
628
|
+
"tax purchase": {
|
|
629
|
+
"description": "Get full detail of a single purchase document.",
|
|
630
|
+
"args": {
|
|
631
|
+
"purchase_id": {
|
|
632
|
+
"type": "UUID",
|
|
633
|
+
"required": true,
|
|
634
|
+
"description": "Purchase document UUID"
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
"example": "fizko tax purchase 550e8400-e29b-41d4-a716-446655440000"
|
|
638
|
+
},
|
|
639
|
+
"tax sales": {
|
|
640
|
+
"description": "List sales documents (facturas de venta). Returns paginated list with customer info, amounts, IVA, document type, and period.",
|
|
641
|
+
"options": {
|
|
642
|
+
"--company": {
|
|
643
|
+
"type": "UUID",
|
|
644
|
+
"required": true,
|
|
645
|
+
"description": "Company UUID"
|
|
646
|
+
},
|
|
647
|
+
"--period-year": {
|
|
648
|
+
"type": "int",
|
|
649
|
+
"required": false,
|
|
650
|
+
"description": "Filter by year"
|
|
651
|
+
},
|
|
652
|
+
"--period-month": {
|
|
653
|
+
"type": "int",
|
|
654
|
+
"required": false,
|
|
655
|
+
"description": "Filter by month (1-12)"
|
|
656
|
+
},
|
|
657
|
+
"--document-type": {
|
|
658
|
+
"type": "str",
|
|
659
|
+
"required": false,
|
|
660
|
+
"description": "DTE type code"
|
|
661
|
+
},
|
|
662
|
+
"--page": {
|
|
663
|
+
"type": "int",
|
|
664
|
+
"required": false,
|
|
665
|
+
"description": "Page number"
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
"example": "fizko tax sales --company UUID --period-year 2026 --period-month 3"
|
|
669
|
+
},
|
|
670
|
+
"tax sale": {
|
|
671
|
+
"description": "Get full detail of a single sales document.",
|
|
672
|
+
"args": {
|
|
673
|
+
"sale_id": {
|
|
674
|
+
"type": "UUID",
|
|
675
|
+
"required": true,
|
|
676
|
+
"description": "Sales document UUID"
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
"example": "fizko tax sale UUID"
|
|
680
|
+
},
|
|
681
|
+
"tax contacts": {
|
|
682
|
+
"description": "List tax contacts (suppliers and customers). Returns business_name, rut, is_supplier, is_customer.",
|
|
683
|
+
"options": {
|
|
684
|
+
"--company": {
|
|
685
|
+
"type": "UUID",
|
|
686
|
+
"required": true,
|
|
687
|
+
"description": "Company UUID"
|
|
688
|
+
},
|
|
689
|
+
"--page": {
|
|
690
|
+
"type": "int",
|
|
691
|
+
"required": false,
|
|
692
|
+
"description": "Page number"
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
"example": "fizko tax contacts --company UUID"
|
|
696
|
+
},
|
|
697
|
+
"tax documents": {
|
|
698
|
+
"description": "List ALL tax documents unified (purchases + sales + honorarios) sorted by date. Best for getting a complete view of transactions.",
|
|
699
|
+
"options": {
|
|
700
|
+
"--company": {
|
|
701
|
+
"type": "UUID",
|
|
702
|
+
"required": true,
|
|
703
|
+
"description": "Company UUID"
|
|
704
|
+
},
|
|
705
|
+
"--period": {
|
|
706
|
+
"type": "str",
|
|
707
|
+
"required": false,
|
|
708
|
+
"description": "Period YYYY-MM"
|
|
709
|
+
},
|
|
710
|
+
"--start-date": {
|
|
711
|
+
"type": "str",
|
|
712
|
+
"required": false,
|
|
713
|
+
"description": "Start date YYYY-MM-DD"
|
|
714
|
+
},
|
|
715
|
+
"--end-date": {
|
|
716
|
+
"type": "str",
|
|
717
|
+
"required": false,
|
|
718
|
+
"description": "End date YYYY-MM-DD"
|
|
719
|
+
},
|
|
720
|
+
"--limit": {
|
|
721
|
+
"type": "int",
|
|
722
|
+
"required": false,
|
|
723
|
+
"description": "Results per page (default 100)"
|
|
724
|
+
},
|
|
725
|
+
"--offset": {
|
|
726
|
+
"type": "int",
|
|
727
|
+
"required": false,
|
|
728
|
+
"description": "Pagination offset"
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
"example": "fizko tax documents --company-id UUID --period 2026-01"
|
|
732
|
+
},
|
|
733
|
+
"tax document": {
|
|
734
|
+
"description": "Get full detail of any tax document by its UUID (purchase, sale, or honorario).",
|
|
735
|
+
"args": {
|
|
736
|
+
"document_id": {
|
|
737
|
+
"type": "UUID",
|
|
738
|
+
"required": true,
|
|
739
|
+
"description": "Document UUID"
|
|
740
|
+
}
|
|
741
|
+
},
|
|
742
|
+
"example": "fizko tax document UUID"
|
|
743
|
+
},
|
|
744
|
+
"tax documents-summary": {
|
|
745
|
+
"description": "Get transaction count summary by document type for the last 3 months. Useful for understanding transaction volume.",
|
|
746
|
+
"options": {
|
|
747
|
+
"--company": {
|
|
748
|
+
"type": "UUID",
|
|
749
|
+
"required": true,
|
|
750
|
+
"description": "Company UUID"
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
"example": "fizko tax documents-summary --company-id UUID"
|
|
754
|
+
},
|
|
755
|
+
"tax f29": {
|
|
756
|
+
"description": "List Form 29 tax declarations (monthly VAT/income tax) grouped by period. Includes both local and SII-downloaded versions.",
|
|
757
|
+
"options": {
|
|
758
|
+
"--company": {
|
|
759
|
+
"type": "UUID",
|
|
760
|
+
"required": true,
|
|
761
|
+
"description": "Company UUID"
|
|
762
|
+
},
|
|
763
|
+
"--year": {
|
|
764
|
+
"type": "int",
|
|
765
|
+
"required": false,
|
|
766
|
+
"description": "Filter by year"
|
|
767
|
+
},
|
|
768
|
+
"--page": {
|
|
769
|
+
"type": "int",
|
|
770
|
+
"required": false,
|
|
771
|
+
"description": "Page number"
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
"example": "fizko tax f29 --company-id UUID --year 2026"
|
|
775
|
+
},
|
|
776
|
+
"tax f29-export": {
|
|
777
|
+
"description": "Export documents contributing to a specific F29 code as CSV data.",
|
|
778
|
+
"options": {
|
|
779
|
+
"--company": {
|
|
780
|
+
"type": "UUID",
|
|
781
|
+
"required": true,
|
|
782
|
+
"description": "Company UUID"
|
|
783
|
+
},
|
|
784
|
+
"--code": {
|
|
785
|
+
"type": "str",
|
|
786
|
+
"required": true,
|
|
787
|
+
"description": "F29 code to export"
|
|
788
|
+
},
|
|
789
|
+
"--period": {
|
|
790
|
+
"type": "str",
|
|
791
|
+
"required": true,
|
|
792
|
+
"description": "Period YYYY-MM"
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
"example": "fizko tax f29-export --company-id UUID --code 538 --period 2026-01"
|
|
796
|
+
},
|
|
797
|
+
"tax f29-codes": {
|
|
798
|
+
"description": "List all F29 codes that have exportable documents for a period.",
|
|
799
|
+
"options": {
|
|
800
|
+
"--company": {
|
|
801
|
+
"type": "UUID",
|
|
802
|
+
"required": true,
|
|
803
|
+
"description": "Company UUID"
|
|
804
|
+
},
|
|
805
|
+
"--period": {
|
|
806
|
+
"type": "str",
|
|
807
|
+
"required": true,
|
|
808
|
+
"description": "Period YYYY-MM"
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
"example": "fizko tax f29-codes --company-id UUID --period 2026-01"
|
|
812
|
+
},
|
|
813
|
+
"tax summary": {
|
|
814
|
+
"description": "Get tax summary for a period from Form 29 data. Includes IVA debito/credito, PPM, retention amounts.",
|
|
815
|
+
"options": {
|
|
816
|
+
"--company": {
|
|
817
|
+
"type": "UUID",
|
|
818
|
+
"required": true,
|
|
819
|
+
"description": "Company UUID"
|
|
820
|
+
},
|
|
821
|
+
"--period": {
|
|
822
|
+
"type": "str",
|
|
823
|
+
"required": true,
|
|
824
|
+
"description": "Period YYYY-MM"
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
"example": "fizko tax summary --company-id UUID --period 2026-01"
|
|
828
|
+
},
|
|
829
|
+
"tax iva": {
|
|
830
|
+
"description": "Get IVA (VAT) summary for a period. Shows IVA debito, credito, and balance.",
|
|
831
|
+
"options": {
|
|
832
|
+
"--company": {
|
|
833
|
+
"type": "UUID",
|
|
834
|
+
"required": true,
|
|
835
|
+
"description": "Company UUID"
|
|
836
|
+
},
|
|
837
|
+
"--period": {
|
|
838
|
+
"type": "str",
|
|
839
|
+
"required": true,
|
|
840
|
+
"description": "Period YYYY-MM"
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
"example": "fizko tax iva --company-id UUID --period 2026-01"
|
|
844
|
+
},
|
|
845
|
+
"tax timeline": {
|
|
846
|
+
"description": "Get tax timeline for the last 12 months. Shows monthly totals for purchases, sales, IVA.",
|
|
847
|
+
"options": {
|
|
848
|
+
"--company": {
|
|
849
|
+
"type": "UUID",
|
|
850
|
+
"required": true,
|
|
851
|
+
"description": "Company UUID"
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
"example": "fizko tax timeline --company-id UUID"
|
|
855
|
+
},
|
|
856
|
+
"tax honorarios": {
|
|
857
|
+
"description": "List boletas de honorarios (freelance receipts). Shows issuer, amount, retention, dates.",
|
|
858
|
+
"options": {
|
|
859
|
+
"--company": {
|
|
860
|
+
"type": "UUID",
|
|
861
|
+
"required": true,
|
|
862
|
+
"description": "Company UUID"
|
|
863
|
+
},
|
|
864
|
+
"--period-year": {
|
|
865
|
+
"type": "int",
|
|
866
|
+
"required": false,
|
|
867
|
+
"description": "Filter by year"
|
|
868
|
+
},
|
|
869
|
+
"--period-month": {
|
|
870
|
+
"type": "int",
|
|
871
|
+
"required": false,
|
|
872
|
+
"description": "Filter by month (1-12)"
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
"example": "fizko tax honorarios --company UUID --period-year 2026"
|
|
876
|
+
},
|
|
877
|
+
"tax ddjj": {
|
|
878
|
+
"description": "List declaraciones juradas (annual sworn statements). Shows DJ number, status, year.",
|
|
879
|
+
"options": {
|
|
880
|
+
"--company": {
|
|
881
|
+
"type": "UUID",
|
|
882
|
+
"required": true,
|
|
883
|
+
"description": "Company UUID"
|
|
884
|
+
},
|
|
885
|
+
"--year": {
|
|
886
|
+
"type": "int",
|
|
887
|
+
"required": false,
|
|
888
|
+
"description": "Tax year"
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
"example": "fizko tax ddjj --company-id UUID --year 2025"
|
|
892
|
+
},
|
|
893
|
+
"tax checker-tributario": {
|
|
894
|
+
"description": "Compare SII purchase/sales books vs Fizko accounting records. Shows discrepancies between declared and booked documents.",
|
|
895
|
+
"options": {
|
|
896
|
+
"--company": {
|
|
897
|
+
"type": "UUID",
|
|
898
|
+
"required": true,
|
|
899
|
+
"description": "Company UUID"
|
|
900
|
+
},
|
|
901
|
+
"--period": {
|
|
902
|
+
"type": "str",
|
|
903
|
+
"required": true,
|
|
904
|
+
"description": "Period YYYY-MM"
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
"example": "fizko tax checker-tributario --company-id UUID --period 2026-01"
|
|
908
|
+
},
|
|
909
|
+
"tax checker-impuestos": {
|
|
910
|
+
"description": "Compare taxes declared in F29 vs taxes booked in Fizko accounting. Shows discrepancies per tax line.",
|
|
911
|
+
"options": {
|
|
912
|
+
"--company": {
|
|
913
|
+
"type": "UUID",
|
|
914
|
+
"required": true,
|
|
915
|
+
"description": "Company UUID"
|
|
916
|
+
},
|
|
917
|
+
"--period": {
|
|
918
|
+
"type": "str",
|
|
919
|
+
"required": true,
|
|
920
|
+
"description": "Period YYYY-MM"
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
"example": "fizko tax checker-impuestos --company-id UUID --period 2026-01"
|
|
924
|
+
},
|
|
925
|
+
"accounting accounts": {
|
|
926
|
+
"description": "List chart of accounts (plan de cuentas). Returns account code, name, type, balance. Use --tree for hierarchical structure.",
|
|
927
|
+
"options": {
|
|
928
|
+
"--company": {
|
|
929
|
+
"type": "UUID",
|
|
930
|
+
"required": true,
|
|
931
|
+
"description": "Company UUID"
|
|
932
|
+
},
|
|
933
|
+
"--tree": {
|
|
934
|
+
"type": "bool",
|
|
935
|
+
"required": false,
|
|
936
|
+
"description": "Return as tree structure instead of flat list"
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
"example": "fizko accounting accounts --company UUID --tree"
|
|
940
|
+
},
|
|
941
|
+
"accounting journal-entries": {
|
|
942
|
+
"description": "List journal entries (asientos contables). Returns entry date, description, lines with debit/credit amounts.",
|
|
943
|
+
"options": {
|
|
944
|
+
"--company": {
|
|
945
|
+
"type": "UUID",
|
|
946
|
+
"required": true,
|
|
947
|
+
"description": "Company UUID"
|
|
948
|
+
},
|
|
949
|
+
"--period": {
|
|
950
|
+
"type": "str",
|
|
951
|
+
"required": false,
|
|
952
|
+
"description": "Period YYYY-MM"
|
|
953
|
+
},
|
|
954
|
+
"--limit": {
|
|
955
|
+
"type": "int",
|
|
956
|
+
"required": false,
|
|
957
|
+
"description": "Results limit"
|
|
958
|
+
},
|
|
959
|
+
"--offset": {
|
|
960
|
+
"type": "int",
|
|
961
|
+
"required": false,
|
|
962
|
+
"description": "Pagination offset"
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
"example": "fizko accounting journal-entries --company UUID --period 2026-01"
|
|
966
|
+
},
|
|
967
|
+
"accounting journal-entry": {
|
|
968
|
+
"description": "Get full detail of a journal entry including all debit/credit lines.",
|
|
969
|
+
"args": {
|
|
970
|
+
"entry_id": {
|
|
971
|
+
"type": "UUID",
|
|
972
|
+
"required": true,
|
|
973
|
+
"description": "Journal entry UUID"
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
"example": "fizko accounting journal-entry UUID"
|
|
977
|
+
},
|
|
978
|
+
"accounting balance-report": {
|
|
979
|
+
"description": "Balance de 8 columnas (Eight-Column Balance Sheet). Shows opening balances, movements, sums, and closing balances per account.",
|
|
980
|
+
"options": {
|
|
981
|
+
"--company": {
|
|
982
|
+
"type": "UUID",
|
|
983
|
+
"required": true,
|
|
984
|
+
"description": "Company UUID"
|
|
985
|
+
},
|
|
986
|
+
"--period-from": {
|
|
987
|
+
"type": "str",
|
|
988
|
+
"required": true,
|
|
989
|
+
"description": "Start period YYYY-MM"
|
|
990
|
+
},
|
|
991
|
+
"--period-to": {
|
|
992
|
+
"type": "str",
|
|
993
|
+
"required": true,
|
|
994
|
+
"description": "End period YYYY-MM"
|
|
995
|
+
},
|
|
996
|
+
"--cost-center-id": {
|
|
997
|
+
"type": "UUID",
|
|
998
|
+
"required": false,
|
|
999
|
+
"description": "Filter by cost center"
|
|
1000
|
+
}
|
|
1001
|
+
},
|
|
1002
|
+
"example": "fizko accounting balance-report --company-id UUID --period-from 2026-01 --period-to 2026-12"
|
|
1003
|
+
},
|
|
1004
|
+
"accounting income-statement": {
|
|
1005
|
+
"description": "Estado de Resultados (Income Statement / EERR). Shows revenue, costs, expenses, and net income by category.",
|
|
1006
|
+
"options": {
|
|
1007
|
+
"--company": {
|
|
1008
|
+
"type": "UUID",
|
|
1009
|
+
"required": true,
|
|
1010
|
+
"description": "Company UUID"
|
|
1011
|
+
},
|
|
1012
|
+
"--period-from": {
|
|
1013
|
+
"type": "str",
|
|
1014
|
+
"required": true,
|
|
1015
|
+
"description": "Start period YYYY-MM"
|
|
1016
|
+
},
|
|
1017
|
+
"--period-to": {
|
|
1018
|
+
"type": "str",
|
|
1019
|
+
"required": true,
|
|
1020
|
+
"description": "End period YYYY-MM"
|
|
1021
|
+
},
|
|
1022
|
+
"--cost-center-id": {
|
|
1023
|
+
"type": "UUID",
|
|
1024
|
+
"required": false,
|
|
1025
|
+
"description": "Filter by cost center"
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
"example": "fizko accounting income-statement --company-id UUID --period-from 2026-01 --period-to 2026-12"
|
|
1029
|
+
},
|
|
1030
|
+
"accounting general-journal": {
|
|
1031
|
+
"description": "Libro Diario (General Journal). Lists all posted journal entries for a period with line detail.",
|
|
1032
|
+
"options": {
|
|
1033
|
+
"--company": {
|
|
1034
|
+
"type": "UUID",
|
|
1035
|
+
"required": true,
|
|
1036
|
+
"description": "Company UUID"
|
|
1037
|
+
},
|
|
1038
|
+
"--period": {
|
|
1039
|
+
"type": "str",
|
|
1040
|
+
"required": true,
|
|
1041
|
+
"description": "Period YYYY-MM"
|
|
1042
|
+
},
|
|
1043
|
+
"--page": {
|
|
1044
|
+
"type": "int",
|
|
1045
|
+
"required": false,
|
|
1046
|
+
"description": "Page number"
|
|
1047
|
+
},
|
|
1048
|
+
"--page-size": {
|
|
1049
|
+
"type": "int",
|
|
1050
|
+
"required": false,
|
|
1051
|
+
"description": "Results per page"
|
|
1052
|
+
}
|
|
1053
|
+
},
|
|
1054
|
+
"example": "fizko accounting general-journal --company-id UUID --period 2026-01"
|
|
1055
|
+
},
|
|
1056
|
+
"accounting general-ledger": {
|
|
1057
|
+
"description": "Libro Mayor (General Ledger). Shows all movements per account for a period range.",
|
|
1058
|
+
"options": {
|
|
1059
|
+
"--company": {
|
|
1060
|
+
"type": "UUID",
|
|
1061
|
+
"required": true,
|
|
1062
|
+
"description": "Company UUID"
|
|
1063
|
+
},
|
|
1064
|
+
"--period-from": {
|
|
1065
|
+
"type": "str",
|
|
1066
|
+
"required": true,
|
|
1067
|
+
"description": "Start period YYYY-MM"
|
|
1068
|
+
},
|
|
1069
|
+
"--period-to": {
|
|
1070
|
+
"type": "str",
|
|
1071
|
+
"required": true,
|
|
1072
|
+
"description": "End period YYYY-MM"
|
|
1073
|
+
},
|
|
1074
|
+
"--account-id": {
|
|
1075
|
+
"type": "UUID",
|
|
1076
|
+
"required": false,
|
|
1077
|
+
"description": "Filter by specific account"
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
"example": "fizko accounting general-ledger --company-id UUID --period-from 2026-01 --period-to 2026-12"
|
|
1081
|
+
},
|
|
1082
|
+
"accounting classified-balance": {
|
|
1083
|
+
"description": "Balance Clasificado (Classified Balance Sheet). Groups accounts by clasificacion_balance categories.",
|
|
1084
|
+
"options": {
|
|
1085
|
+
"--company": {
|
|
1086
|
+
"type": "UUID",
|
|
1087
|
+
"required": true,
|
|
1088
|
+
"description": "Company UUID"
|
|
1089
|
+
},
|
|
1090
|
+
"--period": {
|
|
1091
|
+
"type": "str",
|
|
1092
|
+
"required": false,
|
|
1093
|
+
"description": "Single period YYYY-MM (or use period-from/period-to)"
|
|
1094
|
+
},
|
|
1095
|
+
"--period-from": {
|
|
1096
|
+
"type": "str",
|
|
1097
|
+
"required": false,
|
|
1098
|
+
"description": "Start period YYYY-MM"
|
|
1099
|
+
},
|
|
1100
|
+
"--period-to": {
|
|
1101
|
+
"type": "str",
|
|
1102
|
+
"required": false,
|
|
1103
|
+
"description": "End period YYYY-MM"
|
|
1104
|
+
},
|
|
1105
|
+
"--cost-center-id": {
|
|
1106
|
+
"type": "UUID",
|
|
1107
|
+
"required": false,
|
|
1108
|
+
"description": "Filter by cost center"
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
"example": "fizko accounting classified-balance --company-id UUID --period 2026-12"
|
|
1112
|
+
},
|
|
1113
|
+
"accounting rli-balance": {
|
|
1114
|
+
"description": "Balance RLI (Renta Liquida Imponible). Shows taxable income calculation for Operacion Renta.",
|
|
1115
|
+
"options": {
|
|
1116
|
+
"--company": {
|
|
1117
|
+
"type": "UUID",
|
|
1118
|
+
"required": true,
|
|
1119
|
+
"description": "Company UUID"
|
|
1120
|
+
},
|
|
1121
|
+
"--period-from": {
|
|
1122
|
+
"type": "str",
|
|
1123
|
+
"required": true,
|
|
1124
|
+
"description": "Start period YYYY-MM"
|
|
1125
|
+
},
|
|
1126
|
+
"--period-to": {
|
|
1127
|
+
"type": "str",
|
|
1128
|
+
"required": true,
|
|
1129
|
+
"description": "End period YYYY-MM"
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
"example": "fizko accounting rli-balance --company-id UUID --period-from 2026-01 --period-to 2026-12"
|
|
1133
|
+
},
|
|
1134
|
+
"accounting progress": {
|
|
1135
|
+
"description": "Accounting progress metrics. Shows how many documents are booked vs pending for a period.",
|
|
1136
|
+
"options": {
|
|
1137
|
+
"--company": {
|
|
1138
|
+
"type": "UUID",
|
|
1139
|
+
"required": true,
|
|
1140
|
+
"description": "Company UUID"
|
|
1141
|
+
},
|
|
1142
|
+
"--period": {
|
|
1143
|
+
"type": "str",
|
|
1144
|
+
"required": false,
|
|
1145
|
+
"description": "Period YYYY-MM"
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
"example": "fizko accounting progress --company-id UUID --period 2026-01"
|
|
1149
|
+
},
|
|
1150
|
+
"accounting obligations": {
|
|
1151
|
+
"description": "List accounting obligations (cuentas por pagar/cobrar). Filterable by type, status, period.",
|
|
1152
|
+
"options": {
|
|
1153
|
+
"--company": {
|
|
1154
|
+
"type": "UUID",
|
|
1155
|
+
"required": true,
|
|
1156
|
+
"description": "Company UUID"
|
|
1157
|
+
},
|
|
1158
|
+
"--obligation-type": {
|
|
1159
|
+
"type": "str",
|
|
1160
|
+
"required": false,
|
|
1161
|
+
"description": "payable or receivable"
|
|
1162
|
+
},
|
|
1163
|
+
"--status": {
|
|
1164
|
+
"type": "str",
|
|
1165
|
+
"required": false,
|
|
1166
|
+
"description": "pending, partial, paid, overdue"
|
|
1167
|
+
},
|
|
1168
|
+
"--period": {
|
|
1169
|
+
"type": "str",
|
|
1170
|
+
"required": false,
|
|
1171
|
+
"description": "Period YYYY-MM"
|
|
1172
|
+
},
|
|
1173
|
+
"--limit": {
|
|
1174
|
+
"type": "int",
|
|
1175
|
+
"required": false,
|
|
1176
|
+
"description": "Results limit (default 30)"
|
|
1177
|
+
},
|
|
1178
|
+
"--offset": {
|
|
1179
|
+
"type": "int",
|
|
1180
|
+
"required": false,
|
|
1181
|
+
"description": "Pagination offset"
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
"example": "fizko accounting obligations --company UUID --status pending --period 2026-01"
|
|
1185
|
+
},
|
|
1186
|
+
"accounting obligation": {
|
|
1187
|
+
"description": "Get full detail of an obligation including journal entry, payments, reconciliations.",
|
|
1188
|
+
"args": {
|
|
1189
|
+
"obligation_id": {
|
|
1190
|
+
"type": "UUID",
|
|
1191
|
+
"required": true,
|
|
1192
|
+
"description": "Obligation UUID"
|
|
1193
|
+
}
|
|
1194
|
+
},
|
|
1195
|
+
"example": "fizko accounting obligation UUID"
|
|
1196
|
+
},
|
|
1197
|
+
"accounting contabilizar": {
|
|
1198
|
+
"description": "Create journal entry for an obligation. Without extra params, auto-generates lines from account rules. Provide --lines for explicit control or --account-code for legacy mode.",
|
|
1199
|
+
"args": {
|
|
1200
|
+
"obligation_id": {
|
|
1201
|
+
"type": "UUID",
|
|
1202
|
+
"required": true,
|
|
1203
|
+
"description": "Obligation UUID"
|
|
1204
|
+
}
|
|
1205
|
+
},
|
|
1206
|
+
"options": {
|
|
1207
|
+
"--lines": {
|
|
1208
|
+
"type": "JSON",
|
|
1209
|
+
"required": false,
|
|
1210
|
+
"description": 'Journal lines as JSON array: [{"account_code":"5101","debit":1000,"credit":0}]'
|
|
1211
|
+
},
|
|
1212
|
+
"--account-code": {
|
|
1213
|
+
"type": "str",
|
|
1214
|
+
"required": false,
|
|
1215
|
+
"description": "Counterpart account code (legacy mode)"
|
|
1216
|
+
},
|
|
1217
|
+
"--description": {
|
|
1218
|
+
"type": "str",
|
|
1219
|
+
"required": false,
|
|
1220
|
+
"description": "Journal entry description"
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
"example": "fizko accounting contabilizar UUID"
|
|
1224
|
+
},
|
|
1225
|
+
"accounting descontabilizar": {
|
|
1226
|
+
"description": "Delete the journal entry linked to an obligation.",
|
|
1227
|
+
"args": {
|
|
1228
|
+
"obligation_id": {
|
|
1229
|
+
"type": "UUID",
|
|
1230
|
+
"required": true,
|
|
1231
|
+
"description": "Obligation UUID"
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
"example": "fizko accounting descontabilizar UUID"
|
|
1235
|
+
},
|
|
1236
|
+
"accounting abonar": {
|
|
1237
|
+
"description": "Record a payment on an obligation. By default also creates journal entry (--contabilizar). Use --no-contabilizar to skip.",
|
|
1238
|
+
"args": {
|
|
1239
|
+
"obligation_id": {
|
|
1240
|
+
"type": "UUID",
|
|
1241
|
+
"required": true,
|
|
1242
|
+
"description": "Obligation UUID"
|
|
1243
|
+
}
|
|
1244
|
+
},
|
|
1245
|
+
"options": {
|
|
1246
|
+
"--amount": {
|
|
1247
|
+
"type": "float",
|
|
1248
|
+
"required": true,
|
|
1249
|
+
"description": "Payment amount"
|
|
1250
|
+
},
|
|
1251
|
+
"--payment-type": {
|
|
1252
|
+
"type": "str",
|
|
1253
|
+
"required": true,
|
|
1254
|
+
"description": "cash, check, third_party, international, factoring, bad_debt"
|
|
1255
|
+
},
|
|
1256
|
+
"--notes": {
|
|
1257
|
+
"type": "str",
|
|
1258
|
+
"required": false,
|
|
1259
|
+
"description": "Payment notes"
|
|
1260
|
+
},
|
|
1261
|
+
"--contabilizar/--no-contabilizar": {
|
|
1262
|
+
"type": "bool",
|
|
1263
|
+
"required": false,
|
|
1264
|
+
"description": "Auto-create journal entry (default: yes)"
|
|
1265
|
+
}
|
|
1266
|
+
},
|
|
1267
|
+
"example": "fizko accounting abonar UUID --amount 50000 --payment-type cash"
|
|
1268
|
+
},
|
|
1269
|
+
"banking movements": {
|
|
1270
|
+
"description": "List bank movements. Filterable by status, classification, period.",
|
|
1271
|
+
"options": {
|
|
1272
|
+
"--company": {
|
|
1273
|
+
"type": "UUID",
|
|
1274
|
+
"required": true,
|
|
1275
|
+
"description": "Company UUID"
|
|
1276
|
+
},
|
|
1277
|
+
"--status": {
|
|
1278
|
+
"type": "str",
|
|
1279
|
+
"required": false,
|
|
1280
|
+
"description": "pending, reconciled, matched, split"
|
|
1281
|
+
},
|
|
1282
|
+
"--classification": {
|
|
1283
|
+
"type": "str",
|
|
1284
|
+
"required": false,
|
|
1285
|
+
"description": "Filter by classification text"
|
|
1286
|
+
},
|
|
1287
|
+
"--period": {
|
|
1288
|
+
"type": "str",
|
|
1289
|
+
"required": false,
|
|
1290
|
+
"description": "Period YYYY-MM"
|
|
1291
|
+
},
|
|
1292
|
+
"--limit": {
|
|
1293
|
+
"type": "int",
|
|
1294
|
+
"required": false,
|
|
1295
|
+
"description": "Results limit (default 30)"
|
|
1296
|
+
},
|
|
1297
|
+
"--offset": {
|
|
1298
|
+
"type": "int",
|
|
1299
|
+
"required": false,
|
|
1300
|
+
"description": "Pagination offset"
|
|
1301
|
+
}
|
|
1302
|
+
},
|
|
1303
|
+
"example": "fizko banking movements --company UUID --status pending"
|
|
1304
|
+
},
|
|
1305
|
+
"banking movement": {
|
|
1306
|
+
"description": "Get full detail of a bank movement including journal entry and reconciliations.",
|
|
1307
|
+
"args": {
|
|
1308
|
+
"movement_id": {
|
|
1309
|
+
"type": "UUID",
|
|
1310
|
+
"required": true,
|
|
1311
|
+
"description": "Bank movement UUID"
|
|
1312
|
+
}
|
|
1313
|
+
},
|
|
1314
|
+
"example": "fizko banking movement UUID"
|
|
1315
|
+
},
|
|
1316
|
+
"banking classify": {
|
|
1317
|
+
"description": "Classify a bank movement (e.g., 'Gasto Operacional', 'Ingreso Operacional').",
|
|
1318
|
+
"args": {
|
|
1319
|
+
"movement_id": {
|
|
1320
|
+
"type": "UUID",
|
|
1321
|
+
"required": true,
|
|
1322
|
+
"description": "Bank movement UUID"
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
"options": {
|
|
1326
|
+
"--classification": {
|
|
1327
|
+
"type": "str",
|
|
1328
|
+
"required": true,
|
|
1329
|
+
"description": "Classification label"
|
|
1330
|
+
},
|
|
1331
|
+
"--document-type": {
|
|
1332
|
+
"type": "str",
|
|
1333
|
+
"required": false,
|
|
1334
|
+
"description": "Document type (Factura, Boleta, etc.)"
|
|
1335
|
+
},
|
|
1336
|
+
"--comment": {
|
|
1337
|
+
"type": "str",
|
|
1338
|
+
"required": false,
|
|
1339
|
+
"description": "Explanation comment"
|
|
1340
|
+
}
|
|
1341
|
+
},
|
|
1342
|
+
"example": "fizko banking classify UUID --classification 'Gasto Operacional'"
|
|
1343
|
+
},
|
|
1344
|
+
"banking contabilizar": {
|
|
1345
|
+
"description": "Create journal entry for a bank movement. Requires counterpart account code.",
|
|
1346
|
+
"args": {
|
|
1347
|
+
"movement_id": {
|
|
1348
|
+
"type": "UUID",
|
|
1349
|
+
"required": true,
|
|
1350
|
+
"description": "Bank movement UUID"
|
|
1351
|
+
}
|
|
1352
|
+
},
|
|
1353
|
+
"options": {
|
|
1354
|
+
"--account-code": {
|
|
1355
|
+
"type": "str",
|
|
1356
|
+
"required": true,
|
|
1357
|
+
"description": "Counterpart account code (e.g., '5101')"
|
|
1358
|
+
},
|
|
1359
|
+
"--description": {
|
|
1360
|
+
"type": "str",
|
|
1361
|
+
"required": false,
|
|
1362
|
+
"description": "Journal entry description"
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
"example": "fizko banking contabilizar UUID --account-code 5101"
|
|
1366
|
+
},
|
|
1367
|
+
"banking descontabilizar": {
|
|
1368
|
+
"description": "Delete the journal entry linked to a bank movement.",
|
|
1369
|
+
"args": {
|
|
1370
|
+
"movement_id": {
|
|
1371
|
+
"type": "UUID",
|
|
1372
|
+
"required": true,
|
|
1373
|
+
"description": "Bank movement UUID"
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
"example": "fizko banking descontabilizar UUID"
|
|
1377
|
+
},
|
|
1378
|
+
"banking contabilizar-reconciliaciones": {
|
|
1379
|
+
"description": "Create one journal entry per reconciliation for a movement. Use when movement has multiple reconciliations with different accounts.",
|
|
1380
|
+
"args": {
|
|
1381
|
+
"movement_id": {
|
|
1382
|
+
"type": "UUID",
|
|
1383
|
+
"required": true,
|
|
1384
|
+
"description": "Bank movement UUID"
|
|
1385
|
+
}
|
|
1386
|
+
},
|
|
1387
|
+
"options": {
|
|
1388
|
+
"--entries": {
|
|
1389
|
+
"type": "JSON",
|
|
1390
|
+
"required": true,
|
|
1391
|
+
"description": 'Array: [{"reconciliation_id":"UUID","lines":[{"account_code":"5101","debit":1000,"credit":0}],"description":"optional"}]'
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
"example": `fizko banking contabilizar-reconciliaciones UUID --entries '[{"reconciliation_id":"UUID","lines":[{"account_code":"5101","debit":1000,"credit":0}]}]'`
|
|
1395
|
+
},
|
|
1396
|
+
"banking reconcile": {
|
|
1397
|
+
"description": "Match a bank movement with a single obligation.",
|
|
1398
|
+
"options": {
|
|
1399
|
+
"--movement-id": {
|
|
1400
|
+
"type": "UUID",
|
|
1401
|
+
"required": true,
|
|
1402
|
+
"description": "Bank movement UUID"
|
|
1403
|
+
},
|
|
1404
|
+
"--obligation-id": {
|
|
1405
|
+
"type": "UUID",
|
|
1406
|
+
"required": true,
|
|
1407
|
+
"description": "Obligation UUID"
|
|
1408
|
+
},
|
|
1409
|
+
"--amount": {
|
|
1410
|
+
"type": "float",
|
|
1411
|
+
"required": false,
|
|
1412
|
+
"description": "Reconciliation amount (auto-detected if omitted)"
|
|
1413
|
+
},
|
|
1414
|
+
"--notes": {
|
|
1415
|
+
"type": "str",
|
|
1416
|
+
"required": false,
|
|
1417
|
+
"description": "Notes"
|
|
1418
|
+
}
|
|
1419
|
+
},
|
|
1420
|
+
"example": "fizko banking reconcile --movement-id UUID --obligation-id UUID"
|
|
1421
|
+
},
|
|
1422
|
+
"banking reconcile-multi": {
|
|
1423
|
+
"description": "Match a bank movement with multiple obligations. Automatically splits the movement amount across obligations.",
|
|
1424
|
+
"options": {
|
|
1425
|
+
"--movement-id": {
|
|
1426
|
+
"type": "UUID",
|
|
1427
|
+
"required": true,
|
|
1428
|
+
"description": "Bank movement UUID"
|
|
1429
|
+
},
|
|
1430
|
+
"--obligation-ids": {
|
|
1431
|
+
"type": "str",
|
|
1432
|
+
"required": true,
|
|
1433
|
+
"description": "Comma-separated obligation UUIDs"
|
|
1434
|
+
},
|
|
1435
|
+
"--notes": {
|
|
1436
|
+
"type": "str",
|
|
1437
|
+
"required": false,
|
|
1438
|
+
"description": "Notes"
|
|
1439
|
+
}
|
|
1440
|
+
},
|
|
1441
|
+
"example": "fizko banking reconcile-multi --movement-id UUID --obligation-ids UUID1,UUID2"
|
|
1442
|
+
},
|
|
1443
|
+
"banking unmatch": {
|
|
1444
|
+
"description": "Undo a reconciliation (unmatch). Returns the movement to pending status.",
|
|
1445
|
+
"args": {
|
|
1446
|
+
"reconciliation_id": {
|
|
1447
|
+
"type": "UUID",
|
|
1448
|
+
"required": true,
|
|
1449
|
+
"description": "Reconciliation UUID to undo"
|
|
1450
|
+
}
|
|
1451
|
+
},
|
|
1452
|
+
"example": "fizko banking unmatch UUID"
|
|
1453
|
+
},
|
|
1454
|
+
"banking list-reconciliations": {
|
|
1455
|
+
"description": "List completed reconciliations for a company/period.",
|
|
1456
|
+
"options": {
|
|
1457
|
+
"--company": {
|
|
1458
|
+
"type": "UUID",
|
|
1459
|
+
"required": true,
|
|
1460
|
+
"description": "Company UUID"
|
|
1461
|
+
},
|
|
1462
|
+
"--period": {
|
|
1463
|
+
"type": "str",
|
|
1464
|
+
"required": false,
|
|
1465
|
+
"description": "Period YYYY-MM"
|
|
1466
|
+
},
|
|
1467
|
+
"--limit": {
|
|
1468
|
+
"type": "int",
|
|
1469
|
+
"required": false,
|
|
1470
|
+
"description": "Results limit (default 30)"
|
|
1471
|
+
},
|
|
1472
|
+
"--offset": {
|
|
1473
|
+
"type": "int",
|
|
1474
|
+
"required": false,
|
|
1475
|
+
"description": "Pagination offset"
|
|
1476
|
+
}
|
|
1477
|
+
},
|
|
1478
|
+
"example": "fizko banking list-reconciliations --company UUID --period 2026-01"
|
|
1479
|
+
},
|
|
1480
|
+
"banking suggestions": {
|
|
1481
|
+
"description": "Get AI-scored reconciliation suggestions for a specific bank movement.",
|
|
1482
|
+
"options": {
|
|
1483
|
+
"--company": {
|
|
1484
|
+
"type": "UUID",
|
|
1485
|
+
"required": true,
|
|
1486
|
+
"description": "Company UUID"
|
|
1487
|
+
},
|
|
1488
|
+
"--movement-id": {
|
|
1489
|
+
"type": "UUID",
|
|
1490
|
+
"required": true,
|
|
1491
|
+
"description": "Bank movement UUID"
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
"example": "fizko banking suggestions --company UUID --movement-id UUID"
|
|
1495
|
+
},
|
|
1496
|
+
"banking status": {
|
|
1497
|
+
"description": "Get reconciliation progress metrics for a company/period.",
|
|
1498
|
+
"options": {
|
|
1499
|
+
"--company": {
|
|
1500
|
+
"type": "UUID",
|
|
1501
|
+
"required": true,
|
|
1502
|
+
"description": "Company UUID"
|
|
1503
|
+
},
|
|
1504
|
+
"--period": {
|
|
1505
|
+
"type": "str",
|
|
1506
|
+
"required": false,
|
|
1507
|
+
"description": "Period YYYY-MM"
|
|
1508
|
+
}
|
|
1509
|
+
},
|
|
1510
|
+
"example": "fizko banking status --company UUID --period 2026-01"
|
|
1511
|
+
},
|
|
1512
|
+
"banking obligation-from-movement": {
|
|
1513
|
+
"description": "Create an obligation from a bank movement and auto-reconcile.",
|
|
1514
|
+
"args": {
|
|
1515
|
+
"movement_id": {
|
|
1516
|
+
"type": "UUID",
|
|
1517
|
+
"required": true,
|
|
1518
|
+
"description": "Bank movement UUID"
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
"options": {
|
|
1522
|
+
"--classification": {
|
|
1523
|
+
"type": "str",
|
|
1524
|
+
"required": false,
|
|
1525
|
+
"description": "Classification for unclassified movements"
|
|
1526
|
+
},
|
|
1527
|
+
"--obligation-type": {
|
|
1528
|
+
"type": "str",
|
|
1529
|
+
"required": false,
|
|
1530
|
+
"description": "payable or receivable (auto-detected)"
|
|
1531
|
+
},
|
|
1532
|
+
"--notes": {
|
|
1533
|
+
"type": "str",
|
|
1534
|
+
"required": false,
|
|
1535
|
+
"description": "Notes"
|
|
1536
|
+
}
|
|
1537
|
+
},
|
|
1538
|
+
"example": "fizko banking obligation-from-movement UUID --classification 'Gasto Operacional'"
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
// src/index.ts
|
|
1544
|
+
var program = new import_commander.Command();
|
|
1545
|
+
program.name("fizko").description(
|
|
1546
|
+
"CLI for the Fizko API. Query tax documents, accounting reports, and company data.\n\nQuick start:\n fizko login # authenticate\n fizko companies list # get company UUIDs\n fizko tax purchases --company <uuid> # query data\n fizko schema # show all commands as JSON (for AI agents)"
|
|
1547
|
+
).option("--compact", "Output JSON without indentation").hook("preAction", (thisCommand) => {
|
|
1548
|
+
if (thisCommand.opts().compact) setCompact(true);
|
|
1549
|
+
});
|
|
1550
|
+
program.command("schema").description("Print machine-readable schema of all commands as JSON. Designed for AI agent discovery.").action(() => {
|
|
1551
|
+
output(SCHEMA);
|
|
1552
|
+
});
|
|
1553
|
+
registerAuth(program);
|
|
1554
|
+
registerCompanies(program);
|
|
1555
|
+
registerTax(program);
|
|
1556
|
+
registerAccounting(program);
|
|
1557
|
+
registerBanking(program);
|
|
1558
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
1559
|
+
process.stderr.write(JSON.stringify({ error: String(err) }) + "\n");
|
|
1560
|
+
process.exit(1);
|
|
1561
|
+
});
|