Calculation Methodology & Math Standards
How MerchSites ensures mathematical accuracy, precise floating-point rounding, and standardized cost sequences across all ecommerce profit tools.
1. Decimal Precision & Floating-Point Error Prevention
Standard computer floating-point math often causes tiny rounding errors (e.g., 0.1 + 0.2 = 0.30000000000000004). To eliminate arithmetic drift in financial planning, MerchSites calculations use dedicated arbitrary-precision decimal operations (`big.js`). All dollar amounts are rounded to 2 decimal places using standard half-up rounding at the final display step.
2. Decoupled Architecture & Testing
All financial calculation logic is completely decoupled from UI display components. Pure decimal math functions reside in `src/lib/financial/` and are independently validated by automated Vitest unit test suites (`tests/financial/`). This ensures zero formula duplication and zero regressions when UI styling changes.
3. Order-Level Expense Sequence
MerchSites separates revenue and expenses into distinct accounting layers:
- Gross Revenue: Retail selling price + customer shipping charged - promo discounts.
- Landed Product COGS: Base purchase cost + inbound freight + packaging materials.
- Outbound Shipping & Fulfillment: Postal label costs + pick/pack 3PL warehouse fees.
- Transaction & Marketplace Fees: Variable percentage commission + fixed gateway fees.
- Ad Acquisition Spend (CAC): Paid Meta, Google, or TikTok ad cost allocated per order.
- Return & Allowance Reserves: Expected return rate percentage applied to variable costs.
4. Platform Fee Benchmarks
Fee rates for platforms (such as Shopify, Etsy, Amazon, Stripe, and PayPal) are maintained in a central reference data file (`src/data/platform-fees.ts`). Every benchmark includes documented last-verified dates, market regions, and editable user overrides so sellers can input custom negotiated rates.
5. Educational Nature of Estimates
While our tools use strict financial math, calculations serve as forward-looking estimates. Real-world business outcomes vary due to tax liabilities, currency fluctuations, seasonal return spikes, and overhead allocation. MerchSites outputs do not substitute for certified accounting or tax reporting.