Skip to content

Commit ddc8766

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): require recipient for payment email
1 parent fc6fa6f commit ddc8766

5 files changed

Lines changed: 26 additions & 6 deletions

File tree

apps/docs/content/docs/en/integrations/quickbooks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ Send a supported QuickBooks transaction by email. This causes an external email
26922692
| --------- | ---- | -------- | ----------- |
26932693
| `transactionType` | string | Yes | Supported transaction type to email |
26942694
| `transactionId` | string | Yes | QuickBooks transaction ID |
2695-
| `recipient` | string | No | Optional single recipient override; otherwise QuickBooks uses the stored recipient |
2695+
| `recipient` | string | No | Required for Customer Payments; otherwise an optional single recipient override |
26962696
| `confirmSend` | boolean | Yes | Explicit confirmation that an external email should be sent |
26972697

26982698
#### Output

apps/sim/blocks/blocks/quickbooks.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,17 @@ export const QuickBooksBlock: BlockConfig<QuickBooksResponse> = {
496496
},
497497
{
498498
id: 'recipientOverride',
499-
title: 'Recipient Override',
499+
title: 'Recipient',
500500
type: 'short-input',
501-
placeholder: 'Optional single email address',
501+
placeholder: 'Required for Customer Payments; otherwise optional',
502502
condition: { field: 'operation', value: EMAIL_TRANSACTION_OPERATION },
503-
mode: 'advanced',
503+
required: {
504+
field: 'operation',
505+
value: EMAIL_TRANSACTION_OPERATION,
506+
and: { field: 'documentTransactionType', value: 'payment' },
507+
},
508+
description:
509+
'Required for Customer Payments. For other transactions, leave blank to use the email stored in QuickBooks or provide one override address.',
504510
},
505511
{
506512
id: 'documentFileName',

apps/sim/tools/generated/tool-metadata.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ describe('QuickBooks document tools', () => {
6868
expect(() => requestUrl({ ...base, recipient: 'a@example.com\r\nBcc:x@example.com' })).toThrow(
6969
'one valid email'
7070
)
71+
expect(() => requestUrl({ ...base, transactionType: 'payment' })).toThrow(
72+
'recipient is required when emailing a QuickBooks Customer Payment'
73+
)
74+
expect(new URL(requestUrl(base)).searchParams.has('sendTo')).toBe(false)
7175
})
7276

7377
it('preserves a verified native record from a successful email response', async () => {
@@ -343,6 +347,13 @@ describe('QuickBooks document validation and block parity', () => {
343347
'attachmentFileReference',
344348
])
345349
expect(fileBlocks.every((block) => block.required !== undefined)).toBe(true)
350+
const recipient = QuickBooksBlock.subBlocks.find((block) => block.id === 'recipientOverride')
351+
expect(recipient?.mode).toBeUndefined()
352+
expect(recipient?.required).toEqual({
353+
field: 'operation',
354+
value: 'quickbooks_email_transaction',
355+
and: { field: 'documentTransactionType', value: 'payment' },
356+
})
346357
})
347358

348359
it('maps document params after dynamic references resolve', () => {

apps/sim/tools/quickbooks/email_transaction.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const quickbooksEmailTransactionTool: ToolConfig<
5656
required: false,
5757
visibility: 'user-or-llm',
5858
description:
59-
'Optional single recipient override; otherwise QuickBooks uses the stored recipient',
59+
'Required for Customer Payments; otherwise an optional single recipient override',
6060
},
6161
confirmSend: {
6262
type: 'boolean',
@@ -82,6 +82,9 @@ export const quickbooksEmailTransactionTool: ToolConfig<
8282
`${resource}/${encodeURIComponent(id)}/send`
8383
)
8484
const recipient = validateQuickBooksRecipient(params.recipient)
85+
if (params.transactionType === 'payment' && !recipient) {
86+
throw new Error('recipient is required when emailing a QuickBooks Customer Payment')
87+
}
8588
if (recipient) url.searchParams.set('sendTo', recipient)
8689
return url.toString()
8790
},

0 commit comments

Comments
 (0)