jaz-clio 5.53.0 → 5.53.1

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.53.0
3
+ version: 5.53.1
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
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-cli
3
- version: 5.53.0
3
+ version: 5.53.1
4
4
  description: >-
5
5
  Use this skill when running Clio CLI commands, building shell scripts with
6
6
  Clio, debugging auth issues, understanding --json output, paginating results,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jaz-conversion
3
- version: 5.53.0
3
+ version: 5.53.1
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.53.0
3
+ version: 5.53.1
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.53.0
3
+ version: 5.53.1
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.53.0
3
+ version: 5.53.1
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.53.0
3
+ version: 5.53.1
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
@@ -202,7 +202,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
202
202
  `);return{type:"depreciation",currency:o??null,inputs:{cost:t,salvageValue:e,usefulLifeYears:r,method:"sl",frequency:i},totalDepreciation:n,schedule:d,blueprint:{capsuleType:"Depreciation",capsuleName:`SL Depreciation \u2014 ${r} years`,capsuleDescription:m,tags:["Depreciation"],customFields:{"Asset ID":null},steps:p}}}function xwe(t,e,r,n,i,o,s){let a=[],c=t;for(let m=1;m<=r;m++){let A=re(c),g=r-m+1,y=re(A*n),C=re((A-e)/g),E=re(A-y)<e,I=C>=y||E,v=I?"SL":o==="150db"?"150DB":"DDB",x=I?C:y;re(A-x)<e&&(x=re(A-e)),c=re(A-x);let S={description:`${v} depreciation \u2014 Year ${m} of ${r}`,lines:[{account:"Depreciation Expense",debit:x,credit:0},{account:"Accumulated Depreciation",debit:0,credit:x}]};a.push({period:m,date:null,openingBookValue:A,ddbAmount:y,slAmount:C,methodUsed:v,depreciation:x,closingBookValue:c,journal:S})}let u=a.map((m,A)=>zr(A+1,m.journal.description,m.date,m.journal.lines)),d=s??void 0,f=o==="ddb"?"Double Declining Balance":"150% Declining Balance",p=re(n*100),h=[`${f} Depreciation Workings`,`Cost: ${Ue(t,d)} | Salvage: ${Ue(e,d)} | Depreciable base: ${Ue(i,d)}`,`Useful life: ${r} years | Rate: ${p}% (${o==="ddb"?"2":"1.5"} \xF7 ${r})`,`Total depreciation: ${Ue(i,d)}`,`Method: ${o.toUpperCase()} with auto switch to SL when SL \u2265 declining or floor hit`,"Rounding: 2dp per period, book value never falls below salvage"].join(`
203
203
  `);return{type:"depreciation",currency:s??null,inputs:{cost:t,salvageValue:e,usefulLifeYears:r,method:o,frequency:"annual"},totalDepreciation:i,schedule:a,blueprint:{capsuleType:"Depreciation",capsuleName:`${o.toUpperCase()} Depreciation \u2014 ${r} years`,capsuleDescription:h,tags:["Depreciation"],customFields:{"Asset ID":null},steps:u}}}var K9=X(()=>{"use strict";Fs();cs();Fa()});function LF(t){let{amount:e,periods:r,frequency:n="monthly",startDate:i,currency:o}=t;hn(e,"Amount"),Mi(r,"Periods"),ki(i);let s=Twe(e,r,n,i,"prepaid"),a=null;if(i){let c=[vwe(1,"Create bill from supplier coded to Prepaid Asset, then pay from Cash / Bank Account",i,[{account:"Prepaid Asset",debit:e,credit:0},{account:"Cash / Bank Account",debit:0,credit:e}]),...s.map((f,p)=>zr(p+2,f.journal.description,f.date,f.journal.lines))],u=o??void 0,d=["Prepaid Expense Recognition Workings",`Total prepaid: ${Ue(e,u)} | Periods: ${r} (${n})`,`Per period: ${Ue(re(e/r),u)}`,`Method: Straight-line recognition over ${r} ${n} periods`,"Rounding: 2dp per period, final period absorbs remainder"].join(`
204
204
  `);a={capsuleType:"Prepaid Expenses",capsuleName:`Prepaid Expense \u2014 ${mi(e,o)} \u2014 ${r} periods`,capsuleDescription:d,tags:["Prepaid Expense"],customFields:{"Policy / Contract #":null},steps:c}}return{type:"prepaid-expense",currency:o??null,inputs:{amount:e,periods:r,frequency:n,startDate:i??null},perPeriodAmount:re(e/r),schedule:s,blueprint:a}}function MF(t){let{amount:e,periods:r,frequency:n="monthly",startDate:i,currency:o}=t;hn(e,"Amount"),Mi(r,"Periods"),ki(i);let s=Twe(e,r,n,i,"deferred"),a=null;if(i){let c=[wwe(1,"Create invoice to customer coded to Deferred Revenue, record payment to Cash / Bank Account",i,[{account:"Cash / Bank Account",debit:e,credit:0},{account:"Deferred Revenue",debit:0,credit:e}]),...s.map((f,p)=>zr(p+2,f.journal.description,f.date,f.journal.lines))],u=o??void 0,d=["Deferred Revenue Recognition Workings",`Total deferred: ${Ue(e,u)} | Periods: ${r} (${n})`,`Per period: ${Ue(re(e/r),u)}`,`Method: Straight-line recognition over ${r} ${n} periods`,"Rounding: 2dp per period, final period absorbs remainder"].join(`
