Template
Add EDDM size, income, businesses and USPS map link (#14)
## Summary Closes #13. - Mirror Monica: join USPS EDDM GIS stats onto the carrier-route picker (household size, median income, business count). - Add Open USPS EDDM map link next to Find routes. - GIS miss stays a dash and does not block Find routes. PCM households and cost unchanged. Monica: ai_ml_operations/monica_site#17 ## Test plan - [ ] Find routes for a ZIP; table shows Size / Income / Businesses columns - [ ] Missing GIS values render as — - [ ] Open USPS EDDM map opens eddm.usps.com - [ ] Quote and 1–2 route send still work - [ ] `CarrierRoutePostcardTests` pass Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
1 parent
f2eb4b7152
commit
7ff52c776b
6 files changed
+254
-3
No files matched your search
@@ -159,6 +159,10 @@ def postcard_quote(*, action: str, payload: dict) -> dict:
|
||||
mail_class_for_size,
|
||||
pick_unit_price,
|
||||
)
|
||||
from directmail.providers.postcard.usps_eddm import (
|
||||
USPS_EDDM_MAP_URL,
|
||||
enrich_crrt_rows,
|
||||
)
|
||||
|
||||
design_id = payload.get("design_id")
|
||||
size = str(payload.get("size") or "").strip()
|
||||
@@ -210,7 +214,7 @@ def postcard_quote(*, action: str, payload: dict) -> dict:
|
||||
data = list_count_zipcode(zip_codes=[zip_code])
|
||||
else:
|
||||
raise ValueError("Enter a ZIP code (or address + ZIP + radius).")
|
||||
rows = extract_crrt_rows(data)
|
||||
rows = enrich_crrt_rows(extract_crrt_rows(data), zip_hint=zip_code)
|
||||
priced = []
|
||||
for row in rows:
|
||||
per_piece, source = _price(row["total"])
|
||||
@@ -227,6 +231,7 @@ def postcard_quote(*, action: str, payload: dict) -> dict:
|
||||
"mail_class": mail_class,
|
||||
"zip": zip_code,
|
||||
"routes": priced,
|
||||
"eddm_map_url": USPS_EDDM_MAP_URL,
|
||||
"discovery_list_count_id": data.get("listCountID") or data.get("list_count_id"),
|
||||
}
|
||||
|
||||
@@ -251,6 +256,7 @@ def postcard_quote(*, action: str, payload: dict) -> dict:
|
||||
rows = [{"code": code, "text": code, "total": 0} for code in codes]
|
||||
if record_count and len(rows) == 1:
|
||||
rows[0]["total"] = record_count
|
||||
rows = enrich_crrt_rows(rows, zip_hint=codes[0] if codes else "")
|
||||
record_count = int(data.get("recordCount") or data.get("record_count") or 0)
|
||||
if not record_count:
|
||||
record_count = sum(int(r.get("total") or 0) for r in rows)
|
||||
@@ -278,6 +284,7 @@ def postcard_quote(*, action: str, payload: dict) -> dict:
|
||||
"per_piece": per_piece,
|
||||
"total": money_total(per_piece, record_count),
|
||||
"price_source": source,
|
||||
"eddm_map_url": USPS_EDDM_MAP_URL,
|
||||
"estimated": {
|
||||
"per_piece": per_piece,
|
||||
"pieces": record_count,
|
||||
|
||||
Reference in new issue
Block a user