Seth commited on
Commit ·
0a4bb6a
1
Parent(s): 73f93b9
update
Browse files- backend/app/main.py +14 -1
backend/app/main.py
CHANGED
|
@@ -676,6 +676,18 @@ def _fmt_won_money(amount: float, currency_raw) -> str:
|
|
| 676 |
return f"{sym}{n:,.2f} {lab}"
|
| 677 |
|
| 678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 679 |
async def _notify_tenant_admins_deal_won(
|
| 680 |
db: Session,
|
| 681 |
tenant_id: int,
|
|
@@ -753,8 +765,9 @@ async def _notify_tenant_admins_deal_won(
|
|
| 753 |
af = float(li.get("amount") or 0)
|
| 754 |
except (TypeError, ValueError):
|
| 755 |
qf = rf = af = 0.0
|
|
|
|
| 756 |
body_lines.append(
|
| 757 |
-
f" {i}. {ps} | Qty {qf:g} × {_fmt_won_money(rf, cur)} = {_fmt_won_money(af, cur)}"
|
| 758 |
)
|
| 759 |
desc = _safe_str(li.get("description", ""))
|
| 760 |
if desc:
|
|
|
|
| 676 |
return f"{sym}{n:,.2f} {lab}"
|
| 677 |
|
| 678 |
|
| 679 |
+
def _won_billing_interval_label(raw) -> str:
|
| 680 |
+
"""Human-readable billing cadence (matches win popover)."""
|
| 681 |
+
s = (_safe_str(raw) or "monthly").strip().lower()
|
| 682 |
+
if s in ("one_time", "onetime", "one-time", "non-recurring"):
|
| 683 |
+
return "One-time"
|
| 684 |
+
if s in ("quarterly", "quarter", "every 3 months"):
|
| 685 |
+
return "Every 3 months"
|
| 686 |
+
if s in ("annual", "year", "yearly", "every year"):
|
| 687 |
+
return "Every year"
|
| 688 |
+
return "Every month"
|
| 689 |
+
|
| 690 |
+
|
| 691 |
async def _notify_tenant_admins_deal_won(
|
| 692 |
db: Session,
|
| 693 |
tenant_id: int,
|
|
|
|
| 765 |
af = float(li.get("amount") or 0)
|
| 766 |
except (TypeError, ValueError):
|
| 767 |
qf = rf = af = 0.0
|
| 768 |
+
cadence = _won_billing_interval_label(li.get("billing_interval"))
|
| 769 |
body_lines.append(
|
| 770 |
+
f" {i}. {ps} | {cadence} | Qty {qf:g} × {_fmt_won_money(rf, cur)} = {_fmt_won_money(af, cur)}"
|
| 771 |
)
|
| 772 |
desc = _safe_str(li.get("description", ""))
|
| 773 |
if desc:
|