jaz-clio 5.35.3 → 5.35.4

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-api
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill whenever you call, debug, or review code that touches the Jaz
6
6
  REST API. Covers field names, response shapes, 158 production gotchas, error
@@ -387,7 +387,7 @@ Bills, invoices, and credit notes share identical mandatory field specs. Adding
387
387
 
388
388
  ### Bulk Upserts (transactions)
389
389
 
390
- 118. **8 bulk-upsert endpoints for transactions** — `POST /api/v1/{invoices,bills,customer-credit-notes,supplier-credit-notes,journals,fixed-assets}/bulk-upsert` plus line-item variants for invoices and bills (`/invoices/line-items/bulk-upsert`, `/bills/line-items/bulk-upsert`). Max **500 rows per call**. All async — return `{data: {jobId, subscriptionFBPath, status, totalRecords}}`. Poll `search_background_jobs` with `filter: {resourceId: {eq: jobId}}` until terminal status. **Natural keys**: invoices = `invoiceReference`, bills = `billReference`, credit notes = `creditNoteReference`, **journals = `journalReference` (NOT `reference` — asymmetric vs other entities)**, fixed assets = `reference`. **`currencyCode` is REQUIRED** on every transaction row (invoices, bills, CCN, SCN) — missing it returns errorCode `IMPORT_CURRENCY_REQUIRED`. **Journals are the exception**: the bulk journal row has no currency field and any `currencyCode` sent is discarded (multi-currency rides per-leg `transactionCurrency`). **Journals legs use `journalEntries[]`** (NOT `entries[]` — different from `journals create` which uses entries), and **a journal leg is `organizationAccountResourceId` + exactly one of `debitAmount`/`creditAmount`** — NOT the `accountResourceId`+`amount`+`type` shape `journals create` takes, and omit the unused side rather than sending 0. Provide `resourceId` (UUID) to update by ID; otherwise the natural key drives upsert (journals upsert by `journalReference` only). `rowIndex` is optional caller-supplied for error reporting — on journals it sits on the leg, not the row.
390
+ 118. **8 bulk-upsert endpoints for transactions** — `POST /api/v1/{invoices,bills,customer-credit-notes,supplier-credit-notes,journals,fixed-assets}/bulk-upsert` plus line-item variants for invoices and bills (`/invoices/line-items/bulk-upsert`, `/bills/line-items/bulk-upsert`). Max **500 rows per call**. All async — return `{data: {jobId, subscriptionFBPath, status, totalRecords}}`. Poll `search_background_jobs` with `filter: {resourceId: {eq: jobId}}` until terminal status. **Natural keys**: invoices = `invoiceReference`, bills = `billReference`, credit notes = `creditNoteReference`, **journals = `journalReference` (NOT `reference` — asymmetric vs other entities)**, fixed assets = `reference`. **`currencyCode` is REQUIRED** on every transaction row (invoices, bills, CCN, SCN) — missing it returns errorCode `IMPORT_CURRENCY_REQUIRED`. **Journals are the exception**: the bulk journal row has no currency field and any `currencyCode` sent is discarded, and the public request model exposes no per-leg currency field either. **Journals legs use `journalEntries[]`** (NOT `entries[]` — different from `journals create` which uses entries), and **a journal leg is `organizationAccountResourceId` + exactly one of `debitAmount`/`creditAmount`** — NOT the `accountResourceId`+`amount`+`type` shape `journals create` takes, and omit the unused side rather than sending 0. Provide `resourceId` (UUID) to update by ID; otherwise the natural key drives upsert (journals upsert by `journalReference` only). `rowIndex` is optional caller-supplied for error reporting — on journals it sits on the leg, not the row.
391
391
 
392
392
  119. **PARTIAL_SUCCESS handling** — When `search_background_jobs` returns `PARTIAL_SUCCESS` for a bulk-upsert job, the per-row failures are in `data[0].errorDetails` on the SAME response (an array of per-row error objects). Top-level counts (`processedCount`, `failedCount`, `totalRecords`) tell you *how many* failed; `errorDetails` tells you *which rows and why*. Don't pretend the operation succeeded — surface the failed rows to the user. The rule of thumb: poll with `search_background_jobs` filtered by `resourceId: { eq: jobId }`, then read `data[0].errorDetails` for terminal states.
393
393
 
@@ -226,7 +226,7 @@ DIFFERENT shape from single create — easier to confuse.
226
226
  | `accountResourceId` (leg) | `organizationAccountResourceId` | **The leg account field is NOT `accountResourceId`.** Single create uses `accountResourceId`; bulk uses `organizationAccountResourceId`. Sending the single-create name is silently dropped and the row fails `INVALID_ACCOUNT_TO_IMPORT_JOURNAL` with `columnValue: null`. |
227
227
  | `amount` + `type: "DEBIT"` | `debitAmount` / `creditAmount` (separate fields per leg) | Split numeric fields, NOT amount+type. **Send exactly one side and OMIT the other** — do not set the unused side to 0. Both present → `BOTH_CREDIT_AND_DEBIT_ON_A_JOURNAL_ENTRY_LINE_IS_NOT_ALLOWED`; both zero or `<= 0` → rejected too. Neither present → `INVALID_CREDIT_AND_DEBIT_AMOUNT`. |
228
228
  | `rowIndex` on the row | `rowIndex` on the **leg** | 1-based, caller-supplied, echoed back in per-row `errorDetails`. It is a leg field for journals, not a row field. |
229
- | `currency: { ... }` (object) | *(no currency field)* | **Journals are the exception to the `currencyCode` rule** — the bulk journal row has no currency field at all and any `currencyCode` sent is discarded. Per-leg `transactionCurrency` carries multi-currency instead. |
229
+ | `currency: { ... }` (object) | *(no currency field)* | **Journals are the exception to the `currencyCode` rule** — the bulk journal row has no currency field at all and any `currencyCode` sent is discarded. The public request model exposes no per-leg currency field either, so how a bulk journal carries a non-base currency is not expressible through this endpoint; verify against the spec before advising on it. |
230
230
 
231
231
  ---
232
232
 
