{
  "name": "Docket — 03 · Rappel d'échéance (5 jours avant)",
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": false,
      "dataloss": false,
      "dlq": true,
      "freshVariables": false,
      "scheduling": { "type": "cron", "cron": "0 8 * * *" }
    },
    "designer": { "orphans": [] },
    "zone": "eu1.make.com"
  },
  "flow": [
    {
      "id": 1,
      "module": "airtable:ActionSearchRecords",
      "version": 3,
      "parameters": { "base": "{{env.AIRTABLE_BASE_ID}}", "table": "Documents" },
      "mapper": {
        "formula": "AND({Status} = 'approved', {DueDate} = DATEADD(TODAY(), 5, 'days'))"
      },
      "metadata": { "designer": { "x": 0, "y": 0 } },
      "note": "Chaque matin à 8h00 : factures approuvées dont l'échéance tombe dans exactement 5 jours."
    },
    {
      "id": 2,
      "module": "google-email:ActionSendEmail",
      "version": 3,
      "parameters": { "connection": "{{google.compte_cabinet}}" },
      "mapper": {
        "to": "{{env.EMAIL_GESTIONNAIRE}}",
        "subject": "Échéance J-5 : {{1.Vendor}} — {{1.TotalTTC}} €",
        "content": "La facture {{1.InvoiceNumber}} de {{1.Vendor}} ({{1.TotalTTC}} €) arrive à échéance le {{1.DueDate}}.\n\nFichier archivé : {{1.DriveLink}}\nÉcriture Pennylane : {{1.PennylaneId}}"
      },
      "metadata": { "designer": { "x": 240, "y": 0 } },
      "note": "Rappel au gestionnaire — jamais de paiement automatique, uniquement une alerte."
    }
  ]
}
