New and improved with central fullfillment-pipeline and check for customer name and email adress

This commit is contained in:
peignerpausz committed 2026-11-13 16:34:31 +01:00
1 parent 6580517e9d
commit 47531ea971
11 files changed
+1331 -36

No files matched your search

@@ -27,6 +27,11 @@ def get_customer_name(order):
return f"{firstname} {lastname}".strip()
def get_customer_email(order):
customer = order.get("customer", {})
return customer.get("email", "").strip()
def get_domains(order):
domains = set()
@@ -75,7 +80,10 @@ for filename in glob.glob("*.json"):
order_date = order_date.split("T")[0]
customer_name = get_customer_name(order)
customer_email = get_customer_email(order)
domains = get_domains(order)
customer_name_prompted = False
customer_email_prompted = False
for item in order.get("data", []):
@@ -84,6 +92,22 @@ for filename in glob.glob("*.json"):
if product not in TARGET_PRODUCTS:
continue
if not customer_name and not customer_name_prompted:
customer_name = input(
f"No customer name found for customer {customer_no} "
f"(order {order_no}). "
"Enter a name to add to the CSV: "
).strip()
customer_name_prompted = True
if not customer_email and not customer_email_prompted:
customer_email = input(
f"No customer email found for customer {customer_no} "
f"(order {order_no}). "
"Enter an email to add to the CSV: "
).strip()
customer_email_prompted = True
domain = get_domain_for_product(item, domains)
rows.append({
@@ -91,6 +115,7 @@ for filename in glob.glob("*.json"):
"order_date": order_date,
"customer_no": customer_no,
"customer_name": customer_name,
"customer_email": customer_email,
"product": product,
"domain": domain
})
@@ -107,6 +132,7 @@ with open(OUTPUT_FILE, "w", newline="", encoding="utf-8") as csvfile:
"order_date",
"customer_no",
"customer_name",
"customer_email",
"product",
"domain"
]