@@ -131,7 +131,7 @@ Four entities sharing one shape. Replace `{entity}` with `sale-quotes`, `sale-or
131
131
  | GET | `/journals/:resourceId/attachments` | List attachments |
132
132
  | POST | `/journals/:resourceId/attachments` | Upload attachment |
133
133
  | DELETE | `/journals/:resourceId/attachments/:attachmentResourceId` | Delete attachment |
134
- | POST | `/journals/bulk-upsert` | Bulk create/update manual journals (max 500) — **async**, returns `{ jobId }`. Natural key: `reference`. Multi-leg `entries[]` per row. ISO 8601 dates only. |
134
+ | POST | `/journals/bulk-upsert` | Bulk create/update manual journals (max 500) — **async**, returns `{ jobId }`. Natural key: `journalReference` (NOT `reference`). Legs are `journalEntries[]`, each `organizationAccountResourceId` + exactly one of `debitAmount`/`creditAmount`. ISO 8601 dates only. |
135
135
 
136
136
  ### Cash Entries
137
137
  | Method | Path | Description |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-cli
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill when running Clio CLI commands, building shell scripts with
6
6
  Clio, debugging auth issues, understanding --json output, paginating results,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-conversion
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill when migrating accounting data into Jaz — importing from Xero,
6
6
  QuickBooks, Sage, MYOB, or Excel exports. Covers the full conversion pipeline:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-kit
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill when an accountant, bookkeeper, or owner is running real books
6
6
  in Jaz across one or more organizations from the terminal — setting up a
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-pseudo-sql
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill when answering ad-hoc data questions that aren't covered by
6
6
  download_export (canonical reports — anomaly, audit, aging, P&L, BS, GL,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-jobs
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill for recurring accounting workflows — month/quarter/year-end
6
6
  close, bank reconciliation, GST/VAT filing, payment runs, credit control,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-recipes
3
- version: 5.35.3
3
+ version: 5.35.4
4
4
  description: >-
5
5
  Use this skill when modeling complex multi-step accounting transactions —
6
6
  anything that spans multiple periods, involves changing amounts, or requires
package/cli.mjs CHANGED
@@ -1046,7 +1046,7 @@ clio() {
1046
1046
  clio journals draft finalize ${n} ...
1047
1047
  `))}process.exit(1)}await UMe(o,n,d);let y=(await kl(o,n)).data,C=f.filter(E=>E!=="saveAsDraft"&&E!=="resourceId");i.json?console.log(JSON.stringify({finalized:!0,resourceId:y.resourceId,reference:y.reference||null,status:y.status,fieldsUpdated:C},null,2)):(console.log(Y(`
1048
1048
  \u2713 Journal finalized: ${y.reference||y.resourceId}`)),console.log(R(" Status:"),y.status),C.length>0&&console.log(R(" Updated:"),C.join(", ")))})(i)),r.command("attachments <resourceId>").description("List attachments for a journal (URLs for agent inspection)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let a=(await kl(o,n)).data,u=(await ci(o,"journals",n)).data;if(i.json)console.log(JSON.stringify({journalResourceId:n,journalReference:a.reference||null,attachments:u},null,2));else{if(u.length===0){console.log(`No attachments for journal ${a.reference||n}.`);return}console.log(R(`Attachments for ${a.reference||n}:
1049
- `));for(let d of u)console.log(` ${Se(d.resourceId)} ${d.fileName||"(unnamed)"}`),d.fileUrl&&console.log(` ${H(d.fileUrl)}`)}})(i)),e.command("bulk-upsert").description("Create or update manual journals in bulk (max 500). Natural key: reference. Each row carries multi-leg entries[] (debit + credit must balance). Returns a jobId \u2014 poll with `clio background-jobs get <jobId>`. Dates ISO 8601 only.").option("--input <file>","Read JSON body from file (or pipe via stdin with --input -)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=Ce(i);o||(console.error('Error: --input <file> is required (JSON with { "journals": [...] } or a bare array)'),process.exit(1));let s=o.journals??o;Array.isArray(s)||(console.error('Error: expected { "journals": [...] }'),process.exit(1)),s.length===0&&(console.error("Error: journals array is empty."),process.exit(1)),s.length>500&&(console.error(`Error: max 500 per call (got ${s.length}). Split into batches.`),process.exit(1));let a=await i2(n,s);i.json?console.log(JSON.stringify(a.data,null,2)):(console.log(Y(`Bulk upsert started. Job ID: ${a.data.jobId}`)),console.log(Se(` Poll progress: clio background-jobs get ${a.data.jobId}`)))}))}Fe();Lt();aT();At();Tt();ur();Pt();dr();function Y8(t){return!Number.isFinite(t)||t===0?"\u2014":new Date(t).toISOString().slice(0,10)}function efe(t){let e=An(t.transactionStatus);console.log(R("Reference:"),t.transactionReference||"(none)"),console.log(R(" ID:"),Se(t.resourceId)),console.log(R(" Status:"),e),console.log(R(" Date:"),Y8(t.valueDate)),console.log(R(" Type:"),t.businessTransactionType),console.log(R(" Direction:"),t.direction),console.log(R(" Amount:"),`${t.currencySymbol}${t.totalAmount.toFixed(2)} ${t.currencyCode}`),console.log(R(" Account:"),t.account?.name||"\u2014",H(`(${t.organizationAccountResourceId})`)),t.contactResourceId&&console.log(R(" Contact:"),t.contactResourceId)}var yot=[{key:"resourceId",header:"ID",format:Te},{key:"transactionReference",header:"Reference",format:Yn},{key:"transactionStatus",header:"Status",format:t=>An(String(t))},{key:"totalAmount",header:"Amount",align:"right",format:gn},{key:"valueDate",header:"Date",format:t=>Y8(Number(t))}];function tfe(t,e){let r=t.command(e.name).description(`Manage ${e.label.toLowerCase()} entries`);r.command("list").description(`List ${e.label.toLowerCase()} entries`).option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=await Ye(i,s=>e.listFn(n,s),{label:`Fetching ${e.label.toLowerCase()} entries`});$e(o,yot,i,e.label)})),r.command("get <resourceId>").description(`Get a ${e.label.toLowerCase()} entry by ID`).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let{data:s}=await e.getFn(o,n);i.json?console.log(JSON.stringify(s,null,2)):efe(s)})(i)),r.command("create").description(`Create a ${e.label.toLowerCase()} entry (saves as draft by default)`).option("--jot <text>",we).option("--account <resourceId>","Bank account name or resourceId").option("--entries <json>","Entry lines as JSON array (offset entries)",Dc).option("--date <YYYY-MM-DD>","Value date").option("--ref <reference>","Reference").option("--notes <text>","Notes").option("--tag <tag>","Tag").option(pc,hc).option(mc,Ac,is).option(Ji,Ds,Vi).option("--finalize","Finalize instead of saving as draft").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=Ce(i),s;if(o)s=await e.createFn(n,{...o,saveAsDraft:o.saveAsDraft??!i.finalize});else{Le(i,[{flag:"--account",key:"account"},{flag:"--entries",key:"entries"},{flag:"--date",key:"date"}]);let c=await ii(n,i.account,{filter:"bank",silent:i.json});i.account=c.resourceId;let u={accountResourceId:i.account,lines:i.entries,valueDate:i.date,saveAsDraft:!i.finalize};i.ref&&(u.reference=i.ref),i.notes&&(u.internalNotes=i.notes),i.tag&&(u.tags=[i.tag]);let d=gc(i);yc(d,i),d&&(u.currency=d),s=await e.createFn(n,u)}let a=s.data;if(i.json)console.log(JSON.stringify(a,null,2));else{let c=i.finalize?"finalized":"draft";console.log(Y(`${e.label} created (${c}): ${a.resourceId}`)),console.log(R("ID:"),a.resourceId)}Ie(n,`create_${e.name.replace(/-/g,"_")}`,i,s.data)})),r.command("update <resourceId>").description(`Update a ${e.label.toLowerCase()} entry`).option("--jot <text>",we).option("--entries <json>","Entry lines as JSON array",Dc).option("--date <YYYY-MM-DD>","Value date").option("--ref <reference>","Reference").option("--notes <text>","Notes").option("--tag <tag>","Tag").option("--finalize","Finalize instead of saving as draft").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let s=Ce(i),a;if(s)a=await e.updateFn(o,n,{...s,saveAsDraft:s.saveAsDraft??!i.finalize});else{let u={};i.entries&&(u.lines=i.entries),i.date&&(u.valueDate=i.date),i.ref&&(u.reference=i.ref),i.notes&&(u.internalNotes=i.notes),i.tag&&(u.tags=[i.tag]),u.saveAsDraft=!i.finalize,a=await e.updateFn(o,n,u)}let c=a.data;if(i.json)console.log(JSON.stringify(c,null,2));else{let u=i.finalize?"finalized":"draft";console.log(Y(`${e.label} updated (${u}): ${c.resourceId||n}`))}Ie(o,`update_${e.name.replace(/-/g,"_")}`,i,a.data)})(i)),Ve({parent:r,fields:jd,defaults:Yd,fetcher:cm,columns:yot,label:`Searching ${e.label.toLowerCase()}`,baseFilter:{businessTransactionType:{eq:e.txnType}},preProcess:async(n,i)=>{if(i.account){let o=await ii(n,i.account,{filter:"bank",silent:!!i.json});i.accountId=o.resourceId}}}),r.command("delete <resourceId>").description(`Delete/void a ${e.label.toLowerCase()} entry`).option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{await am(o,n),i.json?console.log(JSON.stringify({deleted:!0,resourceId:n})):console.log(Y(`${e.label} ${n} deleted.`)),Ie(o,`delete_${e.name.replace(/-/g,"_")}`,i,{resourceId:n})})(i))}DH();Fe();Yue();aT();At();Tt();ur();Pt();Lt();dr();var Eot=[{key:"resourceId",header:"ID",format:Te},{key:"transactionReference",header:"Reference",format:Yn},{key:"transactionStatus",header:"Status",format:t=>An(String(t))},{key:"totalAmount",header:"Amount",align:"right",format:gn},{key:"valueDate",header:"Date",format:t=>Y8(Number(t))}];function bot(t){let e=t.command("cash-transfer").description("Manage cash transfer entries");e.command("list").description("List cash transfers").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>SH(r,o),{label:"Fetching cash transfers"});$e(i,Eot,n,"Cash Transfers")})),e.command("get <resourceId>").description("Get a cash transfer by ID").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let{data:o}=await RH(i,r);n.json?console.log(JSON.stringify(o,null,2)):efe(o)})(n)),e.command("create").description("Create a cash transfer (saves as draft by default)").option("--jot <text>",we).option("--from-account <resourceId>","Source bank account name or resourceId (cash-out)").option("--to-account <resourceId>","Destination bank account name or resourceId (cash-in)").option("--amount <amount>","Transfer amount",cr).option("--date <YYYY-MM-DD>","Value date").option("--ref <reference>","Reference").option("--finalize","Finalize instead of saving as draft").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;if(i)o=await eT(r,{...i,saveAsDraft:i.saveAsDraft??!n.finalize});else{Le(n,[{flag:"--from-account",key:"fromAccount"},{flag:"--to-account",key:"toAccount"},{flag:"--amount",key:"amount"},{flag:"--date",key:"date"}]);let a=await ii(r,n.fromAccount,{filter:"bank",silent:n.json});n.fromAccount=a.resourceId;let c=await ii(r,n.toAccount,{filter:"bank",silent:n.json});if(n.toAccount=c.resourceId,n.fromAccount===n.toAccount)throw new Error("--from-account and --to-account must be different");let u={valueDate:n.date,cashOut:{accountResourceId:n.fromAccount,amount:n.amount},cashIn:{accountResourceId:n.toAccount,amount:n.amount},saveAsDraft:!n.finalize};n.ref&&(u.reference=n.ref),o=await eT(r,u)}let s=o.data;if(n.json)console.log(JSON.stringify(s,null,2));else{let a=n.finalize?"finalized":"draft";console.log(Y(`Cash transfer created (${a}): ${s.resourceId}`)),console.log(R("ID:"),s.resourceId)}Ie(r,"create_cash_transfer",n,s)})),Ve({parent:e,fields:jd,defaults:Yd,fetcher:cm,columns:Eot,label:"Searching cash transfers",baseFilter:{businessTransactionType:{eq:"JOURNAL_CASH_TRANSFER"}},preProcess:async(r,n)=>{if(n.account){let i=await ii(r,n.account,{filter:"bank",silent:!!n.json});n.accountId=i.resourceId}}}),e.command("delete <resourceId>").description("Delete/void a cash transfer").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await am(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Cash transfer ${r} deleted.`)),Ie(i,"delete_cash_transfer",n,{resourceId:r})})(n))}Fe();Ade();At();Tt();ur();dr();Pt();Lt();var Cot=[{key:"resourceId",header:"ID",format:Te},{key:"businessTransactionReference",header:"Reference",format:Yn},{key:"direction",header:"Dir",format:jM},{key:"valueDate",header:"Date",format:Bp},{key:"totalAmount",header:"Amount",align:"right"},{key:"businessTransactionType",header:"Type",format:t=>H(String(t??""))}];function vot(t){let e=t.command("payments").description("View cashflow transactions (payments, invoices, bills, journals)");e.command("list").description("List recent cashflow transactions").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>sz(r,o),{label:"Fetching transactions"});$e(i,Cot,n,"Payments")})),Ve({parent:e,fields:tS,defaults:rS,fetcher:lT,columns:Cot,label:"Searching payments"}),e.command("get <resourceId>").description("Get a specific payment record").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await az(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("ID:"),s.resourceId),console.log(R("Amount:"),s.paymentAmount),console.log(R("Date:"),s.valueDate),console.log(R("Method:"),s.paymentMethod),console.log(R("Reference:"),s.reference))})(n)),e.command("update <resourceId>").description("Update a payment record").option("--amount <n>","Corrected payment amount").option("--reference <ref>","Payment reference").option("--date <YYYY-MM-DD>","Payment date").option("--method <method>","Payment method (BANK_TRANSFER, CASH, CHEQUE, etc.)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.amount&&(o.paymentAmount=parseFloat(n.amount)),n.reference&&(o.reference=n.reference),n.date&&(o.valueDate=n.date),n.method&&(o.paymentMethod=n.method);let s=await cz(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Payment ${r} updated.`))})(n)),e.command("delete <resourceId>").description("Delete (void) a payment record").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await lz(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Payment ${r} deleted.`))})(n))}Fe();Ap();qD();At();import{readFileSync as FIr}from"node:fs";import{basename as QIr,extname as LIr,resolve as MIr}from"node:path";Tt();dr();Lt();var PIr=[{key:"resourceId",header:"ID",format:Te},{key:"valueDate",header:"Date"},{key:"netAmount",header:"Amount",align:"right",format:gn},{key:"description",header:"Description"},{key:"extContactName",header:"Payer/Payee"},{key:"status",header:"Status"}],Iot={".csv":"text/csv",".ofx":"application/x-ofx",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};function wot(t){let e=t.command("bank").description("Bank accounts and records");e.command("accounts").description("List bank accounts").option("--limit <n>","Max results",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=await Ub(n,{limit:i.limit});if(i.json)console.log(JSON.stringify(o,null,2));else{console.log(R(`Bank Accounts (${o.data.length}):
1049
+ `));for(let d of u)console.log(` ${Se(d.resourceId)} ${d.fileName||"(unnamed)"}`),d.fileUrl&&console.log(` ${H(d.fileUrl)}`)}})(i)),e.command("bulk-upsert").description("Create or update manual journals in bulk (max 500). Natural key: journalReference (NOT reference). Each row carries multi-leg journalEntries[] (NOT entries[]); each leg is organizationAccountResourceId plus exactly one of debitAmount/creditAmount, omitting the unused side. Returns a jobId \u2014 poll with `clio background-jobs get <jobId>`. Dates ISO 8601 only.").option("--input <file>","Read JSON body from file (or pipe via stdin with --input -)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=Ce(i);o||(console.error('Error: --input <file> is required (JSON with { "journals": [...] } or a bare array)'),process.exit(1));let s=o.journals??o;Array.isArray(s)||(console.error('Error: expected { "journals": [...] }'),process.exit(1)),s.length===0&&(console.error("Error: journals array is empty."),process.exit(1)),s.length>500&&(console.error(`Error: max 500 per call (got ${s.length}). Split into batches.`),process.exit(1));let a=await i2(n,s);i.json?console.log(JSON.stringify(a.data,null,2)):(console.log(Y(`Bulk upsert started. Job ID: ${a.data.jobId}`)),console.log(Se(` Poll progress: clio background-jobs get ${a.data.jobId}`)))}))}Fe();Lt();aT();At();Tt();ur();Pt();dr();function Y8(t){return!Number.isFinite(t)||t===0?"\u2014":new Date(t).toISOString().slice(0,10)}function efe(t){let e=An(t.transactionStatus);console.log(R("Reference:"),t.transactionReference||"(none)"),console.log(R(" ID:"),Se(t.resourceId)),console.log(R(" Status:"),e),console.log(R(" Date:"),Y8(t.valueDate)),console.log(R(" Type:"),t.businessTransactionType),console.log(R(" Direction:"),t.direction),console.log(R(" Amount:"),`${t.currencySymbol}${t.totalAmount.toFixed(2)} ${t.currencyCode}`),console.log(R(" Account:"),t.account?.name||"\u2014",H(`(${t.organizationAccountResourceId})`)),t.contactResourceId&&console.log(R(" Contact:"),t.contactResourceId)}var yot=[{key:"resourceId",header:"ID",format:Te},{key:"transactionReference",header:"Reference",format:Yn},{key:"transactionStatus",header:"Status",format:t=>An(String(t))},{key:"totalAmount",header:"Amount",align:"right",format:gn},{key:"valueDate",header:"Date",format:t=>Y8(Number(t))}];function tfe(t,e){let r=t.command(e.name).description(`Manage ${e.label.toLowerCase()} entries`);r.command("list").description(`List ${e.label.toLowerCase()} entries`).option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=await Ye(i,s=>e.listFn(n,s),{label:`Fetching ${e.label.toLowerCase()} entries`});$e(o,yot,i,e.label)})),r.command("get <resourceId>").description(`Get a ${e.label.toLowerCase()} entry by ID`).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let{data:s}=await e.getFn(o,n);i.json?console.log(JSON.stringify(s,null,2)):efe(s)})(i)),r.command("create").description(`Create a ${e.label.toLowerCase()} entry (saves as draft by default)`).option("--jot <text>",we).option("--account <resourceId>","Bank account name or resourceId").option("--entries <json>","Entry lines as JSON array (offset entries)",Dc).option("--date <YYYY-MM-DD>","Value date").option("--ref <reference>","Reference").option("--notes <text>","Notes").option("--tag <tag>","Tag").option(pc,hc).option(mc,Ac,is).option(Ji,Ds,Vi).option("--finalize","Finalize instead of saving as draft").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=Ce(i),s;if(o)s=await e.createFn(n,{...o,saveAsDraft:o.saveAsDraft??!i.finalize});else{Le(i,[{flag:"--account",key:"account"},{flag:"--entries",key:"entries"},{flag:"--date",key:"date"}]);let c=await ii(n,i.account,{filter:"bank",silent:i.json});i.account=c.resourceId;let u={accountResourceId:i.account,lines:i.entries,valueDate:i.date,saveAsDraft:!i.finalize};i.ref&&(u.reference=i.ref),i.notes&&(u.internalNotes=i.notes),i.tag&&(u.tags=[i.tag]);let d=gc(i);yc(d,i),d&&(u.currency=d),s=await e.createFn(n,u)}let a=s.data;if(i.json)console.log(JSON.stringify(a,null,2));else{let c=i.finalize?"finalized":"draft";console.log(Y(`${e.label} created (${c}): ${a.resourceId}`)),console.log(R("ID:"),a.resourceId)}Ie(n,`create_${e.name.replace(/-/g,"_")}`,i,s.data)})),r.command("update <resourceId>").description(`Update a ${e.label.toLowerCase()} entry`).option("--jot <text>",we).option("--entries <json>","Entry lines as JSON array",Dc).option("--date <YYYY-MM-DD>","Value date").option("--ref <reference>","Reference").option("--notes <text>","Notes").option("--tag <tag>","Tag").option("--finalize","Finalize instead of saving as draft").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let s=Ce(i),a;if(s)a=await e.updateFn(o,n,{...s,saveAsDraft:s.saveAsDraft??!i.finalize});else{let u={};i.entries&&(u.lines=i.entries),i.date&&(u.valueDate=i.date),i.ref&&(u.reference=i.ref),i.notes&&(u.internalNotes=i.notes),i.tag&&(u.tags=[i.tag]),u.saveAsDraft=!i.finalize,a=await e.updateFn(o,n,u)}let c=a.data;if(i.json)console.log(JSON.stringify(c,null,2));else{let u=i.finalize?"finalized":"draft";console.log(Y(`${e.label} updated (${u}): ${c.resourceId||n}`))}Ie(o,`update_${e.name.replace(/-/g,"_")}`,i,a.data)})(i)),Ve({parent:r,fields:jd,defaults:Yd,fetcher:cm,columns:yot,label:`Searching ${e.label.toLowerCase()}`,baseFilter:{businessTransactionType:{eq:e.txnType}},preProcess:async(n,i)=>{if(i.account){let o=await ii(n,i.account,{filter:"bank",silent:!!i.json});i.accountId=o.resourceId}}}),r.command("delete <resourceId>").description(`Delete/void a ${e.label.toLowerCase()} entry`).option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{await am(o,n),i.json?console.log(JSON.stringify({deleted:!0,resourceId:n})):console.log(Y(`${e.label} ${n} deleted.`)),Ie(o,`delete_${e.name.replace(/-/g,"_")}`,i,{resourceId:n})})(i))}DH();Fe();Yue();aT();At();Tt();ur();Pt();Lt();dr();var Eot=[{key:"resourceId",header:"ID",format:Te},{key:"transactionReference",header:"Reference",format:Yn},{key:"transactionStatus",header:"Status",format:t=>An(String(t))},{key:"totalAmount",header:"Amount",align:"right",format:gn},{key:"valueDate",header:"Date",format:t=>Y8(Number(t))}];function bot(t){let e=t.command("cash-transfer").description("Manage cash transfer entries");e.command("list").description("List cash transfers").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>SH(r,o),{label:"Fetching cash transfers"});$e(i,Eot,n,"Cash Transfers")})),e.command("get <resourceId>").description("Get a cash transfer by ID").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let{data:o}=await RH(i,r);n.json?console.log(JSON.stringify(o,null,2)):efe(o)})(n)),e.command("create").description("Create a cash transfer (saves as draft by default)").option("--jot <text>",we).option("--from-account <resourceId>","Source bank account name or resourceId (cash-out)").option("--to-account <resourceId>","Destination bank account name or resourceId (cash-in)").option("--amount <amount>","Transfer amount",cr).option("--date <YYYY-MM-DD>","Value date").option("--ref <reference>","Reference").option("--finalize","Finalize instead of saving as draft").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;if(i)o=await eT(r,{...i,saveAsDraft:i.saveAsDraft??!n.finalize});else{Le(n,[{flag:"--from-account",key:"fromAccount"},{flag:"--to-account",key:"toAccount"},{flag:"--amount",key:"amount"},{flag:"--date",key:"date"}]);let a=await ii(r,n.fromAccount,{filter:"bank",silent:n.json});n.fromAccount=a.resourceId;let c=await ii(r,n.toAccount,{filter:"bank",silent:n.json});if(n.toAccount=c.resourceId,n.fromAccount===n.toAccount)throw new Error("--from-account and --to-account must be different");let u={valueDate:n.date,cashOut:{accountResourceId:n.fromAccount,amount:n.amount},cashIn:{accountResourceId:n.toAccount,amount:n.amount},saveAsDraft:!n.finalize};n.ref&&(u.reference=n.ref),o=await eT(r,u)}let s=o.data;if(n.json)console.log(JSON.stringify(s,null,2));else{let a=n.finalize?"finalized":"draft";console.log(Y(`Cash transfer created (${a}): ${s.resourceId}`)),console.log(R("ID:"),s.resourceId)}Ie(r,"create_cash_transfer",n,s)})),Ve({parent:e,fields:jd,defaults:Yd,fetcher:cm,columns:Eot,label:"Searching cash transfers",baseFilter:{businessTransactionType:{eq:"JOURNAL_CASH_TRANSFER"}},preProcess:async(r,n)=>{if(n.account){let i=await ii(r,n.account,{filter:"bank",silent:!!n.json});n.accountId=i.resourceId}}}),e.command("delete <resourceId>").description("Delete/void a cash transfer").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await am(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Cash transfer ${r} deleted.`)),Ie(i,"delete_cash_transfer",n,{resourceId:r})})(n))}Fe();Ade();At();Tt();ur();dr();Pt();Lt();var Cot=[{key:"resourceId",header:"ID",format:Te},{key:"businessTransactionReference",header:"Reference",format:Yn},{key:"direction",header:"Dir",format:jM},{key:"valueDate",header:"Date",format:Bp},{key:"totalAmount",header:"Amount",align:"right"},{key:"businessTransactionType",header:"Type",format:t=>H(String(t??""))}];function vot(t){let e=t.command("payments").description("View cashflow transactions (payments, invoices, bills, journals)");e.command("list").description("List recent cashflow transactions").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>sz(r,o),{label:"Fetching transactions"});$e(i,Cot,n,"Payments")})),Ve({parent:e,fields:tS,defaults:rS,fetcher:lT,columns:Cot,label:"Searching payments"}),e.command("get <resourceId>").description("Get a specific payment record").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await az(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("ID:"),s.resourceId),console.log(R("Amount:"),s.paymentAmount),console.log(R("Date:"),s.valueDate),console.log(R("Method:"),s.paymentMethod),console.log(R("Reference:"),s.reference))})(n)),e.command("update <resourceId>").description("Update a payment record").option("--amount <n>","Corrected payment amount").option("--reference <ref>","Payment reference").option("--date <YYYY-MM-DD>","Payment date").option("--method <method>","Payment method (BANK_TRANSFER, CASH, CHEQUE, etc.)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o={};n.amount&&(o.paymentAmount=parseFloat(n.amount)),n.reference&&(o.reference=n.reference),n.date&&(o.valueDate=n.date),n.method&&(o.paymentMethod=n.method);let s=await cz(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(Y(`Payment ${r} updated.`))})(n)),e.command("delete <resourceId>").description("Delete (void) a payment record").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await lz(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Payment ${r} deleted.`))})(n))}Fe();Ap();qD();At();import{readFileSync as FIr}from"node:fs";import{basename as QIr,extname as LIr,resolve as MIr}from"node:path";Tt();dr();Lt();var PIr=[{key:"resourceId",header:"ID",format:Te},{key:"valueDate",header:"Date"},{key:"netAmount",header:"Amount",align:"right",format:gn},{key:"description",header:"Description"},{key:"extContactName",header:"Payer/Payee"},{key:"status",header:"Status"}],Iot={".csv":"text/csv",".ofx":"application/x-ofx",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};function wot(t){let e=t.command("bank").description("Bank accounts and records");e.command("accounts").description("List bank accounts").option("--limit <n>","Max results",Ee).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=await Ub(n,{limit:i.limit});if(i.json)console.log(JSON.stringify(o,null,2));else{console.log(R(`Bank Accounts (${o.data.length}):
1050
1050
  `));for(let s of o.data)console.log(` ${Se(s.resourceId)} ${s.name} ${H(s.currencyCode)} ${s.status}`)}})),e.command("get <resourceId>").description("Get a bank account by resourceId").option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let a=(await $b(o,n)).data;i.json?console.log(JSON.stringify(a,null,2)):(console.log(R("Name:"),a.name),console.log(R("ID:"),a.resourceId),console.log(R("Account ID:"),a.accountResourceId),console.log(R("Currency:"),a.currencyCode),console.log(R("Status:"),a.status))})(i)),Ve({parent:e,commandName:"records",fields:nS,defaults:iS,fetcher:qb,columns:PIr,label:"Searching bank records",positionalArg:"accountResourceId",pathParam:"accountResourceId",pathParamDescription:"Bank account resourceId"}),e.command("add-records <accountResourceId>").description("Add bank records via JSON (1-100 records per call)").option("--jot <text>",we).requiredOption("--records <json>","JSON array: [{amount, transactionDate, description?, payerOrPayee?, reference?}]").option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>Q(async o=>{let s=JSON.parse(i.records);if(!Array.isArray(s))throw new Error("--records must be a JSON array");if(s.length<1||s.length>100)throw new Error("--records must contain 1-100 entries");for(let[u,d]of s.entries()){if(typeof d!="object"||d===null)throw new Error(`records[${u}] must be an object`);if(typeof d.amount!="number"||!Number.isFinite(d.amount))throw new Error(`records[${u}].amount must be a finite number`);if(typeof d.transactionDate!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(d.transactionDate))throw new Error(`records[${u}].transactionDate must be YYYY-MM-DD`)}let a=await vL(o,n,s),c=Array.isArray(a?.data?.errors)?a.data.errors:[];if(i.json)console.log(JSON.stringify(a.data,null,2));else if(c.length>0){console.log(ie(`${c.length} error(s):`));for(let u of c)console.log(` ${ie(String(u))}`)}else console.log(Y(`Created ${s.length} bank record(s).`));Ie(o,"add_bank_records",i,a.data)})(i));let r=sP;e.command("auto-recon").description("Get auto-reconciliation recommendations for specific bank statement entries").requiredOption("--type <type>",`Recommendation type (${r.join(", ")})`).requiredOption("--entries <ids>","Comma-separated bank statement entry resourceIds. Required \u2014 there is no account-wide mode, because an unscoped scan exceeds the request timeout on high-volume accounts.").option("--account <resourceId>","Bank account resourceId").option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=i.type.toUpperCase();r.includes(o)||(console.error(ie(`Invalid --type: ${o}`)),console.error(H(`Valid types: ${r.join(", ")}`)),process.exit(1));let s=i.entries.split(",").map(a=>a.trim()).filter(Boolean);s.length===0&&(console.error(ie("--entries must name at least one bank statement entry")),process.exit(1));try{let a=await n.post("/api/v1/search-magic-reconciliation",{bankAccountResourceId:i.account,recommendationType:o,bankStatementEntryResourceIds:s});if(i.json)console.log(JSON.stringify(a,null,2));else{let c=a.data,u=Array.isArray(c)?c.length:0;if(console.log(R(`Auto-Reconciliation Suggestions (${o}): ${u} found
1051
1051
  `)),Array.isArray(c)){for(let d of c.slice(0,50)){let f=d,p=f.description??f.bankRecordDescription??"",h=typeof f.amount=="number"?H(` $${f.amount.toFixed(2)}`):"";console.log(` ${Se(String(f.bankRecordResourceId??f.resourceId??"?"))} ${p}${h}`)}c.length>50&&console.log(H(` ... and ${c.length-50} more (use --json for full output)`))}else console.log(JSON.stringify(a,null,2))}}catch(a){throw(a.status??a.response?.status)===404&&(console.error(ke("Auto-reconciliation endpoint not available on this server.")),process.exit(1)),a}})),e.command("import").description("Import a bank statement file (CSV, OFX, XLS, XLSX)").option("--jot <text>",we).requiredOption("--file <path>","Bank statement file path").requiredOption("--account <resourceId>","Bank account resourceId").option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(n,i)=>{let o=MIr(i.file),s=LIr(o).toLowerCase(),a=Iot[s];a||(console.error(ie(`Error: unsupported file type "${s}". Supported: ${Object.keys(Iot).join(", ")}`)),process.exit(1));let c=FIr(o),u=new Blob([c],{type:a}),d=QIr(o),f=await jb(n,{businessTransactionType:"BANK_STATEMENT",accountResourceId:i.account,sourceFile:u,sourceFileName:d});i.json?console.log(JSON.stringify(f.data,null,2)):(console.log(Y("Bank statement uploaded \u2014 processing started.")),console.log(R("File:"),d),console.log(H("Check status: clio magic search --type bank-statement"))),Ie(n,"import_bank_statement",i,f.data)}))}Fe();AX();At();Tt();var rfe=["trial-balance","balance-sheet","profit-loss","cashflow","aged-ar","aged-ap","cash-balance","general-ledger","vat-ledger","equity-movement","bank-balance-summary","bank-recon-summary","bank-recon-details","fa-summary","fa-recon-summary","ar-report","ledger-highlights"],nfe=["ACCOUNT","TRANSACTION","CAPSULE"];function _ot(t){t.command("reports").description("Generate financial reports").command("generate <type>").description(`Generate a report (${rfe.join(", ")})`).option("--from <YYYY-MM-DD>","Start date (for P&L, cashflow, equity, recon)").option("--to <YYYY-MM-DD>","End/snapshot date").option("--currency <code>","Currency code override").option("--group-by <groupBy>",`Group by for general-ledger/fa-summary (${nfe.join(", ")}, default ACCOUNT)`).option("--bank-account <id>","Bank account resourceId (for bank-recon-*)").option("--aggregate","For aged-ar/aged-ap: compact aging-bucket summary instead of the full per-contact breakdown").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>(rfe.includes(r)||(console.error(ie(`Invalid report type: ${r}`)),console.error(H(`Valid types: ${rfe.join(", ")}`)),process.exit(1)),Q(async i=>{let o=PZ(),s;switch(r){case"trial-balance":s=await o2(i,{endDate:n.to??o,currencyCode:n.currency});break;case"balance-sheet":s=await s2(i,{primarySnapshotDate:n.to??o,currencyCode:n.currency});break;case"profit-loss":s=await a2(i,{startDate:n.from??`${o.slice(0,4)}-01-01`,endDate:n.to??o,currencyCode:n.currency});break;case"cashflow":s=await c2(i,{startDate:n.from??`${o.slice(0,4)}-01-01`,endDate:n.to??o});break;case"aged-ar":{let a=await l2(i,{startDate:n.from??`${(n.to??o).slice(0,4)}-01-01`,endDate:n.to??o});s=n.aggregate?{data:IC(a,"receivables")}:a;break}case"aged-ap":{let a=await u2(i,{startDate:n.from??`${(n.to??o).slice(0,4)}-01-01`,endDate:n.to??o});s=n.aggregate?{data:IC(a,"payables")}:a;break}case"cash-balance":s=await d2(i,{endDate:n.to??o});break;case"general-ledger":{let a=(n.groupBy??"ACCOUNT").toUpperCase();nfe.includes(a)||(console.error(ie(`Invalid --group-by: ${a}`)),console.error(H(`Valid values: ${nfe.join(", ")}`)),process.exit(1)),s=await f2(i,{startDate:n.from??`${o.slice(0,4)}-01-01`,endDate:n.to??o,groupBy:a});break}case"vat-ledger":s=await p2(i,{startDate:n.from??`${o.slice(0,4)}-01-01`,endDate:n.to??o});break;case"equity-movement":s=await h2(i,{primarySnapshotStartDate:n.from??`${o.slice(0,4)}-01-01`,primarySnapshotEndDate:n.to??o,currencyCode:n.currency});break;case"bank-balance-summary":s=await m2(i,{primarySnapshotDate:n.to??o,currencyCode:n.currency});break;case"bank-recon-summary":n.bankAccount||(console.error(ie("--bank-account is required for bank-recon-summary")),process.exit(1)),s=await A2(i,{bankAccountResourceId:n.bankAccount,primarySnapshotStartDate:n.from??`${o.slice(0,4)}-01-01`,primarySnapshotEndDate:n.to??o,currencyCode:n.currency});break;case"bank-recon-details":n.bankAccount||(console.error(ie("--bank-account is required for bank-recon-details")),process.exit(1)),s=await g2(i,{bankAccountResourceId:n.bankAccount,primarySnapshotStartDate:n.from??`${o.slice(0,4)}-01-01`,primarySnapshotEndDate:n.to??o,filter:{},currencyCode:n.currency});break;case"fa-summary":{let a=(n.groupBy??"ACCOUNT").toUpperCase();s=await y2(i,{primarySnapshotStartDate:n.from??`${o.slice(0,4)}-01-01`,primarySnapshotEndDate:n.to??o,groupBy:a,currencyCode:n.currency});break}case"fa-recon-summary":s=await E2(i,{primarySnapshotStartDate:n.from??`${o.slice(0,4)}-01-01`,primarySnapshotEndDate:n.to??o,currencyCode:n.currency});break;case"ar-report":s=await b2(i,{endDate:n.to??o});break;case"ledger-highlights":s=await C2(i);break}n.json||console.log(R(`${r} Report:
1052
1052
  `)),console.log(JSON.stringify(s.data,null,2))})(n)))}Fe();oc();tF();Pn();At();Pt();Tt();ur();Lt();dr();var Dot=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"},{key:"saleItemName",header:"Sale Name"},{key:"purchaseItemName",header:"Purchase Name"}];function Sot(t){let e=t.command("items").description("Manage items (products & services)");e.command("list").description("List items").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").addOption(new ti("--view <tier>","Payload tier: lean (summary rows) or full (default)").choices(["lean","full"])).option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>ZO(r,{...o,view:n.view}),{label:"Fetching items"});$e(i,Dot,n,"Items")})),Ve({parent:e,fields:oS,defaults:sS,fetcher:wE,leanView:!0,columns:Dot,label:"Searching items"}),e.command("get <resourceId>").description("Get an item by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await IE(i,r)).data;if(n.json)console.log(JSON.stringify(s,null,2));else{console.log(R("Name:"),s.internalName),console.log(R("Code:"),s.itemCode),console.log(R("ID:"),s.resourceId);let a=[s.appliesToSale&&"Sale",s.appliesToPurchase&&"Purchase"].filter(Boolean).join(", ");a&&console.log(R("Applies to:"),a)}})(n)),e.command("create").description("Create a new item").option("--jot <text>",we).option("--name <name>","Item name (internalName)").option("--code <code>","Item code").option("--sale","Applies to sales").option("--purchase","Applies to purchases").option("--sale-name <name>","Sale display name (defaults to --name)").option("--purchase-name <name>","Purchase display name (defaults to --name)").option("--sale-price <n>","Default sale price",cr).option("--purchase-price <n>","Default purchase price",cr).option("--sale-account <resourceId>","Sale account resourceId").option("--purchase-account <resourceId>","Purchase account resourceId").option("--sale-tax <resourceId>","Sale tax profile resourceId").option("--purchase-tax <resourceId>","Purchase tax profile resourceId").option("--custom-fields <json>",'Custom field values as JSON array: [{"customFieldName":"PO Number","actualValue":"PO-123"}]').option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o=i?.itemCode??n.code;if(o){let a=await jF(r,o);if(a){n.json?console.log(JSON.stringify(a,null,2)):(console.log(Se(`Item with code "${o}" already exists`)),console.log(R("ID:"),a.resourceId));return}}let s;if(i)s=await Iw(r,i);else{Le(n,[{flag:"--name",key:"name"},{flag:"--code",key:"code"}]);let a=n.customFields?un(n.customFields):void 0;s=await Iw(r,{internalName:n.name,itemCode:n.code,appliesToSale:n.sale??void 0,appliesToPurchase:n.purchase??void 0,saleItemName:n.sale?n.saleName??n.name:void 0,purchaseItemName:n.purchase?n.purchaseName??n.name:void 0,salePrice:n.salePrice,purchaseItemPrice:n.purchasePrice,saleAccountResourceId:n.saleAccount,purchaseAccountResourceId:n.purchaseAccount,saleTaxProfileResourceId:n.saleTax,purchaseTaxProfileResourceId:n.purchaseTax,customFields:a})}n.json?console.log(JSON.stringify(s.data,null,2)):(console.log(Y(`Item created: ${n.name}`)),console.log(R("ID:"),s.data.resourceId)),Ie(r,"create_item",n,s.data)})),e.command("update <resourceId>").description("Update an item").option("--jot <text>",we).option("--name <name>","New name").option("--code <code>","New item code").option("--sale-price <n>","New sale price",cr).option("--purchase-price <n>","New purchase price",cr).option("--status <status>","Status (ACTIVE/INACTIVE)").option("--custom-fields <json>","Custom field values as JSON array").option("--input <file>","Read full update body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=Ce(n),s;o?s=o:(s={},n.name!==void 0&&(s.internalName=n.name),n.code!==void 0&&(s.itemCode=n.code),n.salePrice!==void 0&&(s.salePrice=n.salePrice),n.purchasePrice!==void 0&&(s.purchaseItemPrice=n.purchasePrice),n.status!==void 0&&(s.status=n.status),n.customFields&&(s.customFields=un(n.customFields)));let a=await XO(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`Item updated: ${a.data.internalName}`)),Ie(i,"update_item",n,a.data)})(n)),e.command("delete <resourceId>").description("Delete an item").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await KO(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Item ${r} deleted.`)),Ie(i,"delete_item",n,{resourceId:r})})(n)),e.command("bulk-upsert").description("Create or update items in bulk (max 500). Provide resourceId per item to update, omit to create.").option("--input <file>","Read JSON body from file (or pipe via stdin with --input -)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n);i||(console.error('Error: --input <file> is required (JSON with { "items": [...] })'),process.exit(1));let o=i.items??i;Array.isArray(o)||(console.error('Error: expected { "items": [...] } or a JSON array'),process.exit(1)),o.length>500&&(console.error(`Error: max 500 items per call (got ${o.length}). Split into batches.`),process.exit(1));let s=await eF(r,o);if(n.json)console.log(JSON.stringify(s.data,null,2));else{let a=s.data.resourceIds??[];console.log(Y(`${a.length} item(s) upserted.`)),a.forEach(c=>console.log(` ${c}`))}}))}Fe();yF();Pn();At();Pt();Tt();ur();Lt();dr();var Rot=[{key:"resourceId",header:"ID",format:Te},{key:"name",header:"Name"}];function xot(t){let e=t.command("tags").description("Manage tags");e.command("list").description("List tags").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>kE(r,o),{label:"Fetching tags"});$e(i,Rot,n,"Tags")})),e.command("get <resourceId>").description("Get a tag by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await hF(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId))})(n)),Ve({parent:e,fields:kS,defaults:NS,fetcher:mF,columns:Rot,label:"Searching tags",positionalArg:"tagName",positionalFilter:r=>({tagName:{contains:r}})}),e.command("create").description("Create a new tag").option("--jot <text>",we).option("--name <name>","Tag name").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o=i?.name??n.name;i||Le(n,[{flag:"--name",key:"name"}]);let s=await GF(r,o);if(s){n.json?console.log(JSON.stringify(s,null,2)):(console.log(ke(`Tag "${o}" already exists \u2014 reusing.`)),console.log(R("ID:"),s.resourceId));return}let a=i?await xw(r,i):await xw(r,{name:o});n.json?console.log(JSON.stringify(a.data,null,2)):(console.log(Y(`Tag created: ${o}`)),console.log(R("ID:"),a.data.resourceId)),Ie(r,"create_tag",n,a.data)})),e.command("update <resourceId>").description("Rename a tag").option("--name <name>","New tag name").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{Le(n,[{flag:"--name",key:"name"}]);let o=await AF(i,r,{name:n.name});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Tag renamed to "${n.name}".`)),console.log(R("ID:"),o.data.resourceId))})(n)),e.command("delete <resourceId>").description("Delete a tag").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await gF(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Tag ${r} deleted.`)),Ie(i,"delete_tag",n,{resourceId:r})})(n))}Fe();Sw();At();Pt();Tt();ur();Lt();dr();var Bot=[{key:"resourceId",header:"ID",format:Te},{key:"title",header:"Name"},{key:"status",header:"Status",format:t=>String(t)}];function Tot(t){let e=t.command("capsules").description("Manage capsules (transaction grouping)");e.command("list").description("List capsules").option("--limit <n>","Max results (default 100)",Ee).option("--offset <n>","Page number offset (0-indexed)",Ge).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",Ee).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await Ye(n,o=>oF(r,o),{label:"Fetching capsules"});$e(i,Bot,n,"Capsules")})),Ve({parent:e,fields:QS,defaults:LS,fetcher:xE,columns:Bot,label:"Searching capsules",positionalArg:"title",positionalFilter:r=>({title:{contains:r}})}),e.command("get <resourceId>").description("Get a capsule by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let s=(await Dw(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Title:"),s.title),s.description&&console.log(R("Description:"),s.description),console.log(R("ID:"),s.resourceId),s.type&&console.log(R("Type:"),s.type),s.capsuleType?.resourceId&&console.log(R("Type ID:"),s.capsuleType.resourceId))})(n)),e.command("create").description("Create a new capsule").option("--jot <text>",we).option("--title <title>","Capsule title").option("--type <resourceId>","Capsule type resourceId").option("--description <text>","Description").option("--input <file>","Read full request body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=Ce(n),o;i?o=await oA(r,i):(Le(n,[{flag:"--title",key:"title"},{flag:"--type",key:"type"}]),o=await oA(r,{capsuleTypeResourceId:n.type,title:n.title,description:n.description})),n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(Y(`Capsule created: ${n.title}`)),console.log(R("ID:"),o.data.resourceId)),Ie(r,"create_capsule",n,o.data)})),e.command("update <resourceId>").description("Update a capsule").option("--jot <text>",we).option("--title <title>","New title").option("--description <text>","New description").option("--input <file>","Read full update body from JSON file (or pipe via stdin)").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{let o=Ce(n),s;o?s=o:(s={},n.title!==void 0&&(s.title=n.title),n.description!==void 0&&(s.description=n.description));let a=await sF(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(Y(`Capsule updated: ${a.data.title}`)),Ie(i,"update_capsule",n,a.data)})(n)),e.command("delete <resourceId>").description("Delete a capsule").option("--jot <text>",we).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action((r,n)=>Q(async i=>{await aF(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(Y(`Capsule ${r} deleted.`)),Ie(i,"delete_capsule",n,{resourceId:r})})(n)),e.command("types").description("List capsule types").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(Q(async(r,n)=>{let i=await RE(r);if(n.json)console.log(JSON.stringify(i.data,null,2));else{console.log(R(`Capsule Types (${i.data.length}):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaz-clio",
3
- "version": "5.35.3",
3
+ "version": "5.35.4",
4
4
  "description": "Clio: Command Line Interface Operator for Jaz AI.",
5
5
  "type": "module",
6
6
  "bin": {