Shopify Plus B2B Net-Terms Reconciliation: Why IEEE-754 Float Math Breaks Integer-Cent Deposit Gates

2026-10-31来源 dev.to NodeEnglish

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, }; } 

原文:https://www.a8q9.cn/en/article/shopify-plus-b2b-net-terms-reconciliation-why-ieee-754-float-math-breaks-integer-ba15f0.html

相关文章