{
 "slug": "overdue-invoice-chaser-0887",
 "uc": "UC-0887",
 "webhook": "twwp-overdue-invoice-chaser-0887",
 "workflow_id": "twwpuc0887",
 "gate": "the owner approves every reminder before it is queued (approved=true); nothing is released without it, final notices included. Invoices with an unreadable or impossible date go to a review queue and are never given a tier.",
 "tests": [
  {
   "case": "default",
   "input": {
    "today": "2026-11-26",
    "approved": false,
    "invoices": [
     {
      "id": "INV-1001",
      "customer": "Bright Bakery",
      "amount": 420.0,
      "due": "2026-11-20",
      "status": "open"
     },
     {
      "id": "INV-1002",
      "customer": "Harbour Print",
      "amount": 1180.5,
      "due": "2026-11-01",
      "status": "open"
     },
     {
      "id": "INV-1003",
      "customer": "Old Mill Cafe",
      "amount": 260.0,
      "due": "2026-10-10",
      "status": "open"
     },
     {
      "id": "INV-1004",
      "customer": "Studio Nine",
      "amount": 900.0,
      "due": "2026-10-01",
      "status": "disputed"
     },
     {
      "id": "INV-1005",
      "customer": "Green Door",
      "amount": 75.0,
      "due": "2026-10-05",
      "status": "paid"
     },
     {
      "id": "INV-1006",
      "customer": "Corner Shop",
      "amount": 310.0,
      "due": "2026-12-05",
      "status": "open"
     }
    ]
   },
   "expected": {
    "status": "held_for_approval",
    "held_for_owner": [
     "INV-1003"
    ],
    "drafts": [
     {
      "invoice": "INV-1001",
      "customer": "Bright Bakery",
      "amount": 420.0,
      "days_overdue": 6,
      "tier": "friendly",
      "subject": "Friendly reminder: invoice INV-1001"
     },
     {
      "invoice": "INV-1002",
      "customer": "Harbour Print",
      "amount": 1180.5,
      "days_overdue": 25,
      "tier": "firm",
      "subject": "Reminder: invoice INV-1002 is overdue"
     },
     {
      "invoice": "INV-1003",
      "customer": "Old Mill Cafe",
      "amount": 260.0,
      "days_overdue": 47,
      "tier": "final",
      "subject": "Final notice: invoice INV-1003"
     }
    ],
    "call_the_customer": [
     "INV-1004"
    ],
    "review_queue": []
   }
  },
  {
   "case": "regression_unreadable_date_approved",
   "input": {
    "today": "2026-11-26",
    "approved": true,
    "invoices": [
     {
      "id": "INV-2001",
      "customer": "A",
      "amount": 10.0,
      "due": "26/11/2026",
      "status": "open"
     },
     {
      "id": "INV-2002",
      "customer": "B",
      "amount": 20.0,
      "due": "not a date",
      "status": "open"
     },
     {
      "id": "INV-2003",
      "customer": "C",
      "amount": 30.0,
      "due": "",
      "status": "open"
     },
     {
      "id": "INV-2004",
      "customer": "D",
      "amount": 40.0,
      "due": "2026-02-30",
      "status": "open"
     },
     {
      "id": "INV-2005",
      "customer": "E",
      "amount": 50.0,
      "due": "2026-11-20",
      "status": "open"
     }
    ]
   },
   "expected": {
    "status": "drafts_ready",
    "queued_local": [
     "INV-2005"
    ],
    "drafts": [
     {
      "invoice": "INV-2005",
      "customer": "E",
      "amount": 50.0,
      "days_overdue": 6,
      "tier": "friendly",
      "subject": "Friendly reminder: invoice INV-2005"
     }
    ],
    "call_the_customer": [],
    "review_queue": [
     "INV-2001",
     "INV-2002",
     "INV-2003",
     "INV-2004"
    ]
   }
  },
  {
   "case": "regression_bad_today_date",
   "input": {
    "today": "yesterday",
    "approved": true,
    "invoices": [
     {
      "id": "INV-3001",
      "customer": "A",
      "amount": 10.0,
      "due": "2026-10-01",
      "status": "open"
     }
    ]
   },
   "expected": {
    "status": "drafts_ready",
    "queued_local": [],
    "drafts": [],
    "call_the_customer": [],
    "review_queue": [
     "INV-3001"
    ]
   }
  },
  {
   "case": "final_approved",
   "input": {
    "today": "2026-11-26",
    "approved": true,
    "invoices": [
     {
      "id": "INV-4001",
      "customer": "A",
      "amount": 10.0,
      "due": "2026-10-01",
      "status": "open"
     }
    ]
   },
   "expected": {
    "status": "drafts_ready",
    "queued_local": [
     "INV-4001"
    ],
    "drafts": [
     {
      "invoice": "INV-4001",
      "customer": "A",
      "amount": 10.0,
      "days_overdue": 56,
      "tier": "final",
      "subject": "Final notice: invoice INV-4001"
     }
    ],
    "call_the_customer": [],
    "review_queue": []
   }
  }
 ]
}