205
- `);a={capsuleType:"Deferred Revenue",capsuleName:`Deferred Revenue \u2014 ${mi(e,o)} \u2014 ${r} periods`,capsuleDescription:d,tags:["Deferred Revenue"],customFields:{"Contract #":null},steps:c}}return{type:"deferred-revenue",currency:o??null,inputs:{amount:e,periods:r,frequency:n,startDate:i??null},perPeriodAmount:re(e/r),schedule:s,blueprint:a}}function Twe(t,e,r,n,i){let o=re(t/e),s=[],a=t,c=r==="quarterly"?3:1;for(let u=1;u<=e;u++){let f=u===e?re(a):o;a=re(a-f);let p=n?po(n,u*c):null,h;i==="prepaid"?h={description:`Prepaid expense recognition \u2014 Period ${u} of ${e}`,lines:[{account:"Expense",debit:f,credit:0},{account:"Prepaid Asset",debit:0,credit:f}]}:h={description:`Deferred revenue recognition \u2014 Period ${u} of ${e}`,lines:[{account:"Deferred Revenue",debit:f,credit:0},{account:"Revenue",debit:0,credit:f}]},s.push({period:u,date:p,amortized:f,remainingBalance:a,journal:h})}return s}var e6=X(()=>{"use strict";Fs();cs();Fa()});async function ho(t,e,r,n){return t.post(e,{[r]:n})}function Ot(t,e,r=500,n=e){if(!Array.isArray(t))throw new at(`${e} must be an array.`);if(t.length===0)throw new at(`${e} array is empty.`);if(t.length>r)throw new at(`max ${r} ${n} per call (got ${t.length}). Split into batches.`)}function bl(t,e){t.forEach((r,n)=>{if(!r||typeof r!="object")return;let i=r;if("dateFormat"in i)throw new at(`row ${n}: dateFormat field is no longer supported (ISO 8601 YYYY-MM-DD only)`);for(let o of e){let s=i[o];if(s!=null&&(typeof s!="string"||!o_t.test(s)))throw new at(`row ${n}: ${o} must be YYYY-MM-DD (got ${JSON.stringify(s)})`)}})}function s_t(t,e){t.forEach((r,n)=>{t6(r,"bulk-upsert",n);let i=r[e];if(!(typeof i=="string"&&i.trim()!==""))throw new at(`row ${n}: ${e} is required on every bulk-upsert transaction row (ISO 4217, e.g. "SGD") \u2014 without it the job fails the row with IMPORT_CURRENCY_REQUIRED`)})}function HE(t,e){if(!e.some(([n])=>n in t))return t;let r={...t};for(let[n,i]of e){if(!(n in r))continue;let o=r[n];delete r[n],o!==void 0&&(i in r||(r[i]=o))}return r}function t6(t,e,r){if(!t||typeof t!="object"||Array.isArray(t)){let n=r===void 0?"":`row ${r}: `;throw new at(`${n}each ${e} row must be an object (got ${t===null?"null":typeof t})`)}return t}function a_t(t){return HE(t,Bwe)}function u_t(t){return!t||typeof t!="object"||Array.isArray(t)?t:HE(t,Nwe)}function UF(t){return HE(t6(t,"item"),PF)}function Owe(t){return t.map((e,r)=>{let n=t6(e,"contact",r),i=HE(n,kwe),o=i===n?{...n}:i;if("emails"in o){let s=o.emails;!("emailList"in o)&&Array.isArray(s)&&(o.emailList=s.map(a=>typeof a=="string"?{email:a,label:"Contact Email"}:a)),delete o.emails}for(let s of["billingAddress","deliveryAddress"]){if(!(s in o))continue;o[s]=u_t(o[s]);let a=o[s];if(a&&typeof a=="object"&&!Array.isArray(a)){let c=l_t.filter(u=>!a[u]);if(c.length>0)throw new at(`row ${r}: ${s} requires ${c.join(" and ")} \u2014 the API rejects the WHOLE batch with 422 otherwise`)}}return o})}function up(t){return s_t(t,"currencyCode"),t.map(a_t)}function Fwe(t,e){t.forEach((r,n)=>{if(!r||typeof r!="object")return;let i=r;for(let o of e){let s=i[o];if(s!=null&&(typeof s!="number"||!Number.isFinite(s)))throw new at(`row ${n}: ${o} must be epoch milliseconds on this endpoint, not a date string (got ${JSON.stringify(s)}) \u2014 e.g. 1745107200000`)}})}var o_t,Bwe,c_t,kwe,Nwe,l_t,PF,r6,$qr,En=X(()=>{"use strict";ur();o_t=/^\d{4}-\d{2}-\d{2}$/;Bwe=[["currencyCode","transactionCurrency"]];c_t=["BulkUpsertCustomerCreditNote","BulkUpsertLineItemBill","BulkUpsertLineItemInvoice","BulkUpsertSupplierCreditNote"],kwe=[["billingName","contactBillingName"],["currencyCode","currency"],["registrationNumber","registrationId"],["notes","customerInvoiceNotes"],["shippingAddress","deliveryAddress"]],Nwe=[["address","addressLine1"]],l_t=["addressLine1","country"];PF=[["saleTaxProfileResourceId","saleTaxProfile"],["purchaseTaxProfileResourceId","purchaseTaxProfile"],["purchasePrice","purchaseItemPrice"]];r6=[["contactResourceIds","associatedContactResourceIds"]],$qr=[["BulkUpsertContact",kwe],["UpdateContactGroupClientRequest",r6],["BulkUpsertContactAddress",Nwe],["BulkUpsertItemRequestItem",PF],["CreateItemClientRequest",PF],["UpdateItemClientRequest",PF],...c_t.map(t=>[t,Bwe])]});async function Qwe(t,e,r){return t.get(`/api/v1/contacts/${e}/signals`,{btType:r})}async function dp(t,e){return t.list("/api/v1/contacts",e)}async function bc(t,e){return t.search("/api/v1/contacts/search",e)}async function zE(t,e){return t.post("/api/v1/contacts",e)}async function $F(t,e,r){return t.put(`/api/v1/contacts/${e}`,r)}async function fp(t,e){return t.get(`/api/v1/contacts/${e}`)}async function qF(t,e){await t.delete(`/api/v1/contacts/${e}`)}async function jF(t,e){return ho(t,"/api/v1/contacts/bulk-upsert","contacts",Owe(e))}var pp=X(()=>{"use strict";En()});function Lwe(t,e){let r=t?.sourceCurrencyCode??e;if(!r||t?.baseCurrencyCode&&t.baseCurrencyCode===r)return;let n=t?.baseToSourceRate,i=n==null?void 0:Number(n);return i===void 0||!Number.isFinite(i)||i<=0?{sourceCurrency:r}:{sourceCurrency:r,exchangeRate:i}}async function Cc(t,e){if(t.currency!==void 0&&t.taxCurrency!==void 0)return t;let r;try{r=(await e()).data}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`Refusing to update: could not read the document to preserve its currency. An update that omits \`currency\` re-bases a foreign-currency document to the organization base at rate 1, so this fails rather than risk it. Retry, or pass \`currency\` explicitly to assert the currency yourself. Cause: ${s}`)}let n=t.currency??Lwe(r.currencyExchange,r.currencyCode),i=t.taxCurrency??Lwe(r.taxCurrencyExchange,r.currencyCode);return!n&&!i?t:{...t,...n?{currency:n}:{},...i?{taxCurrency:i}:{}}}var Kw=X(()=>{"use strict"});function hp(t){if(t===null||typeof t!="object"||Array.isArray(t))return t;let r={...t};if(r.organizationAccountResourceId!==void 0&&(r.accountResourceId===void 0&&(r.accountResourceId=r.organizationAccountResourceId),delete r.organizationAccountResourceId),r.discount!==null&&typeof r.discount=="object"&&!Array.isArray(r.discount)){let n=r.discount;r.discount=n.rateValue??0}if(r.taxProfile!==null&&typeof r.taxProfile=="object"&&!Array.isArray(r.taxProfile)){let n=r.taxProfile;r.taxProfileResourceId===void 0&&n.resourceId!==void 0&&(r.taxProfileResourceId=n.resourceId),delete r.taxProfile}return r}function Ic(t){let e={};t.name!=null&&(e.name=t.name),t.quantity!=null&&(e.quantity=t.quantity),t.unitPrice!=null&&(e.unitPrice=t.unitPrice),t.unit&&(e.unit=t.unit);let r=t.accountResourceId||t.organizationAccountResourceId;r&&(e.accountResourceId=r);let n=t.taxProfileResourceId||(t.taxProfile&&typeof t.taxProfile=="object"?t.taxProfile.resourceId:null);return n&&(e.taxProfileResourceId=n),t.itemResourceId&&(e.itemResourceId=t.itemResourceId),t.discount!=null&&(e.discount=typeof t.discount=="object"?t.discount.rateValue??0:t.discount),e}function GE(t){let e={},r=t.accountResourceId||t.organizationAccountResourceId;return r&&(e.accountResourceId=r),t.amount!=null?e.amount=t.amount:t.debitAmount!=null&&t.debitAmount>0?e.amount=t.debitAmount:t.creditAmount!=null&&t.creditAmount>0&&(e.amount=t.creditAmount),t.type?e.type=t.type:t.debitAmount!=null&&t.debitAmount>0?e.type="DEBIT":t.creditAmount!=null&&t.creditAmount>0&&(e.type="CREDIT"),t.description&&(e.description=t.description),t.contactResourceId&&(e.contactResourceId=t.contactResourceId),e}function Ut(t){if(t)return t.split("T")[0]}var RA=X(()=>{"use strict"});async function YF(t,e){return t.list("/api/v1/bills",e)}async function Oo(t,e){return t.get(`/api/v1/bills/${e}`)}async function Md(t,e){return t.search("/api/v1/bills/search",e)}async function xA(t,e){return t.post("/api/v1/bills",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function HF(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(hp)}:r,i=await Cc(n,()=>Oo(t,e));return t.put(`/api/v1/bills/${e}`,i)}async function e_(t,e,r){let n=await Cc({...r,resourceId:e,saveAsDraft:!1},()=>Oo(t,e));return t.put(`/api/v1/bills/${e}`,n)}async function zF(t,e,r){return t.delete(`/api/v1/bills/${e}`,r)}async function GF(t,e){return t.get(`/api/v1/bills/${e}/download`)}async function t_(t,e,r){return t.post(`/api/v1/bills/${e}/payments`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function JF(t,e,r){return t.post(`/api/v1/bills/${e}/credits`,{credits:r})}async function r_(t,e){return t.post("/api/v1/scheduled/bills",{...e,bill:{...e.bill,currency:Sr(e.bill?.currency)}})}async function VF(t,e){let r=await t.get(`/api/v1/bills/${e}/payments`);return{data:Array.isArray(r)?r:r.data??[]}}async function WF(t,e){let r=await t.get(`/api/v1/bills/${e}/credits`);return{data:Array.isArray(r)?r:r.data??[]}}async function ZF(t,e,r){await t.delete(`/api/v1/bills/${e}/credits/${r}`)}async function XF(t,e){return ho(t,"/api/v1/bills/bulk-upsert","bills",e)}async function KF(t,e){return ho(t,"/api/v1/bills/line-items/bulk-upsert","bills",up(e))}var Pd=X(()=>{"use strict";Kw();RA();En();ur()});function Cl(t){if(typeof t=="number"){let e=new Date(t);return Number.isNaN(e.getTime())?void 0:e.toISOString().slice(0,10)}if(typeof t=="string"){let e=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]|$)/.exec(t.trim());return e?`${e[1]}-${e[2].padStart(2,"0")}-${e[3].padStart(2,"0")}`:void 0}}var JE=X(()=>{"use strict"});async function e1(t,e){return t.list("/api/v1/items",e)}async function VE(t,e){return t.get(`/api/v1/items/${e}`)}async function WE(t,e){return t.search("/api/v1/items/search",e)}async function n_(t,e){let r={...e};return e.appliesToSale&&!r.saleItemName&&(r.saleItemName=e.internalName),e.appliesToPurchase&&!r.purchaseItemName&&(r.purchaseItemName=e.internalName),t.post("/api/v1/items",UF(r))}async function t1(t,e,r){let i=(await VE(t,e)).data,o={itemCode:i.itemCode,internalName:i.internalName,appliesToSale:i.appliesToSale,appliesToPurchase:i.appliesToPurchase};return i.appliesToSale&&(i.saleItemName&&(o.saleItemName=i.saleItemName),i.salePrice!==void 0&&(o.salePrice=i.salePrice),i.saleAccountResourceId&&(o.saleAccountResourceId=i.saleAccountResourceId)),i.appliesToPurchase&&(i.purchaseItemName&&(o.purchaseItemName=i.purchaseItemName),i.purchasePrice!==void 0&&(o.purchasePrice=i.purchasePrice),i.purchaseAccountResourceId&&(o.purchaseAccountResourceId=i.purchaseAccountResourceId)),Object.assign(o,r),t.put(`/api/v1/items/${e}`,UF(o))}async function r1(t,e){await t.delete(`/api/v1/items/${e}`)}async function n1(t,e){return t.post("/api/v1/items/bulk-upsert",{items:e.map(UF)})}var i1=X(()=>{"use strict";En()});async function Ud(t,e){return t.list("/api/v1/chart-of-accounts",e)}async function ZE(t,e){return t.search("/api/v1/chart-of-accounts/search",e)}async function o1(t,e){return t.get(`/api/v1/chart-of-accounts/${e}`)}async function i_(t,e){return t.post("/api/v1/chart-of-accounts",e)}async function Mwe(t,e,r){return t.put(`/api/v1/chart-of-accounts/${e}`,r)}function s1(t){let e={};for(let r of d_t){let n=t[r];n!=null&&(r==="accountType"&&typeof n=="string"?e.accountType=KE(n):e[r]=n)}return e}async function a1(t,e){return t.post("/api/v1/chart-of-accounts/bulk-upsert",{accounts:e})}async function c1(t,e){await t.delete(`/api/v1/chart-of-accounts/${e}`)}async function Pwe(t,e){return t.list("/api/v1/account-classifications",e)}var d_t,XE=X(()=>{"use strict";ur();d_t=["resourceId","code","name","accountType","currencyCode","description","status"]});async function eb(t){return t.get("/api/v1/capsuleTypes")}async function o_(t,e){return t.post("/api/v1/capsuleTypes",e)}async function l1(t,e){return t.list("/api/v1/capsules",e)}async function tb(t,e){return t.search("/api/v1/capsules/search",e)}async function s_(t,e){return t.get(`/api/v1/capsules/${e}`)}async function TA(t,e){return t.post("/api/v1/capsules",e)}async function u1(t,e,r){let n=await s_(t,e),i=n.data.capsuleType?.resourceId;if(!i)throw new Error(`Cannot update capsule ${e}: missing capsuleType.resourceId from GET response`);let o={resourceId:e,capsuleTypeResourceId:i,title:n.data.title,description:n.data.description,...r};return t.put(`/api/v1/capsules/${e}`,o)}async function d1(t,e){await t.delete(`/api/v1/capsules/${e}`)}async function f1(t,e){return t.post("/api/v1/moveTransactionCapsules",e)}var a_=X(()=>{"use strict"});async function rb(t,e){return t.list("/api/v1/tax-profiles",e)}async function p1(t,e){return t.list("/api/v1/tax-types",e)}async function h1(t,e){return t.post("/api/v1/tax-profiles",e)}async function nb(t,e){return t.post("/api/v1/tax-profiles/search",e)}async function c_(t,e){return t.get(`/api/v1/tax-profiles/${e}`)}async function m1(t,e,r){let n={...r};if(n.name===void 0||n.description===void 0||n.taxType===void 0||n.vatValue===void 0){let i=await c_(t,e);n.name??=i.data.name??i.data.displayName,n.description??=i.data.description??"",n.taxType??=i.data.taxTypeCode,n.vatValue??=i.data.vatValue??i.data.taxRate}return t.put(`/api/v1/tax-profiles/${e}`,n)}async function A1(t){let e=await t.get("/api/v1/withholding-tax-codes");return{data:Array.isArray(e)?e:e.data??[]}}var l_=X(()=>{"use strict"});async function ib(t,e){return t.list("/api/v1/tags",e)}async function g1(t,e){return t.get(`/api/v1/tags/${e}`)}async function y1(t,e){return t.search("/api/v1/tags/search",e)}async function u_(t,e){return t.post("/api/v1/tags",e)}async function E1(t,e,r){return t.put(`/api/v1/tags/${e}`,r)}async function b1(t,e){await t.delete(`/api/v1/tags/${e}`)}var C1=X(()=>{"use strict"});async function I1(t,e){return t.list("/api/v1/claim-types",e)}async function v1(t,e){return t.get(`/api/v1/claim-types/${e}`)}async function ob(t,e){return t.search("/api/v1/claim-types/search",e)}async function w1(t,e){return t.post("/api/v1/claim-types",e)}async function _1(t,e,r){return t.put(`/api/v1/claim-types/${e}`,r)}async function D1(t,e){await t.delete(`/api/v1/claim-types/${e}`)}var d_,S1=X(()=>{"use strict";d_=["expenseAccountResourceId","taxProfileResourceId","classifierConfig"]});async function R1(t,e){return t.list("/api/v1/claim-profiles",e)}async function x1(t,e){return t.get(`/api/v1/claim-profiles/${e}`)}async function sb(t,e){return t.search("/api/v1/claim-profiles/search",e)}async function T1(t,e){return t.post("/api/v1/claim-profiles",e)}async function B1(t,e,r){return t.put(`/api/v1/claim-profiles/${e}`,r)}async function k1(t,e){await t.delete(`/api/v1/claim-profiles/${e}`)}var f_,n6,p_,h_=X(()=>{"use strict";f_=["DAILY","WEEKLY","MONTHLY","QUARTERLY","YEARLY"],n6=["NO_TAX","INCLUSIVE"],p_=["approverUserResourceId","visibleClaimTypeIds","visibleTaxProfileIds","visibleClassifierIds","visibleVendorResourceIds","allowedCurrencies","minClaimAmount","maxClaimAmount","maxPerPeriodAmount","perPeriod","employeeBalanceAccountResourceId","taxMode"]});async function N1(t,e){return t.list("/api/v1/posting-rules",e)}async function O1(t,e){return t.get(`/api/v1/posting-rules/${e}`)}async function ab(t,e){return t.search("/api/v1/posting-rules/search",e)}async function F1(t,e){return t.post("/api/v1/posting-rules",e)}async function Q1(t,e,r){return t.put(`/api/v1/posting-rules/${e}`,r)}async function L1(t,e){await t.delete(`/api/v1/posting-rules/${e}`)}var m_,A_,g_=X(()=>{"use strict";m_=["PER_EMPLOYEE","PER_VENDOR","PER_PAIR","ONE_BATCH","PER_CLAIM"],A_=["RAW","BY_CT_TP_NC","BY_CT_TP_NC_EMPLOYEE","BY_CT_TP_NC_VENDOR"]});async function cb(t,e){return t.search("/api/v1/employees/search",e)}async function M1(t,e){return t.search("/api/v1/employees/balances/search",e)}async function P1(t,e){return t.get(`/api/v1/employees/${e}`)}async function U1(t,e){return t.post("/api/v1/employees",e)}async function $1(t,e,r){return t.put(`/api/v1/employees/${e}`,r)}async function q1(t,e){return t.delete(`/api/v1/employees/${e}`)}async function j1(t,e,r){return t.post(`/api/v1/employees/${e}/bind-user`,{userResourceId:r})}async function Y1(t,e){return t.post("/api/v1/employees/import/preprocess",e)}async function H1(t,e){if((e.create?.length??0)+(e.update?.length??0)+(e.delete?.length??0)===0)throw new at("import requires at least one create / update / delete row.");for(let[n,i]of Object.entries(e))if(Array.isArray(i)&&i.length>100)throw new at(`max 100 ${n} rows per import. Split into batches.`);return t.post("/api/v1/employees/import",e)}var BA,y_=X(()=>{"use strict";ur();BA=["FULL_TIME","PART_TIME","CONTRACTOR","INTERN","TEMPORARY","CONSULTANT"]});async function b_(t,e){return e?((await bc(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(n=>n.name===e):void 0}async function z1(t,e){return e?((await WE(t,{filter:{itemCode:{eq:e}},limit:5}))?.data??[]).find(n=>n.itemCode===e):void 0}function KE(t){if(typeof t!="string")return String(t??"");let e=t.trim();return p_t[e.toLowerCase()]??e}function G1(t){if(typeof t!="string")return;let e=t.trim().toUpperCase().replace(/[\s-]+/g,"_");return e==="FUNCTIONAL_TO_SOURCE"||e==="SOURCE_TO_FUNCTIONAL"?e:void 0}function i6(t){if(t!=null){if(t!=="FUNCTIONAL_TO_SOURCE"&&t!=="SOURCE_TO_FUNCTIONAL")throw new E_(`Unknown rateDirection ${JSON.stringify(t)}. Use FUNCTIONAL_TO_SOURCE or SOURCE_TO_FUNCTIONAL (exact, upper-case).`);return t}}function o6(t,e){if(typeof t!="number"||!Number.isFinite(t)||t<=0)throw new E_(`${e} must be a finite number greater than 0 (got ${JSON.stringify(t)}).`);return t}function Sr(t){if(!t||typeof t!="object")return t;let{rateDirection:e,exchangeRate:r,...n}=t;if(i6(e),r===void 0){if(e==="SOURCE_TO_FUNCTIONAL")throw new E_("rateDirection SOURCE_TO_FUNCTIONAL was supplied without exchangeRate \u2014 there is nothing to invert. Provide the rate, or drop rateDirection.");return{...n}}o6(r,"exchangeRate");let i=e==="SOURCE_TO_FUNCTIONAL"?1/r:r;return{...n,exchangeRate:i}}function Ap(t,e){if(!t?.exchangeRate)return;let{sourceCurrency:r,exchangeRate:n,rateDirection:i}=t,o=i==="SOURCE_TO_FUNCTIONAL"?1/n:n,s=r||"the foreign currency",a=[`FX: 1 base unit = ${mp(o)} ${s}`];return i==="SOURCE_TO_FUNCTIONAL"&&a.push(`(from 1 ${s} = ${mp(n)} base, inverted for you)`),typeof e=="number"&&Number.isFinite(e)&&e>0&&a.push(`\u2192 ${s} ${mp(e)} books as ${mp(e/o)} base`),a.join(" ")}function s6(t){if(!t)return;let{baseCurrency:e,sourceCurrency:r,exchangeRate:n,date:i}=t;if(!(typeof e!="string"||e.length===0)&&!(typeof r!="string"||r.length===0)&&!(typeof i!="string"||i.length===0)&&!(typeof n!="number"||!Number.isFinite(n)||n<=0))return`FX: 1 ${e} (your base) = ${mp(n)} ${r} (applied rate for ${i})`}function C_(t,e){return s6(t)??Ap(e)}function mp(t){return Number.isFinite(t)?new Intl.NumberFormat("en-US",{maximumSignificantDigits:10,maximumFractionDigits:20,useGrouping:!1,notation:"standard"}).format(t):String(t)}async function Uwe(t,e){if(!e?.trim())return;let r=e.trim().toLowerCase();return((await tb(t,{filter:{title:{contains:e.trim()}},limit:20}))?.data??[]).find(i=>i.title?.trim().toLowerCase()===r)}async function J1(t,e){return e?((await ZE(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(n=>n.name===e):void 0}async function V1(t,e){return e?((await nb(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(n=>n.name===e):void 0}async function W1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await ib(t,{limit:500}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function Z1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await ob(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function X1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await sb(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function K1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await ab(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function eQ(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await cb(t,{filter:{email:{eq:e}},limit:5}))?.data??[]).find(i=>i.email?.toLowerCase().trim()===r)}function y_t(t){let e=Date.parse(`${t}T00:00:00Z`);return Number.isNaN(e)?t:new Date(e+864e5).toISOString().slice(0,10)}function tQ(t){if(!Array.isArray(t))return;let e=0;for(let r of t){if(!r||typeof r!="object")return;let n=r;if(n.discount!==void 0&&n.discount!==null&&Number(n.discount)!==0)return;let i=Number(n.quantity),o=Number(n.unitPrice);if(!Number.isFinite(i)||!Number.isFinite(o))return;e+=i*o}return e>0?e:void 0}async function rQ(t,e){let{contactResourceId:r,valueDate:n,currencyCode:i,lineSubtotal:o}=e;if(!r||!n)return;let s={contactResourceId:{eq:r},valueDate:{gte:n,lte:y_t(n)},status:{in:[...h_t]}};return i&&(s.currencyCode={eq:i}),o!==void 0&&(s.totalAmount={gte:o*m_t,lte:o*A_t}),((await Md(t,{filter:s,limit:g_t}))?.data??[]).find(c=>c.contactResourceId===r&&Cl(c.valueDate)===n&&(!i||c.currencyCode===i)&&String(c.status??"").toUpperCase()!=="VOID")}function ls(t,e,r){if(!E_t.test(t))throw new at(`${e} must be a valid UUID (got "${t}"). ${r}`)}function Il(t,e={}){if(!(e.assumeFinalize===!0||t.saveAsDraft===!1))return;let n=t.lineItems;if(!Array.isArray(n)||n.length===0)return;let i=[];for(let a=0;a<n.length;a++){let c=n[a];if(!c||typeof c!="object")continue;let u=c.accountResourceId;(typeof u!="string"||u.trim().length===0)&&i.push(a)}if(i.length===0)return;let o=i.slice(0,5).join(", "),s=i.length>5?` (and ${i.length-5} more)`:"";return{error:`lineItems[${o}]${s}: accountResourceId is required when finalizing.`,status:422,hint:"Pre-flight guard \u2014 request never hit Clio. Search for the right GL account first, then retry with the resourceId on each line item.",repair:{tool:"search_accounts",arguments:{},reason:"Line item missing accountResourceId on a finalize call. Search for the GL account (by name or accountType) and attach the resourceId to each line item."}}}function nQ(t,e,r){let n=t.totalAmount===void 0?"amount unknown":`${t.currencyCode??""} ${t.totalAmount}`.trim();return`Nothing was created. A bill from this supplier already exists on ${Cl(t.valueDate)??e??"an unknown date"}: ${t.reference} (${n}, ${t.status}). Show it to the user and ask whether this is the same document. If they confirm it is a separate bill, retry with ${r}.`}var f_t,wjr,p_t,E_,h_t,m_t,A_t,g_t,E_t,at,ur=X(()=>{"use strict";cp();pp();Pd();JE();i1();XE();a_();l_();C1();S1();h_();g_();y_();f_t=["duplicate_skipped","duplicate_suspected"],wjr=new Set(f_t);p_t={"current assets":"Current Asset","current asset":"Current Asset","non-current assets":"Non-current Asset","non-current asset":"Non-current Asset","noncurrent asset":"Non-current Asset","non current asset":"Non-current Asset","fixed assets":"Fixed Asset","fixed asset":"Fixed Asset","bank account":"Bank Accounts","bank accounts":"Bank Accounts",bank:"Bank Accounts","current liabilities":"Current Liability","current liability":"Current Liability","non-current liabilities":"Non-current Liability","non-current liability":"Non-current Liability","noncurrent liability":"Non-current Liability","non current liability":"Non-current Liability",equity:"Shareholders Equity","shareholders equity":"Shareholders Equity","shareholders' equity":"Shareholders Equity","shareholder's equity":"Shareholders Equity",revenue:"Operating Revenue","operating revenue":"Operating Revenue","other revenue":"Other Revenue","other income":"Other Revenue",expense:"Operating Expense","operating expense":"Operating Expense",expenses:"Operating Expense","operating expenses":"Operating Expense","other expense":"Other Expense","other expenses":"Other Expense","direct costs":"Direct Costs","direct cost":"Direct Costs","cost of goods sold":"Direct Costs",cogs:"Direct Costs","cost of sales":"Direct Costs",cash:"Cash","cash and cash equivalents":"Cash",inventory:"Inventory","discontinued expense":"Discontinued Expense","discontinued income":"Discontinued Income","finance cost":"Finance Cost","finance costs":"Finance Cost","financing income":"Financing Income",goodwill:"Goodwill","income tax expense":"Income Tax Expense","income tax":"Income Tax Expense","tax expense":"Income Tax Expense","investing expense":"Investing Expense","investing income":"Investing Income",investment:"Investment",investments:"Investment"};E_=class extends No{constructor(e){super(e),this.name="ExchangeRateError"}};h_t=["DRAFT","UNPAID","PARTIALLY_PAID","PAID"],m_t=.995,A_t=1.3,g_t=20;E_t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,at=class extends No{constructor(e){super(e),this.name="ApiValidationError"}}});function qwe(t,e,r,n){let i=r==="SOURCE_TO_FUNCTIONAL"?t*e:t/e;if(!Number.isFinite(i)||Math.abs(i)>b_t)throw new $t(`${n} of ${e} under ${r} translates ${t} into ${i}, outside the representable range. Check the rate direction \u2014 the two conventions are reciprocals, so picking the wrong one moves the result by rate\xB2.`);return i}function cQ(t){let{amount:e,bookRate:r,closingRate:n,rateDirection:i,position:o="ASSET",currency:s="USD",baseCurrency:a="SGD"}=t;if(hn(e,"Foreign currency amount"),hn(r,"Book rate"),hn(n,"Closing rate"),o!=="ASSET"&&o!=="LIABILITY")throw new $t(`position must be ASSET or LIABILITY (got ${JSON.stringify(o)}).`);let c=G1(i);if(!c)throw new $t('rateDirection is required: FUNCTIONAL_TO_SOURCE (1 base unit = N foreign \u2014 what list_currency_rates returns) or SOURCE_TO_FUNCTIONAL (1 foreign unit = N base \u2014 the everyday "1 USD = 1.35 SGD" quote).');let u=re(qwe(e,r,c,"Book rate")),d=re(qwe(e,n,c,"Closing rate")),f=re(o==="LIABILITY"?u-d:d-u),p=f>=0,h=Math.abs(f),m;p?m={description:`FX revaluation \u2014 ${s} ${e.toLocaleString()} @ ${n} (was ${r}, ${c})`,lines:[{account:`${s} Monetary Item`,debit:h,credit:0},{account:"FX Unrealized Gain",debit:0,credit:h}]}:m={description:`FX revaluation \u2014 ${s} ${e.toLocaleString()} @ ${n} (was ${r}, ${c})`,lines:[{account:"FX Unrealized Loss",debit:h,credit:0},{account:`${s} Monetary Item`,debit:0,credit:h}]};let A={description:`Reversal of FX revaluation \u2014 ${s} ${e.toLocaleString()}`,lines:m.lines.map(C=>({account:C.account,debit:C.credit,credit:C.debit}))},g=["FX Revaluation Workings (IAS 21)",`Foreign currency: ${s} ${e.toLocaleString()} | Base currency: ${a}`,`Rate direction: ${c} | Position: ${o}`,`Book rate: ${r} \u2192 Book value: ${Ue(u,a)}`,`Closing rate: ${n} \u2192 Closing value: ${Ue(d,a)}`,`${p?"Unrealized gain":"Unrealized loss"}: ${Ue(Math.abs(f),a)}`,"Method: IAS 21.23 \u2014 monetary items translated at closing rate","Reversal: Day 1 next period (standard reval/reverse approach)"].join(`
205
+ `);a={capsuleType:"Deferred Revenue",capsuleName:`Deferred Revenue \u2014 ${mi(e,o)} \u2014 ${r} periods`,capsuleDescription:d,tags:["Deferred Revenue"],customFields:{"Contract #":null},steps:c}}return{type:"deferred-revenue",currency:o??null,inputs:{amount:e,periods:r,frequency:n,startDate:i??null},perPeriodAmount:re(e/r),schedule:s,blueprint:a}}function Twe(t,e,r,n,i){let o=re(t/e),s=[],a=t,c=r==="quarterly"?3:1;for(let u=1;u<=e;u++){let f=u===e?re(a):o;a=re(a-f);let p=n?po(n,u*c):null,h;i==="prepaid"?h={description:`Prepaid expense recognition \u2014 Period ${u} of ${e}`,lines:[{account:"Expense",debit:f,credit:0},{account:"Prepaid Asset",debit:0,credit:f}]}:h={description:`Deferred revenue recognition \u2014 Period ${u} of ${e}`,lines:[{account:"Deferred Revenue",debit:f,credit:0},{account:"Revenue",debit:0,credit:f}]},s.push({period:u,date:p,amortized:f,remainingBalance:a,journal:h})}return s}var e6=X(()=>{"use strict";Fs();cs();Fa()});async function ho(t,e,r,n){return t.post(e,{[r]:n})}function Ot(t,e,r=500,n=e){if(!Array.isArray(t))throw new at(`${e} must be an array.`);if(t.length===0)throw new at(`${e} array is empty.`);if(t.length>r)throw new at(`max ${r} ${n} per call (got ${t.length}). Split into batches.`)}function bl(t,e){t.forEach((r,n)=>{if(!r||typeof r!="object")return;let i=r;if("dateFormat"in i)throw new at(`row ${n}: dateFormat field is no longer supported (ISO 8601 YYYY-MM-DD only)`);for(let o of e){let s=i[o];if(s!=null&&(typeof s!="string"||!o_t.test(s)))throw new at(`row ${n}: ${o} must be YYYY-MM-DD (got ${JSON.stringify(s)})`)}})}function s_t(t,e){t.forEach((r,n)=>{t6(r,"bulk-upsert",n);let i=r[e];if(!(typeof i=="string"&&i.trim()!==""))throw new at(`row ${n}: ${e} is required on every bulk-upsert transaction row (ISO 4217, e.g. "SGD") \u2014 without it the job fails the row with IMPORT_CURRENCY_REQUIRED`)})}function HE(t,e){if(!e.some(([n])=>n in t))return t;let r={...t};for(let[n,i]of e){if(!(n in r))continue;let o=r[n];delete r[n],o!==void 0&&(i in r||(r[i]=o))}return r}function t6(t,e,r){if(!t||typeof t!="object"||Array.isArray(t)){let n=r===void 0?"":`row ${r}: `;throw new at(`${n}each ${e} row must be an object (got ${t===null?"null":typeof t})`)}return t}function a_t(t){return HE(t,Bwe)}function u_t(t){return!t||typeof t!="object"||Array.isArray(t)?t:HE(t,Nwe)}function UF(t){return HE(t6(t,"item"),PF)}function Owe(t){return t.map((e,r)=>{let n=t6(e,"contact",r),i=HE(n,kwe),o=i===n?{...n}:i;if("emails"in o){let s=o.emails;!("emailList"in o)&&Array.isArray(s)&&(o.emailList=s.map(a=>typeof a=="string"?{email:a,label:"Contact Email"}:a)),delete o.emails}for(let s of["billingAddress","deliveryAddress"]){if(!(s in o))continue;o[s]=u_t(o[s]);let a=o[s];if(a&&typeof a=="object"&&!Array.isArray(a)){let c=l_t.filter(u=>!a[u]);if(c.length>0)throw new at(`row ${r}: ${s} requires ${c.join(" and ")} \u2014 the API rejects the WHOLE batch with 422 otherwise`)}}return o})}function up(t){return s_t(t,"currencyCode"),t.map(a_t)}function Fwe(t,e){t.forEach((r,n)=>{if(!r||typeof r!="object")return;let i=r;for(let o of e){let s=i[o];if(s!=null&&(typeof s!="number"||!Number.isFinite(s)))throw new at(`row ${n}: ${o} must be epoch milliseconds on this endpoint, not a date string (got ${JSON.stringify(s)}) \u2014 e.g. 1745107200000`)}})}var o_t,Bwe,c_t,kwe,Nwe,l_t,PF,r6,$qr,En=X(()=>{"use strict";ur();o_t=/^\d{4}-\d{2}-\d{2}$/;Bwe=[["currencyCode","transactionCurrency"]];c_t=["BulkUpsertCustomerCreditNote","BulkUpsertLineItemBill","BulkUpsertLineItemInvoice","BulkUpsertSupplierCreditNote"],kwe=[["billingName","contactBillingName"],["currencyCode","currency"],["registrationNumber","registrationId"],["notes","customerInvoiceNotes"],["shippingAddress","deliveryAddress"]],Nwe=[["address","addressLine1"]],l_t=["addressLine1","country"];PF=[["saleTaxProfileResourceId","saleTaxProfile"],["purchaseTaxProfileResourceId","purchaseTaxProfile"],["purchasePrice","purchaseItemPrice"]];r6=[["contactResourceIds","associatedContactResourceIds"]],$qr=[["BulkUpsertContact",kwe],["UpdateContactGroupClientRequest",r6],["BulkUpsertContactAddress",Nwe],["BulkUpsertItemRequestItem",PF],["CreateItemClientRequest",PF],["UpdateItemClientRequest",PF],...c_t.map(t=>[t,Bwe])]});async function Qwe(t,e,r){return t.get(`/api/v1/contacts/${e}/signals`,{btType:r})}async function dp(t,e){return t.list("/api/v1/contacts",e)}async function bc(t,e){return t.search("/api/v1/contacts/search",e)}async function zE(t,e){return t.post("/api/v1/contacts",e)}async function $F(t,e,r){return t.put(`/api/v1/contacts/${e}`,r)}async function fp(t,e){return t.get(`/api/v1/contacts/${e}`)}async function qF(t,e){await t.delete(`/api/v1/contacts/${e}`)}async function jF(t,e){return ho(t,"/api/v1/contacts/bulk-upsert","contacts",Owe(e))}var pp=X(()=>{"use strict";En()});function Lwe(t,e){let r=t?.sourceCurrencyCode??e;if(!r||t?.baseCurrencyCode&&t.baseCurrencyCode===r)return;let n=t?.baseToSourceRate,i=n==null?void 0:Number(n);return i===void 0||!Number.isFinite(i)||i<=0?{sourceCurrency:r}:{sourceCurrency:r,exchangeRate:i}}async function Cc(t,e){if(t.currency!==void 0&&t.taxCurrency!==void 0)return t;let r;try{r=(await e()).data}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`Refusing to update: could not read the document to preserve its currency. An update that omits \`currency\` re-bases a foreign-currency document to the organization base at rate 1, so this fails rather than risk it. Retry, or pass \`currency\` explicitly to assert the currency yourself. Cause: ${s}`)}let n=t.currency??Lwe(r.currencyExchange,r.currencyCode),i=t.taxCurrency??Lwe(r.taxCurrencyExchange,r.currencyCode);return!n&&!i?t:{...t,...n?{currency:n}:{},...i?{taxCurrency:i}:{}}}var Kw=X(()=>{"use strict"});function hp(t){if(t===null||typeof t!="object"||Array.isArray(t))return t;let r={...t};if(r.organizationAccountResourceId!==void 0&&(r.accountResourceId===void 0&&(r.accountResourceId=r.organizationAccountResourceId),delete r.organizationAccountResourceId),r.discount!==null&&typeof r.discount=="object"&&!Array.isArray(r.discount)){let n=r.discount;r.discount=n.rateValue??0}if(r.taxProfile!==null&&typeof r.taxProfile=="object"&&!Array.isArray(r.taxProfile)){let n=r.taxProfile;r.taxProfileResourceId===void 0&&n.resourceId!==void 0&&(r.taxProfileResourceId=n.resourceId),delete r.taxProfile}return r}function Ic(t){let e={};t.name!=null&&(e.name=t.name),t.quantity!=null&&(e.quantity=t.quantity),t.unitPrice!=null&&(e.unitPrice=t.unitPrice),t.unit&&(e.unit=t.unit);let r=t.accountResourceId||t.organizationAccountResourceId;r&&(e.accountResourceId=r);let n=t.taxProfileResourceId||(t.taxProfile&&typeof t.taxProfile=="object"?t.taxProfile.resourceId:null);return n&&(e.taxProfileResourceId=n),t.itemResourceId&&(e.itemResourceId=t.itemResourceId),t.discount!=null&&(e.discount=typeof t.discount=="object"?t.discount.rateValue??0:t.discount),e}function GE(t){let e={},r=t.accountResourceId||t.organizationAccountResourceId;return r&&(e.accountResourceId=r),t.amount!=null?e.amount=t.amount:t.debitAmount!=null&&t.debitAmount>0?e.amount=t.debitAmount:t.creditAmount!=null&&t.creditAmount>0&&(e.amount=t.creditAmount),t.type?e.type=t.type:t.debitAmount!=null&&t.debitAmount>0?e.type="DEBIT":t.creditAmount!=null&&t.creditAmount>0&&(e.type="CREDIT"),t.description&&(e.description=t.description),t.contactResourceId&&(e.contactResourceId=t.contactResourceId),e}function Ut(t){if(t)return t.split("T")[0]}var RA=X(()=>{"use strict"});async function YF(t,e){return t.list("/api/v1/bills",e)}async function Oo(t,e){return t.get(`/api/v1/bills/${e}`)}async function Md(t,e){return t.search("/api/v1/bills/search",e)}async function xA(t,e){return t.post("/api/v1/bills",{...e,currency:Sr(e.currency),taxCurrency:Sr(e.taxCurrency),saveAsDraft:e.saveAsDraft??!0})}async function HF(t,e,r){let n=r.lineItems?{...r,lineItems:r.lineItems.map(hp)}:r,i=await Cc(n,()=>Oo(t,e));return t.put(`/api/v1/bills/${e}`,i)}async function e_(t,e,r){let n=await Cc({...r,resourceId:e,saveAsDraft:!1},()=>Oo(t,e));return t.put(`/api/v1/bills/${e}`,n)}async function zF(t,e,r){return t.delete(`/api/v1/bills/${e}`,r)}async function GF(t,e){return t.get(`/api/v1/bills/${e}/download`)}async function t_(t,e,r){return t.post(`/api/v1/bills/${e}/payments`,{...r,currency:Sr(r.currency),saveAsDraft:r.saveAsDraft??!0})}async function JF(t,e,r){return t.post(`/api/v1/bills/${e}/credits`,{credits:r})}async function r_(t,e){return t.post("/api/v1/scheduled/bills",{...e,bill:{...e.bill,currency:Sr(e.bill?.currency)}})}async function VF(t,e){let r=await t.get(`/api/v1/bills/${e}/payments`);return{data:Array.isArray(r)?r:r.data??[]}}async function WF(t,e){let r=await t.get(`/api/v1/bills/${e}/credits`);return{data:Array.isArray(r)?r:r.data??[]}}async function ZF(t,e,r){await t.delete(`/api/v1/bills/${e}/credits/${r}`)}async function XF(t,e){return ho(t,"/api/v1/bills/bulk-upsert","bills",e)}async function KF(t,e){return ho(t,"/api/v1/bills/line-items/bulk-upsert","bills",up(e))}var Pd=X(()=>{"use strict";Kw();RA();En();ur()});function Cl(t){if(typeof t=="number"){let e=new Date(t);return Number.isNaN(e.getTime())?void 0:e.toISOString().slice(0,10)}if(typeof t=="string"){let e=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]|$)/.exec(t.trim());return e?`${e[1]}-${e[2].padStart(2,"0")}-${e[3].padStart(2,"0")}`:void 0}}var JE=X(()=>{"use strict"});async function e1(t,e){return t.list("/api/v1/items",e)}async function VE(t,e){return t.get(`/api/v1/items/${e}`)}async function WE(t,e){return t.search("/api/v1/items/search",e)}async function n_(t,e){let r={...e};return e.appliesToSale&&!r.saleItemName&&(r.saleItemName=e.internalName),e.appliesToPurchase&&!r.purchaseItemName&&(r.purchaseItemName=e.internalName),t.post("/api/v1/items",UF(r))}async function t1(t,e,r){let i=(await VE(t,e)).data,o={itemCode:i.itemCode,internalName:i.internalName,appliesToSale:i.appliesToSale,appliesToPurchase:i.appliesToPurchase};return i.appliesToSale&&(i.saleItemName&&(o.saleItemName=i.saleItemName),i.salePrice!==void 0&&(o.salePrice=i.salePrice),i.saleAccountResourceId&&(o.saleAccountResourceId=i.saleAccountResourceId)),i.appliesToPurchase&&(i.purchaseItemName&&(o.purchaseItemName=i.purchaseItemName),i.purchasePrice!==void 0&&(o.purchasePrice=i.purchasePrice),i.purchaseAccountResourceId&&(o.purchaseAccountResourceId=i.purchaseAccountResourceId)),Object.assign(o,r),t.put(`/api/v1/items/${e}`,UF(o))}async function r1(t,e){await t.delete(`/api/v1/items/${e}`)}async function n1(t,e){return t.post("/api/v1/items/bulk-upsert",{items:e.map(UF)})}var i1=X(()=>{"use strict";En()});async function Ud(t,e){return t.list("/api/v1/chart-of-accounts",e)}async function ZE(t,e){return t.search("/api/v1/chart-of-accounts/search",e)}async function o1(t,e){return t.get(`/api/v1/chart-of-accounts/${e}`)}async function i_(t,e){return t.post("/api/v1/chart-of-accounts",e)}async function Mwe(t,e,r){return t.put(`/api/v1/chart-of-accounts/${e}`,r)}function s1(t){let e={};for(let r of d_t){let n=t[r];n!=null&&(r==="accountType"&&typeof n=="string"?e.accountType=KE(n):e[r]=n)}return e}async function a1(t,e){return t.post("/api/v1/chart-of-accounts/bulk-upsert",{accounts:e})}async function c1(t,e){await t.delete(`/api/v1/chart-of-accounts/${e}`)}async function Pwe(t,e){return t.list("/api/v1/account-classifications",e)}var d_t,XE=X(()=>{"use strict";ur();d_t=["resourceId","code","name","accountType","currencyCode","description","status"]});async function eb(t){return t.get("/api/v1/capsuleTypes")}async function o_(t,e){return t.post("/api/v1/capsuleTypes",e)}async function l1(t,e){return t.list("/api/v1/capsules",e)}async function tb(t,e){return t.search("/api/v1/capsules/search",e)}async function s_(t,e){return t.get(`/api/v1/capsules/${e}`)}async function TA(t,e){return t.post("/api/v1/capsules",e)}async function u1(t,e,r){let n=await s_(t,e),i=n.data.capsuleType?.resourceId;if(!i)throw new Error(`Cannot update capsule ${e}: missing capsuleType.resourceId from GET response`);let o={resourceId:e,capsuleTypeResourceId:i,title:n.data.title,description:n.data.description,...r};return t.put(`/api/v1/capsules/${e}`,o)}async function d1(t,e){await t.delete(`/api/v1/capsules/${e}`)}async function f1(t,e){return t.post("/api/v1/moveTransactionCapsules",e)}var a_=X(()=>{"use strict"});async function rb(t,e){return t.list("/api/v1/tax-profiles",e)}async function p1(t,e){return t.list("/api/v1/tax-types",e)}async function h1(t,e){return t.post("/api/v1/tax-profiles",e)}async function nb(t,e){return t.post("/api/v1/tax-profiles/search",e)}async function c_(t,e){return t.get(`/api/v1/tax-profiles/${e}`)}async function m1(t,e,r){let n={...r};if(n.name===void 0||n.description===void 0||n.taxType===void 0||n.vatValue===void 0){let i=await c_(t,e);n.name??=i.data.name??i.data.displayName,n.description??=i.data.description??"",n.taxType??=i.data.taxTypeCode,n.vatValue??=i.data.vatValue??i.data.taxRate}return t.put(`/api/v1/tax-profiles/${e}`,n)}async function A1(t){let e=await t.get("/api/v1/withholding-tax-codes");return{data:Array.isArray(e)?e:e.data??[]}}var l_=X(()=>{"use strict"});async function ib(t,e){return t.list("/api/v1/tags",e)}async function g1(t,e){return t.get(`/api/v1/tags/${e}`)}async function y1(t,e){return t.search("/api/v1/tags/search",e)}async function u_(t,e){return t.post("/api/v1/tags",e)}async function E1(t,e,r){return t.put(`/api/v1/tags/${e}`,r)}async function b1(t,e){await t.delete(`/api/v1/tags/${e}`)}var C1=X(()=>{"use strict"});async function I1(t,e){return t.list("/api/v1/claim-types",e)}async function v1(t,e){return t.get(`/api/v1/claim-types/${e}`)}async function ob(t,e){return t.search("/api/v1/claim-types/search",e)}async function w1(t,e){return t.post("/api/v1/claim-types",e)}async function _1(t,e,r){return t.put(`/api/v1/claim-types/${e}`,r)}async function D1(t,e){await t.delete(`/api/v1/claim-types/${e}`)}var d_,S1=X(()=>{"use strict";d_=["expenseAccountResourceId","taxProfileResourceId","classifierConfig"]});async function R1(t,e){return t.list("/api/v1/claim-profiles",e)}async function x1(t,e){return t.get(`/api/v1/claim-profiles/${e}`)}async function sb(t,e){return t.search("/api/v1/claim-profiles/search",e)}async function T1(t,e){return t.post("/api/v1/claim-profiles",e)}async function B1(t,e,r){return t.put(`/api/v1/claim-profiles/${e}`,r)}async function k1(t,e){await t.delete(`/api/v1/claim-profiles/${e}`)}var f_,n6,p_,h_=X(()=>{"use strict";f_=["DAILY","WEEKLY","MONTHLY","QUARTERLY","YEARLY"],n6=["NO_TAX","INCLUSIVE"],p_=["approverUserResourceId","visibleClaimTypeIds","visibleTaxProfileIds","visibleClassifierIds","visibleVendorResourceIds","allowedCurrencies","minClaimAmount","maxClaimAmount","maxPerPeriodAmount","perPeriod","employeeBalanceAccountResourceId","taxMode"]});async function N1(t,e){return t.list("/api/v1/posting-rules",e)}async function O1(t,e){return t.get(`/api/v1/posting-rules/${e}`)}async function ab(t,e){return t.search("/api/v1/posting-rules/search",e)}async function F1(t,e){return t.post("/api/v1/posting-rules",e)}async function Q1(t,e,r){return t.put(`/api/v1/posting-rules/${e}`,r)}async function L1(t,e){await t.delete(`/api/v1/posting-rules/${e}`)}var m_,A_,g_=X(()=>{"use strict";m_=["PER_EMPLOYEE","PER_VENDOR","PER_PAIR","ONE_BATCH","PER_CLAIM"],A_=["RAW","BY_CT_TP_NC","BY_CT_TP_NC_EMPLOYEE","BY_CT_TP_NC_VENDOR"]});async function cb(t,e){return t.search("/api/v1/employees/search",e)}async function M1(t,e){return t.search("/api/v1/employees/balances/search",e)}async function P1(t,e){return t.get(`/api/v1/employees/${e}`)}async function U1(t,e){return t.post("/api/v1/employees",e)}async function $1(t,e,r){return t.put(`/api/v1/employees/${e}`,r)}async function q1(t,e){return t.delete(`/api/v1/employees/${e}`)}async function j1(t,e,r){return t.post(`/api/v1/employees/${e}/bind-user`,{userResourceId:r})}async function Y1(t,e){return t.post("/api/v1/employees/import/preprocess",e)}async function H1(t,e){if((e.create?.length??0)+(e.update?.length??0)+(e.delete?.length??0)===0)throw new at("import requires at least one create / update / delete row.");for(let[n,i]of Object.entries(e))if(Array.isArray(i)&&i.length>100)throw new at(`max 100 ${n} rows per import. Split into batches.`);return t.post("/api/v1/employees/import",e)}var BA,y_=X(()=>{"use strict";ur();BA=["FULL_TIME","PART_TIME","CONTRACTOR","INTERN","TEMPORARY","CONSULTANT"]});async function b_(t,e){return e?((await bc(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(n=>n.name===e):void 0}async function z1(t,e){return e?((await WE(t,{filter:{itemCode:{eq:e}},limit:5}))?.data??[]).find(n=>n.itemCode===e):void 0}function KE(t){if(typeof t!="string")return String(t??"");let e=t.trim();return p_t[e.toLowerCase()]??e}function G1(t){if(typeof t!="string")return;let e=t.trim().toUpperCase().replace(/[\s-]+/g,"_");return e==="FUNCTIONAL_TO_SOURCE"||e==="SOURCE_TO_FUNCTIONAL"?e:void 0}function i6(t){if(t!=null){if(t!=="FUNCTIONAL_TO_SOURCE"&&t!=="SOURCE_TO_FUNCTIONAL")throw new E_(`Unknown rateDirection ${JSON.stringify(t)}. Use FUNCTIONAL_TO_SOURCE or SOURCE_TO_FUNCTIONAL (exact, upper-case).`);return t}}function o6(t,e){if(typeof t!="number"||!Number.isFinite(t)||t<=0)throw new E_(`${e} must be a finite number greater than 0 (got ${JSON.stringify(t)}).`);return t}function Sr(t){if(!t||typeof t!="object")return t;let{rateDirection:e,exchangeRate:r,...n}=t;if(i6(e),r===void 0){if(e==="SOURCE_TO_FUNCTIONAL")throw new E_("rateDirection SOURCE_TO_FUNCTIONAL was supplied without exchangeRate \u2014 there is nothing to invert. Provide the rate, or drop rateDirection.");return{...n}}o6(r,"exchangeRate");let i=e==="SOURCE_TO_FUNCTIONAL"?1/r:r;return{...n,exchangeRate:i}}function Ap(t,e){if(!t?.exchangeRate)return;let{sourceCurrency:r,exchangeRate:n,rateDirection:i}=t,o=i==="SOURCE_TO_FUNCTIONAL"?1/n:n,s=r||"the foreign currency",a=[`FX: 1 base unit = ${mp(o)} ${s}`];return i==="SOURCE_TO_FUNCTIONAL"&&a.push(`(from 1 ${s} = ${mp(n)} base, inverted for you)`),typeof e=="number"&&Number.isFinite(e)&&e>0&&a.push(`\u2192 ${s} ${mp(e)} books as ${mp(e/o)} base`),a.join(" ")}function s6(t){if(!t)return;let{baseCurrency:e,sourceCurrency:r,exchangeRate:n,date:i}=t;if(!(typeof e!="string"||e.length===0)&&!(typeof r!="string"||r.length===0)&&!(typeof i!="string"||i.length===0)&&!(typeof n!="number"||!Number.isFinite(n)||n<=0))return`FX: 1 ${e} (your base) = ${mp(n)} ${r} (applied rate for ${i})`}function C_(t,e){return s6(t)??Ap(e)}function mp(t){return Number.isFinite(t)?new Intl.NumberFormat("en-US",{maximumSignificantDigits:10,maximumFractionDigits:20,useGrouping:!1,notation:"standard"}).format(t):String(t)}async function Uwe(t,e){if(!e?.trim())return;let r=e.trim().toLowerCase();return((await tb(t,{filter:{title:{contains:e.trim()}},limit:20}))?.data??[]).find(i=>i.title?.trim().toLowerCase()===r)}async function J1(t,e){return e?((await ZE(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(n=>n.name===e):void 0}async function V1(t,e){return e?((await nb(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(n=>n.name===e):void 0}async function W1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await ib(t,{limit:500}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function Z1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await ob(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function X1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await sb(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function K1(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await ab(t,{filter:{name:{eq:e}},limit:5}))?.data??[]).find(i=>i.name.toLowerCase().trim()===r)}async function eQ(t,e){if(!e)return;let r=e.toLowerCase().trim();return((await cb(t,{filter:{email:{eq:e}},limit:5}))?.data??[]).find(i=>i.email?.toLowerCase().trim()===r)}function y_t(t){let e=Date.parse(`${t}T00:00:00Z`);return Number.isNaN(e)?t:new Date(e+864e5).toISOString().slice(0,10)}function tQ(t){if(!Array.isArray(t))return;let e=0;for(let r of t){if(!r||typeof r!="object")return;let n=r;if(n.discount!==void 0&&n.discount!==null&&Number(n.discount)!==0)return;let i=Number(n.quantity),o=Number(n.unitPrice);if(!Number.isFinite(i)||!Number.isFinite(o))return;e+=i*o}return e>0?e:void 0}async function rQ(t,e){let{contactResourceId:r,valueDate:n,currencyCode:i,lineSubtotal:o}=e;if(!r||!n)return;let s={contactResourceId:{eq:r},valueDate:{gte:n,lte:y_t(n)},status:{in:[...h_t]}};return i&&(s.currencyCode={eq:i}),o!==void 0&&(s.totalAmount={gte:o*m_t,lte:o*A_t}),((await Md(t,{filter:s,limit:g_t}))?.data??[]).find(c=>c.contactResourceId===r&&Cl(c.valueDate)===n&&(!i||c.currencyCode===i)&&String(c.status??"").toUpperCase()!=="VOID")}function ls(t,e,r){if(!E_t.test(t))throw new at(`${e} must be a valid UUID (got "${t}"). ${r}`)}function Il(t,e={}){if(!(e.assumeFinalize===!0||t.saveAsDraft===!1))return;let n=t.lineItems;if(!Array.isArray(n)||n.length===0)return;let i=[];for(let a=0;a<n.length;a++){let c=n[a];if(!c||typeof c!="object")continue;let u=c.accountResourceId;(typeof u!="string"||u.trim().length===0)&&i.push(a)}if(i.length===0)return;let o=i.slice(0,5).join(", "),s=i.length>5?` (and ${i.length-5} more)`:"";return{error:`lineItems[${o}]${s}: accountResourceId is required when finalizing.`,status:422,hint:"Pre-flight guard \u2014 request never hit Clio. Search for the right GL account first, then retry with the resourceId on each line item.",repair:{tool:"search_accounts",arguments:{},reason:"Line item missing accountResourceId on a finalize call. Search for the GL account (by name or accountType) and attach the resourceId to each line item."}}}function nQ(t,e,r){let n=t.totalAmount===void 0?"amount unknown":`${t.currencyCode??""} ${t.totalAmount}`.trim();return`Nothing was created. A bill from this supplier already exists on ${Cl(t.valueDate)??e??"an unknown date"}: ${t.reference} (${n}, ${t.status}). Show it to the user and ask whether this is the same document. If they confirm it is a separate bill, retry with ${r}.`}var f_t,wjr,p_t,E_,h_t,m_t,A_t,g_t,E_t,at,ur=X(()=>{"use strict";cp();pp();Pd();JE();i1();XE();a_();l_();C1();S1();h_();g_();y_();f_t=["duplicate_skipped","duplicate_suspected","invalid_transfer"],wjr=new Set(f_t);p_t={"current assets":"Current Asset","current asset":"Current Asset","non-current assets":"Non-current Asset","non-current asset":"Non-current Asset","noncurrent asset":"Non-current Asset","non current asset":"Non-current Asset","fixed assets":"Fixed Asset","fixed asset":"Fixed Asset","bank account":"Bank Accounts","bank accounts":"Bank Accounts",bank:"Bank Accounts","current liabilities":"Current Liability","current liability":"Current Liability","non-current liabilities":"Non-current Liability","non-current liability":"Non-current Liability","noncurrent liability":"Non-current Liability","non current liability":"Non-current Liability",equity:"Shareholders Equity","shareholders equity":"Shareholders Equity","shareholders' equity":"Shareholders Equity","shareholder's equity":"Shareholders Equity",revenue:"Operating Revenue","operating revenue":"Operating Revenue","other revenue":"Other Revenue","other income":"Other Revenue",expense:"Operating Expense","operating expense":"Operating Expense",expenses:"Operating Expense","operating expenses":"Operating Expense","other expense":"Other Expense","other expenses":"Other Expense","direct costs":"Direct Costs","direct cost":"Direct Costs","cost of goods sold":"Direct Costs",cogs:"Direct Costs","cost of sales":"Direct Costs",cash:"Cash","cash and cash equivalents":"Cash",inventory:"Inventory","discontinued expense":"Discontinued Expense","discontinued income":"Discontinued Income","finance cost":"Finance Cost","finance costs":"Finance Cost","financing income":"Financing Income",goodwill:"Goodwill","income tax expense":"Income Tax Expense","income tax":"Income Tax Expense","tax expense":"Income Tax Expense","investing expense":"Investing Expense","investing income":"Investing Income",investment:"Investment",investments:"Investment"};E_=class extends No{constructor(e){super(e),this.name="ExchangeRateError"}};h_t=["DRAFT","UNPAID","PARTIALLY_PAID","PAID"],m_t=.995,A_t=1.3,g_t=20;E_t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,at=class extends No{constructor(e){super(e),this.name="ApiValidationError"}}});function qwe(t,e,r,n){let i=r==="SOURCE_TO_FUNCTIONAL"?t*e:t/e;if(!Number.isFinite(i)||Math.abs(i)>b_t)throw new $t(`${n} of ${e} under ${r} translates ${t} into ${i}, outside the representable range. Check the rate direction \u2014 the two conventions are reciprocals, so picking the wrong one moves the result by rate\xB2.`);return i}function cQ(t){let{amount:e,bookRate:r,closingRate:n,rateDirection:i,position:o="ASSET",currency:s="USD",baseCurrency:a="SGD"}=t;if(hn(e,"Foreign currency amount"),hn(r,"Book rate"),hn(n,"Closing rate"),o!=="ASSET"&&o!=="LIABILITY")throw new $t(`position must be ASSET or LIABILITY (got ${JSON.stringify(o)}).`);let c=G1(i);if(!c)throw new $t('rateDirection is required: FUNCTIONAL_TO_SOURCE (1 base unit = N foreign \u2014 what list_currency_rates returns) or SOURCE_TO_FUNCTIONAL (1 foreign unit = N base \u2014 the everyday "1 USD = 1.35 SGD" quote).');let u=re(qwe(e,r,c,"Book rate")),d=re(qwe(e,n,c,"Closing rate")),f=re(o==="LIABILITY"?u-d:d-u),p=f>=0,h=Math.abs(f),m;p?m={description:`FX revaluation \u2014 ${s} ${e.toLocaleString()} @ ${n} (was ${r}, ${c})`,lines:[{account:`${s} Monetary Item`,debit:h,credit:0},{account:"FX Unrealized Gain",debit:0,credit:h}]}:m={description:`FX revaluation \u2014 ${s} ${e.toLocaleString()} @ ${n} (was ${r}, ${c})`,lines:[{account:"FX Unrealized Loss",debit:h,credit:0},{account:`${s} Monetary Item`,debit:0,credit:h}]};let A={description:`Reversal of FX revaluation \u2014 ${s} ${e.toLocaleString()}`,lines:m.lines.map(C=>({account:C.account,debit:C.credit,credit:C.debit}))},g=["FX Revaluation Workings (IAS 21)",`Foreign currency: ${s} ${e.toLocaleString()} | Base currency: ${a}`,`Rate direction: ${c} | Position: ${o}`,`Book rate: ${r} \u2192 Book value: ${Ue(u,a)}`,`Closing rate: ${n} \u2192 Closing value: ${Ue(d,a)}`,`${p?"Unrealized gain":"Unrealized loss"}: ${Ue(Math.abs(f),a)}`,"Method: IAS 21.23 \u2014 monetary items translated at closing rate","Reversal: Day 1 next period (standard reval/reverse approach)"].join(`
206
206
  `),y={capsuleType:"FX Revaluation",capsuleName:`FX Reval \u2014 ${s} ${e.toLocaleString()} ${o} \u2014 ${r} \u2192 ${n} (${c})`,capsuleDescription:g,tags:["FX Revaluation",s],customFields:{"Source Account":null,"Period End Date":null},steps:[zr(1,m.description,null,m.lines),zr(2,A.description,null,A.lines)]};return{type:"fx-reval",currency:s,inputs:{amount:e,bookRate:r,closingRate:n,rateDirection:c,position:o,baseCurrency:a},bookValue:u,closingValue:d,gainOrLoss:f,isGain:p,journal:m,reversalJournal:A,blueprint:y}}var b_t,a6=X(()=>{"use strict";Fs();cs();ur();Fa();b_t=Number.MAX_SAFE_INTEGER/100});function lQ(t){let{buckets:e,existingProvision:r=0,currency:n}=t;for(let g of e)_u(g.balance,`${g.name} balance`),_u(g.rate,`${g.name} loss rate`);_u(r,"Existing provision");let i=e.map(g=>({bucket:g.name,balance:g.balance,lossRate:g.rate,ecl:re(g.balance*g.rate/100)})),o=re(e.reduce((g,y)=>g+y.balance,0)),s=re(i.reduce((g,y)=>g+y.ecl,0)),a=re(s-r),c=a>=0,u=Math.abs(a),d=o>0?re(s/o*100*100)/100:0,f;c?f={description:"ECL provision increase \u2014 IFRS 9 simplified approach",lines:[{account:"Bad Debt Expense",debit:u,credit:0},{account:"Allowance for Doubtful Debts",debit:0,credit:u}]}:f={description:"ECL provision release \u2014 IFRS 9 simplified approach",lines:[{account:"Allowance for Doubtful Debts",debit:u,credit:0},{account:"Bad Debt Expense",debit:0,credit:u}]};let p=n??void 0,h=i.map(g=>` ${g.bucket}: ${Ue(g.balance,p)} \xD7 ${g.lossRate}% = ${Ue(g.ecl,p)}`).join(`
207
207
  `),m=["ECL Provision Matrix Workings (IFRS 9)",`Total receivables: ${Ue(o,p)} | Weighted avg loss rate: ${d}%`,"Provision matrix:",h,`Total ECL required: ${Ue(s,p)} | Existing provision: ${Ue(r,p)}`,`Adjustment: ${Ue(Math.abs(a),p)} (${c?"increase":"release"})`,"Method: IFRS 9.5.5.15 simplified approach \u2014 lifetime ECL, provision matrix"].join(`
208
208
  `),A={capsuleType:"ECL Provision",capsuleName:`ECL Provision \u2014 ${mi(s,n)} \u2014 ${e.length} buckets`,capsuleDescription:m,tags:["ECL","Bad Debt"],customFields:{"Reporting Period":null,"Aged Receivables Report Date":null},steps:[zr(1,f.description,null,f.lines)]};return{type:"ecl",currency:n??null,inputs:{buckets:e.map(g=>({name:g.name,balance:g.balance,rate:g.rate})),existingProvision:r},totalReceivables:o,totalEcl:s,weightedRate:d,adjustmentRequired:a,isIncrease:c,bucketDetails:i,journal:f,blueprint:A}}var c6=X(()=>{"use strict";Fs();cs();Fa()});function uQ(t){let{amount:e,annualRate:r,termMonths:n,startDate:i,currency:o}=t;hn(e,"Estimated future outflow"),lp(r,"Discount rate"),Mi(n,"Term (months)"),ki(i);let s=r/100/12,a=re(-(0,jwe.pv)(s,n,0,e)),c=re(e-a),u={description:"Initial provision recognition at PV (IAS 37)",lines:[{account:"Provision Expense",debit:a,credit:0},{account:"Provision for Obligations",debit:0,credit:a}]},d=[],f=a,p=0;for(let m=1;m<=n;m++){let A=re(f),g=m===n,y;g?y=re(e-A):y=re(A*s),f=re(A+y),p=re(p+y);let C=i?po(i,m):null,E={description:`Provision unwinding \u2014 Month ${m} of ${n}`,lines:[{account:"Finance Cost \u2014 Unwinding",debit:y,credit:0},{account:"Provision for Obligations",debit:0,credit:y}]};d.push({period:m,date:C,openingBalance:A,payment:0,interest:y,principal:0,closingBalance:f,journal:E})}let h=null;if(i){let m=po(i,n),A=[zr(1,u.description,i,u.lines),...d.map((C,E)=>zr(E+2,C.journal.description,C.date,C.journal.lines)),SA(n+2,"Settlement \u2014 pay the obligation",m,[{account:"Provision for Obligations",debit:e,credit:0},{account:"Cash / Bank Account",debit:0,credit:e}])],g=o??void 0,y=["IAS 37 Provision Workings",`Nominal obligation: ${Ue(e,g)} | Discount rate: ${r}% p.a. (${re(s*100)}% monthly)`,`Term to settlement: ${n} months | PV at recognition: ${Ue(a,g)}`,`Total unwinding (finance cost): ${Ue(c,g)}`,"Method: PV of single future outflow (IAS 37.45), unwinding via effective interest (IAS 37.60)",`Settlement: ${Ue(e,g)} cash out on ${m}`,"Rounding: 2dp per period, final period closes to nominal amount"].join(`
@@ -750,7 +750,9 @@ Optional capsuleRecipe \u2014 no v1 recipe lists JOURNAL_DIRECT_CASH_OUT; passin
750
750
 
751
751
  NOT for external parties \u2014 use create_cash_in (receiving) / create_cash_out (paying).
752
752
 
753
- cashOut = source, cashIn = destination. Each side needs accountResourceId + amount. reference auto-generated if omitted. Do NOT send currency/exchangeRate (derived server-side).`,params:{reference:{type:"string",description:"Reference number"},valueDate:{type:"string",description:"Date (YYYY-MM-DD)"},cashOut:{type:"object",properties:{accountResourceId:{type:"string",description:"Source bank account resourceId"},amount:{type:"number",description:"Transfer amount"}},required:["accountResourceId","amount"]},cashIn:{type:"object",properties:{accountResourceId:{type:"string",description:"Destination bank account resourceId"},amount:{type:"number",description:"Transfer amount"}},required:["accountResourceId","amount"]},tags:{type:"array",items:{type:"string"},description:"Tags (string array)"},saveAsDraft:{type:"boolean",description:"Save as draft (default false)"}},required:["valueDate","cashOut","cashIn"],group:"cash_transfers",readOnly:!1,searchHint:"create cash transfer between bank accounts",execute:async(t,e)=>{let r={...e};return r.reference||(r.reference=il("CT")),OB(t.client,r)}},Xr("delete_cash_in","Delete (void) a cash-in entry. Uses parentEntityResourceId from create response.","cash_entries",(t,e)=>Rm(t,e),"delete void a cash in receipt entry"),Xr("delete_cash_out","Delete (void) a cash-out entry. Uses parentEntityResourceId from create response.","cash_entries",(t,e)=>Rm(t,e),"delete void a cash out payment entry"),Xr("delete_cash_transfer","Delete (void) a cash transfer. Uses parentEntityResourceId from create response.","cash_transfers",(t,e)=>Rm(t,e),"delete void a cash transfer between accounts"),Ar("list_scheduled_invoices","List scheduled (recurring) invoices. Paginated.","schedulers",(t,e,r)=>Dz(t,{limit:r,offset:e}),"list recurring scheduled invoices subscriptions"),Ar("list_scheduled_bills","List scheduled (recurring) bills. Paginated.","schedulers",(t,e,r)=>Sz(t,{limit:r,offset:e}),"list recurring scheduled bills subscriptions"),Ar("list_scheduled_journals","List scheduled (recurring) journals. Paginated.","schedulers",(t,e,r)=>Rz(t,{limit:r,offset:e}),"list recurring scheduled journal entries"),{name:"get_bank_account",description:"Get full bank account details by resourceId.",params:{resourceId:{type:"string",description:"Bank account resourceId"}},required:["resourceId"],group:"bank",readOnly:!0,searchHint:"get bank account details balance by id",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>pC(t.client,e.resourceId)},Zt({name:"search_bank_records",description:"Search bank records for a specific account. Call list_bank_accounts first to get accountResourceId.",group:"bank",fields:FS,defaults:QS,fetcher:hC,pathParam:"accountResourceId",pathParamDescription:"Bank account resourceId (UUID). Call list_bank_accounts first.",searchHint:"find bank records statement entries transactions by status date amount description payer reference range"}),Zt({name:"search_cashflow_transactions",description:"Search cashflow transactions (unified ledger across cash entries / payments / journals). direction enum: PAYIN | PAYOUT.",group:"cashflow",fields:cf,defaults:lf,fetcher:xm,extraParams:EK,searchHint:"find cashflow transactions money movement by type direction PAYIN PAYOUT status date reference account"}),Ar("list_bookmarks","List organization bookmarks (saved values/settings).","bookmarks",(t,e,r)=>Jz(t,{limit:r,offset:e}),"list saved bookmarks reports shortcuts"),{name:"get_bookmark",description:"Get a bookmark by resourceId.",params:{resourceId:{type:"string",description:"Bookmark resourceId"}},required:["resourceId"],group:"bookmarks",readOnly:!0,searchHint:"get bookmark saved report details",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>Vz(t.client,e.resourceId)},{name:"create_bookmarks",description:"Create one or more bookmarks. categoryCode must be one of: AUDIT_AND_ASSURANCE, BANKING_AND_FINANCE, BUDGETS_AND_CONTROLS, EMPLOYEES_AND_PAYROLL, EXTERNAL_DOCUMENTS, GENERAL_INFORMATION, OWNERS_AND_DIRECTORS, TAXATION_AND_COMPLIANCE, WORKFLOWS_AND_PROCESSES.",params:{items:{type:"array",items:{type:"object",properties:{name:{type:"string",description:"Bookmark name"},value:{type:"string",description:"Bookmark value"},categoryCode:{type:"string",enum:["AUDIT_AND_ASSURANCE","BANKING_AND_FINANCE","BUDGETS_AND_CONTROLS","EMPLOYEES_AND_PAYROLL","EXTERNAL_DOCUMENTS","GENERAL_INFORMATION","OWNERS_AND_DIRECTORS","TAXATION_AND_COMPLIANCE","WORKFLOWS_AND_PROCESSES"],description:"Category code"},datatypeCode:{type:"string",enum:["TEXT","NUMBER","BOOLEAN","DATE","LINK"],description:"Datatype code (default: TEXT)"}},required:["name","value","categoryCode","datatypeCode"]},description:"Bookmarks to create"}},required:["items"],group:"bookmarks",readOnly:!1,searchHint:"create new bookmark saved report shortcut",execute:async(t,e)=>qB(t.client,e.items)},{name:"update_bookmark",description:"Update an existing bookmark (name, value, or category). Use when modifying a previously created bookmark.",params:{resourceId:{type:"string",description:"Bookmark resourceId"},name:{type:"string",description:"New name"},value:{type:"string",description:"New value"},categoryCode:{type:"string",enum:["AUDIT_AND_ASSURANCE","BANKING_AND_FINANCE","BUDGETS_AND_CONTROLS","EMPLOYEES_AND_PAYROLL","EXTERNAL_DOCUMENTS","GENERAL_INFORMATION","OWNERS_AND_DIRECTORS","TAXATION_AND_COMPLIANCE","WORKFLOWS_AND_PROCESSES"],description:"New category code"}},required:["resourceId"],group:"bookmarks",readOnly:!1,searchHint:"update bookmark name or configuration",execute:async(t,e)=>{let{resourceId:r,...n}=e;return Wz(t.client,r,n)}},Ar("list_org_users","List organization users (team members). Returns name, email, roles.","org_users",(t,e,r)=>t8(t,{limit:r,offset:e}),"list organization users team members"),Zt({name:"search_org_users",description:'Search organization users. Names are nested under user; for name-or-email OR, pass filter: {"or":{"user":{"firstName":{"contains":"jo"}},"email":{"contains":"jo"}}}.',group:"org_users",fields:IR,defaults:vR,fetcher:r8,searchHint:"find organization users team members by name email role status OR search"}),{name:"invite_org_user",description:`Invite a new user to the organization.
753
+ cashOut = source, cashIn = destination. Each side needs accountResourceId + amount. reference auto-generated if omitted. Do NOT send currency/exchangeRate (derived server-side).
754
+
755
+ Posts ACTIVE, not a draft. Refuses locally (\`_guard: invalid_transfer\`, nothing written) when both sides name the same account, or the leg amounts differ \u2014 re-read direction and amount with the user, do not retry.`,params:{reference:{type:"string",description:"Reference number"},valueDate:{type:"string",description:"Date (YYYY-MM-DD)"},cashOut:{type:"object",properties:{accountResourceId:{type:"string",description:"Source bank account resourceId"},amount:{type:"number",description:"Transfer amount"}},required:["accountResourceId","amount"]},cashIn:{type:"object",properties:{accountResourceId:{type:"string",description:"Destination bank account resourceId"},amount:{type:"number",description:"Transfer amount"}},required:["accountResourceId","amount"]},tags:{type:"array",items:{type:"string"},description:"Tags (string array)"},saveAsDraft:{type:"boolean",description:"Save as draft (default false)"}},required:["valueDate","cashOut","cashIn"],group:"cash_transfers",readOnly:!1,searchHint:"create cash transfer between bank accounts",execute:async(t,e)=>{let r={...e},n=r.cashOut,i=r.cashIn;return n?.accountResourceId&&i?.accountResourceId&&n.accountResourceId===i.accountResourceId?{_guard:"invalid_transfer",message:"Source and destination are the same account, so this transfer would move nothing and still post an ACTIVE pair of entries against it. Nothing was created. Confirm which account the money leaves and which it lands in.",accountResourceId:n.accountResourceId}:typeof n?.amount=="number"&&typeof i?.amount=="number"&&n.amount!==i.amount?{_guard:"invalid_transfer",message:`cashOut.amount (${n.amount}) and cashIn.amount (${i.amount}) disagree. Both legs of a transfer carry the same amount \u2014 currency and rate are derived server-side, so a difference here is not an FX conversion. Nothing was created.`,cashOut:n.amount,cashIn:i.amount}:(r.reference||(r.reference=il("CT")),OB(t.client,r))}},Xr("delete_cash_in","Delete (void) a cash-in entry. Uses parentEntityResourceId from create response.","cash_entries",(t,e)=>Rm(t,e),"delete void a cash in receipt entry"),Xr("delete_cash_out","Delete (void) a cash-out entry. Uses parentEntityResourceId from create response.","cash_entries",(t,e)=>Rm(t,e),"delete void a cash out payment entry"),Xr("delete_cash_transfer","Delete (void) a cash transfer. Uses parentEntityResourceId from create response.","cash_transfers",(t,e)=>Rm(t,e),"delete void a cash transfer between accounts"),Ar("list_scheduled_invoices","List scheduled (recurring) invoices. Paginated.","schedulers",(t,e,r)=>Dz(t,{limit:r,offset:e}),"list recurring scheduled invoices subscriptions"),Ar("list_scheduled_bills","List scheduled (recurring) bills. Paginated.","schedulers",(t,e,r)=>Sz(t,{limit:r,offset:e}),"list recurring scheduled bills subscriptions"),Ar("list_scheduled_journals","List scheduled (recurring) journals. Paginated.","schedulers",(t,e,r)=>Rz(t,{limit:r,offset:e}),"list recurring scheduled journal entries"),{name:"get_bank_account",description:"Get full bank account details by resourceId.",params:{resourceId:{type:"string",description:"Bank account resourceId"}},required:["resourceId"],group:"bank",readOnly:!0,searchHint:"get bank account details balance by id",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>pC(t.client,e.resourceId)},Zt({name:"search_bank_records",description:"Search bank records for a specific account. Call list_bank_accounts first to get accountResourceId.",group:"bank",fields:FS,defaults:QS,fetcher:hC,pathParam:"accountResourceId",pathParamDescription:"Bank account resourceId (UUID). Call list_bank_accounts first.",searchHint:"find bank records statement entries transactions by status date amount description payer reference range"}),Zt({name:"search_cashflow_transactions",description:"Search cashflow transactions (unified ledger across cash entries / payments / journals). direction enum: PAYIN | PAYOUT.",group:"cashflow",fields:cf,defaults:lf,fetcher:xm,extraParams:EK,searchHint:"find cashflow transactions money movement by type direction PAYIN PAYOUT status date reference account"}),Ar("list_bookmarks","List organization bookmarks (saved values/settings).","bookmarks",(t,e,r)=>Jz(t,{limit:r,offset:e}),"list saved bookmarks reports shortcuts"),{name:"get_bookmark",description:"Get a bookmark by resourceId.",params:{resourceId:{type:"string",description:"Bookmark resourceId"}},required:["resourceId"],group:"bookmarks",readOnly:!0,searchHint:"get bookmark saved report details",isConcurrencySafe:!0,maxResultSizeChars:2e4,execute:async(t,e)=>Vz(t.client,e.resourceId)},{name:"create_bookmarks",description:"Create one or more bookmarks. categoryCode must be one of: AUDIT_AND_ASSURANCE, BANKING_AND_FINANCE, BUDGETS_AND_CONTROLS, EMPLOYEES_AND_PAYROLL, EXTERNAL_DOCUMENTS, GENERAL_INFORMATION, OWNERS_AND_DIRECTORS, TAXATION_AND_COMPLIANCE, WORKFLOWS_AND_PROCESSES.",params:{items:{type:"array",items:{type:"object",properties:{name:{type:"string",description:"Bookmark name"},value:{type:"string",description:"Bookmark value"},categoryCode:{type:"string",enum:["AUDIT_AND_ASSURANCE","BANKING_AND_FINANCE","BUDGETS_AND_CONTROLS","EMPLOYEES_AND_PAYROLL","EXTERNAL_DOCUMENTS","GENERAL_INFORMATION","OWNERS_AND_DIRECTORS","TAXATION_AND_COMPLIANCE","WORKFLOWS_AND_PROCESSES"],description:"Category code"},datatypeCode:{type:"string",enum:["TEXT","NUMBER","BOOLEAN","DATE","LINK"],description:"Datatype code (default: TEXT)"}},required:["name","value","categoryCode","datatypeCode"]},description:"Bookmarks to create"}},required:["items"],group:"bookmarks",readOnly:!1,searchHint:"create new bookmark saved report shortcut",execute:async(t,e)=>qB(t.client,e.items)},{name:"update_bookmark",description:"Update an existing bookmark (name, value, or category). Use when modifying a previously created bookmark.",params:{resourceId:{type:"string",description:"Bookmark resourceId"},name:{type:"string",description:"New name"},value:{type:"string",description:"New value"},categoryCode:{type:"string",enum:["AUDIT_AND_ASSURANCE","BANKING_AND_FINANCE","BUDGETS_AND_CONTROLS","EMPLOYEES_AND_PAYROLL","EXTERNAL_DOCUMENTS","GENERAL_INFORMATION","OWNERS_AND_DIRECTORS","TAXATION_AND_COMPLIANCE","WORKFLOWS_AND_PROCESSES"],description:"New category code"}},required:["resourceId"],group:"bookmarks",readOnly:!1,searchHint:"update bookmark name or configuration",execute:async(t,e)=>{let{resourceId:r,...n}=e;return Wz(t.client,r,n)}},Ar("list_org_users","List organization users (team members). Returns name, email, roles.","org_users",(t,e,r)=>t8(t,{limit:r,offset:e}),"list organization users team members"),Zt({name:"search_org_users",description:'Search organization users. Names are nested under user; for name-or-email OR, pass filter: {"or":{"user":{"firstName":{"contains":"jo"}},"email":{"contains":"jo"}}}.',group:"org_users",fields:IR,defaults:vR,fetcher:r8,searchHint:"find organization users team members by name email role status OR search"}),{name:"invite_org_user",description:`Invite a new user to the organization.
754
756
 
755
757
  userType drives access:
756
758
  - ADMIN: full access to every module \u2014 moduleRoles is ignored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaz-clio",
3
- "version": "5.53.0",
3
+ "version": "5.53.1",
4
4
  "description": "Clio: Command Line Interface Operator for Jaz AI.",
5
5
  "type": "module",
6
6
  "bin": {