Skip to content

Commit 8bb182d

Browse files
refactor(OUT-4005): insert payout sync and log in parallel in seedFailedPayout
The qb_payout_sync and qb_sync_logs inserts are independent (no FK), so run them together with Promise.all instead of sequentially. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 535bab7 commit 8bb182d

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

test/helpers/seed.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,25 +236,28 @@ export async function seedFailedPayout(opts: {
236236
qbDepositId?: string
237237
errorMessage?: string
238238
}) {
239-
await db.insert(QBPayoutSync).values({
240-
portalId: TEST_PORTAL_ID,
241-
payoutId: opts.payoutId,
242-
lineItems: opts.lineItems,
243-
netAmount: opts.netAmount,
244-
feeAmount: opts.feeCents,
245-
arrivalDate: opts.arrivalDate,
246-
qbDepositId: opts.qbDepositId ?? null,
247-
})
248-
await db.insert(QBSyncLog).values({
249-
portalId: TEST_PORTAL_ID,
250-
entityType: EntityType.PAYOUT,
251-
eventType: EventType.SETTLED,
252-
status: LogStatus.FAILED,
253-
copilotId: opts.payoutId,
254-
// Cents-as-string, matching what the webhook writes for a payout log.
255-
amount: opts.netAmount.toFixed(2),
256-
feeAmount: opts.feeCents.toFixed(2),
257-
errorMessage: opts.errorMessage ?? 'QuickBooks timed out',
258-
shouldRetry: true,
259-
})
239+
// Independent tables, no FK between them — insert both at once.
240+
await Promise.all([
241+
db.insert(QBPayoutSync).values({
242+
portalId: TEST_PORTAL_ID,
243+
payoutId: opts.payoutId,
244+
lineItems: opts.lineItems,
245+
netAmount: opts.netAmount,
246+
feeAmount: opts.feeCents,
247+
arrivalDate: opts.arrivalDate,
248+
qbDepositId: opts.qbDepositId ?? null,
249+
}),
250+
db.insert(QBSyncLog).values({
251+
portalId: TEST_PORTAL_ID,
252+
entityType: EntityType.PAYOUT,
253+
eventType: EventType.SETTLED,
254+
status: LogStatus.FAILED,
255+
copilotId: opts.payoutId,
256+
// Cents-as-string, matching what the webhook writes for a payout log.
257+
amount: opts.netAmount.toFixed(2),
258+
feeAmount: opts.feeCents.toFixed(2),
259+
errorMessage: opts.errorMessage ?? 'QuickBooks timed out',
260+
shouldRetry: true,
261+
}),
262+
])
260263
}

0 commit comments

Comments
 (0)