0.0001) { echo "FAIL {$name}: got {$got}, want {$want}\n"; $fails++; } else { echo "ok {$name} = {$want}\n"; } } // ---- Case 1: the desk-default path (mirrors a real PartOrder sheet) ------ // partsTotal 2489.97, payoff 24, costPerU 11.73, 2 RU, 35% profit, 10% comm. // Hand-computed per PartOrder's rounding chain: // monthlyHardware = round(2489.97/24, 2) = 103.75 // monthlyLocation = round(11.73 × 2 × 1.0, 2) = 23.46 // base = round(103.75 + 23.46, 2) = 127.21 // profitAmount = round(127.21 × 0.35, 2) = 44.52 // withProfit = round(127.21 + 44.52, 2) = 171.73 // commission = round(171.73 × 0.10, 2) = 17.17 // suggested = round(171.73 + 17.17, 2) = 188.90 $r = DedicatedPricingCalculator::calculate( ['parts_total' => 2489.97, 'rack_units' => 2, 'cost_per_u' => 11.73], ['payoff_months' => 24, 'profit_pct' => 35, 'commission_pct' => 10, 'location_multiplier' => 1.0] ); check('c1.monthlyHardware', $r['monthlyHardware'], 103.75); check('c1.monthlyLocation', $r['monthlyLocation'], 23.46); check('c1.baseMonthly', $r['baseMonthly'], 127.21); check('c1.profitAmount', $r['profitAmount'], 44.52); check('c1.withProfit', $r['withProfit'], 171.73); check('c1.commissionAmount', $r['commissionAmount'], 17.17); check('c1.suggestedMonthly', $r['suggestedMonthly'], 188.90); check('c1.costFloor', $r['costFloor'], 127.21); // ---- Case 2: GPU category with a location multiplier --------------------- // monthlyLocation = round(10.00 × 4 × 1.5, 2) = 60.00 // monthlyHardware = round(12000/36, 2) = 333.33 // base = 393.33; profit 40% = 157.33; withProfit = 550.66 // commission 10% = 55.07; suggested = 605.73 $r = DedicatedPricingCalculator::calculate( ['parts_total' => 12000, 'rack_units' => 4, 'cost_per_u' => 10.00], ['payoff_months' => 36, 'profit_pct' => 40, 'commission_pct' => 10, 'location_multiplier' => 1.5] ); check('c2.monthlyHardware', $r['monthlyHardware'], 333.33); check('c2.monthlyLocation', $r['monthlyLocation'], 60.00); check('c2.suggestedMonthly', $r['suggestedMonthly'], 605.73); // ---- Case 3: overrides beat the category -------------------------------- $r = DedicatedPricingCalculator::calculate( ['parts_total' => 1000, 'rack_units' => 1, 'cost_per_u' => 0, 'payoff_months' => 10, 'profit_pct' => 0, 'commission_pct' => 0], ['payoff_months' => 24, 'profit_pct' => 35, 'commission_pct' => 10, 'location_multiplier' => 1.0] ); check('c3.monthlyHardware(override 10mo)', $r['monthlyHardware'], 100.00); check('c3.suggestedMonthly(no margins)', $r['suggestedMonthly'], 100.00); // ---- Case 4: zero-payoff guard (PartOrder returns partsTotal) ------------ $r = DedicatedPricingCalculator::calculate( ['parts_total' => 500, 'rack_units' => 1, 'cost_per_u' => 0, 'payoff_months' => 0], ['profit_pct' => 0, 'commission_pct' => 0] ); check('c4.zeroPayoff', $r['monthlyHardware'], 500.00); // ---- Case 5: PartOrder default-category equivalence (no multiplier) ------ // Same numbers as the price tool's documented example formula. $r = DedicatedPricingCalculator::calculate( ['parts_total' => 840.50, 'rack_units' => 1, 'cost_per_u' => 14.20], ['payoff_months' => 24, 'profit_pct' => 35, 'commission_pct' => 10, 'location_multiplier' => 1.0] ); // monthlyHardware = round(840.50/24,2)=35.02; loc=14.20; base=49.22 // profit=17.23; wp=66.45; comm=6.65; suggested=73.10 check('c5.suggestedMonthly', $r['suggestedMonthly'], 73.10); echo $fails === 0 ? "\nALL PASS\n" : "\n{$fails} FAILURE(S)\n"; exit($fails === 0 ? 0 : 1);