Skip to content

Commit f449431

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): align sales metadata conditions
1 parent 7b30396 commit f449431

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

apps/sim/blocks/blocks/quickbooks.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const TRANSACTION_LIST_OPERATIONS = [
7979
'quickbooks_list_purchase_orders',
8080
'quickbooks_list_bills',
8181
] as const
82+
const PAGINATED_OPERATIONS = [
83+
MASTER_DATA_OPERATION,
84+
SALES_READ_OPERATION,
85+
...TRANSACTION_LIST_OPERATIONS,
86+
] as const
8287
const LIST_OUTPUT_CONDITION: OutputCondition = {
8388
field: 'operation',
8489
value: [MASTER_DATA_OPERATION, SALES_READ_OPERATION],
@@ -143,6 +148,12 @@ function paginationCondition(values?: Record<string, unknown>) {
143148
}
144149

145150
function salesTransactionIdCondition(values?: Record<string, unknown>) {
151+
if (!values) {
152+
return {
153+
field: 'operation',
154+
value: [SALES_READ_OPERATION, ...SALES_UPDATE_OPERATIONS, ...SALES_VOID_OPERATIONS],
155+
}
156+
}
146157
if (values?.operation === SALES_READ_OPERATION) {
147158
return { field: 'readMode', value: 'by_id' }
148159
}
@@ -1216,19 +1227,19 @@ export const QuickBooksBlockMeta = {
12161227
name: 'prepare-quickbooks-estimates',
12171228
description: 'Create and revise bounded QuickBooks estimates from approved quote details.',
12181229
content:
1219-
'# Prepare QuickBooks Estimates\n\n## Steps\n1. Validate the customer, item IDs, amounts, and dates.\n2. Use Estimates: Create with bounded item or description lines.\n3. For a revision, use the estimate ID and latest `syncToken` with Estimates: Update.\n\n## Output\nReturn the native Estimate, ID, and latest sync token. Do not claim to email or accept the estimate.',
1230+
'# Prepare QuickBooks Estimates\n\n## Steps\n1. Validate the customer, item IDs, amounts, and dates.\n2. Use Create Estimate with bounded item or description lines.\n3. For a revision, use the estimate ID and latest `syncToken` with Update Estimate.\n\n## Output\nReturn the native Estimate, ID, and latest sync token. Do not claim to email or accept the estimate.',
12201231
},
12211232
{
12221233
name: 'create-quickbooks-invoices',
12231234
description: 'Create approved QuickBooks invoices and retain identifiers for later updates.',
12241235
content:
1225-
'# Create QuickBooks Invoices\n\n## Steps\n1. Validate the approved customer, item IDs, positive amounts, and optional dates.\n2. Use Invoices: Create with at least one bounded line.\n3. Store the returned `recordId` and `syncToken`.\n\n## Output\nReturn the native Invoice and identifiers. Do not claim to email the invoice or collect payment automatically.',
1236+
'# Create QuickBooks Invoices\n\n## Steps\n1. Validate the approved customer, item IDs, positive amounts, and optional dates.\n2. Use Create Invoice with at least one bounded line.\n3. Store the returned `recordId` and `syncToken`.\n\n## Output\nReturn the native Invoice and identifiers. Do not claim to email the invoice or collect payment automatically.',
12261237
},
12271238
{
12281239
name: 'apply-quickbooks-customer-payments',
12291240
description: 'Record customer payments with bounded optional invoice allocations.',
12301241
content:
1231-
'# Apply QuickBooks Customer Payments\n\n## Steps\n1. Validate the customer ID and positive payment total.\n2. Optionally allocate positive amounts to known invoice IDs without exceeding the payment total.\n3. Use Customer Payments: Create and store the returned ID and sync token.\n\n## Output\nReturn the native Payment and any unapplied remainder reported by QuickBooks.',
1242+
'# Apply QuickBooks Customer Payments\n\n## Steps\n1. Validate the customer ID and positive payment total.\n2. Optionally allocate positive amounts to known invoice IDs without exceeding the payment total.\n3. Use Create Customer Payment and store the returned ID and sync token.\n\n## Output\nReturn the native Payment and any unapplied remainder reported by QuickBooks.',
12321243
},
12331244
{
12341245
name: 'manage-quickbooks-credits-and-refunds',

apps/sim/tools/quickbooks/quickbooks.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,29 @@ describe('QuickBooks tool and block boundaries', () => {
10021002
field: 'operation',
10031003
value: [
10041004
'quickbooks_read_master_data',
1005+
'quickbooks_read_sales_transactions',
10051006
'quickbooks_list_purchase_orders',
10061007
'quickbooks_list_bills',
10071008
],
10081009
})
1010+
expect(
1011+
typeof subBlocks.transactionId.condition === 'function'
1012+
? subBlocks.transactionId.condition()
1013+
: subBlocks.transactionId.condition
1014+
).toEqual({
1015+
field: 'operation',
1016+
value: [
1017+
'quickbooks_read_sales_transactions',
1018+
'quickbooks_update_estimate',
1019+
'quickbooks_update_invoice',
1020+
'quickbooks_update_sales_receipt',
1021+
'quickbooks_update_credit_memo',
1022+
'quickbooks_update_refund_receipt',
1023+
'quickbooks_update_customer_payment',
1024+
'quickbooks_void_invoice',
1025+
'quickbooks_void_customer_payment',
1026+
],
1027+
})
10091028
expect(QuickBooksBlock.outputs.items.condition).toEqual({
10101029
field: 'operation',
10111030
value: ['quickbooks_read_master_data', 'quickbooks_read_sales_transactions'],

0 commit comments

Comments
 (0)