jaz-clio 5.55.14 → 5.55.15

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.55.14
3
+ version: 5.55.15
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, 159 production gotchas, error
@@ -194,8 +194,8 @@ One MCP namespace wraps all three: **`claim_settings`**. CLI: `clio claim-types
194
194
 
195
195
  | Entity | What it is | Key fields |
196
196
  |--------|-----------|-----------|
197
- | **Claim Type** | An expense category (e.g. "Travel", "Meals"). | `name` (unique/org), `expenseAccountResourceId`, `taxProfileResourceId`, `classifierConfig`, `isDefault` |
198
- | **Claim Profile** | A per-employee policy bundle (who approves, spend limits, which types are visible, the liability account). | `name` (unique/org), `approverUserResourceId`, `visibleClaimTypeIds[]`, `visibleTaxProfileIds[]`, `visibleClassifierIds[]`, `visibleVendorResourceIds[]`, `allowedCurrencies[]`, `minClaimAmount`, `maxClaimAmount`, `maxPerPeriodAmount`, `perPeriod`, `employeeBalanceAccountResourceId`, `taxMode`, `isDefault` |
197
+ | **Claim Type** | An expense category (e.g. "Travel", "Meals"). | `name` (unique/org), `expenseAccountResourceId`, `taxProfileResourceId`, `classifierConfig` |
198
+ | **Claim Profile** | A per-employee policy bundle (who approves, spend limits, which types are visible, the liability account). | `name` (unique/org), `approverUserResourceId`, `visibleClaimTypeIds[]`, `visibleTaxProfileIds[]`, `visibleClassifierIds[]`, `visibleVendorResourceIds[]`, `allowedCurrencies[]`, `minClaimAmount`, `maxClaimAmount`, `maxPerPeriodAmount`, `perPeriod`, `employeeBalanceAccountResourceId`, `taxMode` |
199
199
  | **Posting Rule** | How approved claims group into journals at conversion (the "Posting Rules" tab). | `name` (unique/org), `outerAxis`, `innerAxis`, `lineDescriptionTemplate`, `journalReferenceTemplate`, `defaultBankAccountResourceId`, `defaultIncludeReimbursementPayout`, `isDefault` |
200
200
 
201
201
  ## Enums (use EXACT values)
@@ -219,4 +219,4 @@ One MCP namespace wraps all three: **`claim_settings`**. CLI: `clio claim-types
219
219
 
220
220
  ## Search
221
221
 
