Add EDDM size, income, businesses and USPS map link (#17)
CI / test (pull_request) Successful in 24s
CI / test (pull_request) Successful in 24s
## Summary Closes #17. - Join USPS EDDM GIS stats onto the carrier-route picker (household size, median income, business count) and link to the official EDDM map. - GIS miss stays a dash and does not block Find routes; PCM households/cost unchanged.
This commit is contained in:
1 parent
045e956011
commit
7691fcd618
6 files changed
+254
-2
No files matched your search
@@ -456,6 +456,10 @@ def postcard_quote(*, action: str, payload: dict) -> dict:
|
||||
mail_class_for_size,
|
||||
pick_unit_price,
|
||||
)
|
||||
from messaging.providers.postcard.usps_eddm import (
|
||||
USPS_EDDM_MAP_URL,
|
||||
enrich_crrt_rows,
|
||||
)
|
||||
|
||||
template_id = str(payload.get("template_id") or "").strip()
|
||||
design_id = payload.get("design_id")
|
||||
@@ -511,7 +515,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"])
|
||||
@@ -528,6 +532,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"),
|
||||
}
|
||||
|
||||
@@ -553,6 +558,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)
|
||||
@@ -580,6 +586,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