jaz-clio 4.2.0 → 4.3.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.
Files changed (42) hide show
  1. package/README.md +89 -248
  2. package/assets/skills/api/SKILL.md +64 -9
  3. package/assets/skills/api/references/endpoints.md +74 -5
  4. package/assets/skills/api/references/full-api-surface.md +4 -3
  5. package/assets/skills/conversion/SKILL.md +1 -1
  6. package/assets/skills/jobs/SKILL.md +1 -1
  7. package/assets/skills/jobs/references/document-collection.md +58 -12
  8. package/assets/skills/transaction-recipes/SKILL.md +1 -1
  9. package/dist/commands/accounts.js +18 -10
  10. package/dist/commands/bank.js +43 -1
  11. package/dist/commands/bills.js +240 -12
  12. package/dist/commands/capsules.js +18 -10
  13. package/dist/commands/cash-entry.js +18 -10
  14. package/dist/commands/cash-transfer.js +18 -10
  15. package/dist/commands/contacts.js +18 -10
  16. package/dist/commands/currency-rates.js +9 -5
  17. package/dist/commands/customer-credit-notes.js +18 -10
  18. package/dist/commands/draft-helpers.js +276 -0
  19. package/dist/commands/init.js +1 -1
  20. package/dist/commands/invoices.js +18 -10
  21. package/dist/commands/items.js +18 -10
  22. package/dist/commands/jobs.js +52 -2
  23. package/dist/commands/journals.js +18 -10
  24. package/dist/commands/magic.js +262 -0
  25. package/dist/commands/pagination.js +44 -10
  26. package/dist/commands/payments.js +18 -10
  27. package/dist/commands/reports.js +18 -1
  28. package/dist/commands/resolve.js +52 -0
  29. package/dist/commands/supplier-credit-notes.js +18 -10
  30. package/dist/commands/tags.js +18 -10
  31. package/dist/core/api/attachments.js +7 -12
  32. package/dist/core/api/bills.js +10 -0
  33. package/dist/core/api/magic.js +78 -0
  34. package/dist/core/api/reports.js +3 -0
  35. package/dist/core/jobs/document-collection/tools/ingest/classify.js +38 -8
  36. package/dist/core/jobs/document-collection/tools/ingest/decrypt.js +111 -0
  37. package/dist/core/jobs/document-collection/tools/ingest/format.js +6 -3
  38. package/dist/core/jobs/document-collection/tools/ingest/scanner.js +17 -2
  39. package/dist/core/jobs/document-collection/tools/ingest/upload.js +20 -7
  40. package/dist/index.js +4 -2
  41. package/dist/utils/template.js +14 -4
  42. package/package.json +4 -1
package/README.md CHANGED
@@ -1,299 +1,140 @@
1
- # Jaz AI
1
+ # Clio — Jaz AI Command Line Tool
2
2
 
3
3
  <p align="center">
4
- <a href="https://github.com/teamtinvio/jaz-ai/releases"><img src="https://img.shields.io/github/v/release/teamtinvio/jaz-ai?style=for-the-badge&color=blue" alt="GitHub Release"></a>
5
- <img src="https://img.shields.io/badge/API_rules-70-green?style=for-the-badge" alt="70 API Rules">
6
- <img src="https://img.shields.io/badge/skills-4-purple?style=for-the-badge" alt="4 Skills">
7
- <img src="https://img.shields.io/badge/recipes-16-orange?style=for-the-badge" alt="16 Recipes">
4
+ <a href="https://www.npmjs.com/package/jaz-clio"><img src="https://img.shields.io/npm/v/jaz-clio?style=for-the-badge&logo=npm" alt="npm"></a>
5
+ <a href="https://www.npmjs.com/package/jaz-clio"><img src="https://img.shields.io/npm/dm/jaz-clio?style=for-the-badge&label=downloads" alt="npm downloads"></a>
8
6
  <img src="https://img.shields.io/badge/calculators-10-red?style=for-the-badge" alt="10 Calculators">
9
7
  <img src="https://img.shields.io/badge/jobs-12-teal?style=for-the-badge" alt="12 Jobs">
10
8
  <a href="https://github.com/teamtinvio/jaz-ai/blob/main/LICENSE"><img src="https://img.shields.io/github/license/teamtinvio/jaz-ai?style=for-the-badge&color=green" alt="License"></a>
11
9
  </p>
12
10
 
