Skip to content

Commit eb8fc44

Browse files
waleedlatif1claude
andcommitted
fix(quickbooks): correct the sparse-void TSDoc and narrow receipt customerId types
The sparse guard's TSDoc claimed Intuit documents `sparse` as required to void any object. That is false for Invoice, whose void request model is `deleterequest` (Id + SyncToken, no sparse); only the `include=void` form carries it. The code was already correct; the comment would have led an editor to 'fix' void_invoice.ts into breaking it. Also narrows QuickBooksCreateSalesReceiptParams.customerId to optional so the type matches the required:false declaration, per salesreceiptrequest.Required listing only Line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RB5M2gk7zZgGomnQqr7WRB
1 parent 89b6a60 commit eb8fc44

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎apps/sim/tools/quickbooks/sales_utils.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export function mergeQuickBooksPaymentLines(
370370
* do list `CustomerRef` and keep the reference required.
371371
*/
372372
export function buildQuickBooksCreateSalesDocumentBody(
373-
params: QuickBooksCreateSalesDocumentParams,
373+
params: Omit<QuickBooksCreateSalesDocumentParams, 'customerId'> & { customerId?: string },
374374
options: { requireDepositAccount?: boolean; customerOptional?: boolean } = {}
375375
): Record<string, unknown> {
376376
if (options.requireDepositAccount && !params.depositAccountId?.trim()) {
@@ -385,7 +385,7 @@ export function buildQuickBooksCreateSalesDocumentBody(
385385
CustomerRef:
386386
options.customerOptional && !params.customerId?.trim()
387387
? undefined
388-
: quickBooksReference(params.customerId, 'customerId'),
388+
: quickBooksReference(params.customerId ?? '', 'customerId'),
389389
Line: buildQuickBooksSalesLines(params.lines),
390390
TxnDate: validateQuickBooksDate(params.transactionDate, 'transactionDate'),
391391
DocNumber: boundedString(

‎apps/sim/tools/quickbooks/types.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,10 +885,14 @@ export type QuickBooksCreateEstimateParams = Omit<QuickBooksNonReceiptCreatePara
885885
export type QuickBooksUpdateEstimateParams = Omit<QuickBooksNonReceiptUpdateParams, 'dueDate'>
886886
export type QuickBooksCreateInvoiceParams = Omit<QuickBooksNonReceiptCreateParams, 'expirationDate'>
887887
export type QuickBooksUpdateInvoiceParams = Omit<QuickBooksNonReceiptUpdateParams, 'expirationDate'>
888+
/**
889+
* Intuit's `salesreceiptrequest` requires only `Line`; `CustomerRef` is absent
890+
* from its required set, so an anonymous counter sale is a valid sales receipt.
891+
*/
888892
export type QuickBooksCreateSalesReceiptParams = Omit<
889893
QuickBooksCreateSalesDocumentParams,
890-
'dueDate' | 'expirationDate'
891-
>
894+
'dueDate' | 'expirationDate' | 'customerId'
895+
> & { customerId?: string }
892896
export type QuickBooksUpdateSalesReceiptParams = Omit<
893897
QuickBooksUpdateSalesDocumentParams,
894898
'dueDate' | 'expirationDate'

‎apps/sim/tools/quickbooks/values.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,11 @@ export function quickBooksActiveValue(
274274
* Enforces both halves of the contract:
275275
* 1. `sparse` is literally `true`. Intuit treats an update without it as a
276276
* *full* replacement, silently clearing every field the body omits, and
277-
* documents `sparse` as required to void an object. A builder that drops it
278-
* would otherwise fail only against the live API.
277+
* documents `sparse` as required by the `include=void` form of the void
278+
* operation (Payment, SalesReceipt). Invoice voids through
279+
* `?operation=void`, whose documented request model is `deleterequest` —
280+
* `Id` and `SyncToken` only, no `sparse`. A builder that drops it would
281+
* otherwise fail only against the live API.
279282
* 2. The body carries at least one field beyond the required identifiers
280283
* (`Id`, `SyncToken`, `sparse` by default), so an update that would change
281284
* nothing never reaches the API.

0 commit comments

Comments
 (0)