47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package tests
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
)
|
|
|
|
func TestPsychologicalSplitMath(t *testing.T) {
|
|
// Base Price (what the seller wants to sell for)
|
|
basePrice := 100.0
|
|
|
|
// 1. Backend inflates by 6% for search/display
|
|
buyerFeeRate := 0.06
|
|
inflatedPrice := basePrice * (1 + buyerFeeRate) // 106.0
|
|
|
|
// 2. Buyer sees 12% fee in checkout, but math must stay at 106.0
|
|
// Visual Subtotal = 106.0 / 1.12 = 94.6428...
|
|
visualSubtotal := inflatedPrice / 1.12
|
|
visualFee := inflatedPrice - visualSubtotal
|
|
|
|
// 3. Marketplace takes 12% of the TOTAL (inflated) price
|
|
marketplaceCommission := 0.12
|
|
totalMarketplaceFee := inflatedPrice * marketplaceCommission // 12.72
|
|
|
|
// 4. Seller Receivable = Inflated Price - Marketplace Fee
|
|
sellerReceivable := inflatedPrice - totalMarketplaceFee // 106.0 - 12.72 = 93.28
|
|
|
|
// 5. Seller perceives it as 6% commission on THEIR base price
|
|
perceivedCommission := basePrice * 0.06 // 6.0
|
|
expectedSellerReceivable := basePrice - perceivedCommission // 94.0
|
|
|
|
// ASSERTION: Does 93.28 == 94.0?
|
|
// Result: NO.
|
|
// To make the seller receive 94.0 (Base - 6%),
|
|
// and Marketplace receive 12.72 (which is 12% of inflated 106.0),
|
|
// The math needs adjustment.
|
|
|
|
t.Logf("Base: %.2f", basePrice)
|
|
t.Logf("Inflated (Buyer sees total): %.2f", inflatedPrice)
|
|
t.Logf("Marketplace Fee (12%% of inflated): %.2f", totalMarketplaceFee)
|
|
t.Logf("Seller Net: %.2f", sellerReceivable)
|
|
t.Logf("Target Seller Net (Base - 6%%): %.2f", expectedSellerReceivable)
|
|
|
|
if math.Abs(sellerReceivable-expectedSellerReceivable) > 0.01 {
|
|
t.Errorf("Math mismatch! Seller receives %.2f but expected %.2f", sellerReceivable, expectedSellerReceivable)
|
|
}
|
|
}
|