Skip to content

Commit b35a81e

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
feat(quickbooks): add safe purchasing and payables tools
1 parent 47bfeb2 commit b35a81e

19 files changed

Lines changed: 1995 additions & 281 deletions
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import { ErrorExtractorId } from '@/tools/error-extractors'
2+
import { QUICKBOOKS_MAX_RESPONSE_BYTES } from '@/tools/quickbooks/client'
3+
import { buildQuickBooksCreateBillBody } from '@/tools/quickbooks/purchasing_utils'
4+
import type {
5+
QuickBooksCreateBillParams,
6+
QuickBooksMutationResponse,
7+
QuickBooksPurchasingTransaction,
8+
} from '@/tools/quickbooks/types'
9+
import {
10+
QUICKBOOKS_MUTATION_OUTPUTS,
11+
QUICKBOOKS_PURCHASING_TRANSACTION_PROPERTIES,
12+
} from '@/tools/quickbooks/types'
13+
import {
14+
addQuickBooksRequestId,
15+
buildQuickBooksEntityUrl,
16+
getQuickBooksToolHeaders,
17+
transformQuickBooksMutationResponse,
18+
} from '@/tools/quickbooks/utils'
19+
import type { ToolConfig } from '@/tools/types'
20+
21+
export const quickbooksCreateBillTool: ToolConfig<
22+
QuickBooksCreateBillParams,
23+
QuickBooksMutationResponse<QuickBooksPurchasingTransaction>
24+
> = {
25+
id: 'quickbooks_create_bill',
26+
name: 'QuickBooks Create Bill',
27+
description: 'Create a vendor bill without paying it',
28+
version: '1.0.0',
29+
params: {
30+
accessToken: {
31+
type: 'string',
32+
required: true,
33+
visibility: 'hidden',
34+
description: 'QuickBooks OAuth access token',
35+
},
36+
realmId: {
37+
type: 'string',
38+
required: true,
39+
visibility: 'hidden',
40+
description: 'QuickBooks company ID derived from the connected credential',
41+
},
42+
vendorId: {
43+
type: 'string',
44+
required: true,
45+
visibility: 'user-or-llm',
46+
description: 'Bill vendor ID',
47+
},
48+
lines: {
49+
type: 'json',
50+
required: true,
51+
visibility: 'user-or-llm',
52+
description: 'Bounded account-based or item-based expense lines',
53+
},
54+
apAccountId: {
55+
type: 'string',
56+
required: false,
57+
visibility: 'user-or-llm',
58+
description: 'Optional accounts-payable account ID',
59+
},
60+
transactionDate: {
61+
type: 'string',
62+
required: false,
63+
visibility: 'user-or-llm',
64+
description: 'Bill date in YYYY-MM-DD format',
65+
},
66+
dueDate: {
67+
type: 'string',
68+
required: false,
69+
visibility: 'user-or-llm',
70+
description: 'Bill due date in YYYY-MM-DD format',
71+
},
72+
documentNumber: {
73+
type: 'string',
74+
required: false,
75+
visibility: 'user-or-llm',
76+
description: 'Optional bill number',
77+
},
78+
privateNote: {
79+
type: 'string',
80+
required: false,
81+
visibility: 'user-or-llm',
82+
description: 'Internal bill note',
83+
},
84+
requestId: {
85+
type: 'string',
86+
required: false,
87+
visibility: 'user-or-llm',
88+
description: 'Optional Intuit idempotency request ID, up to 50 characters',
89+
},
90+
},
91+
oauth: {
92+
required: true,
93+
provider: 'quickbooks',
94+
requiredScopes: ['com.intuit.quickbooks.accounting'],
95+
},
96+
errorExtractor: ErrorExtractorId.QUICKBOOKS_FAULT,
97+
request: {
98+
url: (p) =>
99+
addQuickBooksRequestId(buildQuickBooksEntityUrl(p.realmId, 'bill'), p.requestId).toString(),
100+
method: 'POST',
101+
headers: (p) => getQuickBooksToolHeaders(p.accessToken, 'application/json'),
102+
body: buildQuickBooksCreateBillBody,
103+
retry: { enabled: false },
104+
maxResponseBytes: QUICKBOOKS_MAX_RESPONSE_BYTES,
105+
},
106+
transformResponse: (r) =>
107+
transformQuickBooksMutationResponse<QuickBooksPurchasingTransaction>(r, 'Bill'),
108+
outputs: {
109+
record: {
110+
type: 'json',
111+
description: 'Created native QuickBooks Bill',
112+
properties: QUICKBOOKS_PURCHASING_TRANSACTION_PROPERTIES,
113+
},
114+
...QUICKBOOKS_MUTATION_OUTPUTS,
115+
},
116+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { ErrorExtractorId } from '@/tools/error-extractors'
2+
import { QUICKBOOKS_MAX_RESPONSE_BYTES } from '@/tools/quickbooks/client'
3+
import { buildQuickBooksCreateBillPaymentBody } from '@/tools/quickbooks/purchasing_utils'
4+
import type {
5+
QuickBooksCreateBillPaymentParams,
6+
QuickBooksMutationResponse,
7+
QuickBooksPurchasingTransaction,
8+
} from '@/tools/quickbooks/types'
9+
import {
10+
QUICKBOOKS_MUTATION_OUTPUTS,
11+
QUICKBOOKS_PURCHASING_TRANSACTION_PROPERTIES,
12+
} from '@/tools/quickbooks/types'
13+
import {
14+
addQuickBooksRequestId,
15+
buildQuickBooksEntityUrl,
16+
getQuickBooksToolHeaders,
17+
transformQuickBooksMutationResponse,
18+
} from '@/tools/quickbooks/utils'
19+
import type { ToolConfig } from '@/tools/types'
20+
21+
export const quickbooksCreateBillPaymentTool: ToolConfig<
22+
QuickBooksCreateBillPaymentParams,
23+
QuickBooksMutationResponse<QuickBooksPurchasingTransaction>
24+
> = {
25+
id: 'quickbooks_create_bill_payment',
26+
name: 'QuickBooks Create Bill Payment',
27+
description: 'Record a check or credit-card payment allocated to one or more bills',
28+
version: '1.0.0',
29+
params: {
30+
accessToken: {
31+
type: 'string',
32+
required: true,
33+
visibility: 'hidden',
34+
description: 'QuickBooks OAuth access token',
35+
},
36+
realmId: {
37+
type: 'string',
38+
required: true,
39+
visibility: 'hidden',
40+
description: 'QuickBooks company ID derived from the connected credential',
41+
},
42+
vendorId: {
43+
type: 'string',
44+
required: true,
45+
visibility: 'user-or-llm',
46+
description: 'Vendor whose bills are being paid',
47+
},
48+
totalAmount: {
49+
type: 'number',
50+
required: true,
51+
visibility: 'user-or-llm',
52+
description: 'Positive total payment amount',
53+
},
54+
paymentType: {
55+
type: 'string',
56+
required: true,
57+
visibility: 'user-or-llm',
58+
description: 'Check or credit-card payment type',
59+
},
60+
paymentAccountId: {
61+
type: 'string',
62+
required: true,
63+
visibility: 'user-or-llm',
64+
description: 'Bank or credit-card account ID matching the payment type',
65+
},
66+
billAllocations: {
67+
type: 'json',
68+
required: true,
69+
visibility: 'user-or-llm',
70+
description: 'Bounded Bill ID and amount allocations that equal totalAmount',
71+
},
72+
transactionDate: {
73+
type: 'string',
74+
required: false,
75+
visibility: 'user-or-llm',
76+
description: 'Payment date in YYYY-MM-DD format',
77+
},
78+
privateNote: {
79+
type: 'string',
80+
required: false,
81+
visibility: 'user-or-llm',
82+
description: 'Internal payment note',
83+
},
84+
requestId: {
85+
type: 'string',
86+
required: false,
87+
visibility: 'user-or-llm',
88+
description: 'Optional Intuit idempotency request ID, up to 50 characters',
89+
},
90+
},
91+
oauth: {
92+
required: true,
93+
provider: 'quickbooks',
94+
requiredScopes: ['com.intuit.quickbooks.accounting'],
95+
},
96+
errorExtractor: ErrorExtractorId.QUICKBOOKS_FAULT,
97+
request: {
98+
url: (p) =>
99+
addQuickBooksRequestId(
100+
buildQuickBooksEntityUrl(p.realmId, 'billpayment'),
101+
p.requestId
102+
).toString(),
103+
method: 'POST',
104+
headers: (p) => getQuickBooksToolHeaders(p.accessToken, 'application/json'),
105+
body: buildQuickBooksCreateBillPaymentBody,
106+
retry: { enabled: false },
107+
maxResponseBytes: QUICKBOOKS_MAX_RESPONSE_BYTES,
108+
},
109+
transformResponse: (r) =>
110+
transformQuickBooksMutationResponse<QuickBooksPurchasingTransaction>(r, 'BillPayment'),
111+
outputs: {
112+
record: {
113+
type: 'json',
114+
description: 'Created native QuickBooks BillPayment',
115+
properties: QUICKBOOKS_PURCHASING_TRANSACTION_PROPERTIES,
116+
},
117+
...QUICKBOOKS_MUTATION_OUTPUTS,
118+
},
119+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { ErrorExtractorId } from '@/tools/error-extractors'
2+
import { QUICKBOOKS_MAX_RESPONSE_BYTES } from '@/tools/quickbooks/client'
3+
import { buildQuickBooksCreatePurchaseBody } from '@/tools/quickbooks/purchasing_utils'
4+
import type {
5+
QuickBooksCreatePurchaseParams,
6+
QuickBooksMutationResponse,
7+
QuickBooksPurchasingTransaction,
8+
} from '@/tools/quickbooks/types'
9+
import {
10+
QUICKBOOKS_MUTATION_OUTPUTS,
11+
QUICKBOOKS_PURCHASING_TRANSACTION_PROPERTIES,
12+
} from '@/tools/quickbooks/types'
13+
import {
14+
addQuickBooksRequestId,
15+
buildQuickBooksEntityUrl,
16+
getQuickBooksToolHeaders,
17+
transformQuickBooksMutationResponse,
18+
} from '@/tools/quickbooks/utils'
19+
import type { ToolConfig } from '@/tools/types'
20+
21+
export const quickbooksCreatePurchaseTool: ToolConfig<
22+
QuickBooksCreatePurchaseParams,
23+
QuickBooksMutationResponse<QuickBooksPurchasingTransaction>
24+
> = {
25+
id: 'quickbooks_create_purchase',
26+
name: 'QuickBooks Create Purchase',
27+
description: 'Record a cash, check, or credit-card purchase with bounded expense lines',
28+
version: '1.0.0',
29+
params: {
30+
accessToken: {
31+
type: 'string',
32+
required: true,
33+
visibility: 'hidden',
34+
description: 'QuickBooks OAuth access token',
35+
},
36+
realmId: {
37+
type: 'string',
38+
required: true,
39+
visibility: 'hidden',
40+
description: 'QuickBooks company ID derived from the connected credential',
41+
},
42+
paymentType: {
43+
type: 'string',
44+
required: true,
45+
visibility: 'user-or-llm',
46+
description: 'Cash, check, or credit-card purchase type',
47+
},
48+
paymentAccountId: {
49+
type: 'string',
50+
required: true,
51+
visibility: 'user-or-llm',
52+
description: 'Bank or credit-card account ID matching the purchase type',
53+
},
54+
lines: {
55+
type: 'json',
56+
required: true,
57+
visibility: 'user-or-llm',
58+
description: 'Bounded account-based or item-based expense lines',
59+
},
60+
vendorId: {
61+
type: 'string',
62+
required: false,
63+
visibility: 'user-or-llm',
64+
description: 'Optional vendor payee ID',
65+
},
66+
transactionDate: {
67+
type: 'string',
68+
required: false,
69+
visibility: 'user-or-llm',
70+
description: 'Purchase date in YYYY-MM-DD format',
71+
},
72+
paymentReference: {
73+
type: 'string',
74+
required: false,
75+
visibility: 'user-or-llm',
76+
description: 'Optional payment reference number',
77+
},
78+
privateNote: {
79+
type: 'string',
80+
required: false,
81+
visibility: 'user-or-llm',
82+
description: 'Internal purchase note',
83+
},
84+
requestId: {
85+
type: 'string',
86+
required: false,
87+
visibility: 'user-or-llm',
88+
description: 'Optional Intuit idempotency request ID, up to 50 characters',
89+
},
90+
},
91+
oauth: {
92+
required: true,
93+
provider: 'quickbooks',
94+
requiredScopes: ['com.intuit.quickbooks.accounting'],
95+
},
96+
errorExtractor: ErrorExtractorId.QUICKBOOKS_FAULT,
97+
request: {
98+
url: (p) =>
99+
addQuickBooksRequestId(
100+
buildQuickBooksEntityUrl(p.realmId, 'purchase'),
101+
p.requestId
102+
).toString(),
103+
method: 'POST',
104+
headers: (p) => getQuickBooksToolHeaders(p.accessToken, 'application/json'),
105+
body: buildQuickBooksCreatePurchaseBody,
106+
retry: { enabled: false },
107+
maxResponseBytes: QUICKBOOKS_MAX_RESPONSE_BYTES,
108+
},
109+
transformResponse: (r) =>
110+
transformQuickBooksMutationResponse<QuickBooksPurchasingTransaction>(r, 'Purchase'),
111+
outputs: {
112+
record: {
113+
type: 'json',
114+
description: 'Created native QuickBooks Purchase',
115+
properties: QUICKBOOKS_PURCHASING_TRANSACTION_PROPERTIES,
116+
},
117+
...QUICKBOOKS_MUTATION_OUTPUTS,
118+
},
119+
}

0 commit comments

Comments
 (0)