Skip to content

Commit dfb5e1b

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): align sales metadata conditions
1 parent fe1d484 commit dfb5e1b

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],
@@ -144,6 +149,12 @@ function paginationCondition(values?: Record<string, unknown>) {
144149
}
145150

146151
function salesTransactionIdCondition(values?: Record<string, unknown>) {
152+
if (!values) {
153+
return {
154+
field: 'operation',
155+
value: [SALES_READ_OPERATION, ...SALES_UPDATE_OPERATIONS, ...SALES_VOID_OPERATIONS],
156+
}
157+
}
147158
if (values?.operation === SALES_READ_OPERATION) {
148159
return { field: 'readMode', value: 'by_id' }
149160
}
@@ -1217,19 +1228,19 @@ export const QuickBooksBlockMeta = {
12171228
name: 'prepare-quickbooks-estimates',
12181229
description: 'Create and revise bounded QuickBooks estimates from approved quote details.',
12191230
content:
1220-
'# 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.',
1231+
'# 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.',
12211232
},
12221233
{
12231234
name: 'create-quickbooks-invoices',
12241235
description: 'Create approved QuickBooks invoices and retain identifiers for later updates.',
12251236
content:
1226-
'# 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.',
1237+
'# 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.',
12271238
},
12281239
{
12291240
name: 'apply-quickbooks-customer-payments',
12301241
description: 'Record customer payments with bounded optional invoice allocations.',
12311242
content:
1232-
'# 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.',
1243+
'# 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.',
12331244
},
12341245
{
12351246
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
@@ -1021,10 +1021,29 @@ describe('QuickBooks tool and block boundaries', () => {
10211021
field: 'operation',
10221022
value: [
10231023
'quickbooks_read_master_data',
1024+
'quickbooks_read_sales_transactions',
10241025
'quickbooks_list_purchase_orders',
10251026
'quickbooks_list_bills',
10261027
],
10271028
})
1029+
expect(
1030+
typeof subBlocks.transactionId.condition === 'function'
1031+
? subBlocks.transactionId.condition()
1032+
: subBlocks.transactionId.condition
1033+
).toEqual({
1034+
field: 'operation',
1035+
value: [
1036+
'quickbooks_read_sales_transactions',
1037+
'quickbooks_update_estimate',
1038+
'quickbooks_update_invoice',
1039+
'quickbooks_update_sales_receipt',
1040+
'quickbooks_update_credit_memo',
1041+
'quickbooks_update_refund_receipt',
1042+
'quickbooks_update_customer_payment',
1043+
'quickbooks_void_invoice',
1044+
'quickbooks_void_customer_payment',
1045+
],
1046+
})
10281047
expect(QuickBooksBlock.outputs.items.condition).toEqual({
10291048
field: 'operation',
10301049
value: ['quickbooks_read_master_data', 'quickbooks_read_sales_transactions'],

0 commit comments

Comments
 (0)