222
- Standard `{ filter, sort }` envelope (filter-only — no natural-language `query`). Sort keys: `resourceId`, `name`, `isDefault`, `createdAt`, `updatedAt`. Filterable fields mirror the key fields above (name = contains; ids = eq; amounts = gte/lte; flags = boolean).
222
+ Standard `{ filter, sort }` envelope (filter-only — no natural-language `query`). Sort keys: `resourceId`, `name`, `createdAt`, `updatedAt` (posting rules also sort by `isDefault`). Filterable fields mirror the key fields above (name = contains; ids = eq; amounts = gte/lte; flags = boolean).
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-cli
3
- version: 5.55.14
3
+ version: 5.55.15
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,
@@ -281,7 +281,7 @@ EmploymentType: `FULL_TIME` · `PART_TIME` · `CONTRACTOR` · `INTERN` · `TEMPO
281
281
  | Subcommand | Key flags |
282
282
  |------------|-----------|
283
283
  | `list` / `get <id>` / `search` | `--limit`, `--offset`, `--all`, `--json` |
284
- | `create` | `--name`, `--expense-account <id>`, `--tax-profile <id>`, `--default` |
284
+ | `create` | `--name`, `--expense-account <id>`, `--tax-profile <id>` |
285
285
  | `update <id>` / `delete <id>` | partial update; default-protected delete |
286
286
 
287
287
  ### `clio claim-profiles` — Per-employee spend policies (master data)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-conversion
3
- version: 5.55.14
3
+ version: 5.55.15
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.55.14
3
+ version: 5.55.15
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.55.14
3
+ version: 5.55.15
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.55.14
3
+ version: 5.55.15
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.55.14
3
+ version: 5.55.15
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
@@ -439,7 +439,7 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
439
439
  `)?`"${t.replace(/"/g,'""')}"`:t}function yMe(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function Ezt(t,e){let r=e.map(i=>h2(i.header)).join(","),n=t.map(i=>e.map(o=>{let s=bzt(i,o.key);if(s==null||s==="")return"";let a=o.format?yzt(o.format(s)):yMe(s);return h2(a)}).join(","));return[r,...n].join(`
440
440
  `)}function bzt(t,e){let r=e.split("."),n=t;for(let i of r){if(n==null||typeof n!="object")return;n=n[i]}return n}function Ke(t,e,r,n){let i=th(r),o=t.totalElements??t.data.length;switch(i){case"json":console.log(NK({...t,totalElements:o},r));break;case"csv":console.log(Ezt(t.data,e));break;case"yaml":console.log((0,BK.stringify)({totalElements:o,totalPages:t.totalPages,truncated:t.truncated,...t.stats?{stats:t.stats}:{},data:t.data}).trimEnd());break;case"table":{console.log(R(`${n} (${t.data.length} of ${o}):
441
441
  `));let{items:s,overflow:a}=kK(t.data);if(s.length===0){console.log(" No results found.");return}console.log(Ga(s,e)),a>0&&console.log(M(`
442
- ... and ${a.toLocaleString()} more (use --format json for full output)`));break}}}function DS(t,e){switch(th(e)){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":{let n=Object.keys(t);console.log(n.map(h2).join(",")),console.log(n.map(i=>h2(yMe(t[i]))).join(","));break}case"yaml":console.log((0,BK.stringify)(t).trimEnd());break;case"table":console.log(AMe(t));break}}var BK,bo,Jt=X(()=>{"use strict";Ne();Pd();BK=sn(pMe(),1);_S();ln();gMe();bo=class extends Ki{constructor(e){super(e),this.name="CliValidationError"}}});var CMe={};To(CMe,{displaySlice:()=>kK,paginatedFetch:()=>st,paginatedJson:()=>NK});async function st(t,e,r){let n=r.defaultLimit??100;if(t.all&&t.offset!==void 0)throw new Error("--all and --offset cannot be used together");if(t.all){let d=(t.format?.toLowerCase()??(t.json?"json":"table"))==="table"?wQe(r.label):void 0,f=t.maxRows??bMe,p=await qp((y,C)=>e({limit:C,offset:y}),{pageSize:t.limit??200,maxItems:f,onProgress:d?(y,C)=>d.update(y,C):void 0});d?.clear();let{truncated:h}=p,{data:m}=p;m.length>f&&(m=m.slice(0,f),h=!0),h&&!Ul(t)&&console.error(xe(`Warning: dataset has ${p.totalElements.toLocaleString()} items \u2014 showing ${m.length.toLocaleString()} (max-rows: ${f.toLocaleString()})`));let A=t.limit??n,g=Math.ceil(p.totalElements/A);return{data:m,totalElements:p.totalElements,totalPages:g,truncated:h}}let i=t.limit??n,o=await e({limit:i,offset:t.offset??0}),s=o.data??[],a=(o.totalElements??0)>s.length;return{data:s,totalElements:o.totalElements??0,totalPages:o.totalPages??0,truncated:a}}function kK(t,e=Czt){return t.length<=e?{items:t,overflow:0}:{items:t.slice(0,e),overflow:t.length-e}}function NK(t,e){let{totalElements:r,totalPages:n,truncated:i,data:o,stats:s}=t,a=s?{stats:s}:{};if(i){let c=e.maxRows??bMe;return JSON.stringify({totalElements:r,totalPages:n,truncated:i,_meta:{fetchedRows:o.length,maxRows:c},...a,data:o},null,2)}return JSON.stringify({totalElements:r,totalPages:n,truncated:i,...a,data:o},null,2)}var bMe,Czt,ln=X(()=>{"use strict";Ne();iM();_Qe();Jt();bMe=1e3,Czt=500});async function Izt(){if(!OK){let[t,e,r,n]=await Promise.all([Promise.resolve().then(()=>(ct(),DMe)),Promise.resolve().then(()=>(ln(),CMe)),Promise.resolve().then(()=>(Jt(),EMe)),Promise.resolve().then(()=>(It(),Bwe))]);OK=t.apiAction,IMe=e.paginatedFetch,vMe=r.outputList,FK=n.parsePositiveInt,wMe=n.parseNonNegativeInt}}function je(t){let e=t.commandName??"search",r=t.positionalArg?` <${t.positionalArg}>`:"",n=t.parent.command(`${e}${r}`).description(`Search ${t.label.replace("Searching ","")}`);n.allowExcessArguments(!1);let i=new Map,o=NZ(t.fields);for(let[a,c,u,d]of o){let f=new Bt(a,c),p=t.fields[d];u&&p?.op!=="multi"&&f.choices(u),n.addOption(f);let h=vzt(a);h!==d&&i.set(h,d)}if(t.defaults.supportsQuery&&n.option("--query <expression>",'Jaz search expression (e.g. "status:unpaid AND $500+", "customer:acme AND date:-30d"). Merged with --filter; --filter fields win on conflict.'),n.option("--filter <json>","Raw API filter JSON (merged with flags; flags win on conflict)").addOption(new Bt("--sort <field>","Sort field name")).addOption(new Bt("--order <direction>","Sort direction").choices(["ASC","DESC"])).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON"),t.defaults.supportsPagination!==!1&&n.option("--limit <n>",`Max results (default ${t.defaults.defaultLimit})`).option("--offset <n>","Page number offset (0-indexed)").option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)"),t.defaults.supportsView&&n.addOption(new Bt("--view <tier>","Payload tier: 'lean' = summary rows; 'full' (default) = complete records").choices(["lean","full"])),t.pathParam&&t.pathParam!==t.positionalArg){let a=t.pathParam.replace(/([A-Z])/g,"-$1").toLowerCase();n.requiredOption(`--${a} <id>`,t.pathParamDescription??`${t.pathParam} (required)`)}let s=async(...a)=>{let c=t.positionalArg?a[0]:void 0,u=t.positionalArg?a[1]:a[0];c&&t.positionalArg&&(u[t.positionalArg]=c),await Izt(),await OK(async d=>{t.preProcess&&await t.preProcess(d,u),typeof u.limit=="string"&&(u.limit=FK(u.limit)),typeof u.offset=="string"&&(u.offset=wMe(u.offset)),typeof u.maxRows=="string"&&(u.maxRows=FK(u.maxRows));let f={...u};for(let[v,T]of i)f[v]!==void 0&&(f[T]=f[v]);let p;if(typeof u.filter=="string")try{p=JSON.parse(u.filter)}catch{throw new Error(`Invalid --filter JSON: ${u.filter}`)}let h=t.baseFilter?p?{...t.baseFilter,...p}:t.baseFilter:p,m=MD(f,t.fields,h),A;if(c&&t.positionalFilter){let v=t.positionalFilter(c);A=m?{...v,...m}:v}else A=m;let g={sortBy:[u.sort??t.defaults.sortBy],order:u.order??t.defaults.sortOrder},y=t.defaults.supportsQuery?u.query:void 0,C=t.defaults.supportsView?u.view:void 0,E=t.pathParam?({limit:v,offset:T})=>t.fetcher(d,u[t.pathParam],{filter:A,sort:g,limit:v,offset:T,query:y,view:C}):({limit:v,offset:T})=>t.fetcher(d,{filter:A,sort:g,limit:v,offset:T,query:y,view:C}),I=await IMe(u,E,{label:t.label,defaultLimit:t.defaults.defaultLimit});vMe(I,t.columns,u,t.label.replace("Searching ",""))})(u)};return n.action(s),n}function vzt(t){return t.replace(/^--/,"").split(/[\s<]/)[0].replace(/-([a-z])/g,(r,n)=>n.toUpperCase())}var OK,IMe,vMe,FK,wMe,_Me=X(()=>{"use strict";Oo();OZ();nM()});var MC,UC,SS,RS,SMe=X(()=>{"use strict";la();MC={reference:{path:"reference",op:"contains",type:"string",description:"Invoice reference number"},status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:VFe},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact/customer name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (e.g., SGD, USD)"},approvalStatus:{path:"approvalStatus",op:"multi",type:"string",description:"Approval status",enum:eM},startDate:{path:"valueDate",op:"gte",type:"string",description:"On/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On/before (YYYY-MM-DD)",cliFlag:"--to <date>"},dueDateFrom:{path:"dueDate",op:"gte",type:"string",description:"Due date from (YYYY-MM-DD)"},dueDateTo:{path:"dueDate",op:"lte",type:"string",description:"Due date to (YYYY-MM-DD)"},minAmount:{path:"totalAmount",op:"gte",type:"number",description:"Minimum total amount"},maxAmount:{path:"totalAmount",op:"lte",type:"number",description:"Maximum total amount"}},UC={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0},SS=MC,RS=UC});var RMe,TS,xS,$C,BS,rh,nh,TMe=X(()=>{"use strict";la();RMe={reference:{path:"reference",op:"contains",type:"string",description:"Order reference number"},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact (customer/supplier) name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (e.g., SGD, USD)"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On/before (YYYY-MM-DD)",cliFlag:"--to <date>"},dueDateFrom:{path:"dueDate",op:"gte",type:"string",description:"Due date from (YYYY-MM-DD)"},dueDateTo:{path:"dueDate",op:"lte",type:"string",description:"Due date to (YYYY-MM-DD)"},minAmount:{path:"totalAmount",op:"gte",type:"number",description:"Minimum total amount"},maxAmount:{path:"totalAmount",op:"lte",type:"number",description:"Maximum total amount"}},TS={status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:d1e},...RMe},xS={status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:f1e},...RMe},$C={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0},BS=$C,rh={name:{path:"name",op:"contains",type:"string",description:"Line item text/description"},reference:{path:"reference",op:"contains",type:"string",description:"Parent order reference"},orderId:{path:"btResourceId",op:"eq",type:"string",description:"Parent order resourceId"},contactName:{path:"contactName",op:"contains",type:"string",description:"Contact (customer/supplier) name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (e.g., SGD, USD)"},status:{path:"status",op:"eq",type:"string",description:"Line item status"},account:{path:"organizationAccountName",op:"contains",type:"string",description:"Chart-of-account name on the line"},taxProfile:{path:"taxProfileName",op:"contains",type:"string",description:"Tax profile name on the line"},isOpen:{path:"isOpen",op:"boolean",type:"boolean",description:"Only open (unfulfilled) lines"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On/before (YYYY-MM-DD)",cliFlag:"--to <date>"},minAmount:{path:"totalItemAmount",op:"gte",type:"number",description:"Minimum line amount"},maxAmount:{path:"totalItemAmount",op:"lte",type:"number",description:"Maximum line amount"}},nh={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,supportsQuery:!0}});var ih,qC,kS,xMe=X(()=>{"use strict";la();ih={reference:{path:"reference",op:"contains",type:"string",description:"Credit note reference"},status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:WFe},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code"},approvalStatus:{path:"approvalStatus",op:"multi",type:"string",description:"Approval status",enum:eM},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"}},qC={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0},kS=qC});var NS,OS,BMe=X(()=>{"use strict";la();NS={reference:{path:"reference",op:"contains",type:"string",description:"Journal reference"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:ZFe},type:{path:"type",op:"multi",type:"string",description:"Journal type",enum:XFe},templateType:{path:"templateType",op:"multi",type:"string",description:"Template type",enum:KFe},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact name"},internalNotes:{path:"internalNotes",op:"contains",type:"string",description:"Search internal notes"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"}},OS={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0}});var FS,QS,kMe=X(()=>{"use strict";la();FS={name:{path:"name",op:"contains",type:"string",description:"Contact name"},email:{path:"email",op:"contains",type:"string",description:"Email address"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:KP},isCustomer:{path:"customer",op:"boolean",type:"boolean",description:"Filter to customers only",cliFlag:"--customer"},isSupplier:{path:"supplier",op:"boolean",type:"boolean",description:"Filter to suppliers only",cliFlag:"--supplier"},taxId:{path:"taxId",op:"contains",type:"string",description:"Tax ID"}},QS={sortBy:"name",sortOrder:"ASC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0}});var uf,df,QK,LS,PS,NMe=X(()=>{"use strict";la();uf={type:{path:"businessTransactionType",op:"multi",type:"string",description:"Transaction type",enum:tM},direction:{path:"direction",op:"eq",type:"string",description:"Direction (PAYIN or PAYOUT)",enum:xZ},status:{path:"businessTransactionStatus",op:"multi",type:"string",description:"Status",enum:o1e},reference:{path:"businessTransactionReference",op:"contains",type:"string",description:"Reference",cliFlag:"--ref <reference>"},accountId:{path:"organizationAccountResourceId",op:"eq",type:"string",description:"Bank account resourceId",cliFlag:"--account <id>"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"},businessTransactionType:{path:"businessTransactionType",op:"multi",type:"string",description:"(alias for type)"}},df={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,supportsQuery:!0},QK={magicSort:{type:"object",description:"Rank by match quality to a bank entry: {bankStatementEntryResourceId, magicSort:true}."},transactionType:{type:"string",enum:[...i1e],description:"Scope. Default ALL_CASHFLOWS."}},LS={type:{path:"businessTransactionType",op:"multi",type:"string",description:"Transaction type (SALE, PURCHASE, etc.)",enum:tM},direction:{path:"direction",op:"eq",type:"string",description:"Direction",enum:xZ},reference:{path:"businessTransactionReference",op:"contains",type:"string",description:"Reference",cliFlag:"--ref <reference>"},accountId:{path:"organizationAccountResourceId",op:"eq",type:"string",description:"Account resourceId",cliFlag:"--account <id>"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"},businessTransactionType:{path:"businessTransactionType",op:"multi",type:"string",description:"(alias for type)",enum:tM},fromDate:{path:"valueDate",op:"gte",type:"string",description:"(alias for startDate)"},toDate:{path:"valueDate",op:"lte",type:"string",description:"(alias for endDate)"},accountResourceId:{path:"organizationAccountResourceId",op:"eq",type:"string",description:"(alias for accountId)"}},PS={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20}});var MS,US,OMe=X(()=>{"use strict";la();MS={status:{path:"status",op:"multi",type:"string",description:"Status",enum:n1e},description:{path:"description",op:"contains",type:"string",description:"Description"},payer:{path:"extContactName",op:"contains",type:"string",description:"Payer/payee name"},reference:{path:"extReference",op:"contains",type:"string",description:"Bank reference",cliFlag:"--ref <reference>"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"},minAmount:{path:"netAmount",op:"gte",type:"number",description:"Minimum net amount"},maxAmount:{path:"netAmount",op:"lte",type:"number",description:"Maximum net amount"}},US={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,supportsQuery:!0}});var $S,qS,FMe=X(()=>{"use strict";la();$S={status:{path:"status",op:"multi",type:"string",description:"Status",enum:e1e},itemCategory:{path:"itemCategory",op:"eq",type:"string",description:"Category",enum:r1e},appliesToSale:{path:"appliesToSale",op:"boolean",type:"boolean",description:"Filter to sale items only",cliFlag:"--sale"},appliesToPurchase:{path:"appliesToPurchase",op:"boolean",type:"boolean",description:"Filter to purchase items only",cliFlag:"--purchase"}},qS={sortBy:"internalName",sortOrder:"ASC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0}});var jS,YS,QMe=X(()=>{"use strict";la();jS={name:{path:"name",op:"contains",type:"string",description:"Asset name"},reference:{path:"reference",op:"contains",type:"string",description:"Reference",cliFlag:"--ref <reference>"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:s1e},category:{path:"category",op:"eq",type:"string",description:"Category",enum:a1e},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},typeName:{path:"typeName",op:"contains",type:"string",description:"Asset type name"},startDate:{path:"purchaseDate",op:"gte",type:"string",description:"Purchase date from (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"purchaseDate",op:"lte",type:"string",description:"Purchase date to (YYYY-MM-DD)",cliFlag:"--to <date>"},minAmount:{path:"purchaseAmount",op:"gte",type:"number",description:"Minimum purchase amount"},maxAmount:{path:"purchaseAmount",op:"lte",type:"number",description:"Maximum purchase amount"}},YS={sortBy:"name",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0}});var HS,zS,LMe=X(()=>{"use strict";la();HS={type:{path:"businessTransactionType",op:"eq",type:"string",description:"Transaction type (SALE, PURCHASE, JOURNAL_MANUAL)"},status:{path:"status",op:"multi",type:"string",description:"Scheduler status",enum:c1e},subscriptionStatus:{path:"subscriptionStatus",op:"multi",type:"string",description:"Subscription status",enum:l1e},schedulerType:{path:"schedulerType",op:"eq",type:"string",description:"Scheduler type"},interval:{path:"interval",op:"eq",type:"string",description:"Interval",enum:u1e},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact name"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code"}},zS={sortBy:"nextScheduleDate",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0}});var GS,JS,PMe=X(()=>{"use strict";la();GS={id:{path:"resourceId",op:"eq",type:"string",description:"Job ID (the jobId returned from bulk operations)",cliFlag:"--id"},status:{path:"status",op:"multi",type:"string",description:"Job status",enum:g1e},type:{path:"jobType",op:"eq",type:"string",description:"Job type (e.g. UPSERT_CONTACTS, UPSERT_ITEMS, PROCESS_BANK_STATEMENT_FILES)",cliFlag:"--type"},fileName:{path:"fileName",op:"contains",type:"string",description:"File name (file-based jobs only)",cliFlag:"--file-name"},from:{path:"createdAt",op:"gte",type:"string",description:"On/after (ISO date)",cliFlag:"--from"},to:{path:"createdAt",op:"lte",type:"string",description:"On/before (ISO date)",cliFlag:"--to"}},JS={sortBy:"createdAt",sortOrder:"DESC",defaultLimit:20}});var VS,WS,MMe=X(()=>{"use strict";VS={name:{path:"name",op:"plain",type:"string",description:"Purchase item name"},reference:{path:"reference",op:"plain",type:"string",description:"Reference name"},currencyCode:{path:"currencyCode",op:"plain",type:"string",description:"Currency code (ISO 4217)"}},WS={sortBy:"name",sortOrder:"ASC",defaultLimit:20}});var ZS,XS,KS,eR,UMe=X(()=>{"use strict";ZS={catalogName:{path:"catalogName",op:"contains",type:"string",description:"Catalog name"},description:{path:"description",op:"contains",type:"string",description:"Catalog item description"},status:{path:"status",op:"multi",type:"string",description:"Record status (e.g. ACTIVE, INACTIVE)"},contactGroupResourceId:{path:"contactGroupResourceId",op:"eq",type:"string",description:"Contact group resourceId"}},XS={sortBy:"catalogName",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0},KS={reportType:{path:"reportType",op:"plain",type:"string",description:"Report type"},reportCategory:{path:"reportCategory",op:"eq",type:"string",description:"Report category. Known defect: 500s unless reportType is also supplied."},isDefault:{path:"isDefault",op:"boolean",type:"boolean",description:"Only default templates. Known defect: 500s upstream today.",cliFlag:"--default"}},eR={sortBy:"reportType",sortOrder:"ASC",defaultLimit:20,supportsPagination:!1}});async function m2(t,e){return t.search("/api/v1/claims/search",e)}async function A2(t,e){return t.get(`/api/v1/claims/${e}`)}async function g2(t,e){return t.post("/api/v1/claims",e)}async function y2(t,e,r){return t.put(`/api/v1/claims/${e}`,r)}async function E2(t,e){return t.delete(`/api/v1/claims/${e}`)}async function b2(t,e,r){return t.delete(`/api/v1/claims/${e}/attachments/${r}`)}async function C2(t,e){return t.post(`/api/v1/claims/${e}/submit`,{})}async function I2(t,e){return t.post(`/api/v1/claims/${e}/approve`,{})}async function v2(t,e,r){return t.post(`/api/v1/claims/${e}/reject`,{rejectionReason:r})}async function w2(t,e,r){return t.post(`/api/v1/claims/${e}/cancel`,{cancellationReason:r})}async function _2(t,e){return t.post(`/api/v1/claims/${e}/unpost`,{})}function tR(t){Qt(t,"resourceIds",500,"claims")}async function D2(t,e){return tR(e),t.post("/api/v1/claims/bulk/submit",{resourceIds:e})}async function S2(t,e){return tR(e),t.post("/api/v1/claims/bulk/approve",{resourceIds:e})}async function R2(t,e){return tR(e),t.post("/api/v1/claims/bulk/delete",{resourceIds:e})}async function T2(t,e,r){return tR(e),t.post("/api/v1/claims/bulk/reject",{resourceIds:e,rejectionReason:r})}async function x2(t,e,r){return tR(e),t.post("/api/v1/claims/bulk/cancel",{resourceIds:e,cancellationReason:r})}async function B2(t){let e=await t.get("/api/v1/claims/tracking-tags");return Array.isArray(e)?e:e?.data??[]}async function k2(t){let e=await t.get("/api/v1/claims/custom-field-values");return Array.isArray(e)?e:e?.data??[]}var $Me,N2=X(()=>{"use strict";En();$Me=["DRAFT","SUBMITTED","APPROVED","CONVERTED","REJECTED","CANCELLED"]});var rR,nR,wzt,_zt,iR,oR,sR,aR,cR,lR,uR,dR,qMe=X(()=>{"use strict";g_();b_();N2();rR={status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:$Me},employeeResourceId:{path:"employeeResourceId",op:"eq",type:"string",description:"Employee resourceId"},contactResourceId:{path:"contactResourceId",op:"eq",type:"string",description:"Vendor contact resourceId"},claimProfileResourceId:{path:"claimProfileResourceId",op:"eq",type:"string",description:"Claim profile resourceId"},approverUserResourceId:{path:"approverUserResourceId",op:"eq",type:"string",description:"Approver user resourceId"},reference:{path:"reference",op:"contains",type:"string",description:"Claim reference"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (ISO 4217)"},startDate:{path:"valueDate",op:"gte",type:"string",description:"Value date on/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"Value date on/before (YYYY-MM-DD)",cliFlag:"--to <date>"},createdFrom:{path:"createdAt",op:"gte",type:"string",description:"Created on/after (YYYY-MM-DD)"},createdTo:{path:"createdAt",op:"lte",type:"string",description:"Created on/before (YYYY-MM-DD)"},minAmount:{path:"totalAmount",op:"gte",type:"number",description:"Minimum total amount"},maxAmount:{path:"totalAmount",op:"lte",type:"number",description:"Maximum total amount"}},nR={sortBy:"createdAt",sortOrder:"DESC",defaultLimit:20},wzt=["RECORDED","COMPLETED","CANCELLED","IN_PROGRESS","ACTION_NEEDED"],_zt=["DIRECT_ENTRY","DISBURSEMENT","REIMBURSEMENT_PAYOUT","ADVANCE"],iR={employeeResourceId:{path:"employeeResourceId",op:"eq",type:"string",description:"Employee resourceId"},employeeName:{path:"employeeName",op:"contains",type:"string",description:"Employee name"},reference:{path:"reference",op:"contains",type:"string",description:"Payout reference"},payoutStatus:{path:"payoutStatus",op:"multi",type:"string",description:"Payout status (comma-separated)",enum:wzt},payoutType:{path:"payoutType",op:"multi",type:"string",description:"Payout type (comma-separated): DIRECT_ENTRY (books-only DCE), DISBURSEMENT (gateway direct-debit-backed), REIMBURSEMENT_PAYOUT, ADVANCE",enum:_zt}},oR={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20},sR={name:{path:"name",op:"contains",type:"string",description:"Claim type name"},isDefault:{path:"isDefault",op:"boolean",type:"boolean",description:"Org default claim type"},expenseAccountResourceId:{path:"expenseAccountResourceId",op:"eq",type:"string",description:"Default expense account resourceId"},taxProfileResourceId:{path:"taxProfileResourceId",op:"eq",type:"string",description:"Default tax profile resourceId"}},aR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},cR={name:{path:"name",op:"contains",type:"string",description:"Claim profile name"},approverUserResourceId:{path:"approverUserResourceId",op:"eq",type:"string",description:"Default approver user resourceId"},isDefault:{path:"isDefault",op:"boolean",type:"boolean",description:"Org default profile"},minClaimAmount:{path:"minClaimAmount",op:"gte",type:"number",description:"Minimum claim total (>=)"},maxClaimAmount:{path:"maxClaimAmount",op:"lte",type:"number",description:"Maximum claim total (<=)"},maxPerPeriodAmount:{path:"maxPerPeriodAmount",op:"lte",type:"number",description:"Per-period spend cap (<=)"},perPeriod:{path:"perPeriod",op:"eq",type:"string",description:"Per-period window",enum:m_},employeeBalanceAccountResourceId:{path:"employeeBalanceAccountResourceId",op:"eq",type:"string",description:"Employee balance (liability) account resourceId"}},lR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},uR={name:{path:"name",op:"contains",type:"string",description:"Posting rule name"},outerAxis:{path:"outerAxis",op:"eq",type:"string",description:"Outer grouping axis",enum:y_},innerAxis:{path:"innerAxis",op:"eq",type:"string",description:"Inner line-aggregation axis",enum:E_},defaultBankAccountResourceId:{path:"defaultBankAccountResourceId",op:"eq",type:"string",description:"Default reimbursement bank account resourceId"},defaultIncludeReimbursementPayout:{path:"defaultIncludeReimbursementPayout",op:"boolean",type:"boolean",description:"Creates reimbursement DCE by default"},isDefault:{path:"isDefault",op:"boolean",type:"boolean",description:"Org default rule"}},dR={sortBy:"name",sortOrder:"ASC",defaultLimit:100}});var fR,pR,hR,mR,jMe=X(()=>{"use strict";C_();fR={name:{path:"name",op:"contains",type:"string",description:"Employee name"},email:{path:"email",op:"contains",type:"string",description:"Work email"},phone:{path:"phone",op:"contains",type:"string",description:"Phone"},userResourceId:{path:"userResourceId",op:"eq",type:"string",description:"Bound login user resourceId"},managerEmployeeResourceId:{path:"managerEmployeeResourceId",op:"eq",type:"string",description:"Manager employee resourceId"},claimProfileResourceId:{path:"claimProfileResourceId",op:"eq",type:"string",description:"Claim profile resourceId"},currency:{path:"currency",op:"eq",type:"string",description:"Balance currency (ISO 4217)"},active:{path:"active",op:"boolean",type:"boolean",description:"Active employees only"},createdFrom:{path:"createdAt",op:"gte",type:"string",description:"Created on/after (YYYY-MM-DD)"},createdTo:{path:"createdAt",op:"lte",type:"string",description:"Created on/before (YYYY-MM-DD)"}},pR={sortBy:"name",sortOrder:"ASC",defaultLimit:50},hR={name:{path:"name",op:"contains",type:"string",description:"Employee name"},email:{path:"email",op:"contains",type:"string",description:"Work email"},phone:{path:"phone",op:"contains",type:"string",description:"Phone"},currency:{path:"currency",op:"eq",type:"string",description:"Balance currency (ISO 4217)"},employmentType:{path:"employmentType",op:"eq",type:"string",description:"Employment type",enum:kA},active:{path:"active",op:"boolean",type:"boolean",description:"Active employees only"}},mR={sortBy:"name",sortOrder:"ASC",defaultLimit:50}});var AR,gR,yR,ER,bR,CR,IR,vR,wR,_R,DR,SR,RR,TR,LK,xR,BR,kR,NR,YMe=X(()=>{"use strict";la();AR={name:{path:"name",op:"contains",type:"string",description:"Account name"},code:{path:"code",op:"contains",type:"string",description:"Account code"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:t1e},accountClass:{path:"accountClass",op:"eq",type:"string",description:"Account class",enum:p1e},accountType:{path:"accountType",op:"eq",type:"string",description:"Account type",enum:rM},controlFlag:{path:"controlFlag",op:"boolean",type:"boolean",description:"Control flag (system accounts)"}},gR={sortBy:"code",sortOrder:"ASC",defaultLimit:100,supportsQuery:!1},yR={query:{path:"tagName",op:"contains",type:"string",description:"Tag name"}},ER={sortBy:"tagName",sortOrder:"ASC",defaultLimit:100},bR={name:{path:"name",op:"contains",type:"string",description:"Tax profile name",cliFlag:"--name <name>"},taxTypeCode:{path:"taxTypeCode",op:"contains",type:"string",description:"Tax type code"},appliesToSale:{path:"appliesToSale",op:"boolean",type:"boolean",description:"Filter to sale profiles"},appliesToPurchase:{path:"appliesToPurchase",op:"boolean",type:"boolean",description:"Filter to purchase profiles"},appliesToSaleCreditNote:{path:"appliesToSaleCreditNote",op:"boolean",type:"boolean",description:"Filter to sale CN profiles"},appliesToPurchaseCreditNote:{path:"appliesToPurchaseCreditNote",op:"boolean",type:"boolean",description:"Filter to purchase CN profiles"}},CR={sortBy:"name",sortOrder:"ASC",defaultLimit:100,supportsQuery:!0},IR={title:{path:"title",op:"contains",type:"string",description:"Capsule title"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:A1e}},vR={sortBy:"title",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0},wR={query:{path:"customFieldName",op:"contains",type:"string",description:"Custom field name",cliFlag:"--name <name>"},datatypeCode:{path:"datatypeCode",op:"eq",type:"string",description:"Data type",enum:h1e,cliFlag:"--type <type>"},customFieldName:{path:"customFieldName",op:"contains",type:"string",description:"(alias for query)"}},_R={sortBy:"customFieldName",sortOrder:"ASC",defaultLimit:100},DR={query:{path:"name",op:"contains",type:"string",description:"Group name"}},SR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},RR={firstName:{path:"user.firstName",op:"contains",type:"string",description:"User first name"},lastName:{path:"user.lastName",op:"contains",type:"string",description:"User last name"},email:{path:"user.email",op:"contains",type:"string",description:"Email"},userType:{path:"userType",op:"eq",type:"string",description:"Access tier",enum:m1e},status:{path:"status",op:"multi",type:"string",description:"Status",enum:KP}},TR={sortBy:"user.FirstName",sortOrder:"ASC",defaultLimit:50},LK=t=>({or:{user:{firstName:{contains:t}},or:{user:{lastName:{contains:t}}}}}),xR={query:{path:"name",op:"contains",type:"string",description:"Rule name"},account:{path:"appliesToReconciliationAccount",op:"eq",type:"string",description:"Bank account resourceId",cliFlag:"--account <id>"}},BR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},kR={query:{path:"type",op:"contains",type:"string",description:"Classifier type"}},NR={sortBy:"type",sortOrder:"ASC",defaultLimit:100}});var lr=X(()=>{"use strict";la();nM();OZ();_Me();SMe();TMe();xMe();BMe();kMe();NMe();OMe();FMe();QMe();LMe();PMe();MMe();UMe();qMe();jMe();YMe()});async function O2(t,e){return t.list("/api/v1/modules",e)}async function F2(t,e){return t.get(`/api/v1/modules/${encodeURIComponent(e)}`)}var PK=X(()=>{"use strict"});async function Q2(t,e){return t.list("/api/v1/purchase-items",e)}async function L2(t,e){return t.get(`/api/v1/purchase-items/${encodeURIComponent(e)}`)}async function P2(t,e){return t.search("/api/v1/purchase-items/search",e)}var MK=X(()=>{"use strict"});async function M2(t,e){return t.list("/api/v1/invoices",e)}async function $o(t,e){let r=await t.get(`/api/v1/invoices/${e}`);return"data"in r&&typeof r.data=="object"?r:{data:r}}async function jC(t,e){return t.search("/api/v1/invoices/search",e)}async function bg(t,e){return t.post("/api/v1/invoices",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function U2(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(mp)}:r,i=await Ic(n,()=>$o(t,e));return t.put(`/api/v1/invoices/${e}`,i)}async function $2(t,e,r){return t.delete(`/api/v1/invoices/${e}`,r)}async function OR(t,e,r){return t.post(`/api/v1/invoices/${e}/payments`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function FR(t,e){return t.post("/api/v1/scheduled/invoices",{...e,invoice:{...e.invoice,currency:Sr(e.invoice?.currency)}})}async function q2(t,e,r){return t.post(`/api/v1/invoices/${e}/credits`,{credits:r})}async function QR(t,e,r){let n=await Ic({...r,resourceId:e,saveAsDraft:!1},()=>$o(t,e));return t.put(`/api/v1/invoices/${e}`,n)}async function j2(t,e){return t.get(`/api/v1/invoices/${e}/download`)}async function LR(t,e){let r=await t.get(`/api/v1/invoices/${e}/payments`);return{data:Array.isArray(r)?r:r.data??[]}}async function Y2(t,e){let r=await t.get(`/api/v1/invoices/${e}/credits`);return{data:Array.isArray(r)?r:r.data??[]}}async function H2(t,e,r){await t.delete(`/api/v1/invoices/${e}/credits/${r}`)}async function z2(t,e){return Ao(t,"/api/v1/invoices/bulk-upsert","invoices",e)}async function G2(t,e){return Ao(t,"/api/v1/invoices/line-items/bulk-upsert","invoices",dp(e))}var Cg=X(()=>{"use strict";t_();TA();En();cr()});async function HMe(t,e,r){return t.list(`/api/v1/${$l[e]}`,r)}async function ff(t,e,r){return t.get(`/api/v1/${$l[e]}/${r}`)}async function J2(t,e,r){return t.search(`/api/v1/${$l[e]}/search`,r)}async function V2(t,e,r){return t.search(`/api/v1/${$l[e]}/line-items/search`,r)}async function PR(t,e){return t.post("/api/v1/sale-quotes",{...e,saveAsDraft:e.saveAsDraft??!0})}async function MR(t,e){return t.post("/api/v1/sale-orders",e)}async function W2(t,e,r,n){return t.post(`/api/v1/${$l[e]}/${r}/convert-to-invoice`,n)}async function Z2(t,e,r,n){return t.put(`/api/v1/${$l[e]}/${r}`,n)}async function X2(t,e,r){await t.delete(`/api/v1/${$l[e]}/${r}`)}async function K2(t,e,r,n){return t.post(`/api/v1/${$l[e]}/${r}/void`,n?{internalNotes:n}:{})}async function eU(t,e){return t.post(`/api/v1/sale-quotes/${e}/accept`,{})}async function tU(t,e){return t.post(`/api/v1/sale-orders/${e}/confirm`,{})}async function zMe(t,e,r,n){return t.post(`/api/v1/${$l[e]}/${r}/fast-fix`,{attributes:n})}async function GMe(t,e,r,n){return t.post(`/api/v1/${$l[e]}/bulk-void`,{resourceIds:r,...n?{internalNotes:n}:{}})}async function JMe(t,e){return t.post("/api/v1/sale-quotes/bulk-accept",{resourceIds:e})}async function VMe(t,e){return t.post("/api/v1/sale-orders/bulk-confirm",{resourceIds:e})}async function WMe(t,e,r){return t.post(`/api/v1/${$l[e]}/bulk-delete`,{resourceIds:r})}async function ZMe(t,e){return t.post("/api/v1/sale-orders/line-items/bulk-upsert",{saleOrders:e})}var $l,UK=X(()=>{"use strict";$l={SALE_QUOTE:"sale-quotes",SALE_ORDER:"sale-orders"}});async function XMe(t,e,r){return t.list(`/api/v1/${ql[e]}`,r)}async function pf(t,e,r){return t.get(`/api/v1/${ql[e]}/${r}`)}async function rU(t,e,r){return t.search(`/api/v1/${ql[e]}/search`,r)}async function nU(t,e,r){return t.search(`/api/v1/${ql[e]}/line-items/search`,r)}async function UR(t,e){return t.post("/api/v1/purchase-requests",{...e,saveAsDraft:e.saveAsDraft??!0})}async function $R(t,e){return t.post("/api/v1/purchase-orders",{...e,saveAsDraft:e.saveAsDraft??!0})}async function iU(t,e,r,n){return t.post(`/api/v1/${ql[e]}/${r}/convert-to-bill`,n)}async function oU(t,e,r,n){return t.put(`/api/v1/${ql[e]}/${r}`,n)}async function sU(t,e,r){await t.delete(`/api/v1/${ql[e]}/${r}`)}async function aU(t,e,r,n){return t.post(`/api/v1/${ql[e]}/${r}/void`,n?{internalNotes:n}:{})}async function cU(t,e){return t.post(`/api/v1/purchase-requests/${e}/accept`,{})}async function lU(t,e){return t.post(`/api/v1/purchase-orders/${e}/confirm`,{})}async function KMe(t,e,r,n){return t.post(`/api/v1/${ql[e]}/${r}/fast-fix`,{attributes:n})}async function e2e(t,e,r,n){return t.post(`/api/v1/${ql[e]}/bulk-void`,{resourceIds:r,...n?{internalNotes:n}:{}})}async function t2e(t,e){return t.post("/api/v1/purchase-requests/bulk-accept",{resourceIds:e})}async function r2e(t,e){return t.post("/api/v1/purchase-orders/bulk-confirm",{resourceIds:e})}async function n2e(t,e,r){return t.post(`/api/v1/${ql[e]}/bulk-delete`,{resourceIds:r})}async function i2e(t,e){return t.post("/api/v1/purchase-orders/line-items/bulk-upsert",{purchaseOrders:e})}var ql,$K=X(()=>{"use strict";ql={PURCHASE_REQUEST:"purchase-requests",PURCHASE_ORDER:"purchase-orders"}});async function uU(t,e){return t.list("/api/v1/journals",e)}async function qR(t,e){return t.search("/api/v1/journals/search",e)}async function Ig(t,e){return t.post("/api/v1/journals",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function dU(t,e,r){return t.delete(`/api/v1/journals/${e}`,r)}async function jl(t,e){return t.get(`/api/v1/journals/${e}`)}async function YC(t,e,r){return t.put(`/api/v1/journals/${e}`,{...r,currency:Sr(r.currency),taxCurrency:Sr(r.taxCurrency)})}async function o2e(t,e,r){return t.put(`/api/v1/journals/${e}`,{...r,resourceId:e,saveAsDraft:!1})}async function jR(t,e){return t.post("/api/v1/scheduled/journals",e)}async function fU(t,e){return Ao(t,"/api/v1/journals/bulk-upsert","journals",e)}async function s2e(t,e){return us(e,"resourceId","Pass the journal resourceId."),t.get(`/api/v1/journals/${encodeURIComponent(e)}/download`)}var vg=X(()=>{"use strict";En();cr()});async function pU(t,e){return t.post("/api/v1/generate-reports/trial-balance",e)}async function hU(t,e){return t.post("/api/v1/generate-reports/balance-sheet",e)}async function mU(t,e){return t.post("/api/v1/generate-reports/profit-and-loss",e)}async function AU(t,e){return t.post("/api/v1/generate-reports/cashflow",e)}async function gU(t,e){return t.post("/api/v1/generate-reports/ar-summary-report",e)}async function yU(t,e){return t.post("/api/v1/generate-reports/ap-summary-report",e)}function HC(t,e){let{root:r,rows:n}=Dzt[e],i=t.data?.[r]??{},o=Array.isArray(i[n])?i[n]:[],s={current:0,lessThanOneMonth:0,oneMonth:0,twoMonths:0,threeMonths:0,older:0,total:0};for(let u of o)s.current+=u.currentIso??0,s.lessThanOneMonth+=u.lessThanOneMonthIso??0,s.oneMonth+=u.oneMonthIso??0,s.twoMonths+=u.twoMonthsIso??0,s.threeMonths+=u.threeMonthsIso??0,s.older+=u.olderIso??0,s.total+=u.balanceIso??0;let a=u=>Math.round(u*100)/100,c=i.startDate;return{reportType:e==="receivables"?"AGED_RECEIVABLES":"AGED_PAYABLES",organizationName:i.organizationName,asAt:typeof c=="number"?new Date(c).toISOString().slice(0,10):void 0,currencyCode:i.currencyCode,currencySymbol:i.currencySymbol,buckets:{current:a(s.current),lessThanOneMonth:a(s.lessThanOneMonth),oneMonth:a(s.oneMonth),twoMonths:a(s.twoMonths),threeMonths:a(s.threeMonths),older:a(s.older)},totalOutstanding:a(s.total),contactCount:o.length}}async function EU(t,e){return t.post("/api/v1/generate-reports/cash-balance",e)}async function bU(t,e){return t.post("/api/v1/generate-reports/general-ledger",e)}async function CU(t,e){return t.post("/api/v1/generate-reports/vat-ledger",e)}async function IU(t,e){return t.post("/api/v1/generate-reports/equity-movement",e)}async function vU(t,e){return t.post("/api/v1/generate-reports/bank-balance-summary",e)}async function wU(t,e){return t.post("/api/v1/generate-reports/bank-reconciliation-summary",e)}async function _U(t,e){return t.post("/api/v1/generate-reports/bank-reconciliation-details",e)}async function DU(t,e){return t.post("/api/v1/generate-reports/fixed-assets-summary",e)}async function SU(t,e){return t.post("/api/v1/generate-reports/fixed-assets-recon-summary",e)}async function RU(t,e){return t.post("/api/v1/generate-reports/ar-report",e)}async function TU(t){return t.get("/api/v1/ledger/highlights")}var Dzt,qK=X(()=>{"use strict";Dzt={receivables:{root:"generateAgedReceivablesReportGroupByContact",rows:"customerSummary"},payables:{root:"generateAgedPayablesReportGroupByContact",rows:"supplierSummary"}}});async function xU(t,e){return t.list("/api/v1/catalogs",e)}async function BU(t,e){return t.get(`/api/v1/catalogs/${encodeURIComponent(e)}`)}async function kU(t,e){return t.search("/api/v1/catalogs/search",e)}async function NU(t,e){return t.post("/api/v1/catalogs",e)}async function OU(t,e,r){return t.put(`/api/v1/catalogs/${encodeURIComponent(e)}`,r)}async function FU(t,e){await t.delete(`/api/v1/catalogs/${encodeURIComponent(e)}`)}var jK=X(()=>{"use strict"});async function QU(t,e){let r=await t.list("/api/v1/organization-report-template",e),{reportTemplates:n,...i}=r;return Array.isArray(n)&&n.length>0&&(!r.data||r.data.length===0)?{...i,data:n,totalElements:n.length,totalPages:1}:r}async function LU(t,e){return t.get(`/api/v1/organization-report-template/${encodeURIComponent(e)}`)}async function PU(t,e){return t.search("/api/v1/organization-report-template/search",e)}var YK=X(()=>{"use strict"});async function MU(t,e){return t.list("/api/v1/customer-credit-notes",e)}async function Ja(t,e){return t.get(`/api/v1/customer-credit-notes/${e}`)}async function YR(t,e){return t.search("/api/v1/customer-credit-notes/search",e)}async function HR(t,e){return t.post("/api/v1/customer-credit-notes",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function UU(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(mp)}:r,i=await Ic(n,()=>Ja(t,e));return t.put(`/api/v1/customer-credit-notes/${e}`,i)}async function zR(t,e,r){let n=await Ic({...r,resourceId:e,saveAsDraft:!1},()=>Ja(t,e));return t.put(`/api/v1/customer-credit-notes/${e}`,n)}async function $U(t,e,r){return t.delete(`/api/v1/customer-credit-notes/${e}`,r)}async function GR(t,e,r){return t.post(`/api/v1/customer-credit-notes/${e}/refunds`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function JR(t,e){return t.get(`/api/v1/customer-credit-notes/${e}/refunds`)}async function qU(t,e){return t.get(`/api/v1/customer-credit-notes/${e}/download`)}async function jU(t,e){return Ao(t,"/api/v1/customer-credit-notes/bulk-upsert","customerCreditNotes",dp(e))}var YU=X(()=>{"use strict";t_();TA();En();cr()});async function HU(t,e){return t.list("/api/v1/supplier-credit-notes",e)}async function Va(t,e){return t.get(`/api/v1/supplier-credit-notes/${e}`)}async function VR(t,e){return t.search("/api/v1/supplier-credit-notes/search",e)}async function WR(t,e){return t.post("/api/v1/supplier-credit-notes",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function zU(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(mp)}:r,i=await Ic(n,()=>Va(t,e));return t.put(`/api/v1/supplier-credit-notes/${e}`,i)}async function ZR(t,e,r){let n=await Ic({...r,resourceId:e,saveAsDraft:!1},()=>Va(t,e));return t.put(`/api/v1/supplier-credit-notes/${e}`,n)}async function GU(t,e,r){return t.delete(`/api/v1/supplier-credit-notes/${e}`,r)}async function JU(t,e){return t.get(`/api/v1/supplier-credit-notes/${e}/download`)}async function XR(t,e,r){return t.post(`/api/v1/supplier-credit-notes/${e}/refunds`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function KR(t,e){return t.get(`/api/v1/supplier-credit-notes/${e}/refunds`)}async function VU(t,e){return Ao(t,"/api/v1/supplier-credit-notes/bulk-upsert","supplierCreditNotes",dp(e))}var WU=X(()=>{"use strict";t_();TA();En();cr()});async function eT(t){return t.get("/api/v1/organization/currencies")}async function ZU(t,e){return t.post("/api/v1/organization/currencies",{currencies:e})}async function XU(t,e,r){return t.list(`/api/v1/organization/currencies/${e}/rates`,r)}function a2e(t){E6(t.rate,"rate");let e=y6(t.rateDirection);return{...t,rateDirection:e}}async function KU(t,e,r){return t.post(`/api/v1/organization/currencies/${e}/rates`,a2e(r))}async function e$(t,e,r,n){return t.put(`/api/v1/organization/currencies/${e}/rates/${r}`,a2e(n))}async function t$(t,e){return t.post("/api/v1/organization/currencies/rates/bulk-upsert",{rates:e})}var r$=X(()=>{"use strict";cr()});var c2e=b((HK,zK)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof zK=="object"&&typeof HK<"u"?zK.exports=e():t.Papa=e()})(HK,function t(){"use strict";var e=(function(){return typeof self<"u"?self:typeof window<"u"?window:typeof e<"u"?e:{}})();function r(){var D=e.URL||e.webkitURL||null,B=t.toString();return a.BLOB_URL||(a.BLOB_URL=D.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",B,")();"],{type:"text/javascript"})))}var n=!e.document&&!!e.postMessage,i=e.IS_PAPA_WORKER||!1,o={},s=0,a={};if(a.parse=u,a.unparse=d,a.RECORD_SEP="",a.UNIT_SEP="",a.BYTE_ORDER_MARK="\uFEFF",a.BAD_DELIMITERS=["\r",`
442
+ ... and ${a.toLocaleString()} more (use --format json for full output)`));break}}}function DS(t,e){switch(th(e)){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":{let n=Object.keys(t);console.log(n.map(h2).join(",")),console.log(n.map(i=>h2(yMe(t[i]))).join(","));break}case"yaml":console.log((0,BK.stringify)(t).trimEnd());break;case"table":console.log(AMe(t));break}}var BK,bo,Jt=X(()=>{"use strict";Ne();Pd();BK=sn(pMe(),1);_S();ln();gMe();bo=class extends Ki{constructor(e){super(e),this.name="CliValidationError"}}});var CMe={};To(CMe,{displaySlice:()=>kK,paginatedFetch:()=>st,paginatedJson:()=>NK});async function st(t,e,r){let n=r.defaultLimit??100;if(t.all&&t.offset!==void 0)throw new Error("--all and --offset cannot be used together");if(t.all){let d=(t.format?.toLowerCase()??(t.json?"json":"table"))==="table"?wQe(r.label):void 0,f=t.maxRows??bMe,p=await qp((y,C)=>e({limit:C,offset:y}),{pageSize:t.limit??200,maxItems:f,onProgress:d?(y,C)=>d.update(y,C):void 0});d?.clear();let{truncated:h}=p,{data:m}=p;m.length>f&&(m=m.slice(0,f),h=!0),h&&!Ul(t)&&console.error(xe(`Warning: dataset has ${p.totalElements.toLocaleString()} items \u2014 showing ${m.length.toLocaleString()} (max-rows: ${f.toLocaleString()})`));let A=t.limit??n,g=Math.ceil(p.totalElements/A);return{data:m,totalElements:p.totalElements,totalPages:g,truncated:h}}let i=t.limit??n,o=await e({limit:i,offset:t.offset??0}),s=o.data??[],a=(o.totalElements??0)>s.length;return{data:s,totalElements:o.totalElements??0,totalPages:o.totalPages??0,truncated:a}}function kK(t,e=Czt){return t.length<=e?{items:t,overflow:0}:{items:t.slice(0,e),overflow:t.length-e}}function NK(t,e){let{totalElements:r,totalPages:n,truncated:i,data:o,stats:s}=t,a=s?{stats:s}:{};if(i){let c=e.maxRows??bMe;return JSON.stringify({totalElements:r,totalPages:n,truncated:i,_meta:{fetchedRows:o.length,maxRows:c},...a,data:o},null,2)}return JSON.stringify({totalElements:r,totalPages:n,truncated:i,...a,data:o},null,2)}var bMe,Czt,ln=X(()=>{"use strict";Ne();iM();_Qe();Jt();bMe=1e3,Czt=500});async function Izt(){if(!OK){let[t,e,r,n]=await Promise.all([Promise.resolve().then(()=>(ct(),DMe)),Promise.resolve().then(()=>(ln(),CMe)),Promise.resolve().then(()=>(Jt(),EMe)),Promise.resolve().then(()=>(It(),Bwe))]);OK=t.apiAction,IMe=e.paginatedFetch,vMe=r.outputList,FK=n.parsePositiveInt,wMe=n.parseNonNegativeInt}}function je(t){let e=t.commandName??"search",r=t.positionalArg?` <${t.positionalArg}>`:"",n=t.parent.command(`${e}${r}`).description(`Search ${t.label.replace("Searching ","")}`);n.allowExcessArguments(!1);let i=new Map,o=NZ(t.fields);for(let[a,c,u,d]of o){let f=new Bt(a,c),p=t.fields[d];u&&p?.op!=="multi"&&f.choices(u),n.addOption(f);let h=vzt(a);h!==d&&i.set(h,d)}if(t.defaults.supportsQuery&&n.option("--query <expression>",'Jaz search expression (e.g. "status:unpaid AND $500+", "customer:acme AND date:-30d"). Merged with --filter; --filter fields win on conflict.'),n.option("--filter <json>","Raw API filter JSON (merged with flags; flags win on conflict)").addOption(new Bt("--sort <field>","Sort field name")).addOption(new Bt("--order <direction>","Sort direction").choices(["ASC","DESC"])).option("--format <type>","Output format: table, json, csv, yaml").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON"),t.defaults.supportsPagination!==!1&&n.option("--limit <n>",`Max results (default ${t.defaults.defaultLimit})`).option("--offset <n>","Page number offset (0-indexed)").option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)"),t.defaults.supportsView&&n.addOption(new Bt("--view <tier>","Payload tier: 'lean' = summary rows; 'full' (default) = complete records").choices(["lean","full"])),t.pathParam&&t.pathParam!==t.positionalArg){let a=t.pathParam.replace(/([A-Z])/g,"-$1").toLowerCase();n.requiredOption(`--${a} <id>`,t.pathParamDescription??`${t.pathParam} (required)`)}let s=async(...a)=>{let c=t.positionalArg?a[0]:void 0,u=t.positionalArg?a[1]:a[0];c&&t.positionalArg&&(u[t.positionalArg]=c),await Izt(),await OK(async d=>{t.preProcess&&await t.preProcess(d,u),typeof u.limit=="string"&&(u.limit=FK(u.limit)),typeof u.offset=="string"&&(u.offset=wMe(u.offset)),typeof u.maxRows=="string"&&(u.maxRows=FK(u.maxRows));let f={...u};for(let[v,T]of i)f[v]!==void 0&&(f[T]=f[v]);let p;if(typeof u.filter=="string")try{p=JSON.parse(u.filter)}catch{throw new Error(`Invalid --filter JSON: ${u.filter}`)}let h=t.baseFilter?p?{...t.baseFilter,...p}:t.baseFilter:p,m=MD(f,t.fields,h),A;if(c&&t.positionalFilter){let v=t.positionalFilter(c);A=m?{...v,...m}:v}else A=m;let g={sortBy:[u.sort??t.defaults.sortBy],order:u.order??t.defaults.sortOrder},y=t.defaults.supportsQuery?u.query:void 0,C=t.defaults.supportsView?u.view:void 0,E=t.pathParam?({limit:v,offset:T})=>t.fetcher(d,u[t.pathParam],{filter:A,sort:g,limit:v,offset:T,query:y,view:C}):({limit:v,offset:T})=>t.fetcher(d,{filter:A,sort:g,limit:v,offset:T,query:y,view:C}),I=await IMe(u,E,{label:t.label,defaultLimit:t.defaults.defaultLimit});vMe(I,t.columns,u,t.label.replace("Searching ",""))})(u)};return n.action(s),n}function vzt(t){return t.replace(/^--/,"").split(/[\s<]/)[0].replace(/-([a-z])/g,(r,n)=>n.toUpperCase())}var OK,IMe,vMe,FK,wMe,_Me=X(()=>{"use strict";Oo();OZ();nM()});var MC,UC,SS,RS,SMe=X(()=>{"use strict";la();MC={reference:{path:"reference",op:"contains",type:"string",description:"Invoice reference number"},status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:VFe},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact/customer name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (e.g., SGD, USD)"},approvalStatus:{path:"approvalStatus",op:"multi",type:"string",description:"Approval status",enum:eM},startDate:{path:"valueDate",op:"gte",type:"string",description:"On/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On/before (YYYY-MM-DD)",cliFlag:"--to <date>"},dueDateFrom:{path:"dueDate",op:"gte",type:"string",description:"Due date from (YYYY-MM-DD)"},dueDateTo:{path:"dueDate",op:"lte",type:"string",description:"Due date to (YYYY-MM-DD)"},minAmount:{path:"totalAmount",op:"gte",type:"number",description:"Minimum total amount"},maxAmount:{path:"totalAmount",op:"lte",type:"number",description:"Maximum total amount"}},UC={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0},SS=MC,RS=UC});var RMe,TS,xS,$C,BS,rh,nh,TMe=X(()=>{"use strict";la();RMe={reference:{path:"reference",op:"contains",type:"string",description:"Order reference number"},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact (customer/supplier) name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (e.g., SGD, USD)"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On/before (YYYY-MM-DD)",cliFlag:"--to <date>"},dueDateFrom:{path:"dueDate",op:"gte",type:"string",description:"Due date from (YYYY-MM-DD)"},dueDateTo:{path:"dueDate",op:"lte",type:"string",description:"Due date to (YYYY-MM-DD)"},minAmount:{path:"totalAmount",op:"gte",type:"number",description:"Minimum total amount"},maxAmount:{path:"totalAmount",op:"lte",type:"number",description:"Maximum total amount"}},TS={status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:d1e},...RMe},xS={status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:f1e},...RMe},$C={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0},BS=$C,rh={name:{path:"name",op:"contains",type:"string",description:"Line item text/description"},reference:{path:"reference",op:"contains",type:"string",description:"Parent order reference"},orderId:{path:"btResourceId",op:"eq",type:"string",description:"Parent order resourceId"},contactName:{path:"contactName",op:"contains",type:"string",description:"Contact (customer/supplier) name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (e.g., SGD, USD)"},status:{path:"status",op:"eq",type:"string",description:"Line item status"},account:{path:"organizationAccountName",op:"contains",type:"string",description:"Chart-of-account name on the line"},taxProfile:{path:"taxProfileName",op:"contains",type:"string",description:"Tax profile name on the line"},isOpen:{path:"isOpen",op:"boolean",type:"boolean",description:"Only open (unfulfilled) lines"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On/before (YYYY-MM-DD)",cliFlag:"--to <date>"},minAmount:{path:"totalItemAmount",op:"gte",type:"number",description:"Minimum line amount"},maxAmount:{path:"totalItemAmount",op:"lte",type:"number",description:"Maximum line amount"}},nh={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,supportsQuery:!0}});var ih,qC,kS,xMe=X(()=>{"use strict";la();ih={reference:{path:"reference",op:"contains",type:"string",description:"Credit note reference"},status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:WFe},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact name"},contactId:{path:"contactResourceId",op:"eq",type:"string",description:"Contact resourceId"},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code"},approvalStatus:{path:"approvalStatus",op:"multi",type:"string",description:"Approval status",enum:eM},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"}},qC={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0},kS=qC});var NS,OS,BMe=X(()=>{"use strict";la();NS={reference:{path:"reference",op:"contains",type:"string",description:"Journal reference"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:ZFe},type:{path:"type",op:"multi",type:"string",description:"Journal type",enum:XFe},templateType:{path:"templateType",op:"multi",type:"string",description:"Template type",enum:KFe},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact name"},internalNotes:{path:"internalNotes",op:"contains",type:"string",description:"Search internal notes"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"}},OS={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0}});var FS,QS,kMe=X(()=>{"use strict";la();FS={name:{path:"name",op:"contains",type:"string",description:"Contact name"},email:{path:"email",op:"contains",type:"string",description:"Email address"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:KP},isCustomer:{path:"customer",op:"boolean",type:"boolean",description:"Filter to customers only",cliFlag:"--customer"},isSupplier:{path:"supplier",op:"boolean",type:"boolean",description:"Filter to suppliers only",cliFlag:"--supplier"},taxId:{path:"taxId",op:"contains",type:"string",description:"Tax ID"}},QS={sortBy:"name",sortOrder:"ASC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0}});var uf,df,QK,LS,PS,NMe=X(()=>{"use strict";la();uf={type:{path:"businessTransactionType",op:"multi",type:"string",description:"Transaction type",enum:tM},direction:{path:"direction",op:"eq",type:"string",description:"Direction (PAYIN or PAYOUT)",enum:xZ},status:{path:"businessTransactionStatus",op:"multi",type:"string",description:"Status",enum:o1e},reference:{path:"businessTransactionReference",op:"contains",type:"string",description:"Reference",cliFlag:"--ref <reference>"},accountId:{path:"organizationAccountResourceId",op:"eq",type:"string",description:"Bank account resourceId",cliFlag:"--account <id>"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"},businessTransactionType:{path:"businessTransactionType",op:"multi",type:"string",description:"(alias for type)"}},df={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,supportsQuery:!0},QK={magicSort:{type:"object",description:"Rank by match quality to a bank entry: {bankStatementEntryResourceId, magicSort:true}."},transactionType:{type:"string",enum:[...i1e],description:"Scope. Default ALL_CASHFLOWS."}},LS={type:{path:"businessTransactionType",op:"multi",type:"string",description:"Transaction type (SALE, PURCHASE, etc.)",enum:tM},direction:{path:"direction",op:"eq",type:"string",description:"Direction",enum:xZ},reference:{path:"businessTransactionReference",op:"contains",type:"string",description:"Reference",cliFlag:"--ref <reference>"},accountId:{path:"organizationAccountResourceId",op:"eq",type:"string",description:"Account resourceId",cliFlag:"--account <id>"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"},businessTransactionType:{path:"businessTransactionType",op:"multi",type:"string",description:"(alias for type)",enum:tM},fromDate:{path:"valueDate",op:"gte",type:"string",description:"(alias for startDate)"},toDate:{path:"valueDate",op:"lte",type:"string",description:"(alias for endDate)"},accountResourceId:{path:"organizationAccountResourceId",op:"eq",type:"string",description:"(alias for accountId)"}},PS={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20}});var MS,US,OMe=X(()=>{"use strict";la();MS={status:{path:"status",op:"multi",type:"string",description:"Status",enum:n1e},description:{path:"description",op:"contains",type:"string",description:"Description"},payer:{path:"extContactName",op:"contains",type:"string",description:"Payer/payee name"},reference:{path:"extReference",op:"contains",type:"string",description:"Bank reference",cliFlag:"--ref <reference>"},startDate:{path:"valueDate",op:"gte",type:"string",description:"On or after this date (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"On or before this date (YYYY-MM-DD)",cliFlag:"--to <date>"},minAmount:{path:"netAmount",op:"gte",type:"number",description:"Minimum net amount"},maxAmount:{path:"netAmount",op:"lte",type:"number",description:"Maximum net amount"}},US={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20,supportsQuery:!0}});var $S,qS,FMe=X(()=>{"use strict";la();$S={status:{path:"status",op:"multi",type:"string",description:"Status",enum:e1e},itemCategory:{path:"itemCategory",op:"eq",type:"string",description:"Category",enum:r1e},appliesToSale:{path:"appliesToSale",op:"boolean",type:"boolean",description:"Filter to sale items only",cliFlag:"--sale"},appliesToPurchase:{path:"appliesToPurchase",op:"boolean",type:"boolean",description:"Filter to purchase items only",cliFlag:"--purchase"}},qS={sortBy:"internalName",sortOrder:"ASC",defaultLimit:20,leanDefaultLimit:50,supportsQuery:!0,supportsView:!0}});var jS,YS,QMe=X(()=>{"use strict";la();jS={name:{path:"name",op:"contains",type:"string",description:"Asset name"},reference:{path:"reference",op:"contains",type:"string",description:"Reference",cliFlag:"--ref <reference>"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:s1e},category:{path:"category",op:"eq",type:"string",description:"Category",enum:a1e},tag:{path:"tags",op:"eq",type:"string",description:"Tag name",cliFlag:"--tag <name>"},typeName:{path:"typeName",op:"contains",type:"string",description:"Asset type name"},startDate:{path:"purchaseDate",op:"gte",type:"string",description:"Purchase date from (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"purchaseDate",op:"lte",type:"string",description:"Purchase date to (YYYY-MM-DD)",cliFlag:"--to <date>"},minAmount:{path:"purchaseAmount",op:"gte",type:"number",description:"Minimum purchase amount"},maxAmount:{path:"purchaseAmount",op:"lte",type:"number",description:"Maximum purchase amount"}},YS={sortBy:"name",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0}});var HS,zS,LMe=X(()=>{"use strict";la();HS={type:{path:"businessTransactionType",op:"eq",type:"string",description:"Transaction type (SALE, PURCHASE, JOURNAL_MANUAL)"},status:{path:"status",op:"multi",type:"string",description:"Scheduler status",enum:c1e},subscriptionStatus:{path:"subscriptionStatus",op:"multi",type:"string",description:"Subscription status",enum:l1e},schedulerType:{path:"schedulerType",op:"eq",type:"string",description:"Scheduler type"},interval:{path:"interval",op:"eq",type:"string",description:"Interval",enum:u1e},contactName:{path:"contact.name",op:"contains",type:"string",description:"Contact name"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code"}},zS={sortBy:"nextScheduleDate",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0}});var GS,JS,PMe=X(()=>{"use strict";la();GS={id:{path:"resourceId",op:"eq",type:"string",description:"Job ID (the jobId returned from bulk operations)",cliFlag:"--id"},status:{path:"status",op:"multi",type:"string",description:"Job status",enum:g1e},type:{path:"jobType",op:"eq",type:"string",description:"Job type (e.g. UPSERT_CONTACTS, UPSERT_ITEMS, PROCESS_BANK_STATEMENT_FILES)",cliFlag:"--type"},fileName:{path:"fileName",op:"contains",type:"string",description:"File name (file-based jobs only)",cliFlag:"--file-name"},from:{path:"createdAt",op:"gte",type:"string",description:"On/after (ISO date)",cliFlag:"--from"},to:{path:"createdAt",op:"lte",type:"string",description:"On/before (ISO date)",cliFlag:"--to"}},JS={sortBy:"createdAt",sortOrder:"DESC",defaultLimit:20}});var VS,WS,MMe=X(()=>{"use strict";VS={name:{path:"name",op:"plain",type:"string",description:"Purchase item name"},reference:{path:"reference",op:"plain",type:"string",description:"Reference name"},currencyCode:{path:"currencyCode",op:"plain",type:"string",description:"Currency code (ISO 4217)"}},WS={sortBy:"name",sortOrder:"ASC",defaultLimit:20}});var ZS,XS,KS,eR,UMe=X(()=>{"use strict";ZS={catalogName:{path:"catalogName",op:"contains",type:"string",description:"Catalog name"},description:{path:"description",op:"contains",type:"string",description:"Catalog item description"},status:{path:"status",op:"multi",type:"string",description:"Record status (e.g. ACTIVE, INACTIVE)"},contactGroupResourceId:{path:"contactGroupResourceId",op:"eq",type:"string",description:"Contact group resourceId"}},XS={sortBy:"catalogName",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0},KS={reportType:{path:"reportType",op:"plain",type:"string",description:"Report type"},reportCategory:{path:"reportCategory",op:"eq",type:"string",description:"Report category. Known defect: 500s unless reportType is also supplied."},isDefault:{path:"isDefault",op:"boolean",type:"boolean",description:"Only default templates. Known defect: 500s upstream today.",cliFlag:"--default"}},eR={sortBy:"reportType",sortOrder:"ASC",defaultLimit:20,supportsPagination:!1}});async function m2(t,e){return t.search("/api/v1/claims/search",e)}async function A2(t,e){return t.get(`/api/v1/claims/${e}`)}async function g2(t,e){return t.post("/api/v1/claims",e)}async function y2(t,e,r){return t.put(`/api/v1/claims/${e}`,r)}async function E2(t,e){return t.delete(`/api/v1/claims/${e}`)}async function b2(t,e,r){return t.delete(`/api/v1/claims/${e}/attachments/${r}`)}async function C2(t,e){return t.post(`/api/v1/claims/${e}/submit`,{})}async function I2(t,e){return t.post(`/api/v1/claims/${e}/approve`,{})}async function v2(t,e,r){return t.post(`/api/v1/claims/${e}/reject`,{rejectionReason:r})}async function w2(t,e,r){return t.post(`/api/v1/claims/${e}/cancel`,{cancellationReason:r})}async function _2(t,e){return t.post(`/api/v1/claims/${e}/unpost`,{})}function tR(t){Qt(t,"resourceIds",500,"claims")}async function D2(t,e){return tR(e),t.post("/api/v1/claims/bulk/submit",{resourceIds:e})}async function S2(t,e){return tR(e),t.post("/api/v1/claims/bulk/approve",{resourceIds:e})}async function R2(t,e){return tR(e),t.post("/api/v1/claims/bulk/delete",{resourceIds:e})}async function T2(t,e,r){return tR(e),t.post("/api/v1/claims/bulk/reject",{resourceIds:e,rejectionReason:r})}async function x2(t,e,r){return tR(e),t.post("/api/v1/claims/bulk/cancel",{resourceIds:e,cancellationReason:r})}async function B2(t){let e=await t.get("/api/v1/claims/tracking-tags");return Array.isArray(e)?e:e?.data??[]}async function k2(t){let e=await t.get("/api/v1/claims/custom-field-values");return Array.isArray(e)?e:e?.data??[]}var $Me,N2=X(()=>{"use strict";En();$Me=["DRAFT","SUBMITTED","APPROVED","CONVERTED","REJECTED","CANCELLED"]});var rR,nR,wzt,_zt,iR,oR,sR,aR,cR,lR,uR,dR,qMe=X(()=>{"use strict";g_();b_();N2();rR={status:{path:"status",op:"multi",type:"string",description:"Status (comma-separated for OR)",enum:$Me},employeeResourceId:{path:"employeeResourceId",op:"eq",type:"string",description:"Employee resourceId"},contactResourceId:{path:"contactResourceId",op:"eq",type:"string",description:"Vendor contact resourceId"},claimProfileResourceId:{path:"claimProfileResourceId",op:"eq",type:"string",description:"Claim profile resourceId"},approverUserResourceId:{path:"approverUserResourceId",op:"eq",type:"string",description:"Approver user resourceId"},reference:{path:"reference",op:"contains",type:"string",description:"Claim reference"},currencyCode:{path:"currencyCode",op:"eq",type:"string",description:"Currency code (ISO 4217)"},startDate:{path:"valueDate",op:"gte",type:"string",description:"Value date on/after (YYYY-MM-DD)",cliFlag:"--from <date>"},endDate:{path:"valueDate",op:"lte",type:"string",description:"Value date on/before (YYYY-MM-DD)",cliFlag:"--to <date>"},createdFrom:{path:"createdAt",op:"gte",type:"string",description:"Created on/after (YYYY-MM-DD)"},createdTo:{path:"createdAt",op:"lte",type:"string",description:"Created on/before (YYYY-MM-DD)"},minAmount:{path:"totalAmount",op:"gte",type:"number",description:"Minimum total amount"},maxAmount:{path:"totalAmount",op:"lte",type:"number",description:"Maximum total amount"}},nR={sortBy:"createdAt",sortOrder:"DESC",defaultLimit:20},wzt=["RECORDED","COMPLETED","CANCELLED","IN_PROGRESS","ACTION_NEEDED"],_zt=["DIRECT_ENTRY","DISBURSEMENT","REIMBURSEMENT_PAYOUT","ADVANCE"],iR={employeeResourceId:{path:"employeeResourceId",op:"eq",type:"string",description:"Employee resourceId"},employeeName:{path:"employeeName",op:"contains",type:"string",description:"Employee name"},reference:{path:"reference",op:"contains",type:"string",description:"Payout reference"},payoutStatus:{path:"payoutStatus",op:"multi",type:"string",description:"Payout status (comma-separated)",enum:wzt},payoutType:{path:"payoutType",op:"multi",type:"string",description:"Payout type (comma-separated): DIRECT_ENTRY (books-only DCE), DISBURSEMENT (gateway direct-debit-backed), REIMBURSEMENT_PAYOUT, ADVANCE",enum:_zt}},oR={sortBy:"valueDate",sortOrder:"DESC",defaultLimit:20},sR={name:{path:"name",op:"contains",type:"string",description:"Claim type name"},expenseAccountResourceId:{path:"expenseAccountResourceId",op:"eq",type:"string",description:"Default expense account resourceId"},taxProfileResourceId:{path:"taxProfileResourceId",op:"eq",type:"string",description:"Default tax profile resourceId"}},aR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},cR={name:{path:"name",op:"contains",type:"string",description:"Claim profile name"},approverUserResourceId:{path:"approverUserResourceId",op:"eq",type:"string",description:"Default approver user resourceId"},minClaimAmount:{path:"minClaimAmount",op:"gte",type:"number",description:"Minimum claim total (>=)"},maxClaimAmount:{path:"maxClaimAmount",op:"lte",type:"number",description:"Maximum claim total (<=)"},maxPerPeriodAmount:{path:"maxPerPeriodAmount",op:"lte",type:"number",description:"Per-period spend cap (<=)"},perPeriod:{path:"perPeriod",op:"eq",type:"string",description:"Per-period window",enum:m_},employeeBalanceAccountResourceId:{path:"employeeBalanceAccountResourceId",op:"eq",type:"string",description:"Employee balance (liability) account resourceId"}},lR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},uR={name:{path:"name",op:"contains",type:"string",description:"Posting rule name"},outerAxis:{path:"outerAxis",op:"eq",type:"string",description:"Outer grouping axis",enum:y_},innerAxis:{path:"innerAxis",op:"eq",type:"string",description:"Inner line-aggregation axis",enum:E_},defaultBankAccountResourceId:{path:"defaultBankAccountResourceId",op:"eq",type:"string",description:"Default reimbursement bank account resourceId"},defaultIncludeReimbursementPayout:{path:"defaultIncludeReimbursementPayout",op:"boolean",type:"boolean",description:"Creates reimbursement DCE by default"},isDefault:{path:"isDefault",op:"boolean",type:"boolean",description:"Org default rule"}},dR={sortBy:"name",sortOrder:"ASC",defaultLimit:100}});var fR,pR,hR,mR,jMe=X(()=>{"use strict";C_();fR={name:{path:"name",op:"contains",type:"string",description:"Employee name"},email:{path:"email",op:"contains",type:"string",description:"Work email"},phone:{path:"phone",op:"contains",type:"string",description:"Phone"},userResourceId:{path:"userResourceId",op:"eq",type:"string",description:"Bound login user resourceId"},managerEmployeeResourceId:{path:"managerEmployeeResourceId",op:"eq",type:"string",description:"Manager employee resourceId"},claimProfileResourceId:{path:"claimProfileResourceId",op:"eq",type:"string",description:"Claim profile resourceId"},currency:{path:"currency",op:"eq",type:"string",description:"Balance currency (ISO 4217)"},active:{path:"active",op:"boolean",type:"boolean",description:"Active employees only"},createdFrom:{path:"createdAt",op:"gte",type:"string",description:"Created on/after (YYYY-MM-DD)"},createdTo:{path:"createdAt",op:"lte",type:"string",description:"Created on/before (YYYY-MM-DD)"}},pR={sortBy:"name",sortOrder:"ASC",defaultLimit:50},hR={name:{path:"name",op:"contains",type:"string",description:"Employee name"},email:{path:"email",op:"contains",type:"string",description:"Work email"},phone:{path:"phone",op:"contains",type:"string",description:"Phone"},currency:{path:"currency",op:"eq",type:"string",description:"Balance currency (ISO 4217)"},employmentType:{path:"employmentType",op:"eq",type:"string",description:"Employment type",enum:kA},active:{path:"active",op:"boolean",type:"boolean",description:"Active employees only"}},mR={sortBy:"name",sortOrder:"ASC",defaultLimit:50}});var AR,gR,yR,ER,bR,CR,IR,vR,wR,_R,DR,SR,RR,TR,LK,xR,BR,kR,NR,YMe=X(()=>{"use strict";la();AR={name:{path:"name",op:"contains",type:"string",description:"Account name"},code:{path:"code",op:"contains",type:"string",description:"Account code"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:t1e},accountClass:{path:"accountClass",op:"eq",type:"string",description:"Account class",enum:p1e},accountType:{path:"accountType",op:"eq",type:"string",description:"Account type",enum:rM},controlFlag:{path:"controlFlag",op:"boolean",type:"boolean",description:"Control flag (system accounts)"}},gR={sortBy:"code",sortOrder:"ASC",defaultLimit:100,supportsQuery:!1},yR={query:{path:"tagName",op:"contains",type:"string",description:"Tag name"}},ER={sortBy:"tagName",sortOrder:"ASC",defaultLimit:100},bR={name:{path:"name",op:"contains",type:"string",description:"Tax profile name",cliFlag:"--name <name>"},taxTypeCode:{path:"taxTypeCode",op:"contains",type:"string",description:"Tax type code"},appliesToSale:{path:"appliesToSale",op:"boolean",type:"boolean",description:"Filter to sale profiles"},appliesToPurchase:{path:"appliesToPurchase",op:"boolean",type:"boolean",description:"Filter to purchase profiles"},appliesToSaleCreditNote:{path:"appliesToSaleCreditNote",op:"boolean",type:"boolean",description:"Filter to sale CN profiles"},appliesToPurchaseCreditNote:{path:"appliesToPurchaseCreditNote",op:"boolean",type:"boolean",description:"Filter to purchase CN profiles"}},CR={sortBy:"name",sortOrder:"ASC",defaultLimit:100,supportsQuery:!0},IR={title:{path:"title",op:"contains",type:"string",description:"Capsule title"},status:{path:"status",op:"multi",type:"string",description:"Status",enum:A1e}},vR={sortBy:"title",sortOrder:"ASC",defaultLimit:20,supportsQuery:!0},wR={query:{path:"customFieldName",op:"contains",type:"string",description:"Custom field name",cliFlag:"--name <name>"},datatypeCode:{path:"datatypeCode",op:"eq",type:"string",description:"Data type",enum:h1e,cliFlag:"--type <type>"},customFieldName:{path:"customFieldName",op:"contains",type:"string",description:"(alias for query)"}},_R={sortBy:"customFieldName",sortOrder:"ASC",defaultLimit:100},DR={query:{path:"name",op:"contains",type:"string",description:"Group name"}},SR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},RR={firstName:{path:"user.firstName",op:"contains",type:"string",description:"User first name"},lastName:{path:"user.lastName",op:"contains",type:"string",description:"User last name"},email:{path:"user.email",op:"contains",type:"string",description:"Email"},userType:{path:"userType",op:"eq",type:"string",description:"Access tier",enum:m1e},status:{path:"status",op:"multi",type:"string",description:"Status",enum:KP}},TR={sortBy:"user.FirstName",sortOrder:"ASC",defaultLimit:50},LK=t=>({or:{user:{firstName:{contains:t}},or:{user:{lastName:{contains:t}}}}}),xR={query:{path:"name",op:"contains",type:"string",description:"Rule name"},account:{path:"appliesToReconciliationAccount",op:"eq",type:"string",description:"Bank account resourceId",cliFlag:"--account <id>"}},BR={sortBy:"name",sortOrder:"ASC",defaultLimit:100},kR={query:{path:"type",op:"contains",type:"string",description:"Classifier type"}},NR={sortBy:"type",sortOrder:"ASC",defaultLimit:100}});var lr=X(()=>{"use strict";la();nM();OZ();_Me();SMe();TMe();xMe();BMe();kMe();NMe();OMe();FMe();QMe();LMe();PMe();MMe();UMe();qMe();jMe();YMe()});async function O2(t,e){return t.list("/api/v1/modules",e)}async function F2(t,e){return t.get(`/api/v1/modules/${encodeURIComponent(e)}`)}var PK=X(()=>{"use strict"});async function Q2(t,e){return t.list("/api/v1/purchase-items",e)}async function L2(t,e){return t.get(`/api/v1/purchase-items/${encodeURIComponent(e)}`)}async function P2(t,e){return t.search("/api/v1/purchase-items/search",e)}var MK=X(()=>{"use strict"});async function M2(t,e){return t.list("/api/v1/invoices",e)}async function $o(t,e){let r=await t.get(`/api/v1/invoices/${e}`);return"data"in r&&typeof r.data=="object"?r:{data:r}}async function jC(t,e){return t.search("/api/v1/invoices/search",e)}async function bg(t,e){return t.post("/api/v1/invoices",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function U2(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(mp)}:r,i=await Ic(n,()=>$o(t,e));return t.put(`/api/v1/invoices/${e}`,i)}async function $2(t,e,r){return t.delete(`/api/v1/invoices/${e}`,r)}async function OR(t,e,r){return t.post(`/api/v1/invoices/${e}/payments`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function FR(t,e){return t.post("/api/v1/scheduled/invoices",{...e,invoice:{...e.invoice,currency:Sr(e.invoice?.currency)}})}async function q2(t,e,r){return t.post(`/api/v1/invoices/${e}/credits`,{credits:r})}async function QR(t,e,r){let n=await Ic({...r,resourceId:e,saveAsDraft:!1},()=>$o(t,e));return t.put(`/api/v1/invoices/${e}`,n)}async function j2(t,e){return t.get(`/api/v1/invoices/${e}/download`)}async function LR(t,e){let r=await t.get(`/api/v1/invoices/${e}/payments`);return{data:Array.isArray(r)?r:r.data??[]}}async function Y2(t,e){let r=await t.get(`/api/v1/invoices/${e}/credits`);return{data:Array.isArray(r)?r:r.data??[]}}async function H2(t,e,r){await t.delete(`/api/v1/invoices/${e}/credits/${r}`)}async function z2(t,e){return Ao(t,"/api/v1/invoices/bulk-upsert","invoices",e)}async function G2(t,e){return Ao(t,"/api/v1/invoices/line-items/bulk-upsert","invoices",dp(e))}var Cg=X(()=>{"use strict";t_();TA();En();cr()});async function HMe(t,e,r){return t.list(`/api/v1/${$l[e]}`,r)}async function ff(t,e,r){return t.get(`/api/v1/${$l[e]}/${r}`)}async function J2(t,e,r){return t.search(`/api/v1/${$l[e]}/search`,r)}async function V2(t,e,r){return t.search(`/api/v1/${$l[e]}/line-items/search`,r)}async function PR(t,e){return t.post("/api/v1/sale-quotes",{...e,saveAsDraft:e.saveAsDraft??!0})}async function MR(t,e){return t.post("/api/v1/sale-orders",e)}async function W2(t,e,r,n){return t.post(`/api/v1/${$l[e]}/${r}/convert-to-invoice`,n)}async function Z2(t,e,r,n){return t.put(`/api/v1/${$l[e]}/${r}`,n)}async function X2(t,e,r){await t.delete(`/api/v1/${$l[e]}/${r}`)}async function K2(t,e,r,n){return t.post(`/api/v1/${$l[e]}/${r}/void`,n?{internalNotes:n}:{})}async function eU(t,e){return t.post(`/api/v1/sale-quotes/${e}/accept`,{})}async function tU(t,e){return t.post(`/api/v1/sale-orders/${e}/confirm`,{})}async function zMe(t,e,r,n){return t.post(`/api/v1/${$l[e]}/${r}/fast-fix`,{attributes:n})}async function GMe(t,e,r,n){return t.post(`/api/v1/${$l[e]}/bulk-void`,{resourceIds:r,...n?{internalNotes:n}:{}})}async function JMe(t,e){return t.post("/api/v1/sale-quotes/bulk-accept",{resourceIds:e})}async function VMe(t,e){return t.post("/api/v1/sale-orders/bulk-confirm",{resourceIds:e})}async function WMe(t,e,r){return t.post(`/api/v1/${$l[e]}/bulk-delete`,{resourceIds:r})}async function ZMe(t,e){return t.post("/api/v1/sale-orders/line-items/bulk-upsert",{saleOrders:e})}var $l,UK=X(()=>{"use strict";$l={SALE_QUOTE:"sale-quotes",SALE_ORDER:"sale-orders"}});async function XMe(t,e,r){return t.list(`/api/v1/${ql[e]}`,r)}async function pf(t,e,r){return t.get(`/api/v1/${ql[e]}/${r}`)}async function rU(t,e,r){return t.search(`/api/v1/${ql[e]}/search`,r)}async function nU(t,e,r){return t.search(`/api/v1/${ql[e]}/line-items/search`,r)}async function UR(t,e){return t.post("/api/v1/purchase-requests",{...e,saveAsDraft:e.saveAsDraft??!0})}async function $R(t,e){return t.post("/api/v1/purchase-orders",{...e,saveAsDraft:e.saveAsDraft??!0})}async function iU(t,e,r,n){return t.post(`/api/v1/${ql[e]}/${r}/convert-to-bill`,n)}async function oU(t,e,r,n){return t.put(`/api/v1/${ql[e]}/${r}`,n)}async function sU(t,e,r){await t.delete(`/api/v1/${ql[e]}/${r}`)}async function aU(t,e,r,n){return t.post(`/api/v1/${ql[e]}/${r}/void`,n?{internalNotes:n}:{})}async function cU(t,e){return t.post(`/api/v1/purchase-requests/${e}/accept`,{})}async function lU(t,e){return t.post(`/api/v1/purchase-orders/${e}/confirm`,{})}async function KMe(t,e,r,n){return t.post(`/api/v1/${ql[e]}/${r}/fast-fix`,{attributes:n})}async function e2e(t,e,r,n){return t.post(`/api/v1/${ql[e]}/bulk-void`,{resourceIds:r,...n?{internalNotes:n}:{}})}async function t2e(t,e){return t.post("/api/v1/purchase-requests/bulk-accept",{resourceIds:e})}async function r2e(t,e){return t.post("/api/v1/purchase-orders/bulk-confirm",{resourceIds:e})}async function n2e(t,e,r){return t.post(`/api/v1/${ql[e]}/bulk-delete`,{resourceIds:r})}async function i2e(t,e){return t.post("/api/v1/purchase-orders/line-items/bulk-upsert",{purchaseOrders:e})}var ql,$K=X(()=>{"use strict";ql={PURCHASE_REQUEST:"purchase-requests",PURCHASE_ORDER:"purchase-orders"}});async function uU(t,e){return t.list("/api/v1/journals",e)}async function qR(t,e){return t.search("/api/v1/journals/search",e)}async function Ig(t,e){return t.post("/api/v1/journals",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function dU(t,e,r){return t.delete(`/api/v1/journals/${e}`,r)}async function jl(t,e){return t.get(`/api/v1/journals/${e}`)}async function YC(t,e,r){return t.put(`/api/v1/journals/${e}`,{...r,currency:Sr(r.currency),taxCurrency:Sr(r.taxCurrency)})}async function o2e(t,e,r){return t.put(`/api/v1/journals/${e}`,{...r,resourceId:e,saveAsDraft:!1})}async function jR(t,e){return t.post("/api/v1/scheduled/journals",e)}async function fU(t,e){return Ao(t,"/api/v1/journals/bulk-upsert","journals",e)}async function s2e(t,e){return us(e,"resourceId","Pass the journal resourceId."),t.get(`/api/v1/journals/${encodeURIComponent(e)}/download`)}var vg=X(()=>{"use strict";En();cr()});async function pU(t,e){return t.post("/api/v1/generate-reports/trial-balance",e)}async function hU(t,e){return t.post("/api/v1/generate-reports/balance-sheet",e)}async function mU(t,e){return t.post("/api/v1/generate-reports/profit-and-loss",e)}async function AU(t,e){return t.post("/api/v1/generate-reports/cashflow",e)}async function gU(t,e){return t.post("/api/v1/generate-reports/ar-summary-report",e)}async function yU(t,e){return t.post("/api/v1/generate-reports/ap-summary-report",e)}function HC(t,e){let{root:r,rows:n}=Dzt[e],i=t.data?.[r]??{},o=Array.isArray(i[n])?i[n]:[],s={current:0,lessThanOneMonth:0,oneMonth:0,twoMonths:0,threeMonths:0,older:0,total:0};for(let u of o)s.current+=u.currentIso??0,s.lessThanOneMonth+=u.lessThanOneMonthIso??0,s.oneMonth+=u.oneMonthIso??0,s.twoMonths+=u.twoMonthsIso??0,s.threeMonths+=u.threeMonthsIso??0,s.older+=u.olderIso??0,s.total+=u.balanceIso??0;let a=u=>Math.round(u*100)/100,c=i.startDate;return{reportType:e==="receivables"?"AGED_RECEIVABLES":"AGED_PAYABLES",organizationName:i.organizationName,asAt:typeof c=="number"?new Date(c).toISOString().slice(0,10):void 0,currencyCode:i.currencyCode,currencySymbol:i.currencySymbol,buckets:{current:a(s.current),lessThanOneMonth:a(s.lessThanOneMonth),oneMonth:a(s.oneMonth),twoMonths:a(s.twoMonths),threeMonths:a(s.threeMonths),older:a(s.older)},totalOutstanding:a(s.total),contactCount:o.length}}async function EU(t,e){return t.post("/api/v1/generate-reports/cash-balance",e)}async function bU(t,e){return t.post("/api/v1/generate-reports/general-ledger",e)}async function CU(t,e){return t.post("/api/v1/generate-reports/vat-ledger",e)}async function IU(t,e){return t.post("/api/v1/generate-reports/equity-movement",e)}async function vU(t,e){return t.post("/api/v1/generate-reports/bank-balance-summary",e)}async function wU(t,e){return t.post("/api/v1/generate-reports/bank-reconciliation-summary",e)}async function _U(t,e){return t.post("/api/v1/generate-reports/bank-reconciliation-details",e)}async function DU(t,e){return t.post("/api/v1/generate-reports/fixed-assets-summary",e)}async function SU(t,e){return t.post("/api/v1/generate-reports/fixed-assets-recon-summary",e)}async function RU(t,e){return t.post("/api/v1/generate-reports/ar-report",e)}async function TU(t){return t.get("/api/v1/ledger/highlights")}var Dzt,qK=X(()=>{"use strict";Dzt={receivables:{root:"generateAgedReceivablesReportGroupByContact",rows:"customerSummary"},payables:{root:"generateAgedPayablesReportGroupByContact",rows:"supplierSummary"}}});async function xU(t,e){return t.list("/api/v1/catalogs",e)}async function BU(t,e){return t.get(`/api/v1/catalogs/${encodeURIComponent(e)}`)}async function kU(t,e){return t.search("/api/v1/catalogs/search",e)}async function NU(t,e){return t.post("/api/v1/catalogs",e)}async function OU(t,e,r){return t.put(`/api/v1/catalogs/${encodeURIComponent(e)}`,r)}async function FU(t,e){await t.delete(`/api/v1/catalogs/${encodeURIComponent(e)}`)}var jK=X(()=>{"use strict"});async function QU(t,e){let r=await t.list("/api/v1/organization-report-template",e),{reportTemplates:n,...i}=r;return Array.isArray(n)&&n.length>0&&(!r.data||r.data.length===0)?{...i,data:n,totalElements:n.length,totalPages:1}:r}async function LU(t,e){return t.get(`/api/v1/organization-report-template/${encodeURIComponent(e)}`)}async function PU(t,e){return t.search("/api/v1/organization-report-template/search",e)}var YK=X(()=>{"use strict"});async function MU(t,e){return t.list("/api/v1/customer-credit-notes",e)}async function Ja(t,e){return t.get(`/api/v1/customer-credit-notes/${e}`)}async function YR(t,e){return t.search("/api/v1/customer-credit-notes/search",e)}async function HR(t,e){return t.post("/api/v1/customer-credit-notes",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function UU(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(mp)}:r,i=await Ic(n,()=>Ja(t,e));return t.put(`/api/v1/customer-credit-notes/${e}`,i)}async function zR(t,e,r){let n=await Ic({...r,resourceId:e,saveAsDraft:!1},()=>Ja(t,e));return t.put(`/api/v1/customer-credit-notes/${e}`,n)}async function $U(t,e,r){return t.delete(`/api/v1/customer-credit-notes/${e}`,r)}async function GR(t,e,r){return t.post(`/api/v1/customer-credit-notes/${e}/refunds`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function JR(t,e){return t.get(`/api/v1/customer-credit-notes/${e}/refunds`)}async function qU(t,e){return t.get(`/api/v1/customer-credit-notes/${e}/download`)}async function jU(t,e){return Ao(t,"/api/v1/customer-credit-notes/bulk-upsert","customerCreditNotes",dp(e))}var YU=X(()=>{"use strict";t_();TA();En();cr()});async function HU(t,e){return t.list("/api/v1/supplier-credit-notes",e)}async function Va(t,e){return t.get(`/api/v1/supplier-credit-notes/${e}`)}async function VR(t,e){return t.search("/api/v1/supplier-credit-notes/search",e)}async function WR(t,e){return t.post("/api/v1/supplier-credit-notes",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function zU(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(mp)}:r,i=await Ic(n,()=>Va(t,e));return t.put(`/api/v1/supplier-credit-notes/${e}`,i)}async function ZR(t,e,r){let n=await Ic({...r,resourceId:e,saveAsDraft:!1},()=>Va(t,e));return t.put(`/api/v1/supplier-credit-notes/${e}`,n)}async function GU(t,e,r){return t.delete(`/api/v1/supplier-credit-notes/${e}`,r)}async function JU(t,e){return t.get(`/api/v1/supplier-credit-notes/${e}/download`)}async function XR(t,e,r){return t.post(`/api/v1/supplier-credit-notes/${e}/refunds`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function KR(t,e){return t.get(`/api/v1/supplier-credit-notes/${e}/refunds`)}async function VU(t,e){return Ao(t,"/api/v1/supplier-credit-notes/bulk-upsert","supplierCreditNotes",dp(e))}var WU=X(()=>{"use strict";t_();TA();En();cr()});async function eT(t){return t.get("/api/v1/organization/currencies")}async function ZU(t,e){return t.post("/api/v1/organization/currencies",{currencies:e})}async function XU(t,e,r){return t.list(`/api/v1/organization/currencies/${e}/rates`,r)}function a2e(t){E6(t.rate,"rate");let e=y6(t.rateDirection);return{...t,rateDirection:e}}async function KU(t,e,r){return t.post(`/api/v1/organization/currencies/${e}/rates`,a2e(r))}async function e$(t,e,r,n){return t.put(`/api/v1/organization/currencies/${e}/rates/${r}`,a2e(n))}async function t$(t,e){return t.post("/api/v1/organization/currencies/rates/bulk-upsert",{rates:e})}var r$=X(()=>{"use strict";cr()});var c2e=b((HK,zK)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof zK=="object"&&typeof HK<"u"?zK.exports=e():t.Papa=e()})(HK,function t(){"use strict";var e=(function(){return typeof self<"u"?self:typeof window<"u"?window:typeof e<"u"?e:{}})();function r(){var D=e.URL||e.webkitURL||null,B=t.toString();return a.BLOB_URL||(a.BLOB_URL=D.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",B,")();"],{type:"text/javascript"})))}var n=!e.document&&!!e.postMessage,i=e.IS_PAPA_WORKER||!1,o={},s=0,a={};if(a.parse=u,a.unparse=d,a.RECORD_SEP="",a.UNIT_SEP="",a.BYTE_ORDER_MARK="\uFEFF",a.BAD_DELIMITERS=["\r",`
443
443
  `,'"',a.BYTE_ORDER_MARK],a.WORKERS_SUPPORTED=!n&&!!e.Worker,a.NODE_STREAM_INPUT=1,a.LocalChunkSize=1024*1024*10,a.RemoteChunkSize=1024*1024*5,a.DefaultDelimiter=",",a.Parser=E,a.ParserHandle=y,a.NetworkStreamer=p,a.FileStreamer=h,a.StringStreamer=m,a.ReadableStreamStreamer=A,typeof PAPA_BROWSER_CONTEXT>"u"&&(a.DuplexStreamStreamer=g),e.jQuery){var c=e.jQuery;c.fn.parse=function(D){var B=D.config||{},L=[];return this.each(function(J){var W=c(this).prop("tagName").toUpperCase()==="INPUT"&&c(this).attr("type").toLowerCase()==="file"&&e.FileReader;if(!W||!this.files||this.files.length===0)return!0;for(var oe=0;oe<this.files.length;oe++)L.push({file:this.files[oe],inputElem:this,instanceConfig:c.extend({},B)})}),V(),this;function V(){if(L.length===0){Y(D.complete)&&D.complete();return}var J=L[0];if(Y(D.before)){var W=D.before(J.file,J.inputElem);if(typeof W=="object")if(W.action==="abort"){k("AbortError",J.file,J.inputElem,W.reason);return}else if(W.action==="skip"){$();return}else typeof W.config=="object"&&(J.instanceConfig=c.extend(J.instanceConfig,W.config));else if(W==="skip"){$();return}}var oe=J.instanceConfig.complete;J.instanceConfig.complete=function(me){Y(oe)&&oe(me,J.file,J.inputElem),$()},a.parse(J.file,J.instanceConfig)}function k(J,W,oe,me){Y(D.error)&&D.error({name:J},W,oe,me)}function $(){L.splice(0,1),V()}}}i&&(e.onmessage=O);function u(D,B){B=B||{};var L=B.dynamicTyping||!1;if(Y(L)&&(B.dynamicTypingFunction=L,L={}),B.dynamicTyping=L,B.transform=Y(B.transform)?B.transform:!1,B.worker&&a.WORKERS_SUPPORTED){var V=I();V.userStep=B.step,V.userChunk=B.chunk,V.userComplete=B.complete,V.userError=B.error,B.step=Y(B.step),B.chunk=Y(B.chunk),B.complete=Y(B.complete),B.error=Y(B.error),delete B.worker,V.postMessage({input:D,config:B,workerId:V.id});return}var k=null;if(D===a.NODE_STREAM_INPUT&&typeof PAPA_BROWSER_CONTEXT>"u")return k=new g(B),k.getStream();return typeof D=="string"?(D=$(D),B.download?k=new p(B):k=new m(B)):D.readable===!0&&Y(D.read)&&Y(D.on)?k=new A(B):(e.File&&D instanceof File||D instanceof Object)&&(k=new h(B)),k.stream(D);function $(J){return J.charCodeAt(0)===65279?J.slice(1):J}}function d(D,B){var L=!1,V=!0,k=",",$=`\r
444
444
  `,J='"',W=J+J,oe=!1,me=null,Re=!1;pt();var we=new RegExp(C(J),"g");if(typeof D=="string"&&(D=JSON.parse(D)),Array.isArray(D)){if(!D.length||Array.isArray(D[0]))return Te(null,D,oe);if(typeof D[0]=="object")return Te(me||Object.keys(D[0]),D,oe)}else if(typeof D=="object")return typeof D.data=="string"&&(D.data=JSON.parse(D.data)),Array.isArray(D.data)&&(D.fields||(D.fields=D.meta&&D.meta.fields||me),D.fields||(D.fields=Array.isArray(D.data[0])?D.fields:typeof D.data[0]=="object"?Object.keys(D.data[0]):[]),!Array.isArray(D.data[0])&&typeof D.data[0]!="object"&&(D.data=[D.data])),Te(D.fields||[],D.data||[],oe);throw new Error("Unable to serialize unrecognized input");function pt(){if(typeof B=="object"){if(typeof B.delimiter=="string"&&!a.BAD_DELIMITERS.filter(function(le){return B.delimiter.indexOf(le)!==-1}).length&&(k=B.delimiter),(typeof B.quotes=="boolean"||typeof B.quotes=="function"||Array.isArray(B.quotes))&&(L=B.quotes),(typeof B.skipEmptyLines=="boolean"||typeof B.skipEmptyLines=="string")&&(oe=B.skipEmptyLines),typeof B.newline=="string"&&($=B.newline),typeof B.quoteChar=="string"&&(J=B.quoteChar),typeof B.header=="boolean"&&(V=B.header),Array.isArray(B.columns)){if(B.columns.length===0)throw new Error("Option columns is empty");me=B.columns}B.escapeChar!==void 0&&(W=B.escapeChar+J),B.escapeFormulae instanceof RegExp?Re=B.escapeFormulae:typeof B.escapeFormulae=="boolean"&&B.escapeFormulae&&(Re=/^[=+\-@\t\r].*$/)}}function Te(le,Ie,Oe){var He="";typeof le=="string"&&(le=JSON.parse(le)),typeof Ie=="string"&&(Ie=JSON.parse(Ie));var Pt=Array.isArray(le)&&le.length>0,xt=!Array.isArray(Ie[0]);if(Pt&&V){for(var ar=0;ar<le.length;ar++)ar>0&&(He+=k),He+=Pe(le[ar],ar);Ie.length>0&&(He+=$)}for(var Je=0;Je<Ie.length;Je++){var $e=Pt?le.length:Ie[Je].length,Et=!1,Me=Pt?Object.keys(Ie[Je]).length===0:Ie[Je].length===0;if(Oe&&!Pt&&(Et=Oe==="greedy"?Ie[Je].join("").trim()==="":Ie[Je].length===1&&Ie[Je][0].length===0),Oe==="greedy"&&Pt){for(var Xe=[],tt=0;tt<$e;tt++){var et=xt?le[tt]:tt;Xe.push(Ie[Je][et])}Et=Xe.join("").trim()===""}if(!Et){for(var ae=0;ae<$e;ae++){ae>0&&!Me&&(He+=k);var K=Pt&&xt?le[ae]:ae;He+=Pe(Ie[Je][K],ae)}Je<Ie.length-1&&(!Oe||$e>0&&!Me)&&(He+=$)}}return He}function Pe(le,Ie){if(typeof le>"u"||le===null)return"";if(le.constructor===Date)return JSON.stringify(le).slice(1,25);var Oe=!1;Re&&typeof le=="string"&&Re.test(le)&&(le="'"+le,Oe=!0);var He=le.toString().replace(we,W);return Oe=Oe||L===!0||typeof L=="function"&&L(le,Ie)||Array.isArray(L)&&L[Ie]||fe(He,a.BAD_DELIMITERS)||He.indexOf(k)>-1||He.charAt(0)===" "||He.charAt(He.length-1)===" ",Oe?J+He+J:He}function fe(le,Ie){for(var Oe=0;Oe<Ie.length;Oe++)if(le.indexOf(Ie[Oe])>-1)return!0;return!1}}function f(D){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},B.call(this,D),this.parseChunk=function(L,V){let k=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&k>0){let Re=this._config.newline;if(!Re){let pt=this._config.quoteChar||'"';Re=this._handle.guessLineEndings(L,pt)}L=[...L.split(Re).slice(k)].join(Re)}if(this.isFirstChunk&&Y(this._config.beforeFirstChunk)){var $=this._config.beforeFirstChunk(L);$!==void 0&&(L=$)}this.isFirstChunk=!1,this._halted=!1;var J=this._partialLine+L;this._partialLine="";var W=this._handle.parse(J,this._baseIndex,!this._finished);if(this._handle.paused()||this._handle.aborted()){this._halted=!0;return}var oe=W.meta.cursor;this._finished||(this._partialLine=J.substring(oe-this._baseIndex),this._baseIndex=oe),W&&W.data&&(this._rowCount+=W.data.length);var me=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(i)e.postMessage({results:W,workerId:a.WORKER_ID,finished:me});else if(Y(this._config.chunk)&&!V){if(this._config.chunk(W,this._handle),this._handle.paused()||this._handle.aborted()){this._halted=!0;return}W=void 0,this._completeResults=void 0}return!this._config.step&&!this._config.chunk&&(this._completeResults.data=this._completeResults.data.concat(W.data),this._completeResults.errors=this._completeResults.errors.concat(W.errors),this._completeResults.meta=W.meta),!this._completed&&me&&Y(this._config.complete)&&(!W||!W.meta.aborted)&&(this._config.complete(this._completeResults,this._input),this._completed=!0),!me&&(!W||!W.meta.paused)&&this._nextChunk(),W},this._sendError=function(L){Y(this._config.error)?this._config.error(L):i&&this._config.error&&e.postMessage({workerId:a.WORKER_ID,error:L,finished:!1})};function B(L){var V=N(L);V.chunkSize=parseInt(V.chunkSize),!L.step&&!L.chunk&&(V.chunkSize=null),this._handle=new y(V),this._handle.streamer=this,this._config=V}}function p(D){D=D||{},D.chunkSize||(D.chunkSize=a.RemoteChunkSize),f.call(this,D);var B;n?this._nextChunk=function(){this._readChunk(),this._chunkLoaded()}:this._nextChunk=function(){this._readChunk()},this.stream=function(V){this._input=V,this._nextChunk()},this._readChunk=function(){if(this._finished){this._chunkLoaded();return}if(B=new XMLHttpRequest,this._config.withCredentials&&(B.withCredentials=this._config.withCredentials),n||(B.onload=z(this._chunkLoaded,this),B.onerror=z(this._chunkError,this)),B.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var V=this._config.downloadRequestHeaders;for(var k in V)B.setRequestHeader(k,V[k])}if(this._config.chunkSize){var $=this._start+this._config.chunkSize-1;B.setRequestHeader("Range","bytes="+this._start+"-"+$)}try{B.send(this._config.downloadRequestBody)}catch(J){this._chunkError(J.message)}n&&B.status===0&&this._chunkError()},this._chunkLoaded=function(){if(B.readyState===4){if(B.status<200||B.status>=400){this._chunkError();return}this._start+=this._config.chunkSize?this._config.chunkSize:B.responseText.length,this._finished=!this._config.chunkSize||this._start>=L(B),this.parseChunk(B.responseText)}},this._chunkError=function(V){var k=B.statusText||V;this._sendError(new Error(k))};function L(V){var k=V.getResponseHeader("Content-Range");return k===null?-1:parseInt(k.substring(k.lastIndexOf("/")+1))}}p.prototype=Object.create(f.prototype),p.prototype.constructor=p;function h(D){D=D||{},D.chunkSize||(D.chunkSize=a.LocalChunkSize),f.call(this,D);var B,L,V=typeof FileReader<"u";this.stream=function(k){this._input=k,L=k.slice||k.webkitSlice||k.mozSlice,V?(B=new FileReader,B.onload=z(this._chunkLoaded,this),B.onerror=z(this._chunkError,this)):B=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){!this._finished&&(!this._config.preview||this._rowCount<this._config.preview)&&this._readChunk()},this._readChunk=function(){var k=this._input;if(this._config.chunkSize){var $=Math.min(this._start+this._config.chunkSize,this._input.size);k=L.call(k,this._start,$)}var J=B.readAsText(k,this._config.encoding);V||this._chunkLoaded({target:{result:J}})},this._chunkLoaded=function(k){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(k.target.result)},this._chunkError=function(){this._sendError(B.error)}}h.prototype=Object.create(f.prototype),h.prototype.constructor=h;function m(D){D=D||{},f.call(this,D);var B;this.stream=function(L){return B=L,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var L=this._config.chunkSize,V;return L?(V=B.substring(0,L),B=B.substring(L)):(V=B,B=""),this._finished=!B,this.parseChunk(V)}}}m.prototype=Object.create(m.prototype),m.prototype.constructor=m;function A(D){D=D||{},f.call(this,D);var B=[],L=!0,V=!1;this.pause=function(){f.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){f.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(k){this._input=k,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){V&&B.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),B.length?this.parseChunk(B.shift()):L=!0},this._streamData=z(function(k){try{B.push(typeof k=="string"?k:k.toString(this._config.encoding)),L&&(L=!1,this._checkIsFinished(),this.parseChunk(B.shift()))}catch($){this._streamError($)}},this),this._streamError=z(function(k){this._streamCleanUp(),this._sendError(k)},this),this._streamEnd=z(function(){this._streamCleanUp(),V=!0,this._streamData("")},this),this._streamCleanUp=z(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}A.prototype=Object.create(f.prototype),A.prototype.constructor=A;function g(D){var B=U("stream").Duplex,L=N(D),V=!0,k=!1,$=[],J=null;this._onCsvData=function(W){var oe=W.data;!J.push(oe)&&!this._handle.paused()&&this._handle.pause()},this._onCsvComplete=function(){J.push(null)},L.step=z(this._onCsvData,this),L.complete=z(this._onCsvComplete,this),f.call(this,L),this._nextChunk=function(){k&&$.length===1&&(this._finished=!0),$.length?$.shift()():V=!0},this._addToParseQueue=function(W,oe){$.push(z(function(){if(this.parseChunk(typeof W=="string"?W:W.toString(L.encoding)),Y(oe))return oe()},this)),V&&(V=!1,this._nextChunk())},this._onRead=function(){this._handle.paused()&&this._handle.resume()},this._onWrite=function(W,oe,me){this._addToParseQueue(W,me)},this._onWriteComplete=function(){k=!0,this._addToParseQueue("")},this.getStream=function(){return J},J=new B({readableObjectMode:!0,decodeStrings:!1,read:z(this._onRead,this),write:z(this._onWrite,this)}),J.once("finish",z(this._onWriteComplete,this))}typeof PAPA_BROWSER_CONTEXT>"u"&&(g.prototype=Object.create(f.prototype),g.prototype.constructor=g);function y(D){var B=Math.pow(2,53),L=-B,V=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,k=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,$=this,J=0,W=0,oe,me,Re=!1,we=!1,pt,Te=[],Pe={data:[],errors:[],meta:{}};if(Y(D.step)){var fe=D.step;D.step=function(Me){if(Pe=Me,He())Oe();else{if(Oe(),Pe.data.length===0)return;J+=Me.data.length,D.preview&&J>D.preview?me.abort():(Pe.data=Pe.data[0],fe(Pe,$))}}}this.parse=function(Me,Xe,tt){var et=D.quoteChar||'"';if(D.newline||(D.newline=this.guessLineEndings(Me,et)),pt=!1,D.delimiter)Y(D.delimiter)&&(D.delimiter=D.delimiter(Me),Pe.meta.delimiter=D.delimiter);else{var ae=$e(Me,D.newline,D.skipEmptyLines,D.comments,D.delimitersToGuess);ae.successful?D.delimiter=ae.bestDelimiter:(pt=!0,D.delimiter=a.DefaultDelimiter),Pe.meta.delimiter=D.delimiter}var K=N(D);return D.preview&&D.header&&K.preview++,oe=Me,me=new E(K),Pe=me.parse(oe,Xe,tt),Oe(),Re?{meta:{paused:!0}}:Pe||{meta:{paused:!1}}},this.paused=function(){return Re},this.pause=function(){Re=!0,me.abort(),oe=Y(D.chunk)?"":oe.substring(me.getCharIndex())},this.resume=function(){$.streamer._halted?(Re=!1,$.streamer.parseChunk(oe,!0)):setTimeout($.resume,3)},this.aborted=function(){return we},this.abort=function(){we=!0,me.abort(),Pe.meta.aborted=!0,Y(D.complete)&&D.complete(Pe),oe=""},this.guessLineEndings=function(Me,Xe){Me=Me.substring(0,1024*1024);var tt=new RegExp(C(Xe)+"([^]*?)"+C(Xe),"gm");Me=Me.replace(tt,"");var et=Me.split("\r"),ae=Me.split(`
445
445
  `),K=ae.length>1&&ae[0].length<et[0].length;if(et.length===1||K)return`
@@ -833,7 +833,7 @@ accountResourceId + taxProfileResourceId apply to ALL line items (immutable). in
833
833
 
834
834
  Dynamic strings (reference/lineItem name/notes): ${dk} \u2014 relative to transaction date.`,params:{interval:{type:"string",enum:["ONE_TIME","DAILY","WEEKLY","MONTHLY","YEARLY"],description:"Billing interval, sent as `repeat`. QUARTERLY is rejected with 422."},startDate:{type:"string",description:"Start date (YYYY-MM-DD)"},endDate:{type:"string",description:"End date (YYYY-MM-DD, optional for ongoing)"},contactResourceId:{type:"string",description:"Customer contact resourceId"},reference:{type:"string",description:"Invoice reference (REQUIRED). Supports dynamic strings: {{Month}}, {{Year}}, etc."},valueDate:{type:"string",description:"Invoice date (YYYY-MM-DD)"},dueDate:{type:"string",description:"Due date (YYYY-MM-DD)"},accountResourceId:{type:"string",description:"Revenue account resourceId (applied to ALL line items \u2014 must be same)"},taxProfileResourceId:{type:"string",description:"Tax profile resourceId (applied to ALL line items \u2014 must be same)"},lineItems:{type:"array",items:{type:"object",properties:{name:{type:"string"},unitPrice:{type:"number"},quantity:{type:"number"}},required:["name","unitPrice","quantity"]},description:"Line items (name, unitPrice, quantity only \u2014 account/tax set at top level)"},proratedConfig:{type:"object",description:"Optional prorated-period customization. All fields optional.",properties:{proratedStartDate:{type:"string",description:"Prorated window start (YYYY-MM-DD). Defaults to subscription startDate."},proratedAdjustmentLineText:{type:"string",description:'Adjustment line label on the prorated invoice (default "Prorated adjustment").'},itemResourceId:{type:"string",description:"Non-inventory item resourceId (UUIDv4) for the prorated adjustment line. Defaults to the subscription's first line item."},includeNextPeriod:{type:"boolean",description:"If true: bundle the next full period at 2x quantity AND advance nextScheduleDate by one extra interval. Response carries bundledPeriodEndDate + bundledAmount."}}}},required:["interval","startDate","contactResourceId","lineItems","accountResourceId","valueDate","dueDate","reference"],group:"subscriptions",readOnly:!1,searchHint:"create new recurring subscription billing schedule with proration",execute:async(t,e)=>{let{interval:r,startDate:n,endDate:i,contactResourceId:o,reference:s,valueDate:a,dueDate:c,accountResourceId:u,taxProfileResourceId:d,lineItems:f,proratedConfig:p}=e,h=f.map(A=>({...A,accountResourceId:u,...d?{taxProfileResourceId:d}:{}})),m={repeat:r,startDate:n,status:"ACTIVE",proratedConfig:{proratedAdjustmentLineText:"Prorated adjustment",...p??{}},invoice:{contactResourceId:o,reference:s||ol("SUB"),valueDate:a,dueDate:c,lineItems:h,saveAsDraft:!1}};return i&&(m.endDate=i),tG(t.client,m)}},{name:"update_subscription",description:"Update an existing subscription (interval, end date, transaction template, or proratedConfig). When the user asks to update a subscription, use this tool directly. NOTE: accountResourceId and taxProfileResourceId on line items are immutable after creation \u2014 to change them, cancel and recreate. proratedConfig fields can be amended on update (proratedStartDate, proratedAdjustmentLineText, itemResourceId, includeNextPeriod).",params:{resourceId:{type:"string",description:"Subscription resourceId"},interval:{type:"string",enum:["ONE_TIME","DAILY","WEEKLY","MONTHLY","YEARLY"],description:"Billing interval, sent as `repeat`."},endDate:{type:"string",description:"New end date (YYYY-MM-DD)"},proratedConfig:{type:"object",description:"Amend the prorated-period customization. All fields optional.",properties:{proratedStartDate:{type:"string",description:"YYYY-MM-DD"},proratedAdjustmentLineText:{type:"string"},itemResourceId:{type:"string",description:"UUIDv4"},includeNextPeriod:{type:"boolean"}}},data:{type:"object",description:"Updated transaction template"}},required:["resourceId"],group:"subscriptions",readOnly:!1,searchHint:"update subscription schedule amount details proration",execute:async(t,e)=>{let{resourceId:r,...n}=e;return rG(t.client,r,n)}},Xr("delete_subscription","Delete a subscription. Removes the recurring schedule.","subscriptions",(t,e)=>nG(t,e),"permanently delete a subscription schedule"),{name:"cancel_subscription",description:"Cancel an active subscription. Prorates remaining period and stops future billing. Safe to call \u2014 subscriptions can be reactivated after cancellation. Always use this tool when the user asks to cancel a subscription. Must cancel before delete.",params:{resourceId:{type:"string",description:"Subscription resourceId"},cancelDateType:{type:"string",enum:["END_OF_CURRENT_PERIOD","END_OF_LAST_PERIOD","CUSTOM_DATE"],description:"When to end (default: END_OF_CURRENT_PERIOD)"},endDate:{type:"string",description:"Custom cancel date YYYY-MM-DD (only with CUSTOM_DATE)"},proratedAdjustmentLineText:{type:"string",description:'Label for proration line item (default: "Prorated adjustment")'}},required:["resourceId"],group:"subscriptions",readOnly:!1,searchHint:"cancel stop a recurring subscription",isDestructive:!0,execute:async(t,e)=>iG(t.client,e.resourceId,{cancelDateType:e.cancelDateType,endDate:e.endDate,proratedAdjustmentLineText:e.proratedAdjustmentLineText})},Xt({name:"search_scheduled_transactions",description:"Search scheduled transactions (subscriptions / recurring invoices / journals / cash entries).",group:"subscriptions",fields:HS,defaults:zS,fetcher:oG,searchHint:"find scheduled recurring transactions subscriptions schedulers by type status interval contact"}),{name:"generate_vat_ledger",description:"Generate VAT/GST ledger report showing all tax transactions for the period.",params:{startDate:{type:"string",description:"Start date (YYYY-MM-DD)"},endDate:{type:"string",description:"End date (YYYY-MM-DD)"}},required:["startDate","endDate"],group:"financial_reports",readOnly:!0,searchHint:"generate VAT GST tax ledger report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>CU(t.client,{startDate:e.startDate,endDate:e.endDate})},{name:"generate_equity_movement",description:"Generate equity movement report (statement of changes in equity).",params:{primarySnapshotStartDate:{type:"string",description:"Period start date (YYYY-MM-DD)"},primarySnapshotEndDate:{type:"string",description:"Period end date (YYYY-MM-DD)"},currencyCode:{type:"string",description:'Currency code (e.g., "SGD")'},compareWith:{type:"string",description:'Compare with period (e.g., "PREVIOUS_YEAR")'},compareCount:{type:"number",description:"Number of comparison periods"}},required:["primarySnapshotStartDate","primarySnapshotEndDate"],group:"financial_reports",readOnly:!0,searchHint:"generate equity movement statement report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>IU(t.client,e)},{name:"generate_bank_balance_summary",description:"Generate bank balance summary report \u2014 snapshot of all bank account balances at a point in time.",params:{primarySnapshotDate:{type:"string",description:"Snapshot date (YYYY-MM-DD)"},currencyCode:{type:"string",description:'Currency code (e.g., "SGD")'}},required:["primarySnapshotDate"],group:"operational_reports",readOnly:!0,searchHint:"generate bank account balance summary report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>vU(t.client,{primarySnapshotDate:e.primarySnapshotDate,currencyCode:e.currencyCode})},{name:"generate_bank_recon_summary",description:"Generate bank reconciliation summary for a specific bank account. Essential for month-end close \u2014 call this for each in-scope bank account for the current entity and reporting period. Use for bank recon status, unreconciled items count, or reconciliation summaries.",params:{bankAccountResourceId:{type:"string",description:"Bank account resourceId"},primarySnapshotStartDate:{type:"string",description:"Period start date (YYYY-MM-DD)"},primarySnapshotEndDate:{type:"string",description:"Period end date (YYYY-MM-DD)"},currencyCode:{type:"string",description:"Currency code"},tags:{type:"array",items:{type:"string"},description:"Filter by tags"}},required:["bankAccountResourceId","primarySnapshotStartDate","primarySnapshotEndDate"],group:"operational_reports",readOnly:!0,searchHint:"generate bank reconciliation summary report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>wU(t.client,e)},{name:"generate_bank_recon_details",description:"Generate detailed bank reconciliation report showing matched/unmatched items.",params:{bankAccountResourceId:{type:"string",description:"Bank account resourceId"},primarySnapshotStartDate:{type:"string",description:"Period start date (YYYY-MM-DD)"},primarySnapshotEndDate:{type:"string",description:"Period end date (YYYY-MM-DD)"},filter:{type:"object",description:"Report filter. valueDate is required.",properties:{valueDate:{type:"object",description:"Report window.",properties:{range:{type:"array",items:{type:"string"},description:"Inclusive [from, to], YYYY-MM-DD. The only accepted operator."}},required:["range"]},reconciliationStatus:{type:"string",description:"Reconciliation status (no published enum)."}},required:["valueDate"]},currencyCode:{type:"string",description:"Currency code"}},required:["bankAccountResourceId","primarySnapshotStartDate","primarySnapshotEndDate","filter"],group:"operational_reports",readOnly:!0,searchHint:"generate bank reconciliation detailed report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>_U(t.client,e)},{name:"generate_fa_summary",description:"Generate fixed assets summary report grouped by account, type, category, or status.",params:{primarySnapshotStartDate:{type:"string",description:"Period start date (YYYY-MM-DD)"},primarySnapshotEndDate:{type:"string",description:"Period end date (YYYY-MM-DD)"},groupBy:{type:"string",enum:["ACCOUNT","TYPE","CATEGORY","STATUS"],description:"Grouping dimension"},currencyCode:{type:"string",description:"Currency code"}},required:["primarySnapshotStartDate","primarySnapshotEndDate","groupBy"],group:"operational_reports",readOnly:!0,searchHint:"generate fixed asset summary depreciation report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>DU(t.client,e)},{name:"generate_fa_recon_summary",description:"Generate fixed assets reconciliation summary \u2014 reconciles asset register with general ledger.",params:{primarySnapshotStartDate:{type:"string",description:"Period start date (YYYY-MM-DD)"},primarySnapshotEndDate:{type:"string",description:"Period end date (YYYY-MM-DD)"},accountResourceIds:{type:"array",items:{type:"string"},description:"Filter by specific asset account IDs"},currencyCode:{type:"string",description:"Currency code"}},required:["primarySnapshotStartDate","primarySnapshotEndDate"],group:"operational_reports",readOnly:!0,searchHint:"generate fixed asset reconciliation report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>SU(t.client,e)},{name:"generate_ar_report",description:"Generate accounts receivable aging report. Shows outstanding invoices grouped by aging buckets. Use this when discussing customer payment allocation, credit control, or AR status \u2014 generate the report to show the full picture.",params:{endDate:{type:"string",description:"Report date (YYYY-MM-DD) \u2014 point-in-time snapshot"}},required:["endDate"],group:"operational_reports",readOnly:!0,searchHint:"generate detailed accounts receivable report",isConcurrencySafe:!0,maxResultSizeChars:1e5,execute:async(t,e)=>RU(t.client,{endDate:e.endDate})},{name:"get_ledger_highlights",description:"Get ledger highlights \u2014 summary metadata about the org general ledger: transaction counts by type, date range, active accounts, active currencies, and cross-currency detection. No parameters needed.",params:{},required:[],group:"operational_reports",readOnly:!0,searchHint:"get ledger highlights key metrics for period",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async t=>TU(t.client)},Ar("list_contact_groups","List contact groups with their associated contacts. Used to segment customers/suppliers.","contact_groups",(t,e,r)=>sG(t,{limit:r,offset:e}),"list contact groups customer supplier categories"),xi("get_contact_group","Get contact group details including all associated contacts.","contact_groups",(t,e)=>aG(t,e),"get contact group details members"),Xt({name:"search_contact_groups",description:"Search contact groups.",group:"contact_groups",fields:DR,defaults:SR,fetcher:cG,searchHint:"find contact groups segments categories by name"}),{name:"create_contact_group",description:'Create a new contact group for segmenting contacts (e.g., "VIP Customers", "Government", "Overdue > 90 Days").',params:{name:{type:"string",description:"Group name"},contactResourceIds:{type:"array",items:{type:"string"},description:"Contact IDs to add to the group"}},required:["name"],group:"contact_groups",readOnly:!1,searchHint:"create new contact group category",execute:async(t,e)=>lG(t.client,{name:e.name,contactResourceIds:e.contactResourceIds})},{name:"update_contact_group",description:"Update a contact group name or members. Membership replaces the existing set.",params:{resourceId:{type:"string",description:"Contact group resourceId"},name:{type:"string",description:"New group name"},contactResourceIds:{type:"array",items:{type:"string"},description:"Contact IDs to set as group members, max 50 (replaces existing). Sent as associatedContactResourceIds."}},required:["resourceId"],group:"contact_groups",readOnly:!1,searchHint:"update contact group name details",execute:async(t,e)=>uG(t.client,e.resourceId,{name:e.name,contactResourceIds:e.contactResourceIds})},Xr("delete_contact_group","Delete a contact group. Does not delete the contacts themselves.","contact_groups",(t,e)=>dG(t,e),"permanently delete a contact group"),Ar("list_custom_fields","List custom fields defined for the organization. Custom fields add extra data to invoices, bills, credit notes, and payments.","custom_fields",(t,e,r)=>mG(t,{limit:r,offset:e}),"list custom fields metadata on transactions"),{name:"get_custom_field",description:"Get a custom field by resourceId. Returns full definition including appliesTo flags and list options.",params:{resourceId:{type:"string",description:"Custom field resourceId"}},required:["resourceId"],group:"custom_fields",readOnly:!0,searchHint:"get custom field definition details",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>ik(t.client,e.resourceId)},Xt({name:"search_custom_fields",description:"Search custom fields.",group:"custom_fields",fields:wR,defaults:_R,fetcher:AG,searchHint:"find custom fields user-defined attributes by name data type"}),{name:"create_custom_field",description:`Create a new custom field. Custom fields appear on transactions (invoices, bills, credit notes, payments).
835
835
  - appliesTo controls which transaction types show this field. Omit it and it shows on none.
836
- - printOnDocuments controls whether the field appears on PDFs.`,params:{name:{type:"string",description:'Field name (e.g., "PO Number", "Cost Center")'},description:{type:"string",description:"Field description"},printOnDocuments:{type:"boolean",description:"Show on PDF documents (default false)"},appliesTo:{type:"object",description:"Which transaction types: { invoices: true, bills: true, customerCredits: true, supplierCredits: true, payments: true }"},format:fst},required:["name"],group:"custom_fields",readOnly:!1,searchHint:"create new custom field for transactions",execute:async(t,e)=>gG(t.client,{...e,printOnDocuments:e.printOnDocuments??!1})},{name:"update_custom_field",description:"Update a custom field definition. Omitted fields keep their current values.",params:{resourceId:{type:"string",description:"Custom field resourceId"},name:{type:"string",description:"New field name"},description:{type:"string",description:"New description"},printOnDocuments:{type:"boolean",description:"Show on PDF documents"},appliesTo:{type:"object",description:"Which transaction types: { invoices, bills, customerCredits, supplierCredits, payments }"},format:fst},required:["resourceId"],group:"custom_fields",readOnly:!1,searchHint:"update custom field name type settings",execute:async(t,e)=>{let{resourceId:r,...n}=e;return yG(t.client,r,n)}},Xr("delete_custom_field","Delete a custom field. Removes it from all future transactions.","custom_fields",(t,e)=>EG(t,e),"permanently delete a custom field definition"),{name:"list_withholding_tax_codes",description:"List withholding tax codes (industry classification codes for PH/SG compliance). Returns full list (no pagination).",params:{},required:[],group:"tax_profiles",readOnly:!0,searchHint:"list withholding tax WHT codes",isConcurrencySafe:!0,maxResultSizeChars:5e4,execute:async t=>v1(t.client)},Xt({name:"search_tax_profiles",description:"Search tax profiles. Use appliesToSale / appliesToPurchase filters to scope by transaction type.",group:"tax_profiles",fields:bR,defaults:CR,fetcher:ib,searchHint:"find tax profiles GST VAT WHT by name tax type code applicability sale purchase"}),xi("get_tax_profile","Get full tax profile details including tax rate, type code, and status.","tax_profiles",(t,e)=>d_(t,e),"get tax profile details rate code"),{name:"update_tax_profile",description:"Update an existing tax profile. Omitted fields keep their current values; status is not updatable.",params:{resourceId:{type:"string",description:"Tax profile resourceId"},name:Spe,description:{type:"string"},vatValue:{type:"number",description:"Tax rate % (0-100)"},taxType:{type:"string",description:"Tax type code (list_tax_types)"}},required:["resourceId"],group:"tax_profiles",readOnly:!1,searchHint:"update tax profile name rate details",execute:async(t,e)=>I1(t.client,e.resourceId,{name:e.name,description:e.description,vatValue:e.vatValue,taxType:e.taxType})},{name:"create_claim_type",description:"Create a claim type (expense category for employee claims). Dedups by name. expenseAccountResourceId is server-required.",params:{name:{type:"string",description:"Claim type name (unique per org)"},expenseAccountResourceId:{type:"string",description:'Expense CoA resourceId \u2014 REQUIRED server-side (search_accounts; accountType is a display label e.g. "Operating Expense")'},taxProfileResourceId:{type:"string",description:"Default tax profile resourceId"},classifierConfig:{type:"string",description:"Magic OCR classifier defaults (JSON string)"},isDefault:{type:"boolean",description:"Make org default (sweeps prior default)"}},required:["name"],group:"claim_types",readOnly:!1,searchHint:"create claim type expense category",execute:async(t,e)=>{let r=e.name,n=await iQ(t.client,r);return n?{_guard:"duplicate_skipped",message:`Claim type "${r}" already exists.`,existing:n}:B1(t.client,{name:r,expenseAccountResourceId:e.expenseAccountResourceId,taxProfileResourceId:e.taxProfileResourceId,classifierConfig:e.classifierConfig,isDefault:e.isDefault})}},{name:"update_claim_type",description:"Update a claim type. Omitted fields unchanged; clearFields NULLs optional fields.",params:{resourceId:{type:"string",description:"Claim type resourceId"},name:{type:"string",description:"New name"},expenseAccountResourceId:{type:"string",description:"Default expense CoA resourceId"},taxProfileResourceId:{type:"string",description:"Default tax profile resourceId"},classifierConfig:{type:"string",description:"Classifier defaults (JSON string)"},isDefault:{type:"boolean",description:"Make org default"},clearFields:{type:"array",items:{type:"string",enum:[...h_]},description:"Optional fields to NULL (clear)"}},required:["resourceId"],group:"claim_types",readOnly:!1,searchHint:"update claim type",execute:async(t,e)=>k1(t.client,e.resourceId,{name:e.name,expenseAccountResourceId:e.expenseAccountResourceId,taxProfileResourceId:e.taxProfileResourceId,classifierConfig:e.classifierConfig,isDefault:e.isDefault,...zy(e.clearFields,h_)})},Xt({name:"search_claim_types",description:"Search claim types.",group:"claim_types",fields:sR,defaults:aR,fetcher:sb,searchHint:"find claim types by name default expense account tax profile"}),Ar("list_claim_types","List claim types (alphabetical).","claim_types",(t,e,r)=>T1(t,{offset:e,limit:r}),"list claim types"),xi("get_claim_type","Get a claim type incl. nested expense account + tax profile.","claim_types",(t,e)=>x1(t,e),"get claim type details"),Xr("delete_claim_type","Soft-delete a claim type (name becomes reusable).","claim_types",(t,e)=>N1(t,e),"delete claim type"),{name:"create_claim_profile",description:"Create a claim profile (per-employee policy bundle: approver, limits, visible types, balance account). Dedups by name. taxMode EXCLUSIVE is rejected.",params:{name:{type:"string",description:"Profile name (unique per org)"},approverUserResourceId:{type:"string",description:"Default approver user resourceId"},visibleClaimTypeIds:{type:"array",items:{type:"string"},description:"Allowed claim type IDs"},visibleTaxProfileIds:{type:"array",items:{type:"string"},description:"Allowed tax profile IDs"},visibleClassifierIds:{type:"array",items:{type:"string"},description:"Allowed classifier IDs"},visibleVendorResourceIds:{type:"array",items:{type:"string"},description:"Allowed vendor contact IDs (free-text vendors always allowed)"},allowedCurrencies:{type:"array",items:{type:"string"},description:"Allowed ISO currency codes (null = no restriction)"},minClaimAmount:{type:"number",description:"Min claim total (<= max)"},maxClaimAmount:{type:"number",description:"Max claim total"},maxPerPeriodAmount:{type:"number",description:"Per-period spend cap (requires perPeriod)"},perPeriod:{type:"string",enum:[...m_],description:"Per-period window"},employeeBalanceAccountResourceId:{type:"string",description:"Per-employee liability (CURRENT_LIABILITY) CoA resourceId; required for reimbursement conversion"},taxMode:{type:"string",enum:[...g6],description:"Tax policy (NO_TAX or INCLUSIVE)"},isDefault:{type:"boolean",description:"Make org default"}},required:["name"],group:"claim_profiles",readOnly:!1,searchHint:"create claim profile policy approver limits",execute:async(t,e)=>{let r=e.name,n=await oQ(t.client,r);return n?{_guard:"duplicate_skipped",message:`Claim profile "${r}" already exists.`,existing:n}:L1(t.client,{name:r,approverUserResourceId:e.approverUserResourceId,visibleClaimTypeIds:e.visibleClaimTypeIds,visibleTaxProfileIds:e.visibleTaxProfileIds,visibleClassifierIds:e.visibleClassifierIds,visibleVendorResourceIds:e.visibleVendorResourceIds,allowedCurrencies:e.allowedCurrencies,minClaimAmount:e.minClaimAmount,maxClaimAmount:e.maxClaimAmount,maxPerPeriodAmount:e.maxPerPeriodAmount,perPeriod:e.perPeriod,employeeBalanceAccountResourceId:e.employeeBalanceAccountResourceId,taxMode:e.taxMode,isDefault:e.isDefault})}},{name:"update_claim_profile",description:"Update a claim profile. Omitted fields unchanged; clearFields NULLs optional fields. Balance account cannot change while an employee has a non-zero balance.",params:{resourceId:{type:"string",description:"Claim profile resourceId"},name:{type:"string",description:"New name"},approverUserResourceId:{type:"string",description:"Default approver user resourceId"},visibleClaimTypeIds:{type:"array",items:{type:"string"},description:"Allowed claim type IDs (replaces)"},visibleTaxProfileIds:{type:"array",items:{type:"string"},description:"Allowed tax profile IDs (replaces)"},visibleClassifierIds:{type:"array",items:{type:"string"},description:"Allowed classifier IDs (replaces)"},visibleVendorResourceIds:{type:"array",items:{type:"string"},description:"Allowed vendor contact IDs (replaces)"},allowedCurrencies:{type:"array",items:{type:"string"},description:"Allowed ISO currency codes (replaces)"},minClaimAmount:{type:"number",description:"Min claim total"},maxClaimAmount:{type:"number",description:"Max claim total"},maxPerPeriodAmount:{type:"number",description:"Per-period spend cap"},perPeriod:{type:"string",enum:[...m_],description:"Per-period window"},employeeBalanceAccountResourceId:{type:"string",description:"Employee balance CoA resourceId"},taxMode:{type:"string",enum:[...g6],description:"Tax policy (NO_TAX or INCLUSIVE)"},isDefault:{type:"boolean",description:"Make org default"},clearFields:{type:"array",items:{type:"string",enum:[...A_]},description:"Optional fields to NULL (clear)"}},required:["resourceId"],group:"claim_profiles",readOnly:!1,searchHint:"update claim profile policy limits",execute:async(t,e)=>P1(t.client,e.resourceId,{name:e.name,approverUserResourceId:e.approverUserResourceId,visibleClaimTypeIds:e.visibleClaimTypeIds,visibleTaxProfileIds:e.visibleTaxProfileIds,visibleClassifierIds:e.visibleClassifierIds,visibleVendorResourceIds:e.visibleVendorResourceIds,allowedCurrencies:e.allowedCurrencies,minClaimAmount:e.minClaimAmount,maxClaimAmount:e.maxClaimAmount,maxPerPeriodAmount:e.maxPerPeriodAmount,perPeriod:e.perPeriod,employeeBalanceAccountResourceId:e.employeeBalanceAccountResourceId,taxMode:e.taxMode,isDefault:e.isDefault,...zy(e.clearFields,A_)})},Xt({name:"search_claim_profiles",description:"Search claim profiles.",group:"claim_profiles",fields:cR,defaults:lR,fetcher:ab,searchHint:"find claim profiles by name approver default limits balance account"}),Ar("list_claim_profiles","List claim profiles (alphabetical).","claim_profiles",(t,e,r)=>F1(t,{offset:e,limit:r}),"list claim profiles"),xi("get_claim_profile","Get a claim profile incl. nested balance account.","claim_profiles",(t,e)=>Q1(t,e),"get claim profile details"),Xr("delete_claim_profile","Soft-delete a claim profile.","claim_profiles",(t,e)=>M1(t,e),"delete claim profile"),{name:"create_posting_rule",description:"Create a posting rule (how approved claims group into journals at conversion). outerAxis + innerAxis + lineDescriptionTemplate required. Dedups by name.",params:{name:{type:"string",description:"Rule name (unique per org)"},outerAxis:{type:"string",enum:[...y_],description:"Outer grouping axis"},innerAxis:{type:"string",enum:[...E_],description:"Inner line-aggregation axis"},lineDescriptionTemplate:{type:"string",description:'Handlebars line template, e.g. "{employeeName} - {claimType}"'},journalReferenceTemplate:{type:"string",description:"Optional Handlebars journal-header reference template"},defaultBankAccountResourceId:{type:"string",description:"Default reimbursement bank (Cash/Bank) account resourceId"},defaultIncludeReimbursementPayout:{type:"boolean",description:"Create reimbursement DCE by default"},isDefault:{type:"boolean",description:"Make org default rule"}},required:["name","outerAxis","innerAxis","lineDescriptionTemplate"],group:"posting_rules",readOnly:!1,searchHint:"create posting rule claim conversion grouping",execute:async(t,e)=>{let r=e.name,n=await sQ(t.client,r);return n?{_guard:"duplicate_skipped",message:`Posting rule "${r}" already exists.`,existing:n}:q1(t.client,{name:r,outerAxis:e.outerAxis,innerAxis:e.innerAxis,lineDescriptionTemplate:e.lineDescriptionTemplate,journalReferenceTemplate:e.journalReferenceTemplate,defaultBankAccountResourceId:e.defaultBankAccountResourceId,defaultIncludeReimbursementPayout:e.defaultIncludeReimbursementPayout,isDefault:e.isDefault})}},{name:"update_posting_rule",description:"Update a posting rule. Omitted fields unchanged.",params:{resourceId:{type:"string",description:"Posting rule resourceId"},name:{type:"string",description:"New name"},outerAxis:{type:"string",enum:[...y_],description:"Outer grouping axis"},innerAxis:{type:"string",enum:[...E_],description:"Inner line-aggregation axis"},lineDescriptionTemplate:{type:"string",description:"Handlebars line template"},journalReferenceTemplate:{type:"string",description:"Journal-header reference template"},defaultBankAccountResourceId:{type:"string",description:"Default reimbursement bank account resourceId"},defaultIncludeReimbursementPayout:{type:"boolean",description:"Create reimbursement DCE by default"},isDefault:{type:"boolean",description:"Make org default rule"}},required:["resourceId"],group:"posting_rules",readOnly:!1,searchHint:"update posting rule",execute:async(t,e)=>j1(t.client,e.resourceId,{name:e.name,outerAxis:e.outerAxis,innerAxis:e.innerAxis,lineDescriptionTemplate:e.lineDescriptionTemplate,journalReferenceTemplate:e.journalReferenceTemplate,defaultBankAccountResourceId:e.defaultBankAccountResourceId,defaultIncludeReimbursementPayout:e.defaultIncludeReimbursementPayout,isDefault:e.isDefault})},Xt({name:"search_posting_rules",description:"Search posting rules.",group:"posting_rules",fields:uR,defaults:dR,fetcher:cb,searchHint:"find posting rules by name axis default bank reimbursement"}),Ar("list_posting_rules","List posting rules (alphabetical).","posting_rules",(t,e,r)=>U1(t,{offset:e,limit:r}),"list posting rules"),xi("get_posting_rule","Get a posting rule.","posting_rules",(t,e)=>$1(t,e),"get posting rule details"),Xr("delete_posting_rule","Delete a posting rule. The org default cannot be deleted while default (set another default first).","posting_rules",(t,e)=>Y1(t,e),"delete posting rule"),Xt({name:"search_claims",description:'Search/list employee-expense claims. Status: DRAFT|SUBMITTED|APPROVED|CONVERTED|REJECTED|CANCELLED (CONVERTED = "Processed"). Claims are born via create_claim, attachment, or conversion (no bare list \u2014 use search).',group:"claims",fields:rR,defaults:nR,fetcher:m2,searchHint:"find employee expense claims by status employee contact reference date amount"}),xi("get_claim","Get a claim incl. line items, employee, amounts, status.","claims",(t,e)=>A2(t,e),"get claim details line items"),{name:"create_claim",description:"Create an employee-expense claim directly (bare create, no attachment). Vendor is EITHER contactResourceId OR vendorName, never both. saveAsDraft defaults to true (lands DRAFT with relaxed line validation); set false to validate + submit in one call (lands SUBMITTED). reference is REQUIRED when submitting (saveAsDraft=false) \u2014 omitting it returns 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT; a DRAFT saves without one.",params:{valueDate:{type:"string",description:"Business-transaction date (YYYY-MM-DD)"},currencyCode:{type:"string",description:"Claim currency (ISO 4217)"},saveAsDraft:{type:"boolean",description:"true (default) creates DRAFT; false validates + submits"},employeeResourceId:{type:"string",description:"Employee resourceId the claim is filed for"},contactResourceId:{type:"string",description:"Vendor contact resourceId (mutually exclusive with vendorName)"},vendorName:{type:"string",description:"Free-text vendor name (mutually exclusive with contactResourceId)"},reference:{type:"string",description:"User reference"},autoReference:hd,currencySymbol:{type:"string",description:"Currency symbol override"},taxInclusion:{type:"boolean",description:"Line amounts are tax-inclusive"},tags:{type:"array",items:{type:"string"},description:"Header-level tags"},internalNotes:{type:"string",description:"Internal notes (max 1000)"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId (defaults to org default)"},approverUserResourceId:{type:"string",description:"Approver user resourceId"},customFields:Qi,claimItems:bst},required:["valueDate","currencyCode"],group:"claims",readOnly:!1,searchHint:"create new employee expense claim draft vendor employee line items submit",execute:async(t,e)=>g2(t.client,{valueDate:e.valueDate,currencyCode:e.currencyCode,saveAsDraft:e.saveAsDraft,employeeResourceId:e.employeeResourceId,contactResourceId:e.contactResourceId,vendorName:e.vendorName,reference:await $p(t.client,"CLAIM",e.reference,e.autoReference),currencySymbol:e.currencySymbol,taxInclusion:e.taxInclusion,tags:e.tags,internalNotes:e.internalNotes,claimProfileResourceId:e.claimProfileResourceId,approverUserResourceId:e.approverUserResourceId,customFields:e.customFields,claimItems:e.claimItems})},{name:"update_claim",description:"Update a DRAFT claim (partial \u2014 omitted fields unchanged). claimItems non-empty REPLACES all lines, [] clears. Set saveAsDraft=false to validate + submit in one call \u2014 reference is REQUIRED at submit (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT); a DRAFT save needs none. Only DRAFT claims are editable.",params:{resourceId:{type:"string",description:"Claim resourceId"},saveAsDraft:{type:"boolean",description:"true (default) keeps editing; false validates + submits"},employeeResourceId:{type:"string",description:"Employee resourceId"},contactResourceId:{type:"string",description:"Vendor contact resourceId (mutually exclusive with vendorName)"},vendorName:{type:"string",description:"Free-text vendor name (mutually exclusive with contactResourceId)"},valueDate:{type:"string",description:"Business-transaction date (YYYY-MM-DD)"},reference:{type:"string",description:"User reference"},currencyCode:{type:"string",description:"Claim currency (ISO 4217)"},taxInclusion:{type:"boolean",description:"Line amounts are tax-inclusive"},tags:{type:"array",items:{type:"string"},description:"Header-level tags"},internalNotes:{type:"string",description:"Internal notes (max 1000)"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId"},approverUserResourceId:{type:"string",description:"Approver user resourceId"},customFields:Qi,claimItems:bst},required:["resourceId"],group:"claims",readOnly:!1,searchHint:"edit draft claim line items employee reference submit",execute:async(t,e)=>y2(t.client,e.resourceId,{saveAsDraft:e.saveAsDraft,employeeResourceId:e.employeeResourceId,contactResourceId:e.contactResourceId,vendorName:e.vendorName,valueDate:e.valueDate,reference:e.reference,currencyCode:e.currencyCode,taxInclusion:e.taxInclusion,tags:e.tags,internalNotes:e.internalNotes,claimProfileResourceId:e.claimProfileResourceId,approverUserResourceId:e.approverUserResourceId,customFields:e.customFields,claimItems:e.claimItems})},Xr("delete_claim","Delete a claim. Only DRAFT / REJECTED / CANCELLED claims are deletable (else 422).","claims",(t,e)=>E2(t,e),"delete remove claim record"),{name:"delete_claim_attachment",description:"Remove one attachment (receipt) from a claim. Returns the updated claim.",params:{resourceId:{type:"string",description:"Claim resourceId"},attachmentResourceId:{type:"string",description:"Attachment resourceId"}},required:["resourceId","attachmentResourceId"],group:"claims",readOnly:!1,isDestructive:!0,searchHint:"remove delete claim attachment receipt",execute:async(t,e)=>b2(t.client,e.resourceId,e.attachmentResourceId)},Bpe("submit_claim","Submit a DRAFT claim for approval (DRAFT \u2192 SUBMITTED). Server enforces the transition. The claim must carry a reference \u2014 a referenceless DRAFT returns 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT (set it via update_claim first).","claims",(t,e)=>C2(t,e),{searchHint:"submit draft claim for approval"}),Bpe("approve_claim","Approve a SUBMITTED claim (SUBMITTED \u2192 APPROVED). Approved claims become convertible to journals.","claims",(t,e)=>I2(t,e),{searchHint:"approve submitted claim"}),{name:"reject_claim",description:"Reject a SUBMITTED/APPROVED claim with a reason (\u2192 REJECTED).",params:{resourceId:{type:"string",description:"Claim resourceId"},rejectionReason:{type:"string",description:"Rejection reason (1-1000 chars)"}},required:["resourceId","rejectionReason"],group:"claims",readOnly:!1,isDestructive:!0,searchHint:"reject claim with reason",execute:async(t,e)=>v2(t.client,e.resourceId,e.rejectionReason)},{name:"cancel_claim",description:"Cancel a DRAFT/SUBMITTED claim with a reason (\u2192 CANCELLED).",params:{resourceId:{type:"string",description:"Claim resourceId"},cancellationReason:{type:"string",description:"Cancellation reason (1-1000 chars)"}},required:["resourceId","cancellationReason"],group:"claims",readOnly:!1,isDestructive:!0,searchHint:"cancel claim with reason",execute:async(t,e)=>w2(t.client,e.resourceId,e.cancellationReason)},Bpe("unpost_claim","Unpost a CONVERTED claim \u2014 reverses the journal conversion back to APPROVED.","claims",(t,e)=>_2(t,e),{destructive:!0,searchHint:"unpost reverse converted claim conversion"}),{name:"bulk_submit_claims",description:"Bulk-submit DRAFT claims (ASYNC). Returns a job handle {jobId,...}; poll search_background_jobs by jobId for per-item results. Max 500 ids. Each claim must have a reference \u2014 referenceless claims fail per-item with CLAIM_REFERENCE_REQUIRED_AT_SUBMIT (check the job result).",params:{resourceIds:Ak},required:["resourceIds"],group:"claim_processing",readOnly:!1,searchHint:"bulk submit many claims async job",execute:async(t,e)=>D2(t.client,e.resourceIds)},{name:"bulk_approve_claims",description:"Bulk-approve SUBMITTED claims (ASYNC). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak},required:["resourceIds"],group:"claim_processing",readOnly:!1,searchHint:"bulk approve many claims async job",execute:async(t,e)=>S2(t.client,e.resourceIds)},{name:"bulk_reject_claims",description:"Bulk-reject claims with one shared reason (ASYNC). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak,rejectionReason:{type:"string",description:"Reason applied to the whole batch (1-1000 chars)"}},required:["resourceIds","rejectionReason"],group:"claim_processing",readOnly:!1,isDestructive:!0,searchHint:"bulk reject many claims async job reason",execute:async(t,e)=>T2(t.client,e.resourceIds,e.rejectionReason)},{name:"bulk_cancel_claims",description:"Bulk-cancel claims with one shared reason (ASYNC). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak,cancellationReason:{type:"string",description:"Reason applied to the whole batch (1-1000 chars)"}},required:["resourceIds","cancellationReason"],group:"claim_processing",readOnly:!1,isDestructive:!0,searchHint:"bulk cancel many claims async job reason",execute:async(t,e)=>x2(t.client,e.resourceIds,e.cancellationReason)},{name:"bulk_delete_claims",description:"Bulk-delete claims (ASYNC; only DRAFT/REJECTED/CANCELLED are deletable). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak},required:["resourceIds"],group:"claim_processing",readOnly:!1,isDestructive:!0,searchHint:"bulk delete many claims async job",execute:async(t,e)=>R2(t.client,e.resourceIds)},{name:"get_claim_tracking_tags",description:"List the tracking-tag values available across claims (picker; returns a bare array).",params:{},required:[],group:"claim_processing",readOnly:!0,isConcurrencySafe:!0,searchHint:"list claim tracking tags picker",execute:async t=>B2(t.client)},{name:"get_claim_custom_field_values",description:"List the custom-field values available across claims (picker; returns a bare array).",params:{},required:[],group:"claim_processing",readOnly:!0,isConcurrencySafe:!0,searchHint:"list claim custom field values picker",execute:async t=>k2(t.client)},{name:"preview_claims_conversion",description:"Preview the journals an APPROVED claim batch would produce at conversion \u2014 no write. Returns expenseSubTotal, previewJournals, and reimbursement DCE counts; non-APPROVED claims come back under erroredClaims (check it is empty before converting). Needs a default posting rule or an explicit postingRuleResourceId.",params:{claimResourceIds:{type:"array",items:{type:"string"},description:"APPROVED claim resourceIds (1-500)"},postingRuleResourceId:{type:"string",description:"Posting rule resourceId (null \u2192 org default rule)"},payoutFlow:{type:"string",enum:[...KB],description:"POST (journals only) or POST_AND_RECORD (+ books-only reimbursement DCE)"},includeReimbursementPayout:{type:"boolean",description:"Include per-employee reimbursement DCE lines"},bankAccountResourceId:{type:"string",description:"Reimbursement bank account for preview validation"}},required:["claimResourceIds"],group:"claim_processing",readOnly:!0,isConcurrencySafe:!0,searchHint:"preview claim conversion journals before posting",execute:async(t,e)=>F8(t.client,{claimResourceIds:e.claimResourceIds,postingRuleResourceId:e.postingRuleResourceId,payoutFlow:e.payoutFlow,includeReimbursementPayout:e.includeReimbursementPayout,bankAccountResourceId:e.bankAccountResourceId})},{name:"convert_claims_to_journal",description:"Convert an APPROVED claim batch into journals (atomic write). valueDate (YYYY-MM-DD) required. Preview first and confirm erroredClaims is empty. idempotencyKey is auto-generated for safe retries (pass your own to dedup across calls). includeReimbursementPayout adds a books-only reimbursement DCE \u2014 real-money disburse is intentionally not exposed.",params:{claimResourceIds:{type:"array",items:{type:"string"},description:"APPROVED claim resourceIds (1-500)"},valueDate:{type:"string",description:"Journal value date (YYYY-MM-DD)"},postingRuleResourceId:{type:"string",description:"Posting rule resourceId (null \u2192 org default rule)"},includeReimbursementPayout:{type:"boolean",description:"Create books-only reimbursement DCEs"},bankAccountResourceIdOverride:{type:"string",description:"Override the rule default reimbursement bank account"},contactResourceId:{type:"string",description:"Clearing contact for the reimbursement DCE cash-out"},idempotencyKey:{type:"string",description:"Optional retry-dedup token (must not start with CONV: / CONV-); auto-generated if omitted"}},required:["claimResourceIds","valueDate"],group:"claim_processing",readOnly:!1,searchHint:"convert post approved claims to journal entries",execute:async(t,e)=>Q8(t.client,{claimResourceIds:e.claimResourceIds,valueDate:e.valueDate,postingRuleResourceId:e.postingRuleResourceId,includeReimbursementPayout:e.includeReimbursementPayout,bankAccountResourceIdOverride:e.bankAccountResourceIdOverride,contactResourceId:e.contactResourceId,idempotencyKey:e.idempotencyKey||Kwr()})},{name:"record_employee_payout",description:"Record a books-only employee payout (reimbursement or advance) \u2014 a DCE, no real-money transfer. amount, paymentAccountResourceId and valueDate are required; reference auto-generated if omitted.",params:{employeeResourceId:{type:"string",description:"Employee resourceId"},amount:{type:"number",description:"Payout amount (> 0)"},paymentAccountResourceId:{type:"string",description:"Bank/cash account the DCE credits"},valueDate:{type:"string",description:"Value date (YYYY-MM-DD)"},payoutFor:{type:"string",enum:[...bot],description:"Classification (null \u2192 ADVANCE)"},currencyCode:{type:"string",description:"Settle currency (ISO 4217; omit \u2192 payment account currency)"},reference:{type:"string",description:"Payout reference (auto-generated if omitted)"},description:{type:"string",description:"Line description on the DCE"},internalNotes:{type:"string",description:"Internal notes"}},required:["employeeResourceId","amount","paymentAccountResourceId","valueDate"],group:"claim_processing",readOnly:!1,searchHint:"record employee reimbursement advance payout books-only DCE",execute:async(t,e)=>L8(t.client,{employeeResourceId:e.employeeResourceId,amount:e.amount,paymentAccountResourceId:e.paymentAccountResourceId,valueDate:e.valueDate,payoutFor:e.payoutFor,currencyCode:e.currencyCode,reference:e.reference||ol("EP"),description:e.description,internalNotes:e.internalNotes})},Xt({name:"search_employee_payouts",description:"Search recorded employee payouts (reimbursements + advances).",group:"claim_processing",fields:iR,defaults:oR,fetcher:P8,searchHint:"find employee payouts reimbursements advances by employee reference status type"}),{name:"add_employee",description:"Create an employee (expense-claim member). The server requires userResourceId (a login user to bind \u2014 binding is PERMANENT) and claimProfileResourceId (REQUIRED \u2014 carries the employee balance account; the org default is NOT auto-applied). Dedups by email.",params:{name:{type:"string",description:"Employee display name"},userResourceId:{type:"string",description:"Login user's resourceId to bind \u2014 the userResourceId field from search_org_users, NOT the org-user record id (else EMPLOYEE_USER_NOT_FOUND). Required; permanent once set"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId \u2014 REQUIRED (carries the employee balance account; org default NOT auto-applied \u2192 EMPLOYEE_CLAIM_PROFILE_REQUIRED). search_claim_profiles"},email:{type:"string",description:"Work email (per-org unique)"},phone:{type:"string",description:"Phone (per-org unique)"},managerEmployeeResourceId:{type:"string",description:"Manager employee resourceId"},active:{type:"boolean",description:"Active flag (default true)"},employmentType:{type:"string",enum:[...kA],description:"Employment classification"}},required:["name","userResourceId","claimProfileResourceId"],group:"employees",readOnly:!1,searchHint:"create add employee claim member bind user",execute:async(t,e)=>{let r=e.email;if(r){let n=await aQ(t.client,r);if(n)return{_guard:"duplicate_skipped",message:`Employee with email "${r}" already exists.`,existing:n}}return G1(t.client,{name:e.name,userResourceId:e.userResourceId,claimProfileResourceId:e.claimProfileResourceId,email:r,phone:e.phone,managerEmployeeResourceId:e.managerEmployeeResourceId,active:e.active,employmentType:e.employmentType})}},{name:"update_employee",description:"Update an employee (partial; omit = no change). To ARCHIVE, set active=false (reversible \u2014 prefer over delete_employee). userResourceId is NOT editable here \u2014 use bind_employee_user. Set clearEmploymentType to unset the classification.",params:{resourceId:{type:"string",description:"Employee resourceId"},name:{type:"string",description:"New name"},email:{type:"string",description:'Work email ("" clears it)'},phone:{type:"string",description:"Phone"},managerEmployeeResourceId:{type:"string",description:"Manager employee resourceId"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId"},active:{type:"boolean",description:"Active flag \u2014 set false to archive"},employmentType:{type:"string",enum:[...kA],description:"Employment classification"},clearEmploymentType:{type:"boolean",description:"Clear the classification back to unclassified"}},required:["resourceId"],group:"employees",readOnly:!1,searchHint:"update edit archive employee active claim profile",execute:async(t,e)=>J1(t.client,e.resourceId,{name:e.name,email:e.email,phone:e.phone,managerEmployeeResourceId:e.managerEmployeeResourceId,claimProfileResourceId:e.claimProfileResourceId,active:e.active,employmentType:e.employmentType,clearEmploymentType:e.clearEmploymentType})},Xt({name:"search_employees",description:"Search employees by name, email, phone, manager, claim profile, active, currency.",group:"employees",fields:fR,defaults:pR,fetcher:lb,searchHint:"find employees claim members by name email manager profile active"}),Xt({name:"search_employee_balances",description:"Search the employee-balance directory (per-currency reimbursement balances owed).",group:"employees",fields:hR,defaults:mR,fetcher:H1,searchHint:"employee reimbursement balances owed by currency employment type"}),xi("get_employee","Get an employee incl. claim profile + user binding.","employees",(t,e)=>z1(t,e),"get employee details binding balance"),Xr("delete_employee","Delete an employee (server validates they are settled). Prefer update_employee active=false to archive reversibly.","employees",(t,e)=>V1(t,e),"delete remove employee"),{name:"bind_employee_user",description:"Bind a login user to an OFFLINE employee (one with no user bound yet \u2014 e.g. created via import without a binding email). ONE-WAY and PERMANENT: allowed only while unbound; rebind is blocked once set.",params:{resourceId:{type:"string",description:"Employee resourceId"},userResourceId:{type:"string",description:"Login user's resourceId \u2014 the userResourceId FIELD from search_org_users, NOT the org-user record id (else EMPLOYEE_USER_NOT_FOUND). One-way, permanent once set"}},required:["resourceId","userResourceId"],group:"employees",readOnly:!1,isDestructive:!0,searchHint:"bind link login user to employee",execute:async(t,e)=>W1(t.client,e.resourceId,e.userResourceId)},{name:"preprocess_employees_file",description:"Preprocess an uploaded employee import sheet (CSV/XLSX) \u2014 returns a parsed row preview to review before import_employees. Provide the sheet fileUrl.",params:{fileUrl:{type:"string",description:"URL of the uploaded employee sheet"},fileName:{type:"string",description:"Display file name"},fileType:{type:"string",enum:["CSV","EML","HEIC","JPEG","JPG","PDF","PNG","TEXT","XLS","XLSX"],description:"File type (use CSV / XLS / XLSX for employee sheets)"}},required:["fileUrl"],group:"employees",readOnly:!0,isConcurrencySafe:!0,searchHint:"preprocess preview employee import sheet csv xlsx",execute:async(t,e)=>Z1(t.client,{fileUrl:e.fileUrl,fileName:e.fileName,fileType:e.fileType})},{name:"import_employees",description:"Bulk create/update/delete employees from resolved rows (max 100 per array). Server validates rows synchronously (422 with row errors) then queues an async job \u2014 poll search_background_jobs by jobId. Create rows need a bound user + claim profile.",params:{create:{type:"array",description:"Create rows",items:{type:"object",properties:{name:{type:"string"},email:{type:"string"},userResourceId:{type:"string"},claimProfileResourceId:{type:"string"},employmentType:{type:"string",enum:[...kA]},managerEmployeeResourceId:{type:"string"},active:{type:"boolean"}},required:["name"]}},update:{type:"array",description:"Update rows",items:{type:"object",properties:{employeeResourceId:{type:"string"},name:{type:"string"},email:{type:"string"},employmentType:{type:"string",enum:[...kA]},active:{type:"boolean"}},required:["employeeResourceId"]}},delete:{type:"array",description:"Delete rows",items:{type:"object",properties:{employeeResourceId:{type:"string"}},required:["employeeResourceId"]}}},required:[],group:"employees",readOnly:!1,isDestructive:!0,searchHint:"bulk import employees create update delete sheet async",execute:async(t,e)=>X1(t.client,{create:e.create,update:e.update,delete:e.delete})},Ar("list_inventory_items","List inventory-tracked items with stock details, COGS accounts, and purchase/sale accounts.","inventory",(t,e,r)=>fG(t,{limit:r,offset:e}),"list inventory items stock levels quantities"),{name:"get_inventory_balance",description:"Get current inventory balance for a specific item \u2014 quantity on hand, average cost, base unit.",params:{itemResourceId:{type:"string",description:"Item resourceId"}},required:["itemResourceId"],group:"inventory",readOnly:!0,searchHint:"get inventory balance stock level for item",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>hG(t.client,e.itemResourceId)},{name:"create_inventory_item",description:"Create a new inventory-tracked item. Requires itemCode, name, unit, costingMethod (FIXED or WAC) and three account links. Use --input for full JSON body.",params:{itemCode:{type:"string",description:"Unique item code (SKU)"},name:{type:"string",description:"Item name"},unit:{type:"string",description:'Unit of measure, e.g. "pcs"'},costingMethod:{type:"string",enum:["FIXED","WAC"],description:"Costing method: FIXED or WAC"},cogsResourceId:{type:"string",description:"COGS account resourceId (Direct Costs type)"},purchaseAccountResourceId:{type:"string",description:"Purchase account resourceId (Inventory type)"},saleAccountResourceId:{type:"string",description:"Sale account resourceId"},blockInsufficientDeductions:{type:"boolean",description:"Block transactions when insufficient stock (default: false)"}},required:["itemCode","name","unit","costingMethod","cogsResourceId","purchaseAccountResourceId","saleAccountResourceId"],group:"inventory",readOnly:!1,searchHint:"create new inventory tracked stock item",execute:async(t,e)=>pG(t.client,{itemCode:e.itemCode,name:e.name,unit:e.unit,costingMethod:e.costingMethod,cogsResourceId:e.cogsResourceId,purchaseAccountResourceId:e.purchaseAccountResourceId,saleAccountResourceId:e.saleAccountResourceId,appliesToSale:!0,appliesToPurchase:!0,blockInsufficientDeductions:e.blockInsufficientDeductions??!1})},Xr("delete_contact","Delete a contact. Cannot delete contacts with existing transactions.","contacts",(t,e)=>WF(t,e),"permanently delete a customer supplier contact"),Xr("delete_account","Delete a chart of accounts entry. Cannot delete accounts with existing transactions.","accounts",(t,e)=>m1(t,e),"permanently delete a chart of accounts entry"),xi("get_cash_transfer","Get full cash transfer details by its cashflow-transaction resourceId (from search_cashflow_transactions), NOT the parentEntityResourceId create returns.","cash_transfers",(t,e)=>Lz(t,e),"get cash transfer details between accounts"),yk("download_credit_note_pdf","customer credit note","customer_credit_notes",(t,e)=>qU(t,e)),{name:"get_transaction_summary",description:`Get a complete summary of any transaction \u2014 fetches the transaction, its attachments, and payment history in one call.
836
+ - printOnDocuments controls whether the field appears on PDFs.`,params:{name:{type:"string",description:'Field name (e.g., "PO Number", "Cost Center")'},description:{type:"string",description:"Field description"},printOnDocuments:{type:"boolean",description:"Show on PDF documents (default false)"},appliesTo:{type:"object",description:"Which transaction types: { invoices: true, bills: true, customerCredits: true, supplierCredits: true, payments: true }"},format:fst},required:["name"],group:"custom_fields",readOnly:!1,searchHint:"create new custom field for transactions",execute:async(t,e)=>gG(t.client,{...e,printOnDocuments:e.printOnDocuments??!1})},{name:"update_custom_field",description:"Update a custom field definition. Omitted fields keep their current values.",params:{resourceId:{type:"string",description:"Custom field resourceId"},name:{type:"string",description:"New field name"},description:{type:"string",description:"New description"},printOnDocuments:{type:"boolean",description:"Show on PDF documents"},appliesTo:{type:"object",description:"Which transaction types: { invoices, bills, customerCredits, supplierCredits, payments }"},format:fst},required:["resourceId"],group:"custom_fields",readOnly:!1,searchHint:"update custom field name type settings",execute:async(t,e)=>{let{resourceId:r,...n}=e;return yG(t.client,r,n)}},Xr("delete_custom_field","Delete a custom field. Removes it from all future transactions.","custom_fields",(t,e)=>EG(t,e),"permanently delete a custom field definition"),{name:"list_withholding_tax_codes",description:"List withholding tax codes (industry classification codes for PH/SG compliance). Returns full list (no pagination).",params:{},required:[],group:"tax_profiles",readOnly:!0,searchHint:"list withholding tax WHT codes",isConcurrencySafe:!0,maxResultSizeChars:5e4,execute:async t=>v1(t.client)},Xt({name:"search_tax_profiles",description:"Search tax profiles. Use appliesToSale / appliesToPurchase filters to scope by transaction type.",group:"tax_profiles",fields:bR,defaults:CR,fetcher:ib,searchHint:"find tax profiles GST VAT WHT by name tax type code applicability sale purchase"}),xi("get_tax_profile","Get full tax profile details including tax rate, type code, and status.","tax_profiles",(t,e)=>d_(t,e),"get tax profile details rate code"),{name:"update_tax_profile",description:"Update an existing tax profile. Omitted fields keep their current values; status is not updatable.",params:{resourceId:{type:"string",description:"Tax profile resourceId"},name:Spe,description:{type:"string"},vatValue:{type:"number",description:"Tax rate % (0-100)"},taxType:{type:"string",description:"Tax type code (list_tax_types)"}},required:["resourceId"],group:"tax_profiles",readOnly:!1,searchHint:"update tax profile name rate details",execute:async(t,e)=>I1(t.client,e.resourceId,{name:e.name,description:e.description,vatValue:e.vatValue,taxType:e.taxType})},{name:"create_claim_type",description:"Create a claim type (expense category for employee claims). Dedups by name. expenseAccountResourceId is server-required.",params:{name:{type:"string",description:"Claim type name (unique per org)"},expenseAccountResourceId:{type:"string",description:'Expense CoA resourceId \u2014 REQUIRED server-side (search_accounts; accountType is a display label e.g. "Operating Expense")'},taxProfileResourceId:{type:"string",description:"Default tax profile resourceId"},classifierConfig:{type:"string",description:"Magic OCR classifier defaults (JSON string)"}},required:["name"],group:"claim_types",readOnly:!1,searchHint:"create claim type expense category",execute:async(t,e)=>{let r=e.name,n=await iQ(t.client,r);return n?{_guard:"duplicate_skipped",message:`Claim type "${r}" already exists.`,existing:n}:B1(t.client,{name:r,expenseAccountResourceId:e.expenseAccountResourceId,taxProfileResourceId:e.taxProfileResourceId,classifierConfig:e.classifierConfig})}},{name:"update_claim_type",description:"Update a claim type. Omitted fields unchanged; clearFields NULLs optional fields.",params:{resourceId:{type:"string",description:"Claim type resourceId"},name:{type:"string",description:"New name"},expenseAccountResourceId:{type:"string",description:"Default expense CoA resourceId"},taxProfileResourceId:{type:"string",description:"Default tax profile resourceId"},classifierConfig:{type:"string",description:"Classifier defaults (JSON string)"},clearFields:{type:"array",items:{type:"string",enum:[...h_]},description:"Optional fields to NULL (clear)"}},required:["resourceId"],group:"claim_types",readOnly:!1,searchHint:"update claim type",execute:async(t,e)=>k1(t.client,e.resourceId,{name:e.name,expenseAccountResourceId:e.expenseAccountResourceId,taxProfileResourceId:e.taxProfileResourceId,classifierConfig:e.classifierConfig,...zy(e.clearFields,h_)})},Xt({name:"search_claim_types",description:"Search claim types.",group:"claim_types",fields:sR,defaults:aR,fetcher:sb,searchHint:"find claim types by name default expense account tax profile"}),Ar("list_claim_types","List claim types (alphabetical).","claim_types",(t,e,r)=>T1(t,{offset:e,limit:r}),"list claim types"),xi("get_claim_type","Get a claim type incl. nested expense account + tax profile.","claim_types",(t,e)=>x1(t,e),"get claim type details"),Xr("delete_claim_type","Soft-delete a claim type (name becomes reusable).","claim_types",(t,e)=>N1(t,e),"delete claim type"),{name:"create_claim_profile",description:"Create a claim profile (per-employee policy bundle: approver, limits, visible types, balance account). Dedups by name. taxMode EXCLUSIVE is rejected.",params:{name:{type:"string",description:"Profile name (unique per org)"},approverUserResourceId:{type:"string",description:"Default approver user resourceId"},visibleClaimTypeIds:{type:"array",items:{type:"string"},description:"Allowed claim type IDs"},visibleTaxProfileIds:{type:"array",items:{type:"string"},description:"Allowed tax profile IDs"},visibleClassifierIds:{type:"array",items:{type:"string"},description:"Allowed classifier IDs"},visibleVendorResourceIds:{type:"array",items:{type:"string"},description:"Allowed vendor contact IDs (free-text vendors always allowed)"},allowedCurrencies:{type:"array",items:{type:"string"},description:"Allowed ISO currency codes (null = no restriction)"},minClaimAmount:{type:"number",description:"Min claim total (<= max)"},maxClaimAmount:{type:"number",description:"Max claim total"},maxPerPeriodAmount:{type:"number",description:"Per-period spend cap (requires perPeriod)"},perPeriod:{type:"string",enum:[...m_],description:"Per-period window"},employeeBalanceAccountResourceId:{type:"string",description:"Per-employee liability (CURRENT_LIABILITY) CoA resourceId; required for reimbursement conversion"},taxMode:{type:"string",enum:[...g6],description:"Tax policy (NO_TAX or INCLUSIVE)"}},required:["name"],group:"claim_profiles",readOnly:!1,searchHint:"create claim profile policy approver limits",execute:async(t,e)=>{let r=e.name,n=await oQ(t.client,r);return n?{_guard:"duplicate_skipped",message:`Claim profile "${r}" already exists.`,existing:n}:L1(t.client,{name:r,approverUserResourceId:e.approverUserResourceId,visibleClaimTypeIds:e.visibleClaimTypeIds,visibleTaxProfileIds:e.visibleTaxProfileIds,visibleClassifierIds:e.visibleClassifierIds,visibleVendorResourceIds:e.visibleVendorResourceIds,allowedCurrencies:e.allowedCurrencies,minClaimAmount:e.minClaimAmount,maxClaimAmount:e.maxClaimAmount,maxPerPeriodAmount:e.maxPerPeriodAmount,perPeriod:e.perPeriod,employeeBalanceAccountResourceId:e.employeeBalanceAccountResourceId,taxMode:e.taxMode})}},{name:"update_claim_profile",description:"Update a claim profile. Omitted fields unchanged; clearFields NULLs optional fields. Balance account cannot change while an employee has a non-zero balance.",params:{resourceId:{type:"string",description:"Claim profile resourceId"},name:{type:"string",description:"New name"},approverUserResourceId:{type:"string",description:"Default approver user resourceId"},visibleClaimTypeIds:{type:"array",items:{type:"string"},description:"Allowed claim type IDs (replaces)"},visibleTaxProfileIds:{type:"array",items:{type:"string"},description:"Allowed tax profile IDs (replaces)"},visibleClassifierIds:{type:"array",items:{type:"string"},description:"Allowed classifier IDs (replaces)"},visibleVendorResourceIds:{type:"array",items:{type:"string"},description:"Allowed vendor contact IDs (replaces)"},allowedCurrencies:{type:"array",items:{type:"string"},description:"Allowed ISO currency codes (replaces)"},minClaimAmount:{type:"number",description:"Min claim total"},maxClaimAmount:{type:"number",description:"Max claim total"},maxPerPeriodAmount:{type:"number",description:"Per-period spend cap"},perPeriod:{type:"string",enum:[...m_],description:"Per-period window"},employeeBalanceAccountResourceId:{type:"string",description:"Employee balance CoA resourceId"},taxMode:{type:"string",enum:[...g6],description:"Tax policy (NO_TAX or INCLUSIVE)"},clearFields:{type:"array",items:{type:"string",enum:[...A_]},description:"Optional fields to NULL (clear)"}},required:["resourceId"],group:"claim_profiles",readOnly:!1,searchHint:"update claim profile policy limits",execute:async(t,e)=>P1(t.client,e.resourceId,{name:e.name,approverUserResourceId:e.approverUserResourceId,visibleClaimTypeIds:e.visibleClaimTypeIds,visibleTaxProfileIds:e.visibleTaxProfileIds,visibleClassifierIds:e.visibleClassifierIds,visibleVendorResourceIds:e.visibleVendorResourceIds,allowedCurrencies:e.allowedCurrencies,minClaimAmount:e.minClaimAmount,maxClaimAmount:e.maxClaimAmount,maxPerPeriodAmount:e.maxPerPeriodAmount,perPeriod:e.perPeriod,employeeBalanceAccountResourceId:e.employeeBalanceAccountResourceId,taxMode:e.taxMode,...zy(e.clearFields,A_)})},Xt({name:"search_claim_profiles",description:"Search claim profiles.",group:"claim_profiles",fields:cR,defaults:lR,fetcher:ab,searchHint:"find claim profiles by name approver default limits balance account"}),Ar("list_claim_profiles","List claim profiles (alphabetical).","claim_profiles",(t,e,r)=>F1(t,{offset:e,limit:r}),"list claim profiles"),xi("get_claim_profile","Get a claim profile incl. nested balance account.","claim_profiles",(t,e)=>Q1(t,e),"get claim profile details"),Xr("delete_claim_profile","Soft-delete a claim profile.","claim_profiles",(t,e)=>M1(t,e),"delete claim profile"),{name:"create_posting_rule",description:"Create a posting rule (how approved claims group into journals at conversion). outerAxis + innerAxis + lineDescriptionTemplate required. Dedups by name.",params:{name:{type:"string",description:"Rule name (unique per org)"},outerAxis:{type:"string",enum:[...y_],description:"Outer grouping axis"},innerAxis:{type:"string",enum:[...E_],description:"Inner line-aggregation axis"},lineDescriptionTemplate:{type:"string",description:'Handlebars line template, e.g. "{employeeName} - {claimType}"'},journalReferenceTemplate:{type:"string",description:"Optional Handlebars journal-header reference template"},defaultBankAccountResourceId:{type:"string",description:"Default reimbursement bank (Cash/Bank) account resourceId"},defaultIncludeReimbursementPayout:{type:"boolean",description:"Create reimbursement DCE by default"},isDefault:{type:"boolean",description:"Make org default rule"}},required:["name","outerAxis","innerAxis","lineDescriptionTemplate"],group:"posting_rules",readOnly:!1,searchHint:"create posting rule claim conversion grouping",execute:async(t,e)=>{let r=e.name,n=await sQ(t.client,r);return n?{_guard:"duplicate_skipped",message:`Posting rule "${r}" already exists.`,existing:n}:q1(t.client,{name:r,outerAxis:e.outerAxis,innerAxis:e.innerAxis,lineDescriptionTemplate:e.lineDescriptionTemplate,journalReferenceTemplate:e.journalReferenceTemplate,defaultBankAccountResourceId:e.defaultBankAccountResourceId,defaultIncludeReimbursementPayout:e.defaultIncludeReimbursementPayout,isDefault:e.isDefault})}},{name:"update_posting_rule",description:"Update a posting rule. Omitted fields unchanged.",params:{resourceId:{type:"string",description:"Posting rule resourceId"},name:{type:"string",description:"New name"},outerAxis:{type:"string",enum:[...y_],description:"Outer grouping axis"},innerAxis:{type:"string",enum:[...E_],description:"Inner line-aggregation axis"},lineDescriptionTemplate:{type:"string",description:"Handlebars line template"},journalReferenceTemplate:{type:"string",description:"Journal-header reference template"},defaultBankAccountResourceId:{type:"string",description:"Default reimbursement bank account resourceId"},defaultIncludeReimbursementPayout:{type:"boolean",description:"Create reimbursement DCE by default"},isDefault:{type:"boolean",description:"Make org default rule"}},required:["resourceId"],group:"posting_rules",readOnly:!1,searchHint:"update posting rule",execute:async(t,e)=>j1(t.client,e.resourceId,{name:e.name,outerAxis:e.outerAxis,innerAxis:e.innerAxis,lineDescriptionTemplate:e.lineDescriptionTemplate,journalReferenceTemplate:e.journalReferenceTemplate,defaultBankAccountResourceId:e.defaultBankAccountResourceId,defaultIncludeReimbursementPayout:e.defaultIncludeReimbursementPayout,isDefault:e.isDefault})},Xt({name:"search_posting_rules",description:"Search posting rules.",group:"posting_rules",fields:uR,defaults:dR,fetcher:cb,searchHint:"find posting rules by name axis default bank reimbursement"}),Ar("list_posting_rules","List posting rules (alphabetical).","posting_rules",(t,e,r)=>U1(t,{offset:e,limit:r}),"list posting rules"),xi("get_posting_rule","Get a posting rule.","posting_rules",(t,e)=>$1(t,e),"get posting rule details"),Xr("delete_posting_rule","Delete a posting rule. The org default cannot be deleted while default (set another default first).","posting_rules",(t,e)=>Y1(t,e),"delete posting rule"),Xt({name:"search_claims",description:'Search/list employee-expense claims. Status: DRAFT|SUBMITTED|APPROVED|CONVERTED|REJECTED|CANCELLED (CONVERTED = "Processed"). Claims are born via create_claim, attachment, or conversion (no bare list \u2014 use search).',group:"claims",fields:rR,defaults:nR,fetcher:m2,searchHint:"find employee expense claims by status employee contact reference date amount"}),xi("get_claim","Get a claim incl. line items, employee, amounts, status.","claims",(t,e)=>A2(t,e),"get claim details line items"),{name:"create_claim",description:"Create an employee-expense claim directly (bare create, no attachment). Vendor is EITHER contactResourceId OR vendorName, never both. saveAsDraft defaults to true (lands DRAFT with relaxed line validation); set false to validate + submit in one call (lands SUBMITTED). reference is REQUIRED when submitting (saveAsDraft=false) \u2014 omitting it returns 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT; a DRAFT saves without one.",params:{valueDate:{type:"string",description:"Business-transaction date (YYYY-MM-DD)"},currencyCode:{type:"string",description:"Claim currency (ISO 4217)"},saveAsDraft:{type:"boolean",description:"true (default) creates DRAFT; false validates + submits"},employeeResourceId:{type:"string",description:"Employee resourceId the claim is filed for"},contactResourceId:{type:"string",description:"Vendor contact resourceId (mutually exclusive with vendorName)"},vendorName:{type:"string",description:"Free-text vendor name (mutually exclusive with contactResourceId)"},reference:{type:"string",description:"User reference"},autoReference:hd,currencySymbol:{type:"string",description:"Currency symbol override"},taxInclusion:{type:"boolean",description:"Line amounts are tax-inclusive"},tags:{type:"array",items:{type:"string"},description:"Header-level tags"},internalNotes:{type:"string",description:"Internal notes (max 1000)"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId (defaults to org default)"},approverUserResourceId:{type:"string",description:"Approver user resourceId"},customFields:Qi,claimItems:bst},required:["valueDate","currencyCode"],group:"claims",readOnly:!1,searchHint:"create new employee expense claim draft vendor employee line items submit",execute:async(t,e)=>g2(t.client,{valueDate:e.valueDate,currencyCode:e.currencyCode,saveAsDraft:e.saveAsDraft,employeeResourceId:e.employeeResourceId,contactResourceId:e.contactResourceId,vendorName:e.vendorName,reference:await $p(t.client,"CLAIM",e.reference,e.autoReference),currencySymbol:e.currencySymbol,taxInclusion:e.taxInclusion,tags:e.tags,internalNotes:e.internalNotes,claimProfileResourceId:e.claimProfileResourceId,approverUserResourceId:e.approverUserResourceId,customFields:e.customFields,claimItems:e.claimItems})},{name:"update_claim",description:"Update a DRAFT claim (partial \u2014 omitted fields unchanged). claimItems non-empty REPLACES all lines, [] clears. Set saveAsDraft=false to validate + submit in one call \u2014 reference is REQUIRED at submit (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT); a DRAFT save needs none. Only DRAFT claims are editable.",params:{resourceId:{type:"string",description:"Claim resourceId"},saveAsDraft:{type:"boolean",description:"true (default) keeps editing; false validates + submits"},employeeResourceId:{type:"string",description:"Employee resourceId"},contactResourceId:{type:"string",description:"Vendor contact resourceId (mutually exclusive with vendorName)"},vendorName:{type:"string",description:"Free-text vendor name (mutually exclusive with contactResourceId)"},valueDate:{type:"string",description:"Business-transaction date (YYYY-MM-DD)"},reference:{type:"string",description:"User reference"},currencyCode:{type:"string",description:"Claim currency (ISO 4217)"},taxInclusion:{type:"boolean",description:"Line amounts are tax-inclusive"},tags:{type:"array",items:{type:"string"},description:"Header-level tags"},internalNotes:{type:"string",description:"Internal notes (max 1000)"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId"},approverUserResourceId:{type:"string",description:"Approver user resourceId"},customFields:Qi,claimItems:bst},required:["resourceId"],group:"claims",readOnly:!1,searchHint:"edit draft claim line items employee reference submit",execute:async(t,e)=>y2(t.client,e.resourceId,{saveAsDraft:e.saveAsDraft,employeeResourceId:e.employeeResourceId,contactResourceId:e.contactResourceId,vendorName:e.vendorName,valueDate:e.valueDate,reference:e.reference,currencyCode:e.currencyCode,taxInclusion:e.taxInclusion,tags:e.tags,internalNotes:e.internalNotes,claimProfileResourceId:e.claimProfileResourceId,approverUserResourceId:e.approverUserResourceId,customFields:e.customFields,claimItems:e.claimItems})},Xr("delete_claim","Delete a claim. Only DRAFT / REJECTED / CANCELLED claims are deletable (else 422).","claims",(t,e)=>E2(t,e),"delete remove claim record"),{name:"delete_claim_attachment",description:"Remove one attachment (receipt) from a claim. Returns the updated claim.",params:{resourceId:{type:"string",description:"Claim resourceId"},attachmentResourceId:{type:"string",description:"Attachment resourceId"}},required:["resourceId","attachmentResourceId"],group:"claims",readOnly:!1,isDestructive:!0,searchHint:"remove delete claim attachment receipt",execute:async(t,e)=>b2(t.client,e.resourceId,e.attachmentResourceId)},Bpe("submit_claim","Submit a DRAFT claim for approval (DRAFT \u2192 SUBMITTED). Server enforces the transition. The claim must carry a reference \u2014 a referenceless DRAFT returns 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT (set it via update_claim first).","claims",(t,e)=>C2(t,e),{searchHint:"submit draft claim for approval"}),Bpe("approve_claim","Approve a SUBMITTED claim (SUBMITTED \u2192 APPROVED). Approved claims become convertible to journals.","claims",(t,e)=>I2(t,e),{searchHint:"approve submitted claim"}),{name:"reject_claim",description:"Reject a SUBMITTED/APPROVED claim with a reason (\u2192 REJECTED).",params:{resourceId:{type:"string",description:"Claim resourceId"},rejectionReason:{type:"string",description:"Rejection reason (1-1000 chars)"}},required:["resourceId","rejectionReason"],group:"claims",readOnly:!1,isDestructive:!0,searchHint:"reject claim with reason",execute:async(t,e)=>v2(t.client,e.resourceId,e.rejectionReason)},{name:"cancel_claim",description:"Cancel a DRAFT/SUBMITTED claim with a reason (\u2192 CANCELLED).",params:{resourceId:{type:"string",description:"Claim resourceId"},cancellationReason:{type:"string",description:"Cancellation reason (1-1000 chars)"}},required:["resourceId","cancellationReason"],group:"claims",readOnly:!1,isDestructive:!0,searchHint:"cancel claim with reason",execute:async(t,e)=>w2(t.client,e.resourceId,e.cancellationReason)},Bpe("unpost_claim","Unpost a CONVERTED claim \u2014 reverses the journal conversion back to APPROVED.","claims",(t,e)=>_2(t,e),{destructive:!0,searchHint:"unpost reverse converted claim conversion"}),{name:"bulk_submit_claims",description:"Bulk-submit DRAFT claims (ASYNC). Returns a job handle {jobId,...}; poll search_background_jobs by jobId for per-item results. Max 500 ids. Each claim must have a reference \u2014 referenceless claims fail per-item with CLAIM_REFERENCE_REQUIRED_AT_SUBMIT (check the job result).",params:{resourceIds:Ak},required:["resourceIds"],group:"claim_processing",readOnly:!1,searchHint:"bulk submit many claims async job",execute:async(t,e)=>D2(t.client,e.resourceIds)},{name:"bulk_approve_claims",description:"Bulk-approve SUBMITTED claims (ASYNC). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak},required:["resourceIds"],group:"claim_processing",readOnly:!1,searchHint:"bulk approve many claims async job",execute:async(t,e)=>S2(t.client,e.resourceIds)},{name:"bulk_reject_claims",description:"Bulk-reject claims with one shared reason (ASYNC). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak,rejectionReason:{type:"string",description:"Reason applied to the whole batch (1-1000 chars)"}},required:["resourceIds","rejectionReason"],group:"claim_processing",readOnly:!1,isDestructive:!0,searchHint:"bulk reject many claims async job reason",execute:async(t,e)=>T2(t.client,e.resourceIds,e.rejectionReason)},{name:"bulk_cancel_claims",description:"Bulk-cancel claims with one shared reason (ASYNC). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak,cancellationReason:{type:"string",description:"Reason applied to the whole batch (1-1000 chars)"}},required:["resourceIds","cancellationReason"],group:"claim_processing",readOnly:!1,isDestructive:!0,searchHint:"bulk cancel many claims async job reason",execute:async(t,e)=>x2(t.client,e.resourceIds,e.cancellationReason)},{name:"bulk_delete_claims",description:"Bulk-delete claims (ASYNC; only DRAFT/REJECTED/CANCELLED are deletable). Returns a job handle; poll search_background_jobs by jobId. Max 500 ids.",params:{resourceIds:Ak},required:["resourceIds"],group:"claim_processing",readOnly:!1,isDestructive:!0,searchHint:"bulk delete many claims async job",execute:async(t,e)=>R2(t.client,e.resourceIds)},{name:"get_claim_tracking_tags",description:"List the tracking-tag values available across claims (picker; returns a bare array).",params:{},required:[],group:"claim_processing",readOnly:!0,isConcurrencySafe:!0,searchHint:"list claim tracking tags picker",execute:async t=>B2(t.client)},{name:"get_claim_custom_field_values",description:"List the custom-field values available across claims (picker; returns a bare array).",params:{},required:[],group:"claim_processing",readOnly:!0,isConcurrencySafe:!0,searchHint:"list claim custom field values picker",execute:async t=>k2(t.client)},{name:"preview_claims_conversion",description:"Preview the journals an APPROVED claim batch would produce at conversion \u2014 no write. Returns expenseSubTotal, previewJournals, and reimbursement DCE counts; non-APPROVED claims come back under erroredClaims (check it is empty before converting). Needs a default posting rule or an explicit postingRuleResourceId.",params:{claimResourceIds:{type:"array",items:{type:"string"},description:"APPROVED claim resourceIds (1-500)"},postingRuleResourceId:{type:"string",description:"Posting rule resourceId (null \u2192 org default rule)"},payoutFlow:{type:"string",enum:[...KB],description:"POST (journals only) or POST_AND_RECORD (+ books-only reimbursement DCE)"},includeReimbursementPayout:{type:"boolean",description:"Include per-employee reimbursement DCE lines"},bankAccountResourceId:{type:"string",description:"Reimbursement bank account for preview validation"}},required:["claimResourceIds"],group:"claim_processing",readOnly:!0,isConcurrencySafe:!0,searchHint:"preview claim conversion journals before posting",execute:async(t,e)=>F8(t.client,{claimResourceIds:e.claimResourceIds,postingRuleResourceId:e.postingRuleResourceId,payoutFlow:e.payoutFlow,includeReimbursementPayout:e.includeReimbursementPayout,bankAccountResourceId:e.bankAccountResourceId})},{name:"convert_claims_to_journal",description:"Convert an APPROVED claim batch into journals (atomic write). valueDate (YYYY-MM-DD) required. Preview first and confirm erroredClaims is empty. idempotencyKey is auto-generated for safe retries (pass your own to dedup across calls). includeReimbursementPayout adds a books-only reimbursement DCE \u2014 real-money disburse is intentionally not exposed.",params:{claimResourceIds:{type:"array",items:{type:"string"},description:"APPROVED claim resourceIds (1-500)"},valueDate:{type:"string",description:"Journal value date (YYYY-MM-DD)"},postingRuleResourceId:{type:"string",description:"Posting rule resourceId (null \u2192 org default rule)"},includeReimbursementPayout:{type:"boolean",description:"Create books-only reimbursement DCEs"},bankAccountResourceIdOverride:{type:"string",description:"Override the rule default reimbursement bank account"},contactResourceId:{type:"string",description:"Clearing contact for the reimbursement DCE cash-out"},idempotencyKey:{type:"string",description:"Optional retry-dedup token (must not start with CONV: / CONV-); auto-generated if omitted"}},required:["claimResourceIds","valueDate"],group:"claim_processing",readOnly:!1,searchHint:"convert post approved claims to journal entries",execute:async(t,e)=>Q8(t.client,{claimResourceIds:e.claimResourceIds,valueDate:e.valueDate,postingRuleResourceId:e.postingRuleResourceId,includeReimbursementPayout:e.includeReimbursementPayout,bankAccountResourceIdOverride:e.bankAccountResourceIdOverride,contactResourceId:e.contactResourceId,idempotencyKey:e.idempotencyKey||Kwr()})},{name:"record_employee_payout",description:"Record a books-only employee payout (reimbursement or advance) \u2014 a DCE, no real-money transfer. amount, paymentAccountResourceId and valueDate are required; reference auto-generated if omitted.",params:{employeeResourceId:{type:"string",description:"Employee resourceId"},amount:{type:"number",description:"Payout amount (> 0)"},paymentAccountResourceId:{type:"string",description:"Bank/cash account the DCE credits"},valueDate:{type:"string",description:"Value date (YYYY-MM-DD)"},payoutFor:{type:"string",enum:[...bot],description:"Classification (null \u2192 ADVANCE)"},currencyCode:{type:"string",description:"Settle currency (ISO 4217; omit \u2192 payment account currency)"},reference:{type:"string",description:"Payout reference (auto-generated if omitted)"},description:{type:"string",description:"Line description on the DCE"},internalNotes:{type:"string",description:"Internal notes"}},required:["employeeResourceId","amount","paymentAccountResourceId","valueDate"],group:"claim_processing",readOnly:!1,searchHint:"record employee reimbursement advance payout books-only DCE",execute:async(t,e)=>L8(t.client,{employeeResourceId:e.employeeResourceId,amount:e.amount,paymentAccountResourceId:e.paymentAccountResourceId,valueDate:e.valueDate,payoutFor:e.payoutFor,currencyCode:e.currencyCode,reference:e.reference||ol("EP"),description:e.description,internalNotes:e.internalNotes})},Xt({name:"search_employee_payouts",description:"Search recorded employee payouts (reimbursements + advances).",group:"claim_processing",fields:iR,defaults:oR,fetcher:P8,searchHint:"find employee payouts reimbursements advances by employee reference status type"}),{name:"add_employee",description:"Create an employee (expense-claim member). The server requires userResourceId (a login user to bind \u2014 binding is PERMANENT) and claimProfileResourceId (REQUIRED \u2014 carries the employee balance account; the org default is NOT auto-applied). Dedups by email.",params:{name:{type:"string",description:"Employee display name"},userResourceId:{type:"string",description:"Login user's resourceId to bind \u2014 the userResourceId field from search_org_users, NOT the org-user record id (else EMPLOYEE_USER_NOT_FOUND). Required; permanent once set"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId \u2014 REQUIRED (carries the employee balance account; org default NOT auto-applied \u2192 EMPLOYEE_CLAIM_PROFILE_REQUIRED). search_claim_profiles"},email:{type:"string",description:"Work email (per-org unique)"},phone:{type:"string",description:"Phone (per-org unique)"},managerEmployeeResourceId:{type:"string",description:"Manager employee resourceId"},active:{type:"boolean",description:"Active flag (default true)"},employmentType:{type:"string",enum:[...kA],description:"Employment classification"}},required:["name","userResourceId","claimProfileResourceId"],group:"employees",readOnly:!1,searchHint:"create add employee claim member bind user",execute:async(t,e)=>{let r=e.email;if(r){let n=await aQ(t.client,r);if(n)return{_guard:"duplicate_skipped",message:`Employee with email "${r}" already exists.`,existing:n}}return G1(t.client,{name:e.name,userResourceId:e.userResourceId,claimProfileResourceId:e.claimProfileResourceId,email:r,phone:e.phone,managerEmployeeResourceId:e.managerEmployeeResourceId,active:e.active,employmentType:e.employmentType})}},{name:"update_employee",description:"Update an employee (partial; omit = no change). To ARCHIVE, set active=false (reversible \u2014 prefer over delete_employee). userResourceId is NOT editable here \u2014 use bind_employee_user. Set clearEmploymentType to unset the classification.",params:{resourceId:{type:"string",description:"Employee resourceId"},name:{type:"string",description:"New name"},email:{type:"string",description:'Work email ("" clears it)'},phone:{type:"string",description:"Phone"},managerEmployeeResourceId:{type:"string",description:"Manager employee resourceId"},claimProfileResourceId:{type:"string",description:"Claim profile resourceId"},active:{type:"boolean",description:"Active flag \u2014 set false to archive"},employmentType:{type:"string",enum:[...kA],description:"Employment classification"},clearEmploymentType:{type:"boolean",description:"Clear the classification back to unclassified"}},required:["resourceId"],group:"employees",readOnly:!1,searchHint:"update edit archive employee active claim profile",execute:async(t,e)=>J1(t.client,e.resourceId,{name:e.name,email:e.email,phone:e.phone,managerEmployeeResourceId:e.managerEmployeeResourceId,claimProfileResourceId:e.claimProfileResourceId,active:e.active,employmentType:e.employmentType,clearEmploymentType:e.clearEmploymentType})},Xt({name:"search_employees",description:"Search employees by name, email, phone, manager, claim profile, active, currency.",group:"employees",fields:fR,defaults:pR,fetcher:lb,searchHint:"find employees claim members by name email manager profile active"}),Xt({name:"search_employee_balances",description:"Search the employee-balance directory (per-currency reimbursement balances owed).",group:"employees",fields:hR,defaults:mR,fetcher:H1,searchHint:"employee reimbursement balances owed by currency employment type"}),xi("get_employee","Get an employee incl. claim profile + user binding.","employees",(t,e)=>z1(t,e),"get employee details binding balance"),Xr("delete_employee","Delete an employee (server validates they are settled). Prefer update_employee active=false to archive reversibly.","employees",(t,e)=>V1(t,e),"delete remove employee"),{name:"bind_employee_user",description:"Bind a login user to an OFFLINE employee (one with no user bound yet \u2014 e.g. created via import without a binding email). ONE-WAY and PERMANENT: allowed only while unbound; rebind is blocked once set.",params:{resourceId:{type:"string",description:"Employee resourceId"},userResourceId:{type:"string",description:"Login user's resourceId \u2014 the userResourceId FIELD from search_org_users, NOT the org-user record id (else EMPLOYEE_USER_NOT_FOUND). One-way, permanent once set"}},required:["resourceId","userResourceId"],group:"employees",readOnly:!1,isDestructive:!0,searchHint:"bind link login user to employee",execute:async(t,e)=>W1(t.client,e.resourceId,e.userResourceId)},{name:"preprocess_employees_file",description:"Preprocess an uploaded employee import sheet (CSV/XLSX) \u2014 returns a parsed row preview to review before import_employees. Provide the sheet fileUrl.",params:{fileUrl:{type:"string",description:"URL of the uploaded employee sheet"},fileName:{type:"string",description:"Display file name"},fileType:{type:"string",enum:["CSV","EML","HEIC","JPEG","JPG","PDF","PNG","TEXT","XLS","XLSX"],description:"File type (use CSV / XLS / XLSX for employee sheets)"}},required:["fileUrl"],group:"employees",readOnly:!0,isConcurrencySafe:!0,searchHint:"preprocess preview employee import sheet csv xlsx",execute:async(t,e)=>Z1(t.client,{fileUrl:e.fileUrl,fileName:e.fileName,fileType:e.fileType})},{name:"import_employees",description:"Bulk create/update/delete employees from resolved rows (max 100 per array). Server validates rows synchronously (422 with row errors) then queues an async job \u2014 poll search_background_jobs by jobId. Create rows need a bound user + claim profile.",params:{create:{type:"array",description:"Create rows",items:{type:"object",properties:{name:{type:"string"},email:{type:"string"},userResourceId:{type:"string"},claimProfileResourceId:{type:"string"},employmentType:{type:"string",enum:[...kA]},managerEmployeeResourceId:{type:"string"},active:{type:"boolean"}},required:["name"]}},update:{type:"array",description:"Update rows",items:{type:"object",properties:{employeeResourceId:{type:"string"},name:{type:"string"},email:{type:"string"},employmentType:{type:"string",enum:[...kA]},active:{type:"boolean"}},required:["employeeResourceId"]}},delete:{type:"array",description:"Delete rows",items:{type:"object",properties:{employeeResourceId:{type:"string"}},required:["employeeResourceId"]}}},required:[],group:"employees",readOnly:!1,isDestructive:!0,searchHint:"bulk import employees create update delete sheet async",execute:async(t,e)=>X1(t.client,{create:e.create,update:e.update,delete:e.delete})},Ar("list_inventory_items","List inventory-tracked items with stock details, COGS accounts, and purchase/sale accounts.","inventory",(t,e,r)=>fG(t,{limit:r,offset:e}),"list inventory items stock levels quantities"),{name:"get_inventory_balance",description:"Get current inventory balance for a specific item \u2014 quantity on hand, average cost, base unit.",params:{itemResourceId:{type:"string",description:"Item resourceId"}},required:["itemResourceId"],group:"inventory",readOnly:!0,searchHint:"get inventory balance stock level for item",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>hG(t.client,e.itemResourceId)},{name:"create_inventory_item",description:"Create a new inventory-tracked item. Requires itemCode, name, unit, costingMethod (FIXED or WAC) and three account links. Use --input for full JSON body.",params:{itemCode:{type:"string",description:"Unique item code (SKU)"},name:{type:"string",description:"Item name"},unit:{type:"string",description:'Unit of measure, e.g. "pcs"'},costingMethod:{type:"string",enum:["FIXED","WAC"],description:"Costing method: FIXED or WAC"},cogsResourceId:{type:"string",description:"COGS account resourceId (Direct Costs type)"},purchaseAccountResourceId:{type:"string",description:"Purchase account resourceId (Inventory type)"},saleAccountResourceId:{type:"string",description:"Sale account resourceId"},blockInsufficientDeductions:{type:"boolean",description:"Block transactions when insufficient stock (default: false)"}},required:["itemCode","name","unit","costingMethod","cogsResourceId","purchaseAccountResourceId","saleAccountResourceId"],group:"inventory",readOnly:!1,searchHint:"create new inventory tracked stock item",execute:async(t,e)=>pG(t.client,{itemCode:e.itemCode,name:e.name,unit:e.unit,costingMethod:e.costingMethod,cogsResourceId:e.cogsResourceId,purchaseAccountResourceId:e.purchaseAccountResourceId,saleAccountResourceId:e.saleAccountResourceId,appliesToSale:!0,appliesToPurchase:!0,blockInsufficientDeductions:e.blockInsufficientDeductions??!1})},Xr("delete_contact","Delete a contact. Cannot delete contacts with existing transactions.","contacts",(t,e)=>WF(t,e),"permanently delete a customer supplier contact"),Xr("delete_account","Delete a chart of accounts entry. Cannot delete accounts with existing transactions.","accounts",(t,e)=>m1(t,e),"permanently delete a chart of accounts entry"),xi("get_cash_transfer","Get full cash transfer details by its cashflow-transaction resourceId (from search_cashflow_transactions), NOT the parentEntityResourceId create returns.","cash_transfers",(t,e)=>Lz(t,e),"get cash transfer details between accounts"),yk("download_credit_note_pdf","customer credit note","customer_credit_notes",(t,e)=>qU(t,e)),{name:"get_transaction_summary",description:`Get a complete summary of any transaction \u2014 fetches the transaction, its attachments, and payment history in one call.
837
837
  Works for invoices, bills, customer credit notes, supplier credit notes, and journals. Invoices and bills carry payments, credit notes refunds, journals neither. A failed leg omits its keys and is named in 'partialFailures'.`,params:{transactionType:{type:"string",enum:["invoice","bill","customer_credit_note","supplier_credit_note","journal"],description:"Transaction type"},resourceId:{type:"string",description:"Transaction resourceId"}},required:["transactionType","resourceId"],group:"search",readOnly:!0,searchHint:"transaction summary attachments payments refunds",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>{let r=e.resourceId,n=Fst[e.transactionType]??Fst.journal,[i,o,s]=await Promise.allSettled([n.get(t.client,r),li(t.client,n.attachType,r),n.settlements?n.settlements(t.client,r):Promise.resolve(void 0)]);if(i.status==="rejected")throw i.reason;let a=p=>{let h=p.reason instanceof Error?p.reason.message:typeof p.reason=="string"?p.reason:(()=>{try{return JSON.stringify(p.reason)??"unknown error"}catch{return"unknown error"}})();return h.length>300?`${h.slice(0,297)}...`:h},c=[];o.status==="rejected"&&c.push(`attachments: ${a(o)}`),s.status==="rejected"&&c.push(`${n.settlementKey}: ${a(s)}`);let u=p=>Array.isArray(p)?p:Array.isArray(p?.data)?p.data:void 0,d=o.status==="fulfilled"?u(o.value):void 0,f=s.status==="fulfilled"?u(s.value):void 0;return{...c.length?{partialFailures:c}:{},transaction:i.value.data,...d?{attachments:d,attachmentCount:d.length}:{},...f?{[n.settlementKey]:f,[n.settlementCountKey]:f.length}:{}}}},{name:"bulk_finalize_drafts",description:"Finalize multiple draft transactions in one call. Attempts finalization for each item and returns per-item pass/fail results. Supports invoices, bills, and credit notes.",params:{items:{type:"array",items:{type:"object",properties:{type:{type:"string",enum:["invoice","bill","customer_credit_note","supplier_credit_note"],description:"Transaction type"},resourceId:{type:"string",description:"Transaction resourceId"}},required:["type","resourceId"]},description:"Array of {type, resourceId} to finalize"}},required:["items"],group:"drafts",readOnly:!1,searchHint:"bulk finalize approve multiple draft transactions",isDestructive:!0,execute:async(t,e)=>{let r=e.items,n=[];for(let i of r)try{let o=await Ek(t.client,i.type,i.resourceId,{});i.type==="invoice"?await QR(t.client,i.resourceId,o):i.type==="bill"?await r_(t.client,i.resourceId,o):i.type==="customer_credit_note"?await zR(t.client,i.resourceId,o):i.type==="supplier_credit_note"&&await ZR(t.client,i.resourceId,o),n.push({...i,success:!0})}catch(o){n.push({...i,success:!1,error:o instanceof Error?o.message:String(o)})}return{total:r.length,succeeded:n.filter(i=>i.success).length,failed:n.filter(i=>!i.success).length,results:n}}},{name:"bulk_invite_org_users",description:"Invite multiple users to the organization in one call. Accepts an array of user objects. Each user follows the same contract as invite_org_user. Returns per-user pass/fail results.",params:{users:{type:"array",items:{type:"object",properties:{email:{type:"string",description:"User email"},firstName:{type:"string",description:"First name"},lastName:{type:"string",description:"Last name"},userType:{type:"string",enum:[...dg],description:"ADMIN = full access (moduleRoles ignored). CUSTOM_USER = per-module access via moduleRoles."},moduleRoles:{type:"array",items:{type:"object",properties:{moduleName:{type:"string",enum:[...IC]},roleCode:{type:"string",enum:[...ug]}},required:["moduleName","roleCode"]},description:"Use when userType is CUSTOM_USER; ignored for ADMIN."}},required:["email","firstName","lastName","userType"]},description:"Array of users to invite"}},required:["users"],group:"org_users",readOnly:!1,searchHint:"bulk invite multiple users to organization",execute:async(t,e)=>{let r=e.users,n=[];for(let i of r)try{qd({userType:i.userType,moduleRoles:i.moduleRoles});let o=await o0(t.client,i);n.push({email:i.email,success:!0,resourceId:o.data?.resourceId})}catch(o){n.push({email:i.email,success:!1,error:o instanceof Error?o.message:String(o)})}return{total:r.length,succeeded:n.filter(i=>i.success).length,failed:n.filter(i=>!i.success).length,results:n}}},{name:"bulk_create_contacts",description:`Create multiple contacts in one call. Deduplicates against existing contacts (exact name match).
838
838
  Returns per-contact result: created, skipped (duplicate), or failed.`,params:{contacts:{type:"array",items:{type:"object",properties:{billingName:{type:"string",description:"Official billing name"},name:{type:"string",description:"Display name"},email:{type:"string",description:"Primary email"},customer:{type:"boolean",description:"Is a customer"},supplier:{type:"boolean",description:"Is a supplier"}},required:["billingName"]},description:"Array of contacts to create"},skipDuplicates:{type:"boolean",description:"Skip contacts that match existing names (default true)"}},required:["contacts"],group:"contacts",readOnly:!1,searchHint:"bulk create multiple customer supplier contacts",execute:async(t,e)=>{let r=e.contacts,n=e.skipDuplicates??!0,i=[];for(let o of r)try{if(n){let a=await v_(t.client,o.name??o.billingName);if(a){i.push({billingName:o.billingName,status:"skipped",resourceId:a.resourceId});continue}}let s=await GE(t.client,{billingName:o.billingName,name:o.name??o.billingName,emails:o.email?[o.email]:void 0,customer:o.customer??!0,supplier:o.supplier??!1});i.push({billingName:o.billingName,status:"created",resourceId:s.data.resourceId})}catch(s){i.push({billingName:o.billingName,status:"failed",error:s instanceof Error?s.message:String(s)})}return{total:r.length,created:i.filter(o=>o.status==="created").length,skipped:i.filter(o=>o.status==="skipped").length,failed:i.filter(o=>o.status==="failed").length,results:i}}},{name:"quick_fix_transactions",description:`Bulk-update transactions of the same type. Only included fields change; omitted fields preserved.
839
839
 
@@ -1073,7 +1073,7 @@ clio() {
1073
1073
  `))}process.exit(1)}await ZR(o,n,d);let y=(await Va(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(j(`
1074
1074
  \u2713 Supplier credit note finalized: ${y.reference||y.resourceId}`)),console.log(R(" Status:"),y.status),C.length>0&&console.log(R(" Updated:"),C.join(", "))),Ce(o,"finalize_supplier_credit_note",i,y)})(i)),r.command("attachments <resourceId>").description("List attachments for a supplier credit note (URLs for agent inspection)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((n,i)=>F(async o=>{let a=(await Va(o,n)).data,u=(await li(o,"supplier-credit-notes",n)).data;if(i.json)console.log(JSON.stringify({creditNoteResourceId:n,creditNoteReference:a.reference||null,attachments:u},null,2));else{if(u.length===0){console.log(`No attachments for supplier credit note ${a.reference||n}.`);return}console.log(R(`Attachments for ${a.reference||n}:
1075
1075
  `));for(let d of u)console.log(` ${_e(d.resourceId)} ${d.fileName||"(unnamed)"}`),d.fileUrl&&console.log(` ${M(d.fileUrl)}`)}})(i)),e.command("bulk-upsert").description("Create or update supplier credit notes in bulk (max 500). Natural key: creditNoteReference. Returns a jobId \u2014 poll with `clio background-jobs get <jobId>`.").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(F(async(n,i)=>{let o=be(i);o||(console.error('Error: --input <file> is required (JSON with { "supplierCreditNotes": [...] } or a bare array)'),process.exit(1));let s=o.supplierCreditNotes??o;Array.isArray(s)||(console.error('Error: expected { "supplierCreditNotes": [...] }'),process.exit(1)),Qt(s,"supplierCreditNotes",500,"supplier credit notes");let a=await VU(n,s);i.json?console.log(JSON.stringify(a.data,null,2)):(console.log(j(`Bulk upsert started. Job ID: ${a.data.jobId}`)),console.log(_e(` Poll progress: clio background-jobs get ${a.data.jobId}`)))}))}Ne();r$();ct();Jt();var act=[{key:"currencyCode",header:"Code"},{key:"currencyName",header:"Name"},{key:"currencySymbol",header:"Symbol"},{key:"baseCurrency",header:"Base"}];function cct(t){let e=t.command("currencies").description("Manage organization currencies");e.command("list").description("List enabled currencies for the organization").option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await eT(r),o={data:i.data,totalElements:i.data.length,totalPages:1,truncated:!1};Ke(o,act,n,"Currencies")})),e.command("add <codes...>").description("Add currencies to the organization (e.g. clio currencies add EUR GBP)").option("--jot <text>",ve).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)=>F(async i=>{let o=r.map(a=>a.toUpperCase()),s=await ZU(i,o);if(n.json||n.format){let a=Array.isArray(s.data)?s.data:[s.data],c={data:a,totalElements:a.length,totalPages:1,truncated:!1};Ke(c,act,n,"Currencies")}else console.log(j(`Added currencies: ${o.join(", ")}`));Ce(i,"add_currency",n,s.data)})(n))}En();r$();ct();Jt();Ot();Ne();It();ln();cr();function lct(t){return t.rate===void 0?"unchanged":t.rateDirection!=="SOURCE_TO_FUNCTIONAL"?String(t.rate):`${Ap(1/t.rate)} (from ${Ap(t.rate)} SOURCE_TO_FUNCTIONAL)`}var ahe=[{key:"resourceId",header:"ID",format:Be},{key:"rateFunctionalToSource",header:"Rate (1 base = N)"},{key:"rateSourceToFunctional",header:"Inverse (1 N = base)"},{key:"rateApplicableFrom",header:"From"},{key:"rateApplicableTo",header:"To"}];function uct(t){let e=t.command("currency-rates").description("Manage currency exchange rates");e.command("list <currencyCode>").description("List exchange rates for a currency").option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he).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)=>F(async i=>{let o=r.toUpperCase(),s=await st(n,a=>XU(i,o,a),{label:`Fetching ${o} rates`});Ke(s,ahe,n,`${o} Rates`)})(n)),e.command("add <currencyCode>").description("Add an exchange rate for a currency").option("--jot <text>",ve).option("--rate <number>","Exchange rate \u2014 base\u2192source (1 org-base unit = N of this currency) unless --rate-direction says otherwise",cs).option(eo,Ls,to).option("--from <YYYY-MM-DD>","Rate applicable from date").option("--to <YYYY-MM-DD>","Rate applicable to date (optional)").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)=>F(async i=>{Le(n,[{flag:"--rate",key:"rate"},{flag:"--from",key:"from"}]);let o=r.toUpperCase(),s={rate:n.rate,rateDirection:n.rateDirection,rateApplicableFrom:n.from};n.to&&(s.rateApplicableTo=n.to);let a=await KU(i,o,s);if(n.json||n.format){let c={data:[a.data],totalElements:1,totalPages:1,truncated:!1};Ke(c,ahe,n,`${o} Rates`)}else console.log(j(`Rate added for ${o}: ${lct(n)} (from ${n.from})`));Ce(i,"add_currency_rate",n,a.data)})(n)),e.command("update <currencyCode> <rateResourceId>").description("Update an exchange rate").option("--jot <text>",ve).option("--rate <number>","Exchange rate \u2014 base\u2192source (1 org-base unit = N of this currency) unless --rate-direction says otherwise",cs).option(eo,Ls,to).option("--from <YYYY-MM-DD>","Rate applicable from date").option("--to <YYYY-MM-DD>","Rate applicable to date (optional)").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,i)=>F(async o=>{Le(i,[{flag:"--rate",key:"rate"},{flag:"--from",key:"from"}]);let s=r.toUpperCase(),a={rate:i.rate,rateDirection:i.rateDirection,rateApplicableFrom:i.from};i.to&&(a.rateApplicableTo=i.to);let c=await e$(o,s,n,a);if(i.json||i.format){let u={data:[c.data],totalElements:1,totalPages:1,truncated:!1};Ke(u,ahe,i,`${s} Rates`)}else console.log(j(`Rate updated for ${s}: ${lct(i)}`));Ce(o,"update_currency_rate",i,c.data)})(i)),e.command("bulk-upsert").description("Create exchange rates in bulk (max 500). Auto-enables currencies not yet in the org.").option("--jot <text>",ve).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(F(async(r,n)=>{let i=be(n);i||(console.error('Error: --input <file> is required (JSON with { "rates": [...] })'),process.exit(1));let o=i.rates??i;Array.isArray(o)||(console.error('Error: expected { "rates": [...] } or a JSON array'),process.exit(1)),Qt(o,"rates",500);let s=await t$(r,o);if(n.json)console.log(JSON.stringify(s.data,null,2));else{let a=s.data.resourceIds??[];console.log(j(`${a.length} rate(s) upserted.`)),a.forEach(c=>console.log(` ${c}`))}Ce(r,"bulk_upsert_currency_rates",n,s.data)}))}Bm();ct();import{readFileSync as gDr}from"node:fs";import{basename as dct,extname as yDr,resolve as EDr}from"node:path";Jt();Ot();Ne();var bDr=[{key:"resourceId",header:"ID",format:Be},{key:"fileName",header:"File Name"}],Jf=["invoices","bills","journals","scheduled_journals","customer-credit-notes","supplier-credit-notes","sale-quotes","sale-orders","purchase-requests","purchase-orders"],CDr={".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".csv":"text/csv",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};function fct(t){let e=t.command("attachments").description("Manage transaction attachments");e.command("list").description("List attachments for a transaction").requiredOption("--type <type>",`Transaction type (${Jf.join(", ")})`).requiredOption("--id <resourceId>","Transaction resourceId").option("--api-key <key>","API key").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=n.type;Jf.includes(i)||(console.error(ne(`Invalid type. Use one of: ${Jf.join(", ")}`)),process.exit(1));let o=await li(r,i,n.id),s=o.data??[],a={data:s,totalElements:o.totalElements??s.length,totalPages:o.totalPages??1,truncated:o.truncated??!1};Ke(a,bDr,n,"Attachments")})),e.command("add").description("Add an attachment to a transaction (file upload or URL download)").option("--jot <text>",ve).requiredOption("--type <type>",`Transaction type (${Jf.join(", ")})`).requiredOption("--id <resourceId>","Transaction resourceId").option("--file <path>","Local file path (PDF, PNG, JPG, etc.)").option("--url <url>","Download file from URL and attach").option("--attachment-id <id>","Link existing attachment by ID").option("--api-key <key>","API key").option("--json","Output as JSON").action(F(async(r,n)=>{let i=n.type;Jf.includes(i)||(console.error(ne(`Invalid type. Use one of: ${Jf.join(", ")}`)),process.exit(1)),!n.attachmentId&&!n.url&&!n.file&&(console.error(ne("Provide --file, --url, or --attachment-id")),process.exit(1)),n.attachmentId&&k8.includes(i)&&(console.error(ne(`link-by-id (--attachment-id) is not supported for order documents (${i}). Use --file or --url instead.`)),process.exit(1));let o,s;if(n.file){let c=EDr(n.file),u=yDr(c).toLowerCase(),d=CDr[u]??"application/octet-stream",f=gDr(c);o=new Blob([f],{type:d}),s=dct(c)}else if(n.url){let c=await fetch(n.url);c.ok||(console.error(ne(`Failed to download: ${c.status} ${c.statusText}`)),process.exit(1));let u=await c.arrayBuffer(),d=c.headers.get("content-type")??"application/octet-stream";o=new Blob([u],{type:d});let f=new URL(n.url).pathname;s=dct(f)||"attachment"}let a=await N8(r,{businessTransactionType:i,businessTransactionResourceId:n.id,file:o,fileName:s,attachmentId:n.attachmentId});n.json?console.log(JSON.stringify(a,null,2)):console.log(j("Attachment added.")),Ce(r,"add_attachment",n,a.data)})),e.command("delete").description("Delete an attachment from a transaction").option("--jot <text>",ve).requiredOption("--type <type>",`Transaction type (${Jf.join(", ")})`).requiredOption("--id <resourceId>","Transaction resourceId").argument("<attachmentResourceId>","Attachment resourceId to delete").option("--api-key <key>","API key").option("--json","Output as JSON").action((r,n)=>{let i=n.type;return Jf.includes(i)||(console.error(ne(`Invalid type. Use one of: ${Jf.join(", ")}`)),process.exit(1)),F(async o=>{let s=await O8(o,i,n.id,r);n.json?console.log(JSON.stringify(s,null,2)):console.log(j("Attachment deleted.")),Ce(o,"delete_attachment",n,{resourceId:r})})(n)})}Ne();f_();cr();ct();It();ln();Jt();Ot();lr();var pct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"taxRate",header:"Rate (%)"},{key:"taxTypeCode",header:"Tax Type"}],IDr=[{key:"code",header:"Code"},{key:"name",header:"Name"}];function hct(t){let e=t.command("tax-profiles").description("Manage tax profiles and tax types");e.command("list").description("List tax profiles").option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await st(n,o=>nb(r,o),{label:"Fetching tax profiles"});Ke(i,pct,n,"Tax Profiles")})),e.command("types").description("List available tax types (GST, VAT, WHT, etc.)").option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await st(n,o=>b1(r,o),{label:"Fetching tax types"});Ke(i,IDr,n,"Tax Types")})),e.command("get <resourceId>").description("Get a tax profile by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await d_(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Rate:"),`${s.taxRate}%`),console.log(R("Tax Type:"),s.taxTypeCode))})(n)),je({parent:e,fields:bR,defaults:CR,fetcher:ib,columns:pct,label:"Searching tax profiles"}),e.command("update <resourceId>").description("Update a tax profile").option("--jot <text>",ve).option("--name <name>","New name").option("--description <text>","New description").option("--rate <n>","New tax rate as percentage (0-100)",MF).option("--tax-type-code <code>","New tax type code").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.description!==void 0&&(o.description=n.description),n.rate!==void 0&&(o.vatValue=n.rate),n.taxTypeCode!==void 0&&(o.taxType=n.taxTypeCode);let s=await I1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Tax profile updated: ${s.data.name}`)),Ce(i,"update_tax_profile",n,s.data)})(n)),e.command("wht-codes").description("List withholding tax codes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await v1(r);if(n.json)console.log(JSON.stringify(i.data,null,2));else{if(i.data.length===0){console.log("No withholding tax codes found.");return}console.log(R(`Withholding Tax Codes (${i.data.length}):
1076
- `));for(let o of i.data)console.log(` ${_e(o.code??o.resourceId??"?")} ${o.description??""} ${M(o.countryCode??"")}`)}})),e.command("create").description("Create a new tax profile").option("--jot <text>",ve).option("--name <name>",'Tax profile name (e.g., "GST 9%")').option("--rate <n>","Tax rate as percentage, 0 for exempt/zero-rated (e.g., 9)",MF).option("--tax-type-code <code>","Tax type code (from tax-profiles types)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--rate",key:"rate"},{flag:"--tax-type-code",key:"taxTypeCode"}]);let i=await rQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Tax profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await C1(r,{name:n.name,taxRate:n.rate,taxTypeCode:n.taxTypeCode});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Tax profile created: ${n.name} (${n.rate}%)`)),console.log(R("ID:"),o.data.resourceId)),Ce(r,"create_tax_profile",n,o.data)}))}Ne();O1();Dz();cr();ct();Oo();ct();Jt();ln();It();function zi(t){let e=t.parent.command("list").description(t.description).option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he);return t.view&&(e=e.addOption(new Bt("--view <tier>","Payload tier: lean (summary rows) or full (default)").choices(["lean","full"]))),t.extraOptions&&(e=t.extraOptions(e)),e.option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await st(n,o=>t.fetch(r,o,n),{label:t.label});Ke(i,t.columns,n,t.title)}))}It();Ot();lr();var mct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"expenseAccountResourceId",header:"Expense Acct",format:Be}];function Act(t){let e=t.command("claim-types").description("Manage employee-expense claim types (expense categories)");zi({parent:e,description:"List claim types",columns:mct,label:"Fetching claim types",title:"Claim Types",fetch:(r,n)=>T1(r,n)}),e.command("get <resourceId>").description("Get a claim type by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await x1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Default:"),s.isDefault),s.expenseAccount&&console.log(R("Expense Account:"),`${s.expenseAccount.code} ${s.expenseAccount.name}`),s.taxProfile&&console.log(R("Tax Profile:"),s.taxProfile.name))})(n)),je({parent:e,fields:sR,defaults:aR,fetcher:sb,columns:mct,label:"Searching claim types"}),e.command("create").description("Create a claim type").option("--name <name>","Claim type name (unique per org)").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Magic OCR classifier defaults (JSON string)").option("--default","Make org default").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await iQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Claim type "${n.name}" already exists (${i.resourceId}).`));return}let o=await B1(r,{name:n.name,expenseAccountResourceId:n.expenseAccount,taxProfileResourceId:n.taxProfile,classifierConfig:n.classifierConfig,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Claim type created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a claim type").option("--name <name>","New name").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Classifier defaults (JSON string)").option("--default","Make org default").option("--clear <fields>","Comma-separated optional fields to NULL (expenseAccountResourceId,taxProfileResourceId,classifierConfig)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.expenseAccount!==void 0&&(o.expenseAccountResourceId=n.expenseAccount),n.taxProfile!==void 0&&(o.taxProfileResourceId=n.taxProfile),n.classifierConfig!==void 0&&(o.classifierConfig=n.classifierConfig),n.default!==void 0&&(o.isDefault=n.default),Object.assign(o,zy(Xi(n.clear),h_));let s=await k1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Claim type updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim type").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await N1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Claim type deleted: ${r}`))})(n))}Ne();g_();Dz();cr();ct();It();Ot();lr();var gct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"isDefault",header:"Default"},{key:"taxMode",header:"Tax Mode"},{key:"employeeBalanceAccountResourceId",header:"Balance Acct",format:Be}];function yct(t){let e={};return t.name!==void 0&&(e.name=t.name),t.approver!==void 0&&(e.approverUserResourceId=t.approver),t.visibleClaimTypes!==void 0&&(e.visibleClaimTypeIds=Xi(t.visibleClaimTypes)),t.visibleTaxProfiles!==void 0&&(e.visibleTaxProfileIds=Xi(t.visibleTaxProfiles)),t.visibleClassifiers!==void 0&&(e.visibleClassifierIds=Xi(t.visibleClassifiers)),t.visibleVendors!==void 0&&(e.visibleVendorResourceIds=Xi(t.visibleVendors)),t.allowedCurrencies!==void 0&&(e.allowedCurrencies=Xi(t.allowedCurrencies)),t.minAmount!==void 0&&(e.minClaimAmount=t.minAmount),t.maxAmount!==void 0&&(e.maxClaimAmount=t.maxAmount),t.maxPerPeriod!==void 0&&(e.maxPerPeriodAmount=t.maxPerPeriod),t.perPeriod!==void 0&&(e.perPeriod=t.perPeriod),t.balanceAccount!==void 0&&(e.employeeBalanceAccountResourceId=t.balanceAccount),t.taxMode!==void 0&&(e.taxMode=t.taxMode),t.default!==void 0&&(e.isDefault=t.default),e}function Ect(t){return t.option("--approver <id>","Default approver user resourceId").option("--visible-claim-types <ids>","Allowed claim type IDs (comma-separated)").option("--visible-tax-profiles <ids>","Allowed tax profile IDs (comma-separated)").option("--visible-classifiers <ids>","Allowed classifier IDs (comma-separated)").option("--visible-vendors <ids>","Allowed vendor contact IDs (comma-separated)").option("--allowed-currencies <codes>","Allowed ISO currency codes (comma-separated)").option("--min-amount <n>","Min claim total",dr).option("--max-amount <n>","Max claim total",dr).option("--max-per-period <n>","Per-period spend cap (requires --per-period)",dr).option("--per-period <window>","DAILY | WEEKLY | MONTHLY | QUARTERLY | YEARLY").option("--balance-account <id>","Employee balance (CURRENT_LIABILITY) account resourceId").option("--tax-mode <mode>","NO_TAX | INCLUSIVE (EXCLUSIVE rejected)").option("--default","Make org default")}function bct(t){let e=t.command("claim-profiles").description("Manage employee-expense claim profiles (per-employee policy bundles)");zi({parent:e,description:"List claim profiles",columns:gct,label:"Fetching claim profiles",title:"Claim Profiles",fetch:(r,n)=>F1(r,n)}),e.command("get <resourceId>").description("Get a claim profile by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await Q1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Default:"),s.isDefault),s.taxMode&&console.log(R("Tax mode:"),s.taxMode),s.employeeBalanceAccount&&console.log(R("Balance account:"),`${s.employeeBalanceAccount.code} ${s.employeeBalanceAccount.name}`))})(n)),je({parent:e,fields:cR,defaults:lR,fetcher:ab,columns:gct,label:"Searching claim profiles"}),Ect(e.command("create").description("Create a claim profile").option("--name <name>","Profile name (unique per org)")).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await oQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Claim profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await L1(r,yct(n));n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Claim profile created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),Ect(e.command("update <resourceId>").description("Update a claim profile").option("--name <name>","New name")).option("--clear <fields>","Comma-separated optional fields to NULL (e.g. approverUserResourceId,perPeriod,taxMode)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o=yct(n);Object.assign(o,zy(Xi(n.clear),A_));let s=await P1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Claim profile updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim profile").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await M1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Claim profile deleted: ${r}`))})(n))}Ne();b_();cr();ct();It();Ot();lr();var Cct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"outerAxis",header:"Outer"},{key:"innerAxis",header:"Inner"},{key:"isDefault",header:"Default"}];function Ict(t){let e=t.command("posting-rules").description("Manage claim posting rules (how approved claims group into journals at conversion)");zi({parent:e,description:"List posting rules",columns:Cct,label:"Fetching posting rules",title:"Posting Rules",fetch:(r,n)=>U1(r,n)}),e.command("get <resourceId>").description("Get a posting rule by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await $1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Outer axis:"),s.outerAxis),console.log(R("Inner axis:"),s.innerAxis),console.log(R("Line template:"),s.lineDescriptionTemplate),console.log(R("Default:"),s.isDefault))})(n)),je({parent:e,fields:uR,defaults:dR,fetcher:cb,columns:Cct,label:"Searching posting rules"}),e.command("create").description("Create a posting rule").option("--name <name>","Rule name (unique per org)").option("--outer-axis <axis>","PER_EMPLOYEE | PER_VENDOR | PER_PAIR | ONE_BATCH | PER_CLAIM").option("--inner-axis <axis>","RAW | BY_CT_TP_NC | BY_CT_TP_NC_EMPLOYEE | BY_CT_TP_NC_VENDOR").option("--line-template <tpl>",'Handlebars line template, e.g. "{employeeName} - {claimType}"').option("--journal-reference-template <tpl>","Optional journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout","Create reimbursement DCE by default").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--outer-axis",key:"outerAxis"},{flag:"--inner-axis",key:"innerAxis"},{flag:"--line-template",key:"lineTemplate"}]);let i=await sQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Posting rule "${n.name}" already exists (${i.resourceId}).`));return}let o=await q1(r,{name:n.name,outerAxis:n.outerAxis,innerAxis:n.innerAxis,lineDescriptionTemplate:n.lineTemplate,journalReferenceTemplate:n.journalReferenceTemplate,defaultBankAccountResourceId:n.defaultBankAccount,defaultIncludeReimbursementPayout:n.defaultIncludePayout,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Posting rule created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a posting rule").option("--name <name>","New name").option("--outer-axis <axis>","Outer grouping axis").option("--inner-axis <axis>","Inner line-aggregation axis").option("--line-template <tpl>","Handlebars line template").option("--journal-reference-template <tpl>","Journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout <bool>","Create reimbursement DCE by default (true/false)").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.outerAxis!==void 0&&(o.outerAxis=n.outerAxis),n.innerAxis!==void 0&&(o.innerAxis=n.innerAxis),n.lineTemplate!==void 0&&(o.lineDescriptionTemplate=n.lineTemplate),n.journalReferenceTemplate!==void 0&&(o.journalReferenceTemplate=n.journalReferenceTemplate),n.defaultBankAccount!==void 0&&(o.defaultBankAccountResourceId=n.defaultBankAccount),n.defaultIncludePayout!==void 0&&(o.defaultIncludeReimbursementPayout=n.defaultIncludePayout==="true"),n.default!==void 0&&(o.isDefault=n.default);let s=await j1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Posting rule updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Delete a posting rule (the org default cannot be deleted while default)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await Y1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Posting rule deleted: ${r}`))})(n))}Ne();N2();Xfe();Kfe();OD();Zfe();ct();It();Ot();bp();lr();import{randomUUID as vDr}from"node:crypto";import{readFileSync as vct,statSync as wDr}from"node:fs";import{basename as _Dr,extname as DDr,resolve as wct}from"node:path";var SDr=[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"status",header:"Status"},{key:"employeeResourceId",header:"Employee",format:Be},{key:"totalAmount",header:"Amount"},{key:"currencyCode",header:"Ccy"}];function _ct(t){let e=t.command("claims").description("Employee-expense claims: search, edit drafts, lifecycle, bulk actions");je({parent:e,fields:rR,defaults:nR,fetcher:m2,columns:SDr,label:"Searching claims"}),e.command("get <resourceId>").description("Get a claim by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>F(async c=>{let d=(await A2(c,s)).data;a.json?console.log(JSON.stringify(d,null,2)):(console.log(R("Reference:"),d.reference??"\u2014"),console.log(R("ID:"),d.resourceId),console.log(R("Status:"),d.status),console.log(R("Total:"),`${d.totalAmount??0} ${d.currencyCode??""}`),console.log(R("Lines:"),(d.claimItems??[]).length))})(a)),e.command("create").description("Create a claim directly (bare create). Vendor is EITHER --contact OR --vendor-name. --items / --custom-fields take a JSON array string.").requiredOption("--value-date <date>","Business-transaction date (YYYY-MM-DD)").requiredOption("--currency <code>","Claim currency (ISO 4217)").option("--reference <ref>","User reference").option("--employee <id>","Employee resourceId the claim is filed for").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency-symbol <symbol>","Currency symbol override").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(s=>F(async a=>{let c={valueDate:s.valueDate,currencyCode:s.currency};s.reference!==void 0&&(c.reference=s.reference),s.employee!==void 0&&(c.employeeResourceId=s.employee),s.contact!==void 0&&(c.contactResourceId=s.contact),s.vendorName!==void 0&&(c.vendorName=s.vendorName),s.currencySymbol!==void 0&&(c.currencySymbol=s.currencySymbol),s.internalNotes!==void 0&&(c.internalNotes=s.internalNotes),s.claimProfile!==void 0&&(c.claimProfileResourceId=s.claimProfile),s.approver!==void 0&&(c.approverUserResourceId=s.approver),s.tags!==void 0&&(c.tags=Xi(s.tags)??[]),s.items!==void 0&&(c.claimItems=wu(s.items,"--items")),s.customFields!==void 0&&(c.customFields=wu(s.customFields,"--custom-fields")),s.submit&&(c.saveAsDraft=!1);let u=await g2(a,c);s.json?console.log(JSON.stringify(u.data,null,2)):console.log(j(`Claim created: ${u.data.reference??u.data.resourceId} (${u.data.status})`))})(s)),e.command("update <resourceId>").description("Update a DRAFT claim (partial). --items / --custom-fields take a JSON array string.").option("--reference <ref>","User reference").option("--value-date <date>","Business-transaction date (YYYY-MM-DD)").option("--employee <id>","Employee resourceId").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency <code>","Claim currency (ISO 4217)").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array (REPLACES all lines)").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>F(async c=>{let u={};a.reference!==void 0&&(u.reference=a.reference),a.valueDate!==void 0&&(u.valueDate=a.valueDate),a.employee!==void 0&&(u.employeeResourceId=a.employee),a.contact!==void 0&&(u.contactResourceId=a.contact),a.vendorName!==void 0&&(u.vendorName=a.vendorName),a.currency!==void 0&&(u.currencyCode=a.currency),a.internalNotes!==void 0&&(u.internalNotes=a.internalNotes),a.claimProfile!==void 0&&(u.claimProfileResourceId=a.claimProfile),a.approver!==void 0&&(u.approverUserResourceId=a.approver),a.tags!==void 0&&(u.tags=Xi(a.tags)??[]),a.items!==void 0&&(u.claimItems=wu(a.items,"--items")),a.customFields!==void 0&&(u.customFields=wu(a.customFields,"--custom-fields")),a.submit&&(u.saveAsDraft=!1);let d=await y2(c,s,u);a.json?console.log(JSON.stringify(d.data,null,2)):console.log(j(`Claim updated: ${d.data.reference??d.data.resourceId} (${d.data.status})`))})(a)),e.command("delete <resourceId>").description("Delete a claim (only DRAFT / REJECTED / CANCELLED)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>F(async c=>{await E2(c,s),a.json?console.log(JSON.stringify({deleted:!0,resourceId:s})):console.log(j(`Claim deleted: ${s}`))})(a)),e.command("delete-attachment <resourceId> <attachmentResourceId>").description("Remove one attachment from a claim").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a,c)=>F(async u=>{await b2(u,s,a),c.json?console.log(JSON.stringify({deleted:!0,resourceId:s,attachmentResourceId:a})):console.log(j(`Attachment removed from claim ${s}`))})(c));let r=[["submit",C2,"Submit a DRAFT claim for approval"],["approve",I2,"Approve a SUBMITTED claim"],["unpost",_2,"Unpost a CONVERTED claim (reverse conversion)"]];for(let[s,a,c]of r)e.command(`${s} <resourceId>`).description(c).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>F(async f=>{let p=await a(f,u);d.json?console.log(JSON.stringify(p,null,2)):console.log(j(`Claim ${s}: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let n=[["reject",v2,"Reject a SUBMITTED/APPROVED claim"],["cancel",w2,"Cancel a DRAFT/SUBMITTED claim"]];for(let[s,a,c]of n)e.command(`${s} <resourceId>`).description(c).option("--reason <text>","Reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>F(async f=>{Le(d,[{flag:"--reason",key:"reason"}]);let p=await a(f,u,d.reason);d.json?console.log(JSON.stringify(p,null,2)):console.log(j(`Claim ${s}ed: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let i=[["bulk-submit",D2,"Bulk-submit DRAFT claims (async)"],["bulk-approve",S2,"Bulk-approve SUBMITTED claims (async)"],["bulk-delete",R2,"Bulk-delete DRAFT/REJECTED/CANCELLED claims (async)"]];for(let[s,a,c]of i)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"}]);let f=await a(u,Xi(d.ids)??[]);d.json?console.log(JSON.stringify(f,null,2)):console.log(j(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));let o=[["bulk-reject",T2,"Bulk-reject claims (async)"],["bulk-cancel",x2,"Bulk-cancel claims (async)"]];for(let[s,a,c]of o)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--reason <text>","Shared reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"},{flag:"--reason",key:"reason"}]);let f=await a(u,Xi(d.ids)??[],d.reason);d.json?console.log(JSON.stringify(f,null,2)):console.log(j(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));e.command("tracking-tags").description("List claim tracking-tag values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{let c=await B2(s);if(a.json)console.log(JSON.stringify(c,null,2));else{console.log(R(`Tracking tags (${c.length}):`));for(let u of c)console.log(` ${typeof u=="string"?u:JSON.stringify(u)}`)}})),e.command("custom-field-values").description("List claim custom-field values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{let c=await k2(s);a.json?console.log(JSON.stringify(c,null,2)):console.log(xe(c.length===0?"No custom field values.":`${c.length} custom field value(s).`))})),e.command("preview-conversion").description("Preview the journals an APPROVED claim batch would produce (no write)").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--payout-flow <flow>","POST | POST_AND_RECORD").option("--include-payout","Include reimbursement DCE lines").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{if(Le(a,[{flag:"--ids",key:"ids"}]),a.payoutFlow!==void 0&&!KB.includes(a.payoutFlow))throw new Error(`--payout-flow must be one of: ${KB.join(", ")}`);let c=await F8(s,{claimResourceIds:Xi(a.ids)??[],postingRuleResourceId:a.postingRule,payoutFlow:a.payoutFlow,includeReimbursementPayout:a.includePayout});console.log(JSON.stringify(c.data,null,2))})),e.command("convert").description("Convert an APPROVED claim batch into journals (atomic). Preview first.").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--value-date <date>","Journal value date (YYYY-MM-DD), required").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--include-payout","Create books-only reimbursement DCEs").option("--bank-account <id>","Override reimbursement bank account").option("--idempotency-key <key>","Retry-dedup token (auto-generated if omitted)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{Le(a,[{flag:"--ids",key:"ids"},{flag:"--value-date",key:"valueDate"}]);let c=await Q8(s,{claimResourceIds:Xi(a.ids)??[],valueDate:a.valueDate,postingRuleResourceId:a.postingRule,includeReimbursementPayout:a.includePayout,bankAccountResourceIdOverride:a.bankAccount,idempotencyKey:a.idempotencyKey||vDr()});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(j("Claims converted to journals."))})),e.command("record-payout").description("Record a books-only employee payout (reimbursement / advance)").option("--employee <id>","Employee resourceId").option("--amount <n>","Payout amount (> 0)",dr).option("--payment-account <id>","Bank/cash account the DCE credits").option("--value-date <date>","Value date (YYYY-MM-DD)").option("--payout-for <type>","REIMBURSEMENT | ADVANCE (default ADVANCE)").option("--currency <code>","Settle currency (ISO 4217)").option("--reference <ref>","Payout reference (auto-generated if omitted)").option("--description <text>","DCE line description").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{Le(a,[{flag:"--employee",key:"employee"},{flag:"--amount",key:"amount"},{flag:"--payment-account",key:"paymentAccount"},{flag:"--value-date",key:"valueDate"}]);let c=await L8(s,{employeeResourceId:a.employee,amount:a.amount,paymentAccountResourceId:a.paymentAccount,valueDate:a.valueDate,payoutFor:a.payoutFor,currencyCode:a.currency,reference:a.reference||ol("EP"),description:a.description,internalNotes:a.internalNotes});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(j(`Payout recorded: ${c.data.resourceId}`))})),je({parent:e,commandName:"payouts",fields:iR,defaults:oR,fetcher:P8,columns:[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"employeeResourceId",header:"Employee",format:Be},{key:"amount",header:"Amount"},{key:"payoutType",header:"Type"}],label:"Searching employee payouts"}),e.command("from-attachment").description("Create a claim DRAFT from a receipt via AI extraction \u2014 a local file (--file), a remote URL (--source-url), or raw HTML (--html)").option("--file <path>","Local receipt file (PDF / JPG / PNG / HEIC / XLS / XLSX / EML)").option("--source-url <url>","Remote receipt file URL (alternative to --file)").option("--html <value>","Raw HTML (e.g. an email body) \u2014 inline or @path to read from a file").option("--contact <id>","Vendor contact resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employee <id>","File on behalf of this employee resourceId (default: the uploader's own; server requires a claims Manager/Admin to name another)").option("--currency <code>","Currency override (ISO 4217)").option("--value-date <date>","Value date override (YYYY-MM-DD)").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{if([a.file,a.sourceUrl,a.html].filter(Boolean).length!==1)throw new Error("provide exactly one of --file / --source-url / --html.");let u,d;if(a.file){let h=wct(a.file),m=DDr(h).toLowerCase();if(!Hd.has(m))throw new Error(`unsupported file type "${m}". Supported: ${[...Hd].join(", ")}`);let A=25*1024*1024,g=wDr(h).size;if(g>A)throw new Error(`file too large (${(g/1048576).toFixed(1)}MB > 25MB). Compress or split the receipt.`);u=new Blob([vct(h)],{type:OA(m)}),d=_Dr(h)}let f;a.html&&(a.html.startsWith("@")||console.error(xe("Warning: passing HTML inline can leak invoice data into shell history \u2014 prefer --html @path.")),f=a.html.startsWith("@")?vct(wct(a.html.slice(1)),"utf8"):a.html);let p=await fC(s,{sourceFile:u,sourceFileName:d,sourceURL:a.sourceUrl,html:f,contactResourceId:a.contact,claimProfileResourceId:a.claimProfile,employeeResourceId:a.employee,currencyCode:a.currency,valueDate:a.valueDate,internalNotes:a.internalNotes});console.log(JSON.stringify(p,null,2))}))}Ne();C_();cr();ct();It();Ot();lr();var Dct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"email",header:"Email"},{key:"employmentType",header:"Type"},{key:"active",header:"Active"}];function Sct(t){let e=t.command("employees").description("Manage employees (expense-claim members): CRUD, balances, bind-user, import");je({parent:e,fields:fR,defaults:pR,fetcher:lb,columns:Dct,label:"Searching employees"}),je({parent:e,commandName:"balances",fields:hR,defaults:mR,fetcher:H1,columns:Dct,label:"Searching employee balances"}),e.command("get <resourceId>").description("Get an employee by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await z1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Email:"),s.email??"\u2014"),console.log(R("Active:"),s.active),s.userBinding&&console.log(R("Bound user:"),`${s.userBinding.name??""} (${s.userBinding.status??""})`),s.claimProfile&&console.log(R("Claim profile:"),s.claimProfile.name))})(n)),e.command("create").description("Create an employee (requires --user to bind; binding is permanent)").option("--name <name>","Employee name").option("--user <id>","Login user resourceId to bind (required)").option("--claim-profile <id>","Claim profile resourceId (defaults to org default)").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--employment-type <type>","FULL_TIME | PART_TIME | CONTRACTOR | INTERN | TEMPORARY | CONSULTANT").option("--inactive","Create as inactive").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{if(Le(n,[{flag:"--name",key:"name"},{flag:"--user",key:"user"}]),n.email){let o=await aQ(r,n.email);if(o){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:o},null,2)):console.log(xe(`Employee with email "${n.email}" already exists (${o.resourceId}).`));return}}let i=await G1(r,{name:n.name,userResourceId:n.user,claimProfileResourceId:n.claimProfile,email:n.email,phone:n.phone,managerEmployeeResourceId:n.manager,active:n.inactive?!1:void 0,employmentType:n.employmentType});n.json?console.log(JSON.stringify(i.data,null,2)):(console.log(j(`Employee created: ${n.name}`)),console.log(R("ID:"),i.data.resourceId))})),e.command("update <resourceId>").description("Update an employee. Use --archive to deactivate (reversible).").option("--name <name>","New name").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employment-type <type>","Employment classification").option("--archive","Set active=false (archive)").option("--activate","Set active=true").option("--clear-employment-type","Unset the classification").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};if(n.name!==void 0&&(o.name=n.name),n.email!==void 0&&(o.email=n.email),n.phone!==void 0&&(o.phone=n.phone),n.manager!==void 0&&(o.managerEmployeeResourceId=n.manager),n.claimProfile!==void 0&&(o.claimProfileResourceId=n.claimProfile),n.employmentType!==void 0&&(o.employmentType=n.employmentType),n.archive&&n.activate)throw new Error("--archive and --activate are mutually exclusive.");n.archive&&(o.active=!1),n.activate&&(o.active=!0),n.clearEmploymentType&&(o.clearEmploymentType=!0);let s=await J1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Employee updated: ${s.data.name??r}`))})(n)),e.command("delete <resourceId>").description("Delete an employee (must be settled). Prefer update --archive.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await V1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Employee deleted: ${r}`))})(n)),e.command("bind-user <resourceId> <userResourceId>").description("Bind a login user to an offline employee (no user bound yet). One-way, permanent \u2014 allowed only while unbound.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n,i)=>F(async o=>{let s=await W1(o,r,n);i.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Bound user ${n} to employee ${r}`))})(i)),e.command("preprocess <fileUrl>").description("Preview an employee import sheet before importing").option("--file-name <name>","Display file name").option("--file-type <type>","CSV | XLS | XLSX").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o=await Z1(i,{fileUrl:r,fileName:n.fileName,fileType:n.fileType});console.log(JSON.stringify(o.data,null,2))})(n)),e.command("import").description("Bulk import employees (async). Pass --create / --update / --delete JSON arrays (max 100 each).").option("--create <json>","Create rows (JSON array)").option("--update <json>","Update rows (JSON array, each with employeeResourceId)").option("--delete <json>","Delete rows (JSON array, each with employeeResourceId)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{let i={};n.create!==void 0&&(i.create=wu(n.create,"--create")),n.update!==void 0&&(i.update=wu(n.update,"--update")),n.delete!==void 0&&(i.delete=wu(n.delete,"--delete"));let o=await X1(r,i);n.json?console.log(JSON.stringify(o.data,null,2)):console.log(j(`Queued employee import \u2014 jobId ${o.data?.jobId??"?"}`))}))}Qfe();ct();It();ln();Jt();Ot();Ne();var RDr=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"categoryCode",header:"Category"},{key:"value",header:"Value"}];function Rct(t){let e=t.command("bookmarks").description("Manage organization bookmarks");e.command("list").description("List bookmarks").option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await st(n,o=>s8(r,o),{label:"Fetching bookmarks"});Ke(i,RDr,n,"Bookmarks")})),e.command("get <resourceId>").description("Get a bookmark by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await a8(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Category:"),s.categoryCode),console.log(R("Value:"),s.value))})(n)),e.command("create").description("Create bookmark(s)").option("--name <name>","Bookmark name").option("--value <value>","Bookmark value").option("--category <code>","Category code (GENERAL_INFORMATION, TAXATION_AND_COMPLIANCE, etc.)").option("--datatype <code>","Datatype code (default: TEXT)").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(F(async(r,n)=>{let i=be(n),o;if(i?o=await ZB(r,i.items??[i]):(Le(n,[{flag:"--name",key:"name"},{flag:"--value",key:"value"},{flag:"--category",key:"category"}]),o=await ZB(r,[{name:n.name,value:n.value,categoryCode:n.category,datatypeCode:n.datatype??"TEXT"}])),n.json)console.log(JSON.stringify(o.data,null,2));else{console.log(j(`Bookmark(s) created: ${o.data.length} item(s)`));for(let s of o.data)console.log(` ${_e(s.resourceId)} ${s.name}`)}})),e.command("update <resourceId>").description("Update a bookmark").option("--name <name>","New name").option("--value <value>","New value").option("--category <code>","New category code").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((r,n)=>F(async i=>{let o=be(n),s=o||{...n.name&&{name:n.name},...n.value&&{value:n.value},...n.category&&{categoryCode:n.category}},a=await c8(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(j(`Bookmark updated: ${a.data.name}`))})(n))}u8();bC();Na();ct();It();Jt();ln();Ot();Ne();var TDr=[{key:"resourceId",header:"ID",format:Be},{key:"kind",header:"Kind"},{key:"tier",header:"Tier"},{key:"call",header:"Call"},{key:"dispositions",header:"Dispositions",format:t=>Array.isArray(t)?t.map(e=>e.verb).join(" "):String(t)},{key:"createdAt",header:"Created",format:eh}];function Tct(t){let e=t.command("jots").description("Judgment journal: record and look up judgment entries");e.command("create").description("Record judgment entries (batch via --input, single via flags)").option("--kind <kind>","Judgment kind (CLASSIFICATION, MATCH, SCOPE, ASSUMPTION, RISK, METHOD, RECOVERY, DEVIATION, NOTE)").option("--tier <tier>","Severity tier (LOW, MEDIUM, HIGH, CRITICAL)").option("--call <call>","The decision, one line").option("--why <why>","The basis for the call").option("--ruled-out <text>","Alternatives considered and set aside").option("--ref <ref...>","Entity ref, grammar TYPE:resourceId[#field][:RELATION] (repeatable)").option("--frame <frame>","Set anchor: defining query + counts").option("--confidence <level>","Routing hint (LOW, MEDIUM, HIGH)").option("--cited-rule <rule>","Org rule, policy, threshold, or precedent applied").option("--workflow-label <label>","Short workflow label (e.g. month-end-close)").option("--agent-label <label>","Self-reported product/model").option("--idempotency-key <key>","Retry key: a replay returns the existing entry").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").addHelpText("after",`
1076
+ `));for(let o of i.data)console.log(` ${_e(o.code??o.resourceId??"?")} ${o.description??""} ${M(o.countryCode??"")}`)}})),e.command("create").description("Create a new tax profile").option("--jot <text>",ve).option("--name <name>",'Tax profile name (e.g., "GST 9%")').option("--rate <n>","Tax rate as percentage, 0 for exempt/zero-rated (e.g., 9)",MF).option("--tax-type-code <code>","Tax type code (from tax-profiles types)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--rate",key:"rate"},{flag:"--tax-type-code",key:"taxTypeCode"}]);let i=await rQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Tax profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await C1(r,{name:n.name,taxRate:n.rate,taxTypeCode:n.taxTypeCode});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Tax profile created: ${n.name} (${n.rate}%)`)),console.log(R("ID:"),o.data.resourceId)),Ce(r,"create_tax_profile",n,o.data)}))}Ne();O1();Dz();cr();ct();Oo();ct();Jt();ln();It();function zi(t){let e=t.parent.command("list").description(t.description).option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he);return t.view&&(e=e.addOption(new Bt("--view <tier>","Payload tier: lean (summary rows) or full (default)").choices(["lean","full"]))),t.extraOptions&&(e=t.extraOptions(e)),e.option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await st(n,o=>t.fetch(r,o,n),{label:t.label});Ke(i,t.columns,n,t.title)}))}It();Ot();lr();var mct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"expenseAccountResourceId",header:"Expense Acct",format:Be}];function Act(t){let e=t.command("claim-types").description("Manage employee-expense claim types (expense categories)");zi({parent:e,description:"List claim types",columns:mct,label:"Fetching claim types",title:"Claim Types",fetch:(r,n)=>T1(r,n)}),e.command("get <resourceId>").description("Get a claim type by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await x1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),s.expenseAccount&&console.log(R("Expense Account:"),`${s.expenseAccount.code} ${s.expenseAccount.name}`),s.taxProfile&&console.log(R("Tax Profile:"),s.taxProfile.name))})(n)),je({parent:e,fields:sR,defaults:aR,fetcher:sb,columns:mct,label:"Searching claim types"}),e.command("create").description("Create a claim type").option("--name <name>","Claim type name (unique per org)").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Magic OCR classifier defaults (JSON string)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await iQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Claim type "${n.name}" already exists (${i.resourceId}).`));return}let o=await B1(r,{name:n.name,expenseAccountResourceId:n.expenseAccount,taxProfileResourceId:n.taxProfile,classifierConfig:n.classifierConfig});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Claim type created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a claim type").option("--name <name>","New name").option("--expense-account <id>","Default expense account resourceId").option("--tax-profile <id>","Default tax profile resourceId").option("--classifier-config <json>","Classifier defaults (JSON string)").option("--clear <fields>","Comma-separated optional fields to NULL (expenseAccountResourceId,taxProfileResourceId,classifierConfig)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.expenseAccount!==void 0&&(o.expenseAccountResourceId=n.expenseAccount),n.taxProfile!==void 0&&(o.taxProfileResourceId=n.taxProfile),n.classifierConfig!==void 0&&(o.classifierConfig=n.classifierConfig),Object.assign(o,zy(Xi(n.clear),h_));let s=await k1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Claim type updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim type").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await N1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Claim type deleted: ${r}`))})(n))}Ne();g_();Dz();cr();ct();It();Ot();lr();var gct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"taxMode",header:"Tax Mode"},{key:"employeeBalanceAccountResourceId",header:"Balance Acct",format:Be}];function yct(t){let e={};return t.name!==void 0&&(e.name=t.name),t.approver!==void 0&&(e.approverUserResourceId=t.approver),t.visibleClaimTypes!==void 0&&(e.visibleClaimTypeIds=Xi(t.visibleClaimTypes)),t.visibleTaxProfiles!==void 0&&(e.visibleTaxProfileIds=Xi(t.visibleTaxProfiles)),t.visibleClassifiers!==void 0&&(e.visibleClassifierIds=Xi(t.visibleClassifiers)),t.visibleVendors!==void 0&&(e.visibleVendorResourceIds=Xi(t.visibleVendors)),t.allowedCurrencies!==void 0&&(e.allowedCurrencies=Xi(t.allowedCurrencies)),t.minAmount!==void 0&&(e.minClaimAmount=t.minAmount),t.maxAmount!==void 0&&(e.maxClaimAmount=t.maxAmount),t.maxPerPeriod!==void 0&&(e.maxPerPeriodAmount=t.maxPerPeriod),t.perPeriod!==void 0&&(e.perPeriod=t.perPeriod),t.balanceAccount!==void 0&&(e.employeeBalanceAccountResourceId=t.balanceAccount),t.taxMode!==void 0&&(e.taxMode=t.taxMode),e}function Ect(t){return t.option("--approver <id>","Default approver user resourceId").option("--visible-claim-types <ids>","Allowed claim type IDs (comma-separated)").option("--visible-tax-profiles <ids>","Allowed tax profile IDs (comma-separated)").option("--visible-classifiers <ids>","Allowed classifier IDs (comma-separated)").option("--visible-vendors <ids>","Allowed vendor contact IDs (comma-separated)").option("--allowed-currencies <codes>","Allowed ISO currency codes (comma-separated)").option("--min-amount <n>","Min claim total",dr).option("--max-amount <n>","Max claim total",dr).option("--max-per-period <n>","Per-period spend cap (requires --per-period)",dr).option("--per-period <window>","DAILY | WEEKLY | MONTHLY | QUARTERLY | YEARLY").option("--balance-account <id>","Employee balance (CURRENT_LIABILITY) account resourceId").option("--tax-mode <mode>","NO_TAX | INCLUSIVE (EXCLUSIVE rejected)")}function bct(t){let e=t.command("claim-profiles").description("Manage employee-expense claim profiles (per-employee policy bundles)");zi({parent:e,description:"List claim profiles",columns:gct,label:"Fetching claim profiles",title:"Claim Profiles",fetch:(r,n)=>F1(r,n)}),e.command("get <resourceId>").description("Get a claim profile by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await Q1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),s.taxMode&&console.log(R("Tax mode:"),s.taxMode),s.employeeBalanceAccount&&console.log(R("Balance account:"),`${s.employeeBalanceAccount.code} ${s.employeeBalanceAccount.name}`))})(n)),je({parent:e,fields:cR,defaults:lR,fetcher:ab,columns:gct,label:"Searching claim profiles"}),Ect(e.command("create").description("Create a claim profile").option("--name <name>","Profile name (unique per org)")).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"}]);let i=await oQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Claim profile "${n.name}" already exists (${i.resourceId}).`));return}let o=await L1(r,yct(n));n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Claim profile created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),Ect(e.command("update <resourceId>").description("Update a claim profile").option("--name <name>","New name")).option("--clear <fields>","Comma-separated optional fields to NULL (e.g. approverUserResourceId,perPeriod,taxMode)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o=yct(n);Object.assign(o,zy(Xi(n.clear),A_));let s=await P1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Claim profile updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Soft-delete a claim profile").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await M1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Claim profile deleted: ${r}`))})(n))}Ne();b_();cr();ct();It();Ot();lr();var Cct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"outerAxis",header:"Outer"},{key:"innerAxis",header:"Inner"},{key:"isDefault",header:"Default"}];function Ict(t){let e=t.command("posting-rules").description("Manage claim posting rules (how approved claims group into journals at conversion)");zi({parent:e,description:"List posting rules",columns:Cct,label:"Fetching posting rules",title:"Posting Rules",fetch:(r,n)=>U1(r,n)}),e.command("get <resourceId>").description("Get a posting rule by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await $1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Outer axis:"),s.outerAxis),console.log(R("Inner axis:"),s.innerAxis),console.log(R("Line template:"),s.lineDescriptionTemplate),console.log(R("Default:"),s.isDefault))})(n)),je({parent:e,fields:uR,defaults:dR,fetcher:cb,columns:Cct,label:"Searching posting rules"}),e.command("create").description("Create a posting rule").option("--name <name>","Rule name (unique per org)").option("--outer-axis <axis>","PER_EMPLOYEE | PER_VENDOR | PER_PAIR | ONE_BATCH | PER_CLAIM").option("--inner-axis <axis>","RAW | BY_CT_TP_NC | BY_CT_TP_NC_EMPLOYEE | BY_CT_TP_NC_VENDOR").option("--line-template <tpl>",'Handlebars line template, e.g. "{employeeName} - {claimType}"').option("--journal-reference-template <tpl>","Optional journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout","Create reimbursement DCE by default").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{Le(n,[{flag:"--name",key:"name"},{flag:"--outer-axis",key:"outerAxis"},{flag:"--inner-axis",key:"innerAxis"},{flag:"--line-template",key:"lineTemplate"}]);let i=await sQ(r,n.name);if(i){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:i},null,2)):console.log(xe(`Posting rule "${n.name}" already exists (${i.resourceId}).`));return}let o=await q1(r,{name:n.name,outerAxis:n.outerAxis,innerAxis:n.innerAxis,lineDescriptionTemplate:n.lineTemplate,journalReferenceTemplate:n.journalReferenceTemplate,defaultBankAccountResourceId:n.defaultBankAccount,defaultIncludeReimbursementPayout:n.defaultIncludePayout,isDefault:n.default});n.json?console.log(JSON.stringify(o.data,null,2)):(console.log(j(`Posting rule created: ${n.name}`)),console.log(R("ID:"),o.data.resourceId))})),e.command("update <resourceId>").description("Update a posting rule").option("--name <name>","New name").option("--outer-axis <axis>","Outer grouping axis").option("--inner-axis <axis>","Inner line-aggregation axis").option("--line-template <tpl>","Handlebars line template").option("--journal-reference-template <tpl>","Journal-header reference template").option("--default-bank-account <id>","Default reimbursement bank account resourceId").option("--default-include-payout <bool>","Create reimbursement DCE by default (true/false)").option("--default","Make org default rule").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};n.name!==void 0&&(o.name=n.name),n.outerAxis!==void 0&&(o.outerAxis=n.outerAxis),n.innerAxis!==void 0&&(o.innerAxis=n.innerAxis),n.lineTemplate!==void 0&&(o.lineDescriptionTemplate=n.lineTemplate),n.journalReferenceTemplate!==void 0&&(o.journalReferenceTemplate=n.journalReferenceTemplate),n.defaultBankAccount!==void 0&&(o.defaultBankAccountResourceId=n.defaultBankAccount),n.defaultIncludePayout!==void 0&&(o.defaultIncludeReimbursementPayout=n.defaultIncludePayout==="true"),n.default!==void 0&&(o.isDefault=n.default);let s=await j1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Posting rule updated: ${s.data.name}`))})(n)),e.command("delete <resourceId>").description("Delete a posting rule (the org default cannot be deleted while default)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await Y1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Posting rule deleted: ${r}`))})(n))}Ne();N2();Xfe();Kfe();OD();Zfe();ct();It();Ot();bp();lr();import{randomUUID as vDr}from"node:crypto";import{readFileSync as vct,statSync as wDr}from"node:fs";import{basename as _Dr,extname as DDr,resolve as wct}from"node:path";var SDr=[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"status",header:"Status"},{key:"employeeResourceId",header:"Employee",format:Be},{key:"totalAmount",header:"Amount"},{key:"currencyCode",header:"Ccy"}];function _ct(t){let e=t.command("claims").description("Employee-expense claims: search, edit drafts, lifecycle, bulk actions");je({parent:e,fields:rR,defaults:nR,fetcher:m2,columns:SDr,label:"Searching claims"}),e.command("get <resourceId>").description("Get a claim by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>F(async c=>{let d=(await A2(c,s)).data;a.json?console.log(JSON.stringify(d,null,2)):(console.log(R("Reference:"),d.reference??"\u2014"),console.log(R("ID:"),d.resourceId),console.log(R("Status:"),d.status),console.log(R("Total:"),`${d.totalAmount??0} ${d.currencyCode??""}`),console.log(R("Lines:"),(d.claimItems??[]).length))})(a)),e.command("create").description("Create a claim directly (bare create). Vendor is EITHER --contact OR --vendor-name. --items / --custom-fields take a JSON array string.").requiredOption("--value-date <date>","Business-transaction date (YYYY-MM-DD)").requiredOption("--currency <code>","Claim currency (ISO 4217)").option("--reference <ref>","User reference").option("--employee <id>","Employee resourceId the claim is filed for").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency-symbol <symbol>","Currency symbol override").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(s=>F(async a=>{let c={valueDate:s.valueDate,currencyCode:s.currency};s.reference!==void 0&&(c.reference=s.reference),s.employee!==void 0&&(c.employeeResourceId=s.employee),s.contact!==void 0&&(c.contactResourceId=s.contact),s.vendorName!==void 0&&(c.vendorName=s.vendorName),s.currencySymbol!==void 0&&(c.currencySymbol=s.currencySymbol),s.internalNotes!==void 0&&(c.internalNotes=s.internalNotes),s.claimProfile!==void 0&&(c.claimProfileResourceId=s.claimProfile),s.approver!==void 0&&(c.approverUserResourceId=s.approver),s.tags!==void 0&&(c.tags=Xi(s.tags)??[]),s.items!==void 0&&(c.claimItems=wu(s.items,"--items")),s.customFields!==void 0&&(c.customFields=wu(s.customFields,"--custom-fields")),s.submit&&(c.saveAsDraft=!1);let u=await g2(a,c);s.json?console.log(JSON.stringify(u.data,null,2)):console.log(j(`Claim created: ${u.data.reference??u.data.resourceId} (${u.data.status})`))})(s)),e.command("update <resourceId>").description("Update a DRAFT claim (partial). --items / --custom-fields take a JSON array string.").option("--reference <ref>","User reference").option("--value-date <date>","Business-transaction date (YYYY-MM-DD)").option("--employee <id>","Employee resourceId").option("--contact <id>","Vendor contact resourceId").option("--vendor-name <name>","Free-text vendor name").option("--currency <code>","Claim currency (ISO 4217)").option("--internal-notes <text>","Internal notes").option("--claim-profile <id>","Claim profile resourceId").option("--approver <id>","Approver user resourceId").option("--tags <list>","Header tags (comma-separated)").option("--items <json>","Line items as a JSON array (REPLACES all lines)").option("--custom-fields <json>","Custom field values as a JSON array").option("--submit","Validate + submit in one call (saveAsDraft=false). Requires --reference (else 422 CLAIM_REFERENCE_REQUIRED_AT_SUBMIT)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>F(async c=>{let u={};a.reference!==void 0&&(u.reference=a.reference),a.valueDate!==void 0&&(u.valueDate=a.valueDate),a.employee!==void 0&&(u.employeeResourceId=a.employee),a.contact!==void 0&&(u.contactResourceId=a.contact),a.vendorName!==void 0&&(u.vendorName=a.vendorName),a.currency!==void 0&&(u.currencyCode=a.currency),a.internalNotes!==void 0&&(u.internalNotes=a.internalNotes),a.claimProfile!==void 0&&(u.claimProfileResourceId=a.claimProfile),a.approver!==void 0&&(u.approverUserResourceId=a.approver),a.tags!==void 0&&(u.tags=Xi(a.tags)??[]),a.items!==void 0&&(u.claimItems=wu(a.items,"--items")),a.customFields!==void 0&&(u.customFields=wu(a.customFields,"--custom-fields")),a.submit&&(u.saveAsDraft=!1);let d=await y2(c,s,u);a.json?console.log(JSON.stringify(d.data,null,2)):console.log(j(`Claim updated: ${d.data.reference??d.data.resourceId} (${d.data.status})`))})(a)),e.command("delete <resourceId>").description("Delete a claim (only DRAFT / REJECTED / CANCELLED)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a)=>F(async c=>{await E2(c,s),a.json?console.log(JSON.stringify({deleted:!0,resourceId:s})):console.log(j(`Claim deleted: ${s}`))})(a)),e.command("delete-attachment <resourceId> <attachmentResourceId>").description("Remove one attachment from a claim").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((s,a,c)=>F(async u=>{await b2(u,s,a),c.json?console.log(JSON.stringify({deleted:!0,resourceId:s,attachmentResourceId:a})):console.log(j(`Attachment removed from claim ${s}`))})(c));let r=[["submit",C2,"Submit a DRAFT claim for approval"],["approve",I2,"Approve a SUBMITTED claim"],["unpost",_2,"Unpost a CONVERTED claim (reverse conversion)"]];for(let[s,a,c]of r)e.command(`${s} <resourceId>`).description(c).option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>F(async f=>{let p=await a(f,u);d.json?console.log(JSON.stringify(p,null,2)):console.log(j(`Claim ${s}: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let n=[["reject",v2,"Reject a SUBMITTED/APPROVED claim"],["cancel",w2,"Cancel a DRAFT/SUBMITTED claim"]];for(let[s,a,c]of n)e.command(`${s} <resourceId>`).description(c).option("--reason <text>","Reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((u,d)=>F(async f=>{Le(d,[{flag:"--reason",key:"reason"}]);let p=await a(f,u,d.reason);d.json?console.log(JSON.stringify(p,null,2)):console.log(j(`Claim ${s}ed: ${u}${p.data?.status?` (${p.data.status})`:""}`))})(d));let i=[["bulk-submit",D2,"Bulk-submit DRAFT claims (async)"],["bulk-approve",S2,"Bulk-approve SUBMITTED claims (async)"],["bulk-delete",R2,"Bulk-delete DRAFT/REJECTED/CANCELLED claims (async)"]];for(let[s,a,c]of i)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"}]);let f=await a(u,Xi(d.ids)??[]);d.json?console.log(JSON.stringify(f,null,2)):console.log(j(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));let o=[["bulk-reject",T2,"Bulk-reject claims (async)"],["bulk-cancel",x2,"Bulk-cancel claims (async)"]];for(let[s,a,c]of o)e.command(s).description(`${c}. Poll with: clio background-jobs search`).option("--ids <list>","Claim resourceIds (comma-separated, 1-500)").option("--reason <text>","Shared reason (1-1000 chars), required").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(u,d)=>{Le(d,[{flag:"--ids",key:"ids"},{flag:"--reason",key:"reason"}]);let f=await a(u,Xi(d.ids)??[],d.reason);d.json?console.log(JSON.stringify(f,null,2)):console.log(j(`Queued ${s} \u2014 jobId ${f.data?.jobId??"?"}`))}));e.command("tracking-tags").description("List claim tracking-tag values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{let c=await B2(s);if(a.json)console.log(JSON.stringify(c,null,2));else{console.log(R(`Tracking tags (${c.length}):`));for(let u of c)console.log(` ${typeof u=="string"?u:JSON.stringify(u)}`)}})),e.command("custom-field-values").description("List claim custom-field values (picker)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{let c=await k2(s);a.json?console.log(JSON.stringify(c,null,2)):console.log(xe(c.length===0?"No custom field values.":`${c.length} custom field value(s).`))})),e.command("preview-conversion").description("Preview the journals an APPROVED claim batch would produce (no write)").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--payout-flow <flow>","POST | POST_AND_RECORD").option("--include-payout","Include reimbursement DCE lines").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{if(Le(a,[{flag:"--ids",key:"ids"}]),a.payoutFlow!==void 0&&!KB.includes(a.payoutFlow))throw new Error(`--payout-flow must be one of: ${KB.join(", ")}`);let c=await F8(s,{claimResourceIds:Xi(a.ids)??[],postingRuleResourceId:a.postingRule,payoutFlow:a.payoutFlow,includeReimbursementPayout:a.includePayout});console.log(JSON.stringify(c.data,null,2))})),e.command("convert").description("Convert an APPROVED claim batch into journals (atomic). Preview first.").option("--ids <list>","APPROVED claim resourceIds (comma-separated)").option("--value-date <date>","Journal value date (YYYY-MM-DD), required").option("--posting-rule <id>","Posting rule resourceId (default: org default)").option("--include-payout","Create books-only reimbursement DCEs").option("--bank-account <id>","Override reimbursement bank account").option("--idempotency-key <key>","Retry-dedup token (auto-generated if omitted)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{Le(a,[{flag:"--ids",key:"ids"},{flag:"--value-date",key:"valueDate"}]);let c=await Q8(s,{claimResourceIds:Xi(a.ids)??[],valueDate:a.valueDate,postingRuleResourceId:a.postingRule,includeReimbursementPayout:a.includePayout,bankAccountResourceIdOverride:a.bankAccount,idempotencyKey:a.idempotencyKey||vDr()});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(j("Claims converted to journals."))})),e.command("record-payout").description("Record a books-only employee payout (reimbursement / advance)").option("--employee <id>","Employee resourceId").option("--amount <n>","Payout amount (> 0)",dr).option("--payment-account <id>","Bank/cash account the DCE credits").option("--value-date <date>","Value date (YYYY-MM-DD)").option("--payout-for <type>","REIMBURSEMENT | ADVANCE (default ADVANCE)").option("--currency <code>","Settle currency (ISO 4217)").option("--reference <ref>","Payout reference (auto-generated if omitted)").option("--description <text>","DCE line description").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{Le(a,[{flag:"--employee",key:"employee"},{flag:"--amount",key:"amount"},{flag:"--payment-account",key:"paymentAccount"},{flag:"--value-date",key:"valueDate"}]);let c=await L8(s,{employeeResourceId:a.employee,amount:a.amount,paymentAccountResourceId:a.paymentAccount,valueDate:a.valueDate,payoutFor:a.payoutFor,currencyCode:a.currency,reference:a.reference||ol("EP"),description:a.description,internalNotes:a.internalNotes});a.json?console.log(JSON.stringify(c.data,null,2)):console.log(j(`Payout recorded: ${c.data.resourceId}`))})),je({parent:e,commandName:"payouts",fields:iR,defaults:oR,fetcher:P8,columns:[{key:"resourceId",header:"ID",format:Be},{key:"reference",header:"Reference"},{key:"employeeResourceId",header:"Employee",format:Be},{key:"amount",header:"Amount"},{key:"payoutType",header:"Type"}],label:"Searching employee payouts"}),e.command("from-attachment").description("Create a claim DRAFT from a receipt via AI extraction \u2014 a local file (--file), a remote URL (--source-url), or raw HTML (--html)").option("--file <path>","Local receipt file (PDF / JPG / PNG / HEIC / XLS / XLSX / EML)").option("--source-url <url>","Remote receipt file URL (alternative to --file)").option("--html <value>","Raw HTML (e.g. an email body) \u2014 inline or @path to read from a file").option("--contact <id>","Vendor contact resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employee <id>","File on behalf of this employee resourceId (default: the uploader's own; server requires a claims Manager/Admin to name another)").option("--currency <code>","Currency override (ISO 4217)").option("--value-date <date>","Value date override (YYYY-MM-DD)").option("--internal-notes <text>","Internal notes").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(s,a)=>{if([a.file,a.sourceUrl,a.html].filter(Boolean).length!==1)throw new Error("provide exactly one of --file / --source-url / --html.");let u,d;if(a.file){let h=wct(a.file),m=DDr(h).toLowerCase();if(!Hd.has(m))throw new Error(`unsupported file type "${m}". Supported: ${[...Hd].join(", ")}`);let A=25*1024*1024,g=wDr(h).size;if(g>A)throw new Error(`file too large (${(g/1048576).toFixed(1)}MB > 25MB). Compress or split the receipt.`);u=new Blob([vct(h)],{type:OA(m)}),d=_Dr(h)}let f;a.html&&(a.html.startsWith("@")||console.error(xe("Warning: passing HTML inline can leak invoice data into shell history \u2014 prefer --html @path.")),f=a.html.startsWith("@")?vct(wct(a.html.slice(1)),"utf8"):a.html);let p=await fC(s,{sourceFile:u,sourceFileName:d,sourceURL:a.sourceUrl,html:f,contactResourceId:a.contact,claimProfileResourceId:a.claimProfile,employeeResourceId:a.employee,currencyCode:a.currency,valueDate:a.valueDate,internalNotes:a.internalNotes});console.log(JSON.stringify(p,null,2))}))}Ne();C_();cr();ct();It();Ot();lr();var Dct=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"email",header:"Email"},{key:"employmentType",header:"Type"},{key:"active",header:"Active"}];function Sct(t){let e=t.command("employees").description("Manage employees (expense-claim members): CRUD, balances, bind-user, import");je({parent:e,fields:fR,defaults:pR,fetcher:lb,columns:Dct,label:"Searching employees"}),je({parent:e,commandName:"balances",fields:hR,defaults:mR,fetcher:H1,columns:Dct,label:"Searching employee balances"}),e.command("get <resourceId>").description("Get an employee by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await z1(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Email:"),s.email??"\u2014"),console.log(R("Active:"),s.active),s.userBinding&&console.log(R("Bound user:"),`${s.userBinding.name??""} (${s.userBinding.status??""})`),s.claimProfile&&console.log(R("Claim profile:"),s.claimProfile.name))})(n)),e.command("create").description("Create an employee (requires --user to bind; binding is permanent)").option("--name <name>","Employee name").option("--user <id>","Login user resourceId to bind (required)").option("--claim-profile <id>","Claim profile resourceId (defaults to org default)").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--employment-type <type>","FULL_TIME | PART_TIME | CONTRACTOR | INTERN | TEMPORARY | CONSULTANT").option("--inactive","Create as inactive").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{if(Le(n,[{flag:"--name",key:"name"},{flag:"--user",key:"user"}]),n.email){let o=await aQ(r,n.email);if(o){n.json?console.log(JSON.stringify({_guard:"duplicate_skipped",existing:o},null,2)):console.log(xe(`Employee with email "${n.email}" already exists (${o.resourceId}).`));return}}let i=await G1(r,{name:n.name,userResourceId:n.user,claimProfileResourceId:n.claimProfile,email:n.email,phone:n.phone,managerEmployeeResourceId:n.manager,active:n.inactive?!1:void 0,employmentType:n.employmentType});n.json?console.log(JSON.stringify(i.data,null,2)):(console.log(j(`Employee created: ${n.name}`)),console.log(R("ID:"),i.data.resourceId))})),e.command("update <resourceId>").description("Update an employee. Use --archive to deactivate (reversible).").option("--name <name>","New name").option("--email <email>","Work email").option("--phone <phone>","Phone").option("--manager <id>","Manager employee resourceId").option("--claim-profile <id>","Claim profile resourceId").option("--employment-type <type>","Employment classification").option("--archive","Set active=false (archive)").option("--activate","Set active=true").option("--clear-employment-type","Unset the classification").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o={};if(n.name!==void 0&&(o.name=n.name),n.email!==void 0&&(o.email=n.email),n.phone!==void 0&&(o.phone=n.phone),n.manager!==void 0&&(o.managerEmployeeResourceId=n.manager),n.claimProfile!==void 0&&(o.claimProfileResourceId=n.claimProfile),n.employmentType!==void 0&&(o.employmentType=n.employmentType),n.archive&&n.activate)throw new Error("--archive and --activate are mutually exclusive.");n.archive&&(o.active=!1),n.activate&&(o.active=!0),n.clearEmploymentType&&(o.clearEmploymentType=!0);let s=await J1(i,r,o);n.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Employee updated: ${s.data.name??r}`))})(n)),e.command("delete <resourceId>").description("Delete an employee (must be settled). Prefer update --archive.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{await V1(i,r),n.json?console.log(JSON.stringify({deleted:!0,resourceId:r})):console.log(j(`Employee deleted: ${r}`))})(n)),e.command("bind-user <resourceId> <userResourceId>").description("Bind a login user to an offline employee (no user bound yet). One-way, permanent \u2014 allowed only while unbound.").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n,i)=>F(async o=>{let s=await W1(o,r,n);i.json?console.log(JSON.stringify(s.data,null,2)):console.log(j(`Bound user ${n} to employee ${r}`))})(i)),e.command("preprocess <fileUrl>").description("Preview an employee import sheet before importing").option("--file-name <name>","Display file name").option("--file-type <type>","CSV | XLS | XLSX").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let o=await Z1(i,{fileUrl:r,fileName:n.fileName,fileType:n.fileType});console.log(JSON.stringify(o.data,null,2))})(n)),e.command("import").description("Bulk import employees (async). Pass --create / --update / --delete JSON arrays (max 100 each).").option("--create <json>","Create rows (JSON array)").option("--update <json>","Update rows (JSON array, each with employeeResourceId)").option("--delete <json>","Delete rows (JSON array, each with employeeResourceId)").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action(F(async(r,n)=>{let i={};n.create!==void 0&&(i.create=wu(n.create,"--create")),n.update!==void 0&&(i.update=wu(n.update,"--update")),n.delete!==void 0&&(i.delete=wu(n.delete,"--delete"));let o=await X1(r,i);n.json?console.log(JSON.stringify(o.data,null,2)):console.log(j(`Queued employee import \u2014 jobId ${o.data?.jobId??"?"}`))}))}Qfe();ct();It();ln();Jt();Ot();Ne();var RDr=[{key:"resourceId",header:"ID",format:Be},{key:"name",header:"Name"},{key:"categoryCode",header:"Category"},{key:"value",header:"Value"}];function Rct(t){let e=t.command("bookmarks").description("Manage organization bookmarks");e.command("list").description("List bookmarks").option("--limit <n>","Max results (default 100)",he).option("--offset <n>","Page number offset (0-indexed)",ot).option("--all","Fetch all pages").option("--max-rows <n>","Max rows for --all (default 1000)",he).option("--api-key <key>","API key (overrides stored/env)").option("--format <type>","Output format: table, json, csv, yaml").option("--json","Output as JSON").action(F(async(r,n)=>{let i=await st(n,o=>s8(r,o),{label:"Fetching bookmarks"});Ke(i,RDr,n,"Bookmarks")})),e.command("get <resourceId>").description("Get a bookmark by resourceId").option("--api-key <key>","API key (overrides stored/env)").option("--json","Output as JSON").action((r,n)=>F(async i=>{let s=(await a8(i,r)).data;n.json?console.log(JSON.stringify(s,null,2)):(console.log(R("Name:"),s.name),console.log(R("ID:"),s.resourceId),console.log(R("Category:"),s.categoryCode),console.log(R("Value:"),s.value))})(n)),e.command("create").description("Create bookmark(s)").option("--name <name>","Bookmark name").option("--value <value>","Bookmark value").option("--category <code>","Category code (GENERAL_INFORMATION, TAXATION_AND_COMPLIANCE, etc.)").option("--datatype <code>","Datatype code (default: TEXT)").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(F(async(r,n)=>{let i=be(n),o;if(i?o=await ZB(r,i.items??[i]):(Le(n,[{flag:"--name",key:"name"},{flag:"--value",key:"value"},{flag:"--category",key:"category"}]),o=await ZB(r,[{name:n.name,value:n.value,categoryCode:n.category,datatypeCode:n.datatype??"TEXT"}])),n.json)console.log(JSON.stringify(o.data,null,2));else{console.log(j(`Bookmark(s) created: ${o.data.length} item(s)`));for(let s of o.data)console.log(` ${_e(s.resourceId)} ${s.name}`)}})),e.command("update <resourceId>").description("Update a bookmark").option("--name <name>","New name").option("--value <value>","New value").option("--category <code>","New category code").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((r,n)=>F(async i=>{let o=be(n),s=o||{...n.name&&{name:n.name},...n.value&&{value:n.value},...n.category&&{categoryCode:n.category}},a=await c8(i,r,s);n.json?console.log(JSON.stringify(a.data,null,2)):console.log(j(`Bookmark updated: ${a.data.name}`))})(n))}u8();bC();Na();ct();It();Jt();ln();Ot();Ne();var TDr=[{key:"resourceId",header:"ID",format:Be},{key:"kind",header:"Kind"},{key:"tier",header:"Tier"},{key:"call",header:"Call"},{key:"dispositions",header:"Dispositions",format:t=>Array.isArray(t)?t.map(e=>e.verb).join(" "):String(t)},{key:"createdAt",header:"Created",format:eh}];function Tct(t){let e=t.command("jots").description("Judgment journal: record and look up judgment entries");e.command("create").description("Record judgment entries (batch via --input, single via flags)").option("--kind <kind>","Judgment kind (CLASSIFICATION, MATCH, SCOPE, ASSUMPTION, RISK, METHOD, RECOVERY, DEVIATION, NOTE)").option("--tier <tier>","Severity tier (LOW, MEDIUM, HIGH, CRITICAL)").option("--call <call>","The decision, one line").option("--why <why>","The basis for the call").option("--ruled-out <text>","Alternatives considered and set aside").option("--ref <ref...>","Entity ref, grammar TYPE:resourceId[#field][:RELATION] (repeatable)").option("--frame <frame>","Set anchor: defining query + counts").option("--confidence <level>","Routing hint (LOW, MEDIUM, HIGH)").option("--cited-rule <rule>","Org rule, policy, threshold, or precedent applied").option("--workflow-label <label>","Short workflow label (e.g. month-end-close)").option("--agent-label <label>","Self-reported product/model").option("--idempotency-key <key>","Retry key: a replay returns the existing entry").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").addHelpText("after",`
1077
1077
  Doctrine (docs/jot-doctrine.md):
1078
1078
  Tier ${qP}
1079
1079
  Confidence ${jP}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaz-clio",
3
- "version": "5.55.14",
3
+ "version": "5.55.15",
4
4
  "description": "Clio: Command Line Interface Operator for Jaz AI.",
5
5
  "type": "module",
6
6
  "bin": {