13
- <p align="center">
14
- <a href="https://www.npmjs.com/package/jaz-clio"><img src="https://img.shields.io/npm/v/jaz-clio?style=flat-square&logo=npm&label=CLI" alt="npm"></a>
15
- <a href="https://www.npmjs.com/package/jaz-clio"><img src="https://img.shields.io/npm/dm/jaz-clio?style=flat-square&label=downloads" alt="npm downloads"></a>
16
- <a href="https://github.com/teamtinvio/jaz-ai/stargazers"><img src="https://img.shields.io/github/stars/teamtinvio/jaz-ai?style=flat-square&logo=github" alt="GitHub stars"></a>
17
- </p>
18
-
19
- API reference, financial calculators, IFRS recipes, accounting jobs, data conversion playbooks, and tax computation — directly inside the AI that builders, accountants, and developers are already using to get things done.
11
+ CLI for the [Jaz](https://jaz.ai) accounting platform. Create invoices, record bills, manage contacts, run financial calculators, execute accounting jobs, and install AI agent skills — all from your terminal.
20
12
 
21
- Agent skills for [Jaz](https://jaz.ai) accounting platform. Works with [Claude Code](https://claude.com/claude-code), [Google Antigravity](https://antigravity.google), [OpenAI Codex](https://openai.com/codex), [GitHub Copilot](https://github.com/features/copilot), [Cursor](https://cursor.com), and any tool that supports the [Agent Skills](https://agentskills.io) open standard.
13
+ > Also fully compatible with [Juan Accounting](https://juan.ac).
22
14
 
23
- > All skills, CLI commands, and the plugin are fully compatible with [Juan Accounting](https://juan.ac) too.
15
+ ## Prerequisites
24
16
 
25
- ## Skills
17
+ **Node.js 18 or later** is required. If `node --version` works, skip ahead.
26
18
 
27
- | Skill | What It Does |
28
- |-------|-------------|
29
- | **jaz-api** | 70 rules, full endpoint catalog, error catalog, field mapping. Agents write correct Jaz API code on the first try instead of guessing |
30
- | **jaz-conversion** | Xero, QuickBooks, Sage, Excel migration playbook. CoA mapping, tax profiles, FX, clearing accounts, trial balance verification |
31
- | **jaz-recipes** | 16 IFRS-compliant recipes (loans, leases, depreciation, FX reval, ECL, provisions, and more) + 10 CLI financial calculators with blueprint output |
32
- | **jaz-jobs** | 12 accounting jobs (month/quarter/year-end close, bank recon, document collection, GST/VAT filing, payment runs, credit control, supplier recon, audit prep, FA review, statutory filing) + Singapore Form C-S tax computation with AI-guided wizard workflow |
19
+ Otherwise: download the LTS installer from [nodejs.org](https://nodejs.org). It includes `npm`.
33
20
 
34
- ## Installation
35
-
36
- ### Using Clio CLI (Recommended)
37
-
38
- Works with any AI tool. Auto-detects your platform and installs to the right path.
21
+ ## Install
39
22
 
40
23
  ```bash
41
- # Install CLI globally
42
24
  npm install -g jaz-clio
43
-
44
- # Go to your project
45
- cd /path/to/your/project
46
-
47
- # Install all skills (auto-detects platform)
48
- clio init
49
-
50
- # Or install a specific skill
51
- clio init --skill jaz-api
52
- clio init --skill jaz-conversion
53
- clio init --skill jaz-recipes
54
- clio init --skill jaz-jobs
55
-
56
- # Force a specific platform
57
- clio init --platform claude # → .claude/skills/
58
- clio init --platform antigravity # → .agents/skills/
59
- clio init --platform codex # → .agents/skills/
60
- clio init --platform agents # → .agents/skills/ (universal)
61
25
  ```
62
26
 
63
- ### Claude Code Marketplace
27
+ ## Authenticate
64
28
 
65
- ```
66
- /plugin marketplace add teamtinvio/jaz-ai
67
- /plugin install jaz-ai@jaz-plugins
68
- ```
29
+ ```bash
30
+ # Add your Jaz API key (get one from Settings > API in the Jaz app)
31
+ clio auth add <your-api-key>
69
32
 
70
- ### OpenAI Codex
33
+ # Verify it works
34
+ clio auth whoami
71
35
 
72
- ```
73
- $skill-installer https://github.com/teamtinvio/jaz-ai
36
+ # Manage multiple orgs
37
+ clio auth add <another-key> # Adds a second profile
38
+ clio auth list # See all profiles
39
+ clio auth switch <label> # Switch active org
74
40
  ```
75
41
 
76
- ### Manual Install
42
+ ## Commands
77
43
 
78
- Copy the skill directories into your project:
44
+ ### Transactions
79
45
 
80
46
  ```bash
81
- # For Antigravity, Codex, Copilot, Cursor (Agent Skills standard)
82
- cp -r .agents/skills/ /path/to/your/project/.agents/skills/
83
-
84
- # For Claude Code
85
- cp -r .claude/skills/ /path/to/your/project/.claude/skills/
47
+ clio invoices list # List invoices
48
+ clio invoices create --contact "ACME" # Create a draft invoice
49
+ clio invoices pay <id> # Record payment
50
+ clio bills list --status APPROVED # List approved bills
51
+ clio bills pay <id> # Pay a bill
52
+ clio customer-credit-notes list # List customer credit notes
53
+ clio supplier-credit-notes list # List supplier credit notes
54
+ clio journals list # List journal entries
55
+ clio cash-in list # List cash-in entries
56
+ clio cash-out list # List cash-out entries
57
+ clio cash-transfer list # List cash transfers
86
58
  ```
87
59
 
88
- ### Other CLI Commands
60
+ ### Contacts, Accounts & Items
89
61
 
90
62
  ```bash
91
- clio versions # List available versions
92
- clio update # Update to latest version
93
- clio --help # Show all commands
94
- ```
95
-
96
- ## Usage
97
-
98
- Skills activate automatically when you or your agent work with Jaz API code or data conversion tasks. Just describe what you need:
99
-
100
- ### API Skill
101
-
102
- ```
103
- Create an invoice with 3 line items and 7% GST
104
-
105
- Build a payment for invoice INV-001 in USD
106
-
107
- Query all overdue bills with pagination
108
-
109
- Set up chart of accounts for a Singapore company
110
- ```
111
-
112
- ### Conversion Skill
113
-
63
+ clio contacts search "ACME" # Fuzzy search contacts
64
+ clio contacts create --name "ACME Ltd" # Create a contact
65
+ clio accounts list # Chart of accounts
66
+ clio items list # Products and services
67
+ clio tags list # Tracking tags
114
68
  ```
115
- Convert this Xero trial balance export to Jaz
116
-
117
- Migrate QuickBooks aged receivables to conversion invoices
118
-
119
- Map this Excel chart of accounts to Jaz CoA structure
120
69
 
121
- Verify the trial balance after conversion
122
- ```
70
+ ### Financial Calculators
123
71
 
124
- ### Transaction Recipes Skill
72
+ 10 IFRS-compliant calculators that output structured blueprints with journal entries, workings, and execution plans.
125
73
 
74
+ ```bash
75
+ clio calc loan --principal 100000 --rate 6 --term 60 --json
76
+ clio calc depreciation --cost 50000 --salvage 5000 --life 5 --method ddb --json
77
+ clio calc lease --value 120000 --term 36 --rate 5 --json
78
+ clio calc ecl --receivables '[{"bucket":"0-30","balance":50000,"rate":0.5}]' --json
79
+ clio calc provision --amount 100000 --rate 4 --periods 24 --json
80
+ clio calc fx-reval --account "USD Cash" --balance 10000 --old-rate 1.35 --new-rate 1.34 --json
81
+ clio calc fixed-deposit --principal 100000 --rate 3.5 --term 12 --json
82
+ clio calc disposal --cost 50000 --accum-dep 30000 --proceeds 15000 --json
83
+ clio calc amortization --amount 12000 --periods 12 --start 2025-01-01 --json
84
+ clio calc hire-purchase --value 80000 --term 48 --rate 4.5 --json
126
85
  ```
127
- Set up a 5-year bank loan with monthly repayment schedule
128
-
129
- Model IFRS 16 lease for a 3-year office lease at 5% IBR
130
86
 
131
- Calculate ECL provision on aged receivables
87
+ ### Accounting Jobs
132
88
 
133
- Record prepaid insurance with monthly amortization via capsule
134
- ```
89
+ 12 job blueprints that generate step-by-step playbooks with checklists and paired tools.
135
90
 
136
- ### Jobs Skill
91
+ ```bash
92
+ clio jobs month-end --period 2025-01 # Month-end close
93
+ clio jobs quarter-end --period 2025-Q1 # Quarter-end close
94
+ clio jobs year-end --period 2025 # Year-end close
95
+ clio jobs bank-recon match --input bank-data.json --json # Bank reconciliation matcher
96
+ clio jobs document-collection ingest --source "./receipts" --json # Document scanner
97
+ clio jobs gst-vat --period 2025-Q1 # GST/VAT filing prep
98
+ clio jobs payment-run --due-before 2025-02-28 # Payment run
99
+ clio jobs credit-control # AR aging + chase list
100
+ clio jobs supplier-recon # AP vs supplier statements
101
+ clio jobs audit-prep --period 2025 # Audit pack
102
+ clio jobs fa-review # Fixed asset review
103
+ clio jobs statutory-filing sg-cs --ya 2026 --revenue 500000 --profit 120000 --json # SG Form C-S
104
+ ```
105
+
106
+ ### Other
137
107
 
108
+ ```bash
109
+ clio org info # Current org details
110
+ clio currencies list # Enabled currencies
111
+ clio currency-rates list # Exchange rates
112
+ clio payments search # Search payments
113
+ clio bank import --file statement.csv # Import bank statement
114
+ clio reports generate --type pnl # Generate reports
115
+ clio capsules list # List capsules (transaction groups)
116
+ clio versions # Show version info
117
+ clio update # Update to latest
138
118
  ```
139
- Close the books for January 2025
140
-
141
- Run bank reconciliation for DBS Current account
142
119
 
143
- Prepare GST return for Q1 2025
120
+ Every command supports `--json` for structured output — ideal for piping to other tools or for AI agents.
144
121
 
145
- Generate a payment run for all overdue bills
122
+ ## Install AI Skills
146
123
 
147
- Prepare audit pack for FY 2025
148
- ```
149
-
150
- ### Financial Calculators & Job Tools (CLI)
124
+ Clio also installs AI agent skills into your project. Skills are knowledge files that teach AI tools (Claude Code, Antigravity, Codex, Copilot, Cursor) how to work with the Jaz API.
151
125
 
152
126
  ```bash
153
- clio calc loan --principal 100000 --rate 6 --term 60 --json
154
- clio calc depreciation --cost 50000 --salvage 5000 --life 5 --method ddb --json
155
- clio jobs bank-recon match --input bank-data.json --json
156
- clio jobs document-collection ingest --source "https://www.dropbox.com/scl/fo/..." --json
157
- clio jobs statutory-filing sg-cs --ya 2026 --revenue 500000 --profit 120000 --json
127
+ cd /path/to/your/project
128
+ clio init # Auto-detects your AI tool, installs all 4 skills
129
+ clio init --skill jaz-api # Install a specific skill
130
+ clio init --platform claude # Force a specific platform
158
131
  ```
159
132
 
160
- 10 financial calculators, 12 job blueprints, and paired tools (bank matcher, document ingest with cloud support, SG Form C-S tax computation). Add `--json` for structured blueprint output with capsule type, journal entries, workings, and step-by-step execution plan.
161
-
162
- Full command reference: [transaction-recipes skill](src/skills/transaction-recipes/SKILL.md) and [jobs skill](src/skills/jobs/SKILL.md).
163
-
164
- ## What's Inside
165
-
166
- ### API Skill (`jaz-api`)
167
-
168
- | Reference | Lines | Content |
169
- |-----------|-------|---------|
170
- | `SKILL.md` | 185 | 70 critical rules — auth, IDs, dates, FX, payments, field aliases, response shapes |
171
- | `endpoints.md` | 1,299 | Request/response examples for every core endpoint |
172
- | `errors.md` | 751 | Error catalog with root causes and fixes |
173
- | `field-map.md` | 428 | Intuitive name -> actual field name mapping |
174
- | `search-reference.md` | 714 | Filter fields, sort fields, operators for 28 search endpoints |
175
- | `full-api-surface.md` | 699 | Complete endpoint catalog (80+), enums, limits |
176
- | `dependencies.md` | 139 | Resource creation order (currencies -> CoA -> transactions) |
177
- | `feature-glossary.md` | 216 | Business context per feature |
178
-
179
- ### Conversion Skill (`jaz-conversion`)
180
-
181
- | Reference | Content |
182
- |-----------|---------|
183
- | `SKILL.md` | Conversion domain knowledge, clearing account pattern, FX handling |
184
- | `mapping-rules.md` | CoA, contact, and tax code mapping rules |
185
- | `option1-full.md` | Full conversion workflow (all transactions FY + FY-1) |
186
- | `option2-quick.md` | Quick conversion workflow (opening balances at FYE) |
187
- | `file-types.md` | Supported file formats and detection heuristics |
188
- | `edge-cases.md` | Platform-specific quirks (Sage 300 preambles, Xero rounding) |
189
- | `verification.md` | Trial balance comparison and verification checklist |
190
- | `file-analysis.md` | Excel/CSV structure analysis and smart detection |
191
-
192
- ### Transaction Recipes Skill (`jaz-recipes`)
193
-
194
- | Reference | Content |
195
- |-----------|---------|
196
- | `SKILL.md` | 16 recipes in 4 tiers, building blocks, key principles, calculator index |
197
- | `building-blocks.md` | Capsules, schedulers, manual journals, FA, tracking tags, nano classifiers |
198
- | `prepaid-amortization.md` | Annual insurance/rent paid upfront, monthly scheduler recognition |
199
- | `deferred-revenue.md` | Upfront customer payment, monthly revenue recognition |
200
- | `accrued-expenses.md` | Month-end accrual + reversal cycle using dual schedulers |
201
- | `bank-loan.md` | Loan disbursement, amortization table, monthly installments |
202
- | `ifrs16-lease.md` | ROU asset + lease liability unwinding (IFRS 16) |
203
- | `declining-balance.md` | DDB/150DB with switch-to-SL logic |
204
- | `fixed-deposit.md` | Placement, compound interest accrual, maturity (IFRS 9) |
205
- | `hire-purchase.md` | Like IFRS 16 but depreciate over useful life |
206
- | `asset-disposal.md` | Sale/scrap/write-off with gain/loss (IAS 16) |
207
- | `fx-revaluation.md` | Non-AR/AP FX revaluation with Day 1 reversal (IAS 21) |
208
- | `bad-debt-provision.md` | ECL simplified approach provision matrix (IFRS 9) |
209
- | `employee-accruals.md` | Leave (scheduler) + bonus (manual) accruals (IAS 19) |
210
- | `provisions.md` | PV recognition + monthly discount unwinding (IAS 37) |
211
- | `dividend.md` | Declaration + payment (two manual journals) |
212
- | `intercompany.md` | Mirrored invoices/bills across two entities |
213
- | `capital-wip.md` | CIP accumulation → FA transfer on completion |
214
-
215
-
216
- ### Jobs Skill (`jaz-jobs`)
217
-
218
- | Reference | Content |
219
- |-----------|---------|
220
- | `SKILL.md` | 12 accounting jobs + SG tax computation, CLI commands, wizard workflow overview |
221
- | `building-blocks.md` | Shared concepts: accounting periods, lock dates, period verification |
222
- | `month-end-close.md` | 5 phases, ~18 steps — the foundation for all period closes |
223
- | `quarter-end-close.md` | Monthly + quarterly extras (GST/VAT, ECL, bonus accruals) |
224
- | `year-end-close.md` | Quarterly + annual extras (true-ups, dividends, CYE rollover) |
225
- | `bank-recon.md` | Match, categorize, resolve unreconciled items |
226
- | `bank-match.md` | Bank reconciliation matcher — 5-phase cascade algorithm (1:1, N:1, 1:N, N:M) |
227
- | `document-collection.md` | Scan and classify documents from local directories and cloud links (Dropbox, Google Drive, OneDrive) — outputs file paths for agent upload |
228
- | `gst-vat-filing.md` | Tax ledger review, discrepancy check, filing summary |
229
- | `payment-run.md` | Select outstanding bills by due date, process payments |
230
- | `credit-control.md` | AR aging review, overdue chase list, bad debt assessment |
231
- | `supplier-recon.md` | AP vs supplier statement, identify mismatches |
232
- | `audit-prep.md` | Compile reports, schedules, reconciliations for auditor |
233
- | `fa-review.md` | Fixed asset register review, disposal/write-off processing |
234
- | `sg-tax/overview.md` | SG CIT framework: 17% rate, YA concept, Form C-S eligibility |
235
- | `sg-tax/form-cs-fields.md` | 18 Form C-S + 6 C-S Lite fields with IRAS labels |
236
- | `sg-tax/wizard-workflow.md` | Step-by-step AI agent wizard procedure |
237
- | `sg-tax/data-extraction.md` | How to pull P&L, TB, GL, FA from Jaz API for tax |
238
- | `sg-tax/add-backs-guide.md` | Which expenses are non-deductible + GL patterns |
239
- | `sg-tax/capital-allowances-guide.md` | S19, S19A, S19B, S14Q rules per asset category |
240
- | `sg-tax/ifrs16-tax-adjustment.md` | IFRS 16 lease reversal for tax purposes |
241
- | `sg-tax/enhanced-deductions.md` | R&D (250-400%), IP, donations (250% IPC), S14Q |
242
- | `sg-tax/exemptions-and-rebates.md` | SUTE, PTE, CIT rebate schedule by YA |
243
- | `sg-tax/losses-and-carry-forwards.md` | Set-off order, carry-forward rules |
244
-
245
- ## Architecture
246
-
247
- ```
248
- .claude-plugin/ Claude Code marketplace manifest
249
- ├── plugin.json
250
- └── marketplace.json
251
-
252
- .agents/skills/ Agent Skills standard (Codex, Copilot, Cursor)
253
- ├── api/ → src/skills/api/
254
- ├── conversion/ → src/skills/conversion/
255
- ├── transaction-recipes/ → src/skills/transaction-recipes/
256
- └── jobs/ → src/skills/jobs/
257
-
258
- .claude/skills/ Claude Code native path
259
- ├── api/ → src/skills/api/
260
- ├── conversion/ → src/skills/conversion/
261
- ├── transaction-recipes/ → src/skills/transaction-recipes/
262
- └── jobs/ → src/skills/jobs/
263
-
264
- src/skills/ Source of truth (single copy, dual discovery paths)
265
- ├── api/ 70 rules + 7 reference files
266
- ├── conversion/ Conversion domain + 7 reference files
267
- ├── transaction-recipes/ 16 recipes + 18 reference files
268
- └── jobs/ 12 jobs + 12 job files + 10 sg-tax files
269
-
270
- src/ npm CLI (jaz-clio)
271
- ├── commands/ CLI command handlers (23 command groups)
272
- │ ├── calc.ts 10 financial calculator commands
273
- │ ├── jobs.ts Job blueprints + nested tools
274
- │ ├── invoices.ts Invoice CRUD + pay + apply-credits + download
275
- │ ├── bills.ts Bill CRUD + pay + apply-credits
276
- │ ├── customer-credit-notes.ts CCN CRUD + refund + refunds (list)
277
- │ ├── supplier-credit-notes.ts SCN CRUD + refund + refunds (list)
278
- │ ├── contacts.ts Contact CRUD + search
279
- │ ├── journals.ts Journal entries + search
280
- │ ├── cash-entry.ts Cash-in / cash-out journals
281
- │ ├── cash-transfer.ts Cash transfer journals
282
- │ ├── currencies.ts Currency list + enable
283
- │ ├── currency-rates.ts Exchange rate CRUD
284
- │ └── ... 10 more (auth, org, bank, accounts, reports, etc.)
285
- ├── core/ Shared logic
286
- │ ├── api/ Jaz REST client (30+ modules, 70+ endpoints)
287
- │ ├── calc/ 10 financial calculators
288
- │ ├── jobs/ 12 job blueprints + paired tools
289
- │ ├── auth/ Credential management
290
- │ └── intelligence/ Fuzzy matching, date parsing, contact resolution
291
- └── assets/skills/ Bundled skill content for npm package
292
- ```
133
+ See the [full README](https://github.com/teamtinvio/jaz-ai) for skill details, reference file catalogs, and plugin installation.
293
134
 
294
135
  ## Common API Gotchas
295
136
 
296
- Mistakes the skill prevents — for agents and humans alike:
137
+ Mistakes the CLI and skills prevent:
297
138
 
298
139
  | Gotcha | Wrong | Right |
299
140
  |--------|-------|-------|
@@ -308,4 +149,4 @@ Mistakes the skill prevents — for agents and humans alike:
308
149
 
309
150
  ## License
310
151
 
311
- [MIT](LICENSE) - Copyright (c) 2026 Tinvio / Jaz
152
+ [MIT](https://github.com/teamtinvio/jaz-ai/blob/main/LICENSE) - Copyright (c) 2026 Tinvio / Jaz
@@ -1,14 +1,14 @@
1
1
  ---
2
2
  name: jaz-api
3
- version: 4.2.0
4
- description: Complete reference for the Jaz/Juan REST API — the accounting platform backend. Use this skill whenever building, modifying, debugging, or extending any code that calls the API — including API clients, integrations, data seeding, test data, or new endpoint work. Contains every field name, response shape, error, gotcha, and edge case discovered through live production testing.
3
+ version: 4.3.0
4
+ description: Complete reference for the Jaz REST API — the accounting platform backend. Use this skill whenever building, modifying, debugging, or extending any code that calls the API — including API clients, integrations, data seeding, test data, or new endpoint work. Contains every field name, response shape, error, gotcha, and edge case discovered through live production testing.
5
5
  license: MIT
6
- compatibility: Requires Jaz/Juan API key (x-jk-api-key header). Works with Claude Code, Claude Cowork, Claude.ai, and any agent that reads markdown.
6
+ compatibility: Requires Jaz API key (x-jk-api-key header). Works with Claude Code, Google Antigravity, OpenAI Codex, GitHub Copilot, Cursor, and any agent that reads markdown.
7
7
  ---
8
8
 
9
9
  # Jaz API Skill
10
10
 
11
- You are working with the **Jaz/Juan REST API** — the backend for Jaz (Singapore) and Juan (Philippines) accounting platforms.
11
+ You are working with the **Jaz REST API** — the accounting platform backend. Also fully compatible with Juan Accounting (same API, same endpoints).
12
12
 
13
13
  ## When to Use This Skill
14
14
 
@@ -94,7 +94,7 @@ You are working with the **Jaz/Juan REST API** — the backend for Jaz (Singapor
94
94
  | Trial balance | `startDate`, `endDate` |
95
95
  | Balance sheet | `primarySnapshotDate` |
96
96
  | P&L | `primarySnapshotDate`, `secondarySnapshotDate` |
97
- | General ledger | `startDate`, `endDate`, `groupBy: "ACCOUNT"` |
97
+ | General ledger | `startDate`, `endDate`, `groupBy: "ACCOUNT"` (also `TRANSACTION`, `CAPSULE`) |
98
98
  | Cashflow | `primaryStartDate`, `primaryEndDate` |
99
99
  | Cash balance | `reportDate` |
100
100
  | AR/AP report | `endDate` |
@@ -105,7 +105,7 @@ You are working with the **Jaz/Juan REST API** — the backend for Jaz (Singapor
105
105
  37. **Data exports use simpler field names**: P&L export uses `startDate`/`endDate` (NOT `primarySnapshotDate`). AR/AP export uses `endDate`.
106
106
 
107
107
  ### Pagination
108
- 38. **All list/search endpoints use `limit`/`offset` pagination** — NOT `page`/`size`. Default limit=100, offset=0. Max limit=1000, max offset=65536. `page`/`size` params are silently ignored. Response shape: `{ totalPages, totalElements, data: [...] }`.
108
+ 38. **All list/search endpoints use `limit`/`offset` pagination** — NOT `page`/`size`. Default limit=100, offset=0. Max limit=1000, max offset=65536. `page`/`size` params are silently ignored. Response shape: `{ totalPages, totalElements, truncated, data: [...] }`. When `truncated: true`, a `_meta: { fetchedRows, maxRows }` field explains why (offset cap or `--max-rows` soft cap — default 10,000). Use `--max-rows <n>` to override. Always check `truncated` before assuming the full dataset was returned.
109
109
 
110
110
  ### Other
111
111
  39. **Currency rates use `/organization-currencies/:code/rates`** — note the HYPHENATED path (NOT `/organization/currencies`). Enable currencies first via `POST /organization/currencies`, then set rates via `POST /organization-currencies/:code/rates` with body `{ "rate": 0.74, "rateApplicableFrom": "YYYY-MM-DD" }` (see Rule 49 for direction). Cannot set rates for org base currency. Full CRUD: POST (create), GET (list), GET/:id, PUT/:id, DELETE/:id.
@@ -132,11 +132,12 @@ You are working with the **Jaz/Juan REST API** — the backend for Jaz (Singapor
132
132
  ### Jaz Magic — Extraction & Autofill
133
133
  57. **When the user starts from an attachment, always use Jaz Magic** — if the input is a PDF, JPG, or any document image (invoice, bill, receipt), the correct path is `POST /magic/createBusinessTransactionFromAttachment`. Do NOT manually construct a `POST /invoices` or `POST /bills` payload from an attachment — Jaz Magic handles the entire extraction-and-autofill pipeline server-side: OCR, line item detection, contact matching, CoA auto-mapping via ML learning, and draft creation with all fields pre-filled. Only use `POST /invoices` or `POST /bills` when building transactions from structured data (JSON, CSV, database rows) where the fields are already known.
134
134
  58. **Two upload modes with different content types** — `sourceType: "FILE"` requires **multipart/form-data** with `sourceFile` blob (JSON body fails with 400 "sourceFile is a required field"). `sourceType: "URL"` accepts **application/json** with `sourceURL` string. The OAS only documents URL mode — FILE mode (the common case) is undocumented.
135
- 59. **Three required fields**: `sourceFile` (multipart blob — NOT `file`), `businessTransactionType` (`"INVOICE"` or `"BILL"` only — `EXPENSE` rejected), `sourceType` (`"FILE"` or `"URL"`). All three are validated server-side. **CRITICAL: multipart form field names are camelCase** — `businessTransactionType`, `sourceType`, `sourceFile`, NOT snake_case. Using `business_transaction_type` returns 422 "businessTransactionType is a required field". The File blob must include a filename and correct MIME type (e.g. `application/pdf`, `image/jpeg`) — bare `application/octet-stream` blobs are rejected with 400 "Invalid file type".
136
- 60. **Response maps transaction types**: Request `BILL` → response `businessTransactionType: "PURCHASE"`. Request `INVOICE` → response `businessTransactionType: "SALE"`. S3 paths follow: `/purchases/` vs `/sales/`.
137
- 61. **Extraction is asynchronous** — the API response is immediate (file upload confirmation only). The actual Magic pipeline — OCR, line item extraction, contact matching, CoA learning, and autofill — runs asynchronously. The `subscriptionFBPath` in the response (e.g., `magic_transactions/{orgId}/purchase/{fileId}`) is a Firebase Realtime Database path for subscribing to extraction status updates.
135
+ 59. **Three required fields**: `sourceFile` (multipart blob — NOT `file`), `businessTransactionType` (`"INVOICE"`, `"BILL"`, `"CUSTOMER_CREDIT_NOTE"`, or `"SUPPLIER_CREDIT_NOTE"` — `EXPENSE` rejected), `sourceType` (`"FILE"` or `"URL"`). All three are validated server-side. **CRITICAL: multipart form field names are camelCase** — `businessTransactionType`, `sourceType`, `sourceFile`, NOT snake_case. Using `business_transaction_type` returns 422 "businessTransactionType is a required field". The File blob must include a filename and correct MIME type (e.g. `application/pdf`, `image/jpeg`) — bare `application/octet-stream` blobs are rejected with 400 "Invalid file type".
136
+ 60. **Response maps transaction types**: Request `INVOICE` → response `SALE`. Request `BILL` → response `PURCHASE`. Request `CUSTOMER_CREDIT_NOTE` → response `SALE_CREDIT_NOTE`. Request `SUPPLIER_CREDIT_NOTE` → response `PURCHASE_CREDIT_NOTE`. S3 paths follow the response type. The response `validFiles[]` array contains `workflowResourceId` for tracking extraction progress via `POST /magic/workflows/search`.
137
+ 61. **Extraction is asynchronous** — the API response is immediate (file upload confirmation only). The actual Magic pipeline — OCR, line item extraction, contact matching, CoA learning, and autofill — runs asynchronously. Use `POST /magic/workflows/search` with `filter.resourceId.eq: "<workflowResourceId>"` to check status (SUBMITTED → PROCESSING → COMPLETED/FAILED). When COMPLETED, `businessTransactionDetails.businessTransactionResourceId` contains the created draft BT ID. The `subscriptionFBPath` in the response is a Firebase Realtime Database path for real-time status updates (alternative to polling).
138
138
  62. **Accepts PDF and JPG/JPEG** — both file types confirmed working. Handwritten documents are accepted at upload stage (extraction quality varies). `fileType` in response reflects actual format: `"PDF"`, `"JPEG"`.
139
139
  63. **Never use magic-search endpoints** — `GET /invoices/magic-search` and `GET /bills/magic-search` require a separate `x-magic-api-key` (not available to agents). Always use `POST /invoices/search` or `POST /bills/search` with standard `x-jk-api-key` auth instead.
140
+ 63b. **Workflow search tracks all magic uploads** — `POST /magic/workflows/search` searches across BT extractions AND bank statement imports. Filter by `resourceId` (eq), `documentType` (SALE, PURCHASE, SALE_CREDIT_NOTE, PURCHASE_CREDIT_NOTE, BANK_STATEMENT), `status` (SUBMITTED, PROCESSING, COMPLETED, FAILED), `fileName` (contains), `fileType`, `createdAt` (date range). Response: paginated `MagicWorkflowItem` with `businessTransactionDetails.businessTransactionResourceId` (the draft BT ID when COMPLETED) or `bankStatementDetails` (for bank imports). Standard search sort: `{ sortBy: ["createdAt"], order: "DESC" }`.
140
141
 
141
142
  ### Cashflow & Unified Ledger
142
143
  64. **No standalone payments list/search** — `GET /payments`, `POST /payments/search`, and `GET /payments` do NOT exist. Per-payment CRUD (`GET/PUT/DELETE /payments/:resourceId`) exists for individual payment records, but to **list or search** payments, use `POST /cashflow-transactions/search` — the unified transaction ledger that spans invoices, bills, credit notes, journals, cash entries, and payments. Filter by `businessTransactionType` (e.g., `SALE`, `PURCHASE`) and `direction` (`PAYIN`, `PAYOUT`). Response dates are epoch milliseconds.
@@ -163,6 +164,60 @@ You are working with the **Jaz/Juan REST API** — the backend for Jaz (Singapor
163
164
  79. **`capsule-transaction` recipes auto-resolve accounts** — when `--input` is omitted, the CLI searches the org's chart of accounts for each blueprint account name (e.g., "Interest Expense", "Loan Payable"). If all accounts resolve with high confidence, no JSON mapping file is needed. If any fail, the error message shows exactly which accounts could not be found and suggests close matches. `--contact` and `--bank-account` on recipes also accept names.
164
165
  80. **Payment/refund account filter is conditional on `--method`** — for BANK_TRANSFER, CASH, and CHEQUE, the `--account` resolver filters to bank/cash accounts only. For other payment methods, all account types are considered.
165
166
 
167
+ ### Draft Finalization Pipeline (Convert & Next)
168
+
169
+ The `clio bills draft` subcommand group enables the full "review → fill missing → convert" workflow that mirrors the Jaz UI's "Convert and Next" button. Designed for AI agents processing a queue of draft bills.
170
+
171
+ #### Commands
172
+
173
+ | Command | Purpose |
174
+ |---------|---------|
175
+ | `clio bills draft list [--ids <ids>] [--json]` | Queue view: all drafts with per-field validation + attachment count |
176
+ | `clio bills draft finalize <id> [flags] [--json]` | Fill missing fields + convert DRAFT → UNPAID in one PUT |
177
+ | `clio bills draft attachments <id> [--json]` | List attachments with download URLs for agent inspection |
178
+
179
+ #### Mandatory Fields for Bill Finalization
180
+
181
+ | Field | JSON Path | CLI Flag | Resolver |
182
+ |-------|-----------|----------|----------|
183
+ | Contact | `contactResourceId` | `--contact <name/UUID>` | Fuzzy resolved |
184
+ | Bill date | `valueDate` | `--date <YYYY-MM-DD>` | Literal |
185
+ | Due date | `dueDate` | `--due <YYYY-MM-DD>` | Literal |
186
+ | Line items | `lineItems` (non-empty) | `--lines <json>` | — |
187
+ | Item name | `lineItems[i].name` | via `--lines` | — |
188
+ | Item price | `lineItems[i].unitPrice` | via `--lines` | — |
189
+ | Item account | `lineItems[i].accountResourceId` | `--account <name/UUID>` (bulk) | Fuzzy resolved |
190
+
191
+ Optional: `--ref`, `--notes`, `--tag`, `--tax-profile <name/UUID>` (bulk, fuzzy resolved), `--tax`, `--tax-inclusive`, `--dry-run`, `--input <file>`.
192
+
193
+ #### Agent Workflow Pattern
194
+
195
+ ```
196
+ Step 1: clio bills draft list --json
197
+ → Batch queue: every DRAFT with per-field validation + attachment count
198
+
199
+ Step 2: For each draft where ready = false:
200
+ a) Read validation.missingFields from Step 1 output
201
+ b) Optional: clio bills draft attachments <id> --json
202
+ → Download fileUrl, read PDF/image, extract or verify values
203
+ c) Resolve values (ask user, or infer from attachment + context)
204
+ d) clio bills draft finalize <id> --contact "Acme" --date 2025-01-15 ... --json
205
+ → Updates + converts to UNPAID in one PUT (Rule 67: bills/invoices → UNPAID, journals → APPROVED)
206
+
207
+ Step 3: For each draft where ready = true:
208
+ clio bills draft finalize <id> --json
209
+ → Converts directly (all mandatory fields already present)
210
+ ```
211
+
212
+ 81. **`--account` bulk patches line items** — when used with `clio bills draft finalize`, `--account` resolves the name to a UUID then sets `accountResourceId` on EVERY line item where it's currently null. Existing accounts are NOT overwritten. Same for `--tax-profile`. `--lines` takes priority (full replacement).
213
+ 82. **`--dry-run` validates without modifying** — returns the same validation structure as `draft list` (per-field status/hint), so agents can preview what would happen before committing. No API write occurs.
214
+ 83. **Finalization is a single PUT** — `updateBill()` with `saveAsDraft: false` transitions DRAFT → UNPAID (per Rule 67) and updates all fields in one call. No delete-and-recreate.
215
+ 84. **Draft list attachment count** — `draft list` includes `attachmentCount` per draft (from `GET /bills/:id/attachments`). Use `draft attachments <id>` for full details including `fileUrl` download links.
216
+
217
+ #### DRY Extension Pattern
218
+
219
+ Bills, invoices, and credit notes share identical mandatory field specs. Adding `clio invoices draft` or `clio customer-credit-notes draft` later reuses all validation, formatting, and CLI flag logic from `draft-helpers.ts` — only the API calls differ.
220
+
166
221
  ## Supporting Files
167
222
 
168
223
  For detailed reference, read these files in this skill directory:
@@ -919,6 +919,12 @@ Valid `datatypeCode`: `TEXT`, `NUMBER`, `BOOLEAN`, `DATE`, `LINK`.
919
919
 
920
920
  Processing is **asynchronous** — the API response confirms file upload immediately. The extraction pipeline runs server-side and pushes status updates via Firebase Realtime Database.
921
921
 
922
+ **Supported document types:**
923
+ - `INVOICE` → creates a draft sale (response type: `SALE`)
924
+ - `BILL` → creates a draft purchase (response type: `PURCHASE`)
925
+ - `CUSTOMER_CREDIT_NOTE` → creates a draft customer CN (response type: `SALE_CREDIT_NOTE`)
926
+ - `SUPPLIER_CREDIT_NOTE` → creates a draft supplier CN (response type: `PURCHASE_CREDIT_NOTE`)
927
+
922
928
  **Two modes** — content type depends on `sourceType`:
923
929
 
924
930
  #### FILE mode (multipart/form-data) — most common
@@ -929,7 +935,7 @@ Content-Type: multipart/form-data
929
935
 
930
936
  Fields:
931
937
  - sourceFile: PDF or JPG file blob (NOT "file")
932
- - businessTransactionType: "INVOICE" or "BILL" (NOT "EXPENSE")
938
+ - businessTransactionType: "INVOICE", "BILL", "CUSTOMER_CREDIT_NOTE", or "SUPPLIER_CREDIT_NOTE"
933
939
  - sourceType: "FILE"
934
940
  ```
935
941
 
@@ -941,6 +947,7 @@ Fields:
941
947
  "filename": "NB64458.pdf",
942
948
  "invalidFiles": [],
943
949
  "validFiles": [{
950
+ "workflowResourceId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
944
951
  "subscriptionFBPath": "magic_transactions/{orgId}/purchase/{fileId}",
945
952
  "errorCode": null,
946
953
  "errorMessage": null,
@@ -980,12 +987,74 @@ Content-Type: application/json
980
987
 
981
988
  **Key gotchas:**
982
989
  - `sourceFile` is the field name (NOT `file`) — same pattern as bank statement endpoint
983
- - Only `INVOICE` and `BILL` accepted `EXPENSE` returns 422
984
- - Response maps types: `INVOICE` → `SALE`, `BILL` → `PURCHASE`
990
+ - `EXPENSE` returns 422use one of the 4 valid types above
991
+ - Response maps types: `INVOICE` → `SALE`, `BILL` → `PURCHASE`, `CUSTOMER_CREDIT_NOTE` → `SALE_CREDIT_NOTE`, `SUPPLIER_CREDIT_NOTE` → `PURCHASE_CREDIT_NOTE`
985
992
  - JSON body with `sourceType: "FILE"` always fails (400) — MUST use multipart
986
- - `subscriptionFBPath` is the Firebase path for tracking extraction progress
993
+ - `workflowResourceId` in `validFiles[]` is for tracking via `POST /magic/workflows/search`
994
+ - `subscriptionFBPath` is the Firebase path for real-time status updates
987
995
  - All three fields (`sourceFile`/`sourceURL`, `businessTransactionType`, `sourceType`) are required — omitting any returns 422
988
- - File types confirmed: PDF, JPG/JPEG (handwritten documents accepted extraction quality varies)
996
+ - File types confirmed: PDF, JPG/JPEG, PNG, HEIC, XLS, XLSX, EML (max 1 MB)
997
+
998
+ ---
999
+
1000
+ ### POST /api/v1/magic/workflows/search
1001
+
1002
+ Search across magic BT extraction workflows and bank statement imports. Use this to track the status of uploads and retrieve the created draft BT resource ID.
1003
+
1004
+ ```json
1005
+ / Request:
1006
+ POST /api/v1/magic/workflows/search
1007
+ Content-Type: application/json
1008
+
1009
+ {
1010
+ "filter": {
1011
+ "resourceId": { "eq": "f47ac10b-58cc-4372-a567-0e02b2c3d479" },
1012
+ "documentType": ["SALE", "PURCHASE"],
1013
+ "status": ["COMPLETED"],
1014
+ "fileName": { "contains": "invoice" },
1015
+ "createdAt": { "gte": "2025-01-01", "lte": "2025-12-31" }
1016
+ },
1017
+ "limit": 20,
1018
+ "offset": 0,
1019
+ "sort": { "sortBy": ["createdAt"], "order": "DESC" }
1020
+ }
1021
+
1022
+ / Response (200):
1023
+ {
1024
+ "data": [{
1025
+ "resourceId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
1026
+ "documentType": "SALE",
1027
+ "status": "COMPLETED",
1028
+ "fileName": "invoice.pdf",
1029
+ "fileType": "PDF",
1030
+ "fileUrl": "https://s3...",
1031
+ "fileId": "6e999313...",
1032
+ "createdAt": "2025-01-15",
1033
+ "updatedAt": "2025-01-15",
1034
+ "businessTransactionDetails": {
1035
+ "businessTransactionResourceId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
1036
+ "ocrJobType": "SYNC",
1037
+ "workflowStatus": "TRANSACTION_CREATED"
1038
+ }
1039
+ }],
1040
+ "totalElements": 1,
1041
+ "totalPages": 1
1042
+ }
1043
+ ```
1044
+
1045
+ **Filter fields:**
1046
+ - `resourceId`: StringExpression (eq, contains) — workflow ID from magic create response
1047
+ - `documentType`: Array — SALE, PURCHASE, SALE_CREDIT_NOTE, PURCHASE_CREDIT_NOTE, BANK_STATEMENT
1048
+ - `status`: Array — SUBMITTED, PROCESSING, COMPLETED, FAILED
1049
+ - `fileName`: StringExpression — original uploaded filename
1050
+ - `fileType`: Array — PDF, PNG, JPEG, JPG, HEIC, CSV, XLS, XLSX, EML
1051
+ - `createdAt`: DateExpression (eq, gte, lte) — workflow creation date
1052
+
1053
+ **Workflow for agents:**
1054
+ 1. Upload via `POST /magic/createBusinessTransactionFromAttachment` → get `workflowResourceId`
1055
+ 2. Search with `filter.resourceId.eq` → check `status`
1056
+ 3. When `COMPLETED` → read `businessTransactionDetails.businessTransactionResourceId`
1057
+ 4. Use the BT resource ID with `GET /invoices/:id`, `GET /bills/:id`, `GET /customer-credit-notes/:id`, or `GET /supplier-credit-notes/:id`
989
1058
 
990
1059
  ---
991
1060