In Shopify Plus B2B commerce, wholesale orders on Net-15, Net-30, or Net-60 payment schedules frequently require an upfront deposit (such as 20 percent) before warehouse fulfillment is released.
When webhook workers evaluate deposit thresholds using standard JavaScript floating-point numbers (Number(order.total_price) * 0.20), IEEE-754 binary rounding drift and unapplied credit notes cause premature fulfillment releases or false accounting discrepancies.
export function reconcileNetTermsDeposit({ invoiceTotalCents, creditNotesCents = 0, settledPaidCents = 0, requiredDepositBps = 2000, }) { const netInvoiceCents = Math.max(0, invoiceTotalCents - creditNotesCents); const requiredDepositCents = Math.round((netInvoiceCents * requiredDepositBps) / 10_000); const depositShortfallCents = Math.max(0, requiredDepositCents - settledPaidCents); return { fulfillmentHold: depositShortfallCents > 0, requiredDepositCents, depositShortfallCents, }; } - Engineering deep-dive: Shopify B2B Net-Terms Integer-Cent Reconciliation
- Interactive sandbox: Free B2B Net-Terms & Deposit Calculator
