{
  "schema_version": "1.0.0",
  "id": "receipt-forward-to-expense-row",
  "title": "Forward a receipt and log it as an expense",
  "category": "invoices-docs",
  "difficulty": "beginner",
  "featured": false,
  "description": "Staff forward receipts to a Zapier email address; each one becomes an expense row with merchant, date, amount, and category.",
  "tags": [
    "receipts",
    "expenses",
    "email-by-zapier",
    "google-sheets"
  ],
  "apps": [
    "Email by Zapier",
    "AI by Zapier",
    "Code by Zapier",
    "Google Sheets"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger",
      "AI by Zapier"
    ]
  },
  "tasks": {
    "typical": 3,
    "max": 3
  },
  "trigger": {
    "app": "Email by Zapier",
    "event": "New Inbound Email",
    "kind": "instant",
    "title": "Receipt forwarded to the team address",
    "why": "Gives the team one address to forward receipts to. Nobody needs access to anyone else's mailbox.",
    "config": {
      "Email Address": "receipts-YOUR_TEAM@robot.zapier.com"
    },
    "outputs": [
      "from_email",
      "from_name",
      "subject",
      "body_plain",
      "date"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "extract",
      "kind": "ai",
      "app": "AI by Zapier",
      "event": "Analyze and Return Data",
      "title": "Read the receipt",
      "why": "Pulls merchant, date, the total as printed, and a category from a fixed list so the sheet stays filterable.",
      "fields": {
        "Model": "Default (fast)",
        "Instructions": "This is a forwarded purchase receipt. Return merchant, purchase_date (YYYY-MM-DD), total_text (the charged total exactly as printed, with currency symbol or code), currency (ISO code if clear), and category: one of software, travel, meals, office, advertising, other. Leave a value empty if it is not in the text.",
        "Input data": "Forwarded by {{trigger.from_email}}\nSubject: {{trigger.subject}}\n\n{{trigger.body_plain}}",
        "Output fields": "merchant, purchase_date, total_text, currency, category"
      },
      "outputs": [
        "merchant",
        "purchase_date",
        "total_text",
        "currency",
        "category"
      ]
    },
    {
      "key": "money",
      "kind": "code",
      "app": "Code by Zapier",
      "event": "Run JavaScript",
      "title": "Read the amount",
      "why": "Converts the printed total into an exact decimal and flags anything ambiguous.",
      "code": {
        "language": "javascript",
        "module": "parse-money",
        "file": "code/parse-money.js"
      },
      "input_data": {
        "amount_text": "{{extract.total_text}}",
        "currency_hint": "{{extract.currency}}"
      },
      "outputs": [
        "amount",
        "amount_fixed",
        "amount_cents",
        "currency",
        "format",
        "needs_review"
      ]
    },
    {
      "key": "log",
      "kind": "action",
      "app": "Google Sheets",
      "event": "Create Spreadsheet Row",
      "title": "Add the expense row",
      "why": "One row per receipt, with who forwarded it.",
      "fields": {
        "Drive": "My Google Drive",
        "Spreadsheet": "Expenses",
        "Worksheet": "Receipts",
        "Columns": {
          "logged_at": "{{trigger.date}}",
          "submitted_by": "{{trigger.from_email}}",
          "merchant": "{{extract.merchant}}",
          "purchase_date": "{{extract.purchase_date}}",
          "amount": "{{money.amount_fixed}}",
          "currency": "{{money.currency}}",
          "category": "{{extract.category}}",
          "needs_review": "{{money.needs_review}}"
        }
      },
      "outputs": [
        "id",
        "row_number"
      ]
    }
  ]
}
