{
  "schema_version": "1.0.0",
  "id": "morning-overdue-receivables",
  "title": "Email the owner a morning note on overdue invoices",
  "category": "reporting",
  "difficulty": "beginner",
  "featured": false,
  "description": "Each weekday morning, read the receivables summary row and email the owner the count, total, and oldest overdue invoice when anything is late.",
  "tags": [
    "receivables",
    "invoices",
    "google-sheets",
    "gmail",
    "daily"
  ],
  "apps": [
    "Schedule by Zapier",
    "Google Sheets",
    "Filter by Zapier",
    "Gmail"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger",
      "Filter by Zapier"
    ]
  },
  "tasks": {
    "typical": 2,
    "max": 2
  },
  "trigger": {
    "app": "Schedule by Zapier",
    "event": "Every Day",
    "kind": "schedule",
    "title": "Weekdays at 8am",
    "why": "Runs every weekday morning.",
    "config": {
      "Trigger on Weekends?": "No",
      "Time of Day": "8am",
      "Timezone": "YOUR_TIMEZONE"
    },
    "outputs": [
      "pretty_date",
      "date",
      "day_of_week",
      "week_of_year"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "ar",
      "kind": "search",
      "app": "Google Sheets",
      "event": "Lookup Spreadsheet Row",
      "title": "Read the receivables summary row",
      "why": "One row keyed `today`, built with COUNTIFS and SUMIFS over the invoice tab.",
      "fields": {
        "Drive": "My Google Drive",
        "Spreadsheet": "Receivables",
        "Worksheet": "Summary",
        "Lookup Column": "key",
        "Lookup Value": "today",
        "Should this step be considered a \"success\" when nothing is found?": "Yes"
      },
      "outputs": [
        "row_number",
        "_zap_search_was_found_status",
        "overdue_count",
        "overdue_total",
        "currency",
        "oldest_client",
        "oldest_invoice",
        "oldest_days"
      ]
    },
    {
      "key": "any",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only when something is overdue",
      "why": "On a clean morning the run stops and no email is sent.",
      "conditions": [
        [
          {
            "field": "{{ar.overdue_count}}",
            "operator": "(Number) Greater than",
            "value": "0"
          }
        ]
      ],
      "usually": true
    },
    {
      "key": "note",
      "kind": "action",
      "app": "Gmail",
      "event": "Send Email",
      "title": "Email the owner",
      "why": "A short note with the oldest invoice first, because that is the call to make today.",
      "fields": {
        "To": "YOUR_EMAIL",
        "Subject": "{{ar.overdue_count}} overdue invoices, {{ar.overdue_total}} {{ar.currency}}",
        "Body Type": "plain",
        "Body": "Good morning,\n\n{{ar.overdue_count}} invoices are overdue, {{ar.overdue_total}} {{ar.currency}} in total.\n\nOldest: {{ar.oldest_invoice}} from {{ar.oldest_client}}, {{ar.oldest_days}} days late.\n\nReceivables sheet: YOUR_SHEET_URL",
        "From Name": "Receivables"
      },
      "outputs": [
        "id",
        "thread_id"
      ]
    }
  ]
}
