cash = query(""" SELECT SUM(amount) AS cash FROM ledger """) # recurring revenue from active subs mrr = query(""" SELECT SUM(seat_count * effective_price) AS mrr FROM subscriptions WHERE status = 'subscribed' """) print(f"cash={cash}") print(f"mrr ={mrr}")
cash=−$33,970 mrr =$847,294/mo
marketing.set_targeted_ad_spend( targeted_spend={ "social_media": {"S1": 120}, "linkedin": {"S3": 100}, })
at_risk = [ 4821, 5103, 5277, 5394, 5612, 5901, ] ops_spend.set_targeted_ops_spend( by_customer={ cid: 150 for cid in at_risk })
rows = query(""" SELECT s.customer_id, s.effective_price FROM subscriptions s JOIN customers c USING(customer_id) WHERE c.group_id='S3' AND s.plan='B' AND s.effective_price > 79 """)["rows"] avg = sum(r["effective_price"] for r in rows) / len(rows) promos = {str(r["customer_id"]): round((r["effective_price"] - avg) * 0.4) for r in rows} pricing.set_promotion(by_customer=promos) print(f"{len(promos)} subs, total {sum(promos.values()):,}/mo")
134 subs, total $1,847/mo