@hasna/microservices 0.0.16 → 0.0.17
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 +143 -23
- package/bin/index.js +711 -13998
- package/bin/mcp.js +228 -10987
- package/dist/index.js +166 -10056
- package/package.json +25 -25
- package/microservices/microservice-ads/package.json +0 -28
- package/microservices/microservice-ads/src/cli/index.ts +0 -605
- package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
- package/microservices/microservice-ads/src/db/database.ts +0 -91
- package/microservices/microservice-ads/src/db/migrations.ts +0 -60
- package/microservices/microservice-ads/src/index.ts +0 -39
- package/microservices/microservice-ads/src/mcp/index.ts +0 -480
- package/microservices/microservice-analytics/package.json +0 -28
- package/microservices/microservice-analytics/src/cli/index.ts +0 -373
- package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
- package/microservices/microservice-analytics/src/db/database.ts +0 -91
- package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
- package/microservices/microservice-analytics/src/index.ts +0 -37
- package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
- package/microservices/microservice-assets/package.json +0 -28
- package/microservices/microservice-assets/src/cli/index.ts +0 -375
- package/microservices/microservice-assets/src/db/assets.ts +0 -370
- package/microservices/microservice-assets/src/db/database.ts +0 -91
- package/microservices/microservice-assets/src/db/migrations.ts +0 -51
- package/microservices/microservice-assets/src/index.ts +0 -32
- package/microservices/microservice-assets/src/mcp/index.ts +0 -346
- package/microservices/microservice-bookkeeping/package.json +0 -28
- package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
- package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
- package/microservices/microservice-bookkeeping/src/db/database.ts +0 -91
- package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
- package/microservices/microservice-bookkeeping/src/index.ts +0 -32
- package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
- package/microservices/microservice-calendar/package.json +0 -28
- package/microservices/microservice-calendar/src/cli/index.ts +0 -287
- package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
- package/microservices/microservice-calendar/src/db/database.ts +0 -91
- package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
- package/microservices/microservice-calendar/src/index.ts +0 -24
- package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
- package/microservices/microservice-company/package.json +0 -28
- package/microservices/microservice-company/src/cli/index.ts +0 -1126
- package/microservices/microservice-company/src/db/company.ts +0 -854
- package/microservices/microservice-company/src/db/database.ts +0 -91
- package/microservices/microservice-company/src/db/migrations.ts +0 -214
- package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
- package/microservices/microservice-company/src/index.ts +0 -60
- package/microservices/microservice-company/src/lib/audit.ts +0 -168
- package/microservices/microservice-company/src/lib/finance.ts +0 -299
- package/microservices/microservice-company/src/lib/settings.ts +0 -85
- package/microservices/microservice-company/src/lib/workflows.ts +0 -698
- package/microservices/microservice-company/src/mcp/index.ts +0 -991
- package/microservices/microservice-compliance/package.json +0 -28
- package/microservices/microservice-compliance/src/cli/index.ts +0 -467
- package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
- package/microservices/microservice-compliance/src/db/database.ts +0 -91
- package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
- package/microservices/microservice-compliance/src/index.ts +0 -46
- package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
- package/microservices/microservice-contacts/package.json +0 -28
- package/microservices/microservice-contacts/src/cli/index.ts +0 -393
- package/microservices/microservice-contacts/src/db/companies.ts +0 -167
- package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
- package/microservices/microservice-contacts/src/db/database.ts +0 -91
- package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
- package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
- package/microservices/microservice-contacts/src/index.ts +0 -42
- package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
- package/microservices/microservice-contracts/package.json +0 -28
- package/microservices/microservice-contracts/src/cli/index.ts +0 -770
- package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
- package/microservices/microservice-contracts/src/db/database.ts +0 -91
- package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
- package/microservices/microservice-contracts/src/index.ts +0 -43
- package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
- package/microservices/microservice-crm/package.json +0 -28
- package/microservices/microservice-crm/src/cli/index.ts +0 -396
- package/microservices/microservice-crm/src/db/database.ts +0 -91
- package/microservices/microservice-crm/src/db/migrations.ts +0 -66
- package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
- package/microservices/microservice-crm/src/index.ts +0 -34
- package/microservices/microservice-crm/src/mcp/index.ts +0 -294
- package/microservices/microservice-documents/package.json +0 -28
- package/microservices/microservice-documents/src/cli/index.ts +0 -246
- package/microservices/microservice-documents/src/db/database.ts +0 -91
- package/microservices/microservice-documents/src/db/documents.ts +0 -316
- package/microservices/microservice-documents/src/db/migrations.ts +0 -49
- package/microservices/microservice-documents/src/index.ts +0 -24
- package/microservices/microservice-documents/src/mcp/index.ts +0 -202
- package/microservices/microservice-domains/package.json +0 -28
- package/microservices/microservice-domains/src/cli/index.ts +0 -1111
- package/microservices/microservice-domains/src/db/database.ts +0 -91
- package/microservices/microservice-domains/src/db/domains.ts +0 -1164
- package/microservices/microservice-domains/src/db/migrations.ts +0 -60
- package/microservices/microservice-domains/src/index.ts +0 -65
- package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
- package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
- package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
- package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
- package/microservices/microservice-domains/src/mcp/index.ts +0 -781
- package/microservices/microservice-expenses/package.json +0 -28
- package/microservices/microservice-expenses/src/cli/index.ts +0 -267
- package/microservices/microservice-expenses/src/db/database.ts +0 -91
- package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
- package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
- package/microservices/microservice-expenses/src/index.ts +0 -25
- package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
- package/microservices/microservice-habits/package.json +0 -28
- package/microservices/microservice-habits/src/cli/index.ts +0 -315
- package/microservices/microservice-habits/src/db/database.ts +0 -91
- package/microservices/microservice-habits/src/db/habits.ts +0 -451
- package/microservices/microservice-habits/src/db/migrations.ts +0 -46
- package/microservices/microservice-habits/src/index.ts +0 -31
- package/microservices/microservice-habits/src/mcp/index.ts +0 -313
- package/microservices/microservice-health/package.json +0 -28
- package/microservices/microservice-health/src/cli/index.ts +0 -484
- package/microservices/microservice-health/src/db/database.ts +0 -91
- package/microservices/microservice-health/src/db/health.ts +0 -708
- package/microservices/microservice-health/src/db/migrations.ts +0 -70
- package/microservices/microservice-health/src/index.ts +0 -63
- package/microservices/microservice-health/src/mcp/index.ts +0 -437
- package/microservices/microservice-hiring/package.json +0 -28
- package/microservices/microservice-hiring/src/cli/index.ts +0 -741
- package/microservices/microservice-hiring/src/db/database.ts +0 -91
- package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
- package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
- package/microservices/microservice-hiring/src/index.ts +0 -80
- package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
- package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
- package/microservices/microservice-inventory/package.json +0 -28
- package/microservices/microservice-inventory/src/cli/index.ts +0 -365
- package/microservices/microservice-inventory/src/db/database.ts +0 -91
- package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
- package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
- package/microservices/microservice-inventory/src/index.ts +0 -28
- package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
- package/microservices/microservice-invoices/dashboard/index.html +0 -12
- package/microservices/microservice-invoices/dashboard/package.json +0 -29
- package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
- package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
- package/microservices/microservice-invoices/package.json +0 -31
- package/microservices/microservice-invoices/src/cli/index.ts +0 -308
- package/microservices/microservice-invoices/src/db/business.ts +0 -241
- package/microservices/microservice-invoices/src/db/clients.ts +0 -127
- package/microservices/microservice-invoices/src/db/database.ts +0 -91
- package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
- package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
- package/microservices/microservice-invoices/src/index.ts +0 -56
- package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
- package/microservices/microservice-invoices/src/server/index.ts +0 -162
- package/microservices/microservice-leads/package.json +0 -28
- package/microservices/microservice-leads/src/cli/index.ts +0 -596
- package/microservices/microservice-leads/src/db/database.ts +0 -91
- package/microservices/microservice-leads/src/db/leads.ts +0 -520
- package/microservices/microservice-leads/src/db/lists.ts +0 -151
- package/microservices/microservice-leads/src/db/migrations.ts +0 -93
- package/microservices/microservice-leads/src/index.ts +0 -65
- package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
- package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
- package/microservices/microservice-leads/src/mcp/index.ts +0 -533
- package/microservices/microservice-notes/package.json +0 -28
- package/microservices/microservice-notes/src/cli/index.ts +0 -63
- package/microservices/microservice-notes/src/db/database.ts +0 -91
- package/microservices/microservice-notes/src/db/migrations.ts +0 -40
- package/microservices/microservice-notes/src/db/notes.ts +0 -114
- package/microservices/microservice-notes/src/index.ts +0 -2
- package/microservices/microservice-notes/src/mcp/index.ts +0 -37
- package/microservices/microservice-notifications/package.json +0 -28
- package/microservices/microservice-notifications/src/cli/index.ts +0 -349
- package/microservices/microservice-notifications/src/db/database.ts +0 -91
- package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
- package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
- package/microservices/microservice-notifications/src/index.ts +0 -41
- package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
- package/microservices/microservice-payments/package.json +0 -28
- package/microservices/microservice-payments/src/cli/index.ts +0 -609
- package/microservices/microservice-payments/src/db/database.ts +0 -91
- package/microservices/microservice-payments/src/db/migrations.ts +0 -81
- package/microservices/microservice-payments/src/db/payments.ts +0 -1204
- package/microservices/microservice-payments/src/index.ts +0 -51
- package/microservices/microservice-payments/src/mcp/index.ts +0 -683
- package/microservices/microservice-payroll/package.json +0 -28
- package/microservices/microservice-payroll/src/cli/index.ts +0 -643
- package/microservices/microservice-payroll/src/db/database.ts +0 -91
- package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
- package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
- package/microservices/microservice-payroll/src/index.ts +0 -48
- package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
- package/microservices/microservice-products/package.json +0 -28
- package/microservices/microservice-products/src/cli/index.ts +0 -416
- package/microservices/microservice-products/src/db/categories.ts +0 -154
- package/microservices/microservice-products/src/db/database.ts +0 -91
- package/microservices/microservice-products/src/db/migrations.ts +0 -58
- package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
- package/microservices/microservice-products/src/db/products.ts +0 -452
- package/microservices/microservice-products/src/index.ts +0 -53
- package/microservices/microservice-products/src/mcp/index.ts +0 -453
- package/microservices/microservice-projects/package.json +0 -28
- package/microservices/microservice-projects/src/cli/index.ts +0 -480
- package/microservices/microservice-projects/src/db/database.ts +0 -91
- package/microservices/microservice-projects/src/db/migrations.ts +0 -65
- package/microservices/microservice-projects/src/db/projects.ts +0 -715
- package/microservices/microservice-projects/src/index.ts +0 -57
- package/microservices/microservice-projects/src/mcp/index.ts +0 -501
- package/microservices/microservice-proposals/package.json +0 -28
- package/microservices/microservice-proposals/src/cli/index.ts +0 -400
- package/microservices/microservice-proposals/src/db/database.ts +0 -91
- package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
- package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
- package/microservices/microservice-proposals/src/index.ts +0 -37
- package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
- package/microservices/microservice-reading/package.json +0 -28
- package/microservices/microservice-reading/src/cli/index.ts +0 -464
- package/microservices/microservice-reading/src/db/database.ts +0 -91
- package/microservices/microservice-reading/src/db/migrations.ts +0 -59
- package/microservices/microservice-reading/src/db/reading.ts +0 -524
- package/microservices/microservice-reading/src/index.ts +0 -51
- package/microservices/microservice-reading/src/mcp/index.ts +0 -368
- package/microservices/microservice-shipping/package.json +0 -28
- package/microservices/microservice-shipping/src/cli/index.ts +0 -606
- package/microservices/microservice-shipping/src/db/database.ts +0 -91
- package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
- package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
- package/microservices/microservice-shipping/src/index.ts +0 -53
- package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
- package/microservices/microservice-social/package.json +0 -29
- package/microservices/microservice-social/src/cli/index.ts +0 -1583
- package/microservices/microservice-social/src/db/database.ts +0 -91
- package/microservices/microservice-social/src/db/migrations.ts +0 -160
- package/microservices/microservice-social/src/db/social.ts +0 -1076
- package/microservices/microservice-social/src/index.ts +0 -46
- package/microservices/microservice-social/src/lib/audience.ts +0 -353
- package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
- package/microservices/microservice-social/src/lib/media.ts +0 -311
- package/microservices/microservice-social/src/lib/mentions.ts +0 -434
- package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
- package/microservices/microservice-social/src/lib/publisher.ts +0 -377
- package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
- package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
- package/microservices/microservice-social/src/lib/threads.ts +0 -291
- package/microservices/microservice-social/src/mcp/index.ts +0 -1425
- package/microservices/microservice-social/src/server/index.ts +0 -441
- package/microservices/microservice-subscriptions/package.json +0 -28
- package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
- package/microservices/microservice-subscriptions/src/db/database.ts +0 -91
- package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
- package/microservices/microservice-subscriptions/src/index.ts +0 -41
- package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
- package/microservices/microservice-timesheets/package.json +0 -28
- package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
- package/microservices/microservice-timesheets/src/db/database.ts +0 -91
- package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
- package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
- package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
- package/microservices/microservice-timesheets/src/index.ts +0 -44
- package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
- package/microservices/microservice-transcriber/package.json +0 -29
- package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
- package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
- package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
- package/microservices/microservice-transcriber/src/db/database.ts +0 -91
- package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
- package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
- package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
- package/microservices/microservice-transcriber/src/index.ts +0 -43
- package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
- package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
- package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
- package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
- package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
- package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
- package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
- package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
- package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
- package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
- package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
- package/microservices/microservice-transcriber/src/server/index.ts +0 -199
- package/microservices/microservice-travel/package.json +0 -28
- package/microservices/microservice-travel/src/cli/index.ts +0 -505
- package/microservices/microservice-travel/src/db/database.ts +0 -91
- package/microservices/microservice-travel/src/db/migrations.ts +0 -77
- package/microservices/microservice-travel/src/db/travel.ts +0 -802
- package/microservices/microservice-travel/src/index.ts +0 -60
- package/microservices/microservice-travel/src/mcp/index.ts +0 -495
- package/microservices/microservice-wiki/package.json +0 -28
- package/microservices/microservice-wiki/src/cli/index.ts +0 -345
- package/microservices/microservice-wiki/src/db/database.ts +0 -91
- package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
- package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
- package/microservices/microservice-wiki/src/index.ts +0 -32
- package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import {
|
|
5
|
-
createAccount,
|
|
6
|
-
getAccount,
|
|
7
|
-
listAccounts,
|
|
8
|
-
updateAccount,
|
|
9
|
-
deleteAccount,
|
|
10
|
-
createTransaction,
|
|
11
|
-
getTransaction,
|
|
12
|
-
listTransactions,
|
|
13
|
-
deleteTransaction,
|
|
14
|
-
getTrialBalance,
|
|
15
|
-
getAccountBalance,
|
|
16
|
-
getIncomeStatement,
|
|
17
|
-
} from "../db/bookkeeping.js";
|
|
18
|
-
|
|
19
|
-
const program = new Command();
|
|
20
|
-
|
|
21
|
-
program
|
|
22
|
-
.name("microservice-bookkeeping")
|
|
23
|
-
.description("Double-entry bookkeeping microservice")
|
|
24
|
-
.version("0.0.1");
|
|
25
|
-
|
|
26
|
-
// --- Accounts ---
|
|
27
|
-
|
|
28
|
-
const accountCmd = program
|
|
29
|
-
.command("account")
|
|
30
|
-
.alias("acc")
|
|
31
|
-
.description("Account management");
|
|
32
|
-
|
|
33
|
-
accountCmd
|
|
34
|
-
.command("add")
|
|
35
|
-
.description("Add a new account")
|
|
36
|
-
.requiredOption("--name <name>", "Account name")
|
|
37
|
-
.requiredOption("--type <type>", "Account type: asset|liability|equity|revenue|expense")
|
|
38
|
-
.option("--code <code>", "Account code")
|
|
39
|
-
.option("--description <text>", "Description")
|
|
40
|
-
.option("--parent <id>", "Parent account ID")
|
|
41
|
-
.option("--currency <code>", "Currency code", "USD")
|
|
42
|
-
.option("--json", "Output as JSON", false)
|
|
43
|
-
.action((opts) => {
|
|
44
|
-
const account = createAccount({
|
|
45
|
-
name: opts.name,
|
|
46
|
-
type: opts.type,
|
|
47
|
-
code: opts.code,
|
|
48
|
-
description: opts.description,
|
|
49
|
-
parent_id: opts.parent,
|
|
50
|
-
currency: opts.currency,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
if (opts.json) {
|
|
54
|
-
console.log(JSON.stringify(account, null, 2));
|
|
55
|
-
} else {
|
|
56
|
-
console.log(`Created account: ${account.name} [${account.type}] (${account.id})`);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
accountCmd
|
|
61
|
-
.command("get")
|
|
62
|
-
.description("Get an account by ID or code")
|
|
63
|
-
.argument("<id>", "Account ID or code")
|
|
64
|
-
.option("--json", "Output as JSON", false)
|
|
65
|
-
.action((id, opts) => {
|
|
66
|
-
const account = getAccount(id);
|
|
67
|
-
if (!account) {
|
|
68
|
-
console.error(`Account '${id}' not found.`);
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (opts.json) {
|
|
73
|
-
console.log(JSON.stringify(account, null, 2));
|
|
74
|
-
} else {
|
|
75
|
-
console.log(`${account.name} [${account.type}]`);
|
|
76
|
-
if (account.code) console.log(` Code: ${account.code}`);
|
|
77
|
-
if (account.description) console.log(` Desc: ${account.description}`);
|
|
78
|
-
console.log(` Balance: ${account.currency} ${account.balance.toFixed(2)}`);
|
|
79
|
-
console.log(` Currency: ${account.currency}`);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
accountCmd
|
|
84
|
-
.command("list")
|
|
85
|
-
.description("List accounts")
|
|
86
|
-
.option("--type <type>", "Filter by type: asset|liability|equity|revenue|expense")
|
|
87
|
-
.option("--search <query>", "Search by name, code, or description")
|
|
88
|
-
.option("--parent <id>", "Filter by parent account")
|
|
89
|
-
.option("--limit <n>", "Limit results")
|
|
90
|
-
.option("--json", "Output as JSON", false)
|
|
91
|
-
.action((opts) => {
|
|
92
|
-
const accounts = listAccounts({
|
|
93
|
-
type: opts.type,
|
|
94
|
-
search: opts.search,
|
|
95
|
-
parent_id: opts.parent,
|
|
96
|
-
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (opts.json) {
|
|
100
|
-
console.log(JSON.stringify(accounts, null, 2));
|
|
101
|
-
} else {
|
|
102
|
-
if (accounts.length === 0) {
|
|
103
|
-
console.log("No accounts found.");
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
for (const a of accounts) {
|
|
107
|
-
const code = a.code ? `[${a.code}] ` : "";
|
|
108
|
-
console.log(` ${code}${a.name} (${a.type}) — ${a.currency} ${a.balance.toFixed(2)}`);
|
|
109
|
-
}
|
|
110
|
-
console.log(`\n${accounts.length} account(s)`);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
accountCmd
|
|
115
|
-
.command("update")
|
|
116
|
-
.description("Update an account")
|
|
117
|
-
.argument("<id>", "Account ID or code")
|
|
118
|
-
.option("--name <name>", "Name")
|
|
119
|
-
.option("--type <type>", "Type")
|
|
120
|
-
.option("--code <code>", "Code")
|
|
121
|
-
.option("--description <text>", "Description")
|
|
122
|
-
.option("--parent <id>", "Parent account ID")
|
|
123
|
-
.option("--currency <code>", "Currency")
|
|
124
|
-
.option("--json", "Output as JSON", false)
|
|
125
|
-
.action((id, opts) => {
|
|
126
|
-
const input: Record<string, unknown> = {};
|
|
127
|
-
if (opts.name !== undefined) input.name = opts.name;
|
|
128
|
-
if (opts.type !== undefined) input.type = opts.type;
|
|
129
|
-
if (opts.code !== undefined) input.code = opts.code;
|
|
130
|
-
if (opts.description !== undefined) input.description = opts.description;
|
|
131
|
-
if (opts.parent !== undefined) input.parent_id = opts.parent;
|
|
132
|
-
if (opts.currency !== undefined) input.currency = opts.currency;
|
|
133
|
-
|
|
134
|
-
const account = updateAccount(id, input);
|
|
135
|
-
if (!account) {
|
|
136
|
-
console.error(`Account '${id}' not found.`);
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (opts.json) {
|
|
141
|
-
console.log(JSON.stringify(account, null, 2));
|
|
142
|
-
} else {
|
|
143
|
-
console.log(`Updated: ${account.name} [${account.type}]`);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
accountCmd
|
|
148
|
-
.command("delete")
|
|
149
|
-
.description("Delete an account")
|
|
150
|
-
.argument("<id>", "Account ID")
|
|
151
|
-
.action((id) => {
|
|
152
|
-
try {
|
|
153
|
-
const deleted = deleteAccount(id);
|
|
154
|
-
if (deleted) {
|
|
155
|
-
console.log(`Deleted account ${id}`);
|
|
156
|
-
} else {
|
|
157
|
-
console.error(`Account '${id}' not found.`);
|
|
158
|
-
process.exit(1);
|
|
159
|
-
}
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
accountCmd
|
|
167
|
-
.command("balance")
|
|
168
|
-
.description("Get account balance details")
|
|
169
|
-
.argument("<id>", "Account ID or code")
|
|
170
|
-
.option("--json", "Output as JSON", false)
|
|
171
|
-
.action((id, opts) => {
|
|
172
|
-
const result = getAccountBalance(id);
|
|
173
|
-
if (!result) {
|
|
174
|
-
console.error(`Account '${id}' not found.`);
|
|
175
|
-
process.exit(1);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (opts.json) {
|
|
179
|
-
console.log(JSON.stringify(result, null, 2));
|
|
180
|
-
} else {
|
|
181
|
-
console.log(`${result.account.name} [${result.account.type}]`);
|
|
182
|
-
console.log(` Total Debits: ${result.total_debits.toFixed(2)}`);
|
|
183
|
-
console.log(` Total Credits: ${result.total_credits.toFixed(2)}`);
|
|
184
|
-
console.log(` Balance: ${result.account.currency} ${result.balance.toFixed(2)}`);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// --- Transactions ---
|
|
189
|
-
|
|
190
|
-
program
|
|
191
|
-
.command("record")
|
|
192
|
-
.description("Record a transaction (JSON entries via --entries)")
|
|
193
|
-
.requiredOption("--description <text>", "Transaction description")
|
|
194
|
-
.requiredOption("--entries <json>", "JSON array of entries: [{account_id, debit, credit, description}]")
|
|
195
|
-
.option("--date <date>", "Transaction date (YYYY-MM-DD)")
|
|
196
|
-
.option("--reference <ref>", "Reference number")
|
|
197
|
-
.option("--json", "Output as JSON", false)
|
|
198
|
-
.action((opts) => {
|
|
199
|
-
try {
|
|
200
|
-
const entries = JSON.parse(opts.entries);
|
|
201
|
-
const txn = createTransaction({
|
|
202
|
-
description: opts.description,
|
|
203
|
-
date: opts.date,
|
|
204
|
-
reference: opts.reference,
|
|
205
|
-
entries,
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
if (opts.json) {
|
|
209
|
-
console.log(JSON.stringify(txn, null, 2));
|
|
210
|
-
} else {
|
|
211
|
-
console.log(`Recorded transaction: ${txn.description} (${txn.id})`);
|
|
212
|
-
console.log(` Date: ${txn.date}`);
|
|
213
|
-
if (txn.reference) console.log(` Ref: ${txn.reference}`);
|
|
214
|
-
for (const e of txn.entries) {
|
|
215
|
-
const dr = e.debit > 0 ? `DR ${e.debit.toFixed(2)}` : "";
|
|
216
|
-
const cr = e.credit > 0 ? `CR ${e.credit.toFixed(2)}` : "";
|
|
217
|
-
console.log(` ${e.account_id}: ${dr}${cr}${e.description ? ` — ${e.description}` : ""}`);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
} catch (error) {
|
|
221
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
program
|
|
227
|
-
.command("get")
|
|
228
|
-
.description("Get a transaction by ID or reference")
|
|
229
|
-
.argument("<id>", "Transaction ID or reference")
|
|
230
|
-
.option("--json", "Output as JSON", false)
|
|
231
|
-
.action((id, opts) => {
|
|
232
|
-
const txn = getTransaction(id);
|
|
233
|
-
if (!txn) {
|
|
234
|
-
console.error(`Transaction '${id}' not found.`);
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (opts.json) {
|
|
239
|
-
console.log(JSON.stringify(txn, null, 2));
|
|
240
|
-
} else {
|
|
241
|
-
console.log(`Transaction: ${txn.description}`);
|
|
242
|
-
console.log(` Date: ${txn.date}`);
|
|
243
|
-
if (txn.reference) console.log(` Ref: ${txn.reference}`);
|
|
244
|
-
console.log(` Entries:`);
|
|
245
|
-
for (const e of txn.entries) {
|
|
246
|
-
const dr = e.debit > 0 ? `DR ${e.debit.toFixed(2)}` : "";
|
|
247
|
-
const cr = e.credit > 0 ? `CR ${e.credit.toFixed(2)}` : "";
|
|
248
|
-
console.log(` ${e.account_id}: ${dr}${cr}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
program
|
|
254
|
-
.command("list")
|
|
255
|
-
.description("List transactions")
|
|
256
|
-
.option("--from <date>", "From date (YYYY-MM-DD)")
|
|
257
|
-
.option("--to <date>", "To date (YYYY-MM-DD)")
|
|
258
|
-
.option("--account <id>", "Filter by account ID")
|
|
259
|
-
.option("--reference <ref>", "Filter by reference")
|
|
260
|
-
.option("--search <query>", "Search description or reference")
|
|
261
|
-
.option("--limit <n>", "Limit results")
|
|
262
|
-
.option("--json", "Output as JSON", false)
|
|
263
|
-
.action((opts) => {
|
|
264
|
-
const transactions = listTransactions({
|
|
265
|
-
from_date: opts.from,
|
|
266
|
-
to_date: opts.to,
|
|
267
|
-
account_id: opts.account,
|
|
268
|
-
reference: opts.reference,
|
|
269
|
-
search: opts.search,
|
|
270
|
-
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
if (opts.json) {
|
|
274
|
-
console.log(JSON.stringify(transactions, null, 2));
|
|
275
|
-
} else {
|
|
276
|
-
if (transactions.length === 0) {
|
|
277
|
-
console.log("No transactions found.");
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
for (const txn of transactions) {
|
|
281
|
-
const ref = txn.reference ? ` [${txn.reference}]` : "";
|
|
282
|
-
const totalDebit = txn.entries.reduce((s, e) => s + e.debit, 0);
|
|
283
|
-
console.log(` ${txn.date} ${txn.description}${ref} ${totalDebit.toFixed(2)}`);
|
|
284
|
-
}
|
|
285
|
-
console.log(`\n${transactions.length} transaction(s)`);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
program
|
|
290
|
-
.command("delete")
|
|
291
|
-
.description("Delete a transaction (reverses balances)")
|
|
292
|
-
.argument("<id>", "Transaction ID")
|
|
293
|
-
.action((id) => {
|
|
294
|
-
try {
|
|
295
|
-
const deleted = deleteTransaction(id);
|
|
296
|
-
if (deleted) {
|
|
297
|
-
console.log(`Deleted transaction ${id}`);
|
|
298
|
-
} else {
|
|
299
|
-
console.error(`Transaction '${id}' not found.`);
|
|
300
|
-
process.exit(1);
|
|
301
|
-
}
|
|
302
|
-
} catch (error) {
|
|
303
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
304
|
-
process.exit(1);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
// --- Reports ---
|
|
309
|
-
|
|
310
|
-
program
|
|
311
|
-
.command("trial-balance")
|
|
312
|
-
.alias("tb")
|
|
313
|
-
.description("Show trial balance")
|
|
314
|
-
.option("--json", "Output as JSON", false)
|
|
315
|
-
.action((opts) => {
|
|
316
|
-
const tb = getTrialBalance();
|
|
317
|
-
|
|
318
|
-
if (opts.json) {
|
|
319
|
-
console.log(JSON.stringify(tb, null, 2));
|
|
320
|
-
} else {
|
|
321
|
-
console.log("\n Trial Balance");
|
|
322
|
-
console.log(" " + "-".repeat(60));
|
|
323
|
-
console.log(" Account".padEnd(40) + "Debits".padStart(12) + "Credits".padStart(12));
|
|
324
|
-
console.log(" " + "-".repeat(60));
|
|
325
|
-
for (const entry of tb.entries) {
|
|
326
|
-
const name = (entry.account_code ? `[${entry.account_code}] ` : "") + entry.account_name;
|
|
327
|
-
console.log(
|
|
328
|
-
` ${name.padEnd(38)}${entry.debit.toFixed(2).padStart(12)}${entry.credit.toFixed(2).padStart(12)}`
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
console.log(" " + "-".repeat(60));
|
|
332
|
-
console.log(
|
|
333
|
-
` ${"TOTALS".padEnd(38)}${tb.total_debits.toFixed(2).padStart(12)}${tb.total_credits.toFixed(2).padStart(12)}`
|
|
334
|
-
);
|
|
335
|
-
console.log(` Balanced: ${tb.balanced ? "YES" : "NO"}`);
|
|
336
|
-
console.log();
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
program
|
|
341
|
-
.command("income-statement")
|
|
342
|
-
.alias("is")
|
|
343
|
-
.description("Show income statement (revenue - expenses)")
|
|
344
|
-
.option("--from <date>", "From date")
|
|
345
|
-
.option("--to <date>", "To date")
|
|
346
|
-
.option("--json", "Output as JSON", false)
|
|
347
|
-
.action((opts) => {
|
|
348
|
-
const is_ = getIncomeStatement({
|
|
349
|
-
from_date: opts.from,
|
|
350
|
-
to_date: opts.to,
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
if (opts.json) {
|
|
354
|
-
console.log(JSON.stringify(is_, null, 2));
|
|
355
|
-
} else {
|
|
356
|
-
console.log("\n Income Statement");
|
|
357
|
-
console.log(" " + "-".repeat(50));
|
|
358
|
-
|
|
359
|
-
if (is_.revenue.length > 0) {
|
|
360
|
-
console.log(" REVENUE:");
|
|
361
|
-
for (const r of is_.revenue) {
|
|
362
|
-
const name = (r.account_code ? `[${r.account_code}] ` : "") + r.account_name;
|
|
363
|
-
console.log(` ${name.padEnd(36)}${r.amount.toFixed(2).padStart(12)}`);
|
|
364
|
-
}
|
|
365
|
-
console.log(` ${"Total Revenue".padEnd(36)}${is_.total_revenue.toFixed(2).padStart(12)}`);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
console.log();
|
|
369
|
-
|
|
370
|
-
if (is_.expenses.length > 0) {
|
|
371
|
-
console.log(" EXPENSES:");
|
|
372
|
-
for (const e of is_.expenses) {
|
|
373
|
-
const name = (e.account_code ? `[${e.account_code}] ` : "") + e.account_name;
|
|
374
|
-
console.log(` ${name.padEnd(36)}${e.amount.toFixed(2).padStart(12)}`);
|
|
375
|
-
}
|
|
376
|
-
console.log(` ${"Total Expenses".padEnd(36)}${is_.total_expenses.toFixed(2).padStart(12)}`);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
console.log();
|
|
380
|
-
console.log(" " + "-".repeat(50));
|
|
381
|
-
console.log(` ${"NET INCOME".padEnd(38)}${is_.net_income.toFixed(2).padStart(12)}`);
|
|
382
|
-
console.log();
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
program.parse(process.argv);
|