Promotion Stacking Simulator
Pricing
$1.00 / 1,000 completed cart-rule scenarios
Promotion Stacking Simulator
Simulate coupon stacking on CSV/JSON carts. Compare discounts, shipping and supplied-cost contribution margins with an auditable trace. Platform-neutral; no store writes. $1 per 1,000 completed cart-rule scenarios.
Pricing
$1.00 / 1,000 completed cart-rule scenarios
Rating
0.0
(0)
Developer
AFK Digital
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
14 days ago
Last modified
Categories
Features
Share
AFK Digital — NEWAPI90 — release 0.1
Simulate customer-supplied promotions against carts before creating a campaign. This is a platform-neutral calculator, not a Shopify or other platform replica. It never creates coupons, contacts stores, or places orders. No tax, currency conversion, returns, checkout, or customer identity logic is inferred.
Input
See demo.json. cartsFile and productCostsFile accept an encoded file object: {"format":"json","content":"[...rows...]"} or {"format":"csv","content":"header\nrow..."}. JSON row arrays also work in the engine. No external URLs or local file paths are fetched. Cart JSON: cart_id, currency, items containing sku, quantity, unit_price. Cart CSV columns: cart_id,currency,sku,quantity,unit_price (one line per item). Cost rows/CSV: sku,currency,unit_cost. Duplicate cost keys and mixed currency within a CSV cart fail validation. Currency labels must agree for cost matching; no conversion is performed.
promotionRules: unique id; type percent, fixed, or free_shipping; scope product or cart (default cart); value; optional minimum; minimumBasis pre or post; includedSkus, excludedSkus; usageLimit and usageCount; stackable (default true). rulePriority must contain all rules exactly once when more than one exists. scenarios is an array of coupon ID arrays, each defining a selected subset. The priority always controls execution order. Repeated IDs apply once and subsequent occurrences are rejected. allCombinations generates all subsets including the empty baseline, not permutations. It fails before expansion if the total exceeds maxScenarios. Changing order requires a separate run.
Calculation contract
Prices are line totals rounded from quantity × unit price. Each discount step is rounded. Percentages apply to remaining eligible balances. Product fixed discounts are per unit; cart fixed discounts apply once and are proportionally allocated to eligible lines. Largest remainder allocation breaks ties by input line index. minimum is inclusive and uses the whole merchandise subtotal, excluding shipping, including excluded products: pre uses original rounded subtotal; post uses the remaining subtotal immediately before this rule. SKU filters constrain discounts, not the minimum subtotal. Free shipping removes remaining shipping revenue only; shipping expense remains. SKU filters have no effect on free_shipping. Usage counters are supplied snapshots and evaluated independently per scenario/cart; no global consumption or live redemption enforcement is simulated. A nonstackable promotion is rejected when another has already applied; an applied nonstackable promotion blocks later rules. Discounts never make line or shipping balances negative. roundingPolicy: decimals 0..4, mode HALF_UP (default), HALF_EVEN, or DOWN. Monetary output is decimal strings.
net_sales = discounted merchandise + remaining shipping revenue (tax excluded). gross_margin = discounted merchandise − supplied product costs (amount, not percent). contribution_margin = gross_margin + shipping revenue − shipping cost − other variable costs. shippingInputs is keyed by cart_id with revenue, cost and variable_cost in the cart currency. Omitted revenue means no shipping revenue. Missing cost or variable_cost remains unknown: explicitly supply 0 only if known to be zero. Missing product costs never become zero: gross/contribution margin and applicable threshold result are null. Missing shipping/variable expenses make contribution unknown. The calculator is not a claim of actual accounting profit. marginThreshold: {type:amount|percent,value:number}. Percent uses contribution / net sales × 100; zero revenue produces an unknown percent. Breach means strictly below the threshold, not equal. Summary counts breaches and unknown margins without summing mixed currencies.
Output and billing
Dataset rows include scenario_id, cart_id, currency, applied_promotions, rejected_promotions, rejection_reasons, discount_breakdown, net_sales, supplied_costs, gross_margin, contribution_margin, contribution_margin_percent, threshold_breach and calculation_trace. Export the Dataset as JSON or CSV from Apify Console/API. Nested breakdown/trace objects remain JSON in local CSV. SUMMARY is a key-value record; local samples are sample_output.json, sample_output.csv and sample_summary.json. One completed cart-rule scenario = one completed-scenario event. Price: USD 1.00 per 1,000 events (USD 0.001 each), platform usage included. 100 carts × 8 subsets = 800 events = USD 0.80, even though only 100 carts were supplied. A no-discount or rejected-promotion result is still a completed simulation and counts once. Validation failures are not charged. No additional startup charge is proposed. Each result uses the Apify SDK completed-scenario charging event. Retries should be new runs only when intended; do not assume free replay.
Limits
4 MB per encoded file, 8 MB total serialized input; 1,000 carts; 200 items/cart; 20,000 cost rows; 16 rules; 32 coupon references per explicit scenario; maxScenarios 1..10,000, default 1,000; engine 120 seconds; Actor process 240 seconds. Set platform timeout to 300 seconds and memory to 256 MB for the demo. CSV must contain headers and decimal values using a dot. JSON monetary values should be strings to preserve exact representation.
Run
python -m unittest discover -s tests -v python main.py --local docker build -t newapi90:0.1.0 . docker run --rm newapi90:0.1.0
Data and release
Input/output use the customer's Apify run storage and account permissions/retention settings. Do not submit sensitive personal data. No third-party API is called by the simulator. Delete run storage according to your account policy. Actor ID: LvAArMz7gA8UzMqlS. Review platform storage retention/access before production use.