{
 "name": "Mendera · 008 · Parte semanal por WhatsApp",
 "nodes": [
  {
   "id": "a0080000-0000-4000-8000-000000000001",
   "name": "Mendera Systems",
   "parameters": {
    "content": "## Creado con Mendera Systems\nmenderasystems.com — Sistema 008 de la biblioteca.\nSi te lo han pasado, es gratis: el resto de la biblioteca está en menderasystems.com/biblioteca-de-sistemas.",
    "height": 160,
    "width": 420
   },
   "position": [
    0,
    -160
   ],
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1
  },
  {
   "id": "a0080000-0000-4000-8000-000000000002",
   "name": "Cómo se monta",
   "parameters": {
    "content": "## Cómo se monta\n1. Importa este archivo en n8n (Workflows → Import from File).\n2. Crea una hoja de cálculo con las columnas fecha | concepto | importe y pon su ID en TU_ID_DE_HOJA.\n3. Conecta tu credencial de Google Sheets en «Leer ventas».\n4. Conecta tu credencial de WhatsApp Business en «Enviar parte».\n5. En «Enviar parte», pon tu Phone Number ID en TU_PHONE_NUMBER_ID y tu número de móvil en TU_TELEFONO_DUENO.\n6. Activa el flujo: cada lunes a las 8:00 te llega el parte con todas las ventas de la hoja.",
    "height": 340,
    "width": 420
   },
   "position": [
    0,
    40
   ],
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1
  },
  {
   "id": "a0080000-0000-4000-8000-000000000003",
   "name": "Cada lunes 08:00",
   "parameters": {
    "rule": {
     "interval": [
      {
       "field": "cronExpression",
       "expression": "0 8 * * 1"
      }
     ]
    }
   },
   "position": [
    480,
    300
   ],
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1
  },
  {
   "id": "a0080000-0000-4000-8000-000000000004",
   "name": "Leer ventas",
   "parameters": {
    "documentId": {
     "__rl": true,
     "mode": "id",
     "value": "TU_ID_DE_HOJA"
    },
    "operation": "read",
    "sheetName": {
     "__rl": true,
     "mode": "name",
     "value": "Ventas"
    }
   },
   "position": [
    720,
    300
   ],
   "type": "n8n-nodes-base.googleSheets",
   "typeVersion": 4,
   "credentials": {
    "googleSheetsOAuth2Api": {
     "id": "",
     "name": "TU_CREDENCIAL_GOOGLE_SHEETS"
    }
   }
  },
  {
   "id": "a0080000-0000-4000-8000-000000000005",
   "name": "Juntar ventas",
   "parameters": {
    "aggregate": "aggregateAllItemData",
    "destinationFieldName": "ventas",
    "include": "allFields",
    "options": {}
   },
   "position": [
    960,
    300
   ],
   "type": "n8n-nodes-base.aggregate",
   "typeVersion": 1
  },
  {
   "id": "a0080000-0000-4000-8000-000000000006",
   "name": "Componer parte",
   "parameters": {
    "jsCode": "const ventas = $input.first().json.ventas || [];\nconst lineas = ventas.map(v => `• ${v.fecha} — ${v.concepto}: ${Number(v.importe) || 0} €`);\nconst total = ventas.reduce((s, v) => s + (Number(v.importe) || 0), 0);\nconst texto = `Parte semanal de ventas — Mendera Systems\\n${lineas.join('\\n')}\\nTotal: ${total} €`;\nreturn [{ json: { texto, total, numVentas: ventas.length } }];"
   },
   "position": [
    1200,
    300
   ],
   "type": "n8n-nodes-base.code",
   "typeVersion": 2
  },
  {
   "id": "a0080000-0000-4000-8000-000000000007",
   "name": "Enviar parte",
   "parameters": {
    "additionalFields": {},
    "operation": "send",
    "phoneNumberId": "TU_PHONE_NUMBER_ID",
    "recipientPhoneNumber": "TU_TELEFONO_DUENO",
    "textBody": "={{ $json.texto }}"
   },
   "position": [
    1440,
    300
   ],
   "type": "n8n-nodes-base.whatsApp",
   "typeVersion": 1,
   "credentials": {
    "whatsAppApi": {
     "id": "",
     "name": "TU_CREDENCIAL_WHATSAPP"
    }
   }
  }
 ],
 "connections": {
  "Cada lunes 08:00": {
   "main": [
    [
     {
      "node": "Leer ventas",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Leer ventas": {
   "main": [
    [
     {
      "node": "Juntar ventas",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Juntar ventas": {
   "main": [
    [
     {
      "node": "Componer parte",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Componer parte": {
   "main": [
    [
     {
      "node": "Enviar parte",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "active": false,
 "settings": {
  "executionOrder": "v1"
 },
 "pinData": {}
}
