{
  "name": "Automated Petroleum Billing (Local Files + PDFco + Gemini)",
  "nodes": [
    {
      "parameters": {
        "filePath": "/Users/neeraj.g4/Desktop/NeerajWorkspace/docker/data/finance_usecase/Customer_PO_data_for_SO_creation.xlsx"
      },
      "name": "ReadSOExcel",
      "type": "n8n-nodes-base.readBinaryFile",
      "typeVersion": 1,
      "position": [
        -600,
        150
      ]
    },
    {
      "parameters": {
        "sheetName": "SalesOrders"
      },
      "name": "ParseSOExcel",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 1,
      "position": [
        -400,
        150
      ]
    },
    {
      "parameters": {
        "filePath": "/Users/neeraj.g4/Desktop/NeerajWorkspace/docker/data/finance_usecase/Signed Purchase Order 4510888536.PDF"
      },
      "name": "ReadPDFFile",
      "type": "n8n-nodes-base.readBinaryFile",
      "typeVersion": 1,
      "position": [
        -600,
        0
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "headerAuth": {
          "name": "x-api-key",
          "value": "guptneer09@gmail.com_Er1yw6qEmaDJCbL1GMqDK5R2nbW1kFS9QSXoWX5HRO0YPYL7eWHjewtX64h1ByBP"
        },
        "url": "https://app.pdf.co/",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": "{}",
        "options": {},
        "binaryData": [
          {
            "propertyName": "file",
            "binaryPropertyName": "data"
          }
        ]
      },
      "name": "PDFco Convert to Text",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -400,
        0
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent",
        "authentication": "headerAuth",
        "jsonParameters": true,
        "bodyParametersJson": "{\"contents\":[{\"parts\":[{\"text\":\"Extract customer, PO number, items, quantity, BOM info, PO date from this text:\\n{{ $json[\\\"body\\\"] }}\"}]}]}",
        "options": {}
      },
      "name": "GeminiPOParser",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -200,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "// This is a placeholder for SO validation logic\n// Ideally compare Gemini output with Excel SO data\nreturn items;"
      },
      "name": "ValidateSO",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        0,
        75
      ]
    },
    {
      "parameters": {
        "functionCode": "// Placeholder for billing request validation\nreturn items;"
      },
      "name": "ValidateBillingRequest",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        200,
        75
      ]
    },
    {
      "parameters": {
        "functionCode": "// Simulate RPA invoice generation in Navision\nreturn items;"
      },
      "name": "NavisionRPABot",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        400,
        75
      ]
    },
    {
      "parameters": {
        "functionCode": "// Simulate IRN wait and invoice signing\nreturn items;"
      },
      "name": "IRNSignAndEmail",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        600,
        75
      ]
    },
    {
      "parameters": {
        "functionCode": "// Update billing tracker dashboard\nreturn items;"
      },
      "name": "UpdateDashboard",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        800,
        75
      ]
    }
  ],
  "connections": {
    "ReadSOExcel": {
      "main": [
        [
          {
            "node": "ParseSOExcel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ParseSOExcel": {
      "main": [
        [
          {
            "node": "ValidateSO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ReadPDFFile": {
      "main": [
        [
          {
            "node": "PDFco Convert to Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDFco Convert to Text": {
      "main": [
        [
          {
            "node": "GeminiPOParser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GeminiPOParser": {
      "main": [
        [
          {
            "node": "ValidateSO",
            "type": "main",
            "index": 0
          },
          {
            "node": "ValidateBillingRequest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ValidateBillingRequest": {
      "main": [
        [
          {
            "node": "NavisionRPABot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NavisionRPABot": {
      "main": [
        [
          {
            "node": "IRNSignAndEmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IRNSignAndEmail": {
      "main": [
        [
          {
            "node": "UpdateDashboard",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}