8
n8n 한국어amn8n.com

Outlook을 통해 Square 월간 판매 보고서 자동 발송

고급

이것은Document Extraction, Multimodal AI분야의자동화 워크플로우로, 16개의 노드를 포함합니다.주로 If, Code, SplitOut, HttpRequest, ConvertToFile 등의 노드를 사용하며. Outlook을 통해 Square 월간 판매 보고서 자동 발송

사전 요구사항
  • 대상 API의 인증 정보가 필요할 수 있음
워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "meta": {
    "instanceId": "d6e2f2f655b1125bbcac14a4cac6d2e46c7a150e927f85fc96fdca1a6dc39e0e",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "850021bd-91b4-4a19-9bcc-9727131ac584",
      "name": "Square 매장 위치 가져오기",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1312,
        544
      ],
      "parameters": {
        "url": "https://connect.squareup.com/v2/locations",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "n1GRrdbh899dbLYB",
          "name": "Square Header Auth"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3ffebacb-7d53-4fbe-8ee8-aefa4aad2473",
      "name": "위치 목록으로 변환",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1536,
        544
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "locations",
        "fieldsToInclude": "id"
      },
      "typeVersion": 1
    },
    {
      "id": "c48961b3-deef-495a-bb50-3ba3b9c5c893",
      "name": "판매 실적 없는 매장 제외",
      "type": "n8n-nodes-base.if",
      "position": [
        2032,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "498f5fab-6930-4e89-9fbe-0d67671da8d2",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.orders }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "303aa5f9-6950-4524-b166-7c57e4c3fe5c",
      "name": "Square에서 판매 데이터 가져오기",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1792,
        544
      ],
      "parameters": {
        "url": "https://connect.squareup.com/v2/orders/search",
        "method": "POST",
        "options": {
          "batching": {
            "batch": {}
          }
        },
        "jsonBody": "={\n  \"location_ids\": [\"{{ $json.locations.id }}\"],\n  \"query\": {\n    \"filter\": {\n      \"state_filter\": {\n        \"states\": [\"COMPLETED\"]\n      },\n      \"date_time_filter\": {\n        \"created_at\": {\n          \"start_at\": \"{{ $('Get Dates From Last Month').item.json.date }}T00:00:00-05:00\",\n          \"end_at\": \"{{ $('Get Dates From Last Month').item.json.date }}T23:59:59-05:00\"\n        }\n      }\n    }\n  },\n  \"limit\": 1000,\n  \"return_entries\": false\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "n1GRrdbh899dbLYB",
          "name": "Square Header Auth"
        }
      },
      "executeOnce": false,
      "typeVersion": 4.2
    },
    {
      "id": "b9956b5b-612f-4078-a1c3-3f01da244855",
      "name": "판매 보고서 작성",
      "type": "n8n-nodes-base.code",
      "position": [
        2320,
        544
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Date and Location Metadata\nconst date = $('Get Dates From Last Month').item.json.date;\nconst location_id = $json.orders[0].location_id || null;\nconst location_name = $('Get Square Locations').item.json.locations.find(locations => locations.id === location_id)?.name;\n\n// Our Result Variables\nlet total_money = 0;\nlet total_tax = 0;\nlet total_discount = 0;\nlet total_tip = 0;\nlet total_returns = 0;\nlet cash_rounding = 0;\n\nlet cash_tender = 0;\nlet card_tender = 0;\nlet gift_card_tender = 0;\nlet other_tender = 0;\nlet fees = 0;\n\n// Loop Through Each Order\nfor (const sale of $json.orders) {\n\n    // Add the sales, taxes, discounts and tips\n    total_money += sale.total_money?.amount || 0;\n    total_tax += sale.total_tax_money?.amount || 0;\n    total_discount += -(sale.total_discount_money?.amount || 0);\n    total_tip += sale.total_tip_money?.amount || 0;\n    if (sale.rounding_adjustment) {\n      cash_rounding += sale.rounding_adjustment.amount_money?.amount || 0;\n    }\n\n  \n    if (sale.return_amounts) {\n      // If there are returns, subtract from sales totals and add to return amount total\n      total_money -= sale.return_amounts?.total_money?.amount || 0;\n      total_tax -= sale.return_amounts?.tax_money?.amount || 0;\n      total_discount -= sale.return_amounts?.discount_money?.amount || 0;\n      total_tip -= sale.return_amounts?.tip_money?.amount || 0;\n  \n      total_returns += -(sale.return_amounts?.total_money?.amount || 0);\n      total_returns -= -(sale.return_amounts?.tax_money?.amount || 0);\n      total_returns -= -(sale.return_amounts?.tip_money?.amount || 0);\n      total_returns -= -(sale.return_amounts?.discount_money?.amount || 0);\n  \n      // If an array of refunds is provided\n      for (const refund of sale.refunds || []) {\n        const transaction_id = refund.transaction_id;\n      \n        // Look for the original sale this refund refers to\n        const original_sale = $json.orders.find(original =>\n          original.id && transaction_id && original.id.includes(transaction_id)\n        );\n      \n        if (original_sale) {\n          if (original_sale.rounding_adjustment) {\n            const amount = original_sale.rounding_adjustment.amount_money?.amount || 0;\n            cash_rounding -= amount;\n            total_returns += amount;\n          }\n      \n          if (original_sale.tenders) {\n            for (const tender of original_sale.tenders) {\n              if (tender.id === refund.tender_id) {\n                const amount = refund.amount_money?.amount || 0;\n                if (tender.type === 'CARD') card_tender -= amount;\n                else if (tender.type === 'CASH') cash_tender -= amount;\n                else if (tender.type === 'SQUARE_GIFT_CARD') gift_card_tender -= amount;\n                else other_tender -= amount;\n      \n                if (refund.processing_fee_money && tender.id === refund.tender_id) {\n                  fees -= refund.processing_fee_money.amount || 0;\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  \n    if (sale.tenders) {\n      for (const tender of sale.tenders) {\n        const amount = tender.amount_money?.amount || 0;\n        if (tender.type === 'CARD') card_tender += amount;\n        else if (tender.type === 'CASH') cash_tender += amount;\n        else if (tender.type === 'SQUARE_GIFT_CARD') gift_card_tender += amount;\n        else other_tender += amount;\n  \n        if (tender.processing_fee_money) {\n          fees -= tender.processing_fee_money.amount || 0;\n        }\n      }\n    }\n  \n}\n\n// Final computed values\nconst net_sales = total_money - total_tip - total_tax - cash_rounding;\nconst gross_sales = net_sales - total_discount - total_returns;\nconst net_total = cash_tender + card_tender + gift_card_tender + other_tender + fees;\n\nreturn {\n  json: {\n    date,\n    location_id,\n    location_name,\n    gross_sales: gross_sales / 100.0,\n    total_returns: total_returns / 100.0,\n    total_discount: total_discount / 100.0,\n    net_sales: net_sales / 100.0,\n    total_tax: total_tax / 100.0,\n    total_tip: total_tip / 100.0,\n    cash_rounding: cash_rounding / 100.0,\n    total_payments_collected: total_money / 100.0,\n    cash: cash_tender / 100.0,\n    card: card_tender / 100.0,\n    gift_card: gift_card_tender / 100.0,\n    other: other_tender / 100.0,\n    fees: fees / 100.0,\n    net_total: net_total / 100.0,\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "01d6eb5f-4ec9-4ddb-9a73-410bcf44c1f1",
      "name": "메모1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        352
      ],
      "parameters": {
        "color": 5,
        "height": 420,
        "content": "## Trigger  \n- This workflow runs on the first day of every Month.  \n- Each month, it pulls the previous month's sales data from Square.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "3b116ff4-4bef-4653-99da-9aa768e07d4c",
      "name": "메모2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        352
      ],
      "parameters": {
        "color": 5,
        "width": 460,
        "height": 420,
        "content": "## Get Square Locations and Process Each One Separately  \n- This HTTP node connects to the Square Locations API to fetch all your locations.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b32a6432-7bcd-4e8e-be26-4f3454f36e84",
      "name": "메모3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        352
      ],
      "parameters": {
        "color": 5,
        "height": 420,
        "content": "## Get Sales from Square  \n- This HTTP node retrieves all orders for the given location on the specified date."
      },
      "typeVersion": 1
    },
    {
      "id": "31d64d79-8904-4460-83e5-43f22d5ecb7d",
      "name": "메모4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        352
      ],
      "parameters": {
        "color": 5,
        "height": 420,
        "content": "## Compile a Report for Each Location  \n- This code node calculates totals for each location.  \n- Please ensure the numbers match EXACTLY with the Square Sales Summary Dashboard.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "33c85a0d-eefb-4ae5-b5f3-544aa2a4a6e3",
      "name": "일정 트리거",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        784,
        544
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e5a3755f-ecbb-4afa-ae23-2fdd06e1f4af",
      "name": "메모5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2512,
        352
      ],
      "parameters": {
        "color": 5,
        "height": 420,
        "content": "## Convert the Square Sales Summary into a CSV File \n"
      },
      "typeVersion": 1
    },
    {
      "id": "abc96e29-7cac-462c-83f0-199e7c43a954",
      "name": "판매 요약을 CSV 파일로 변환",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        2576,
        544
      ],
      "parameters": {
        "options": {
          "fileName": "=sales_report_{{ $('Schedule Trigger').item.json.timestamp }}.csv"
        },
        "binaryPropertyName": "sales_report"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ef17143b-adc8-4320-8861-af7f680faf05",
      "name": "메모6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2768,
        352
      ],
      "parameters": {
        "color": 5,
        "height": 420,
        "content": "## Send the Report to the Finance Team / Manager"
      },
      "typeVersion": 1
    },
    {
      "id": "ccdf9712-ee33-4271-9d8f-7872c706446e",
      "name": "지난 달 날짜 계산",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        544
      ],
      "parameters": {
        "jsCode": "const inputDate = new Date($input.first().json.timestamp);\nconst year = inputDate.getFullYear();\nconst month = inputDate.getMonth();\n\n// Get first day of previous month\nconst firstDay = new Date(year, month - 1, 1);\n\n// Get last day of previous month by setting date to 0 of current month\nconst lastDay = new Date(year, month, 0).getDate();\n\nconst output = [];\n\nfor (let day = 1; day <= lastDay; day++) {\n  const date = new Date(year, month - 1, day);\n  const formatted = date.toISOString().split('T')[0];\n  output.push({ json: { date: formatted } });\n}\n\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f635bdce-e732-405c-ace1-718d13d49885",
      "name": "보고서 발송",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        2832,
        544
      ],
      "webhookId": "9b21e092-ebd1-4969-b1eb-a78603ae521d",
      "parameters": {
        "subject": "Your Last Month's Square Sales Report",
        "bodyContent": "<p>Hello User,</p><p>Please see the attached report containing last month's sales!</p><p>Best,<br> An Efficient Person</p>",
        "toRecipients": "user@example.com",
        "additionalFields": {
          "attachments": {
            "attachments": [
              {
                "binaryPropertyName": "sales_report"
              }
            ]
          },
          "bodyContentType": "html"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9a94d6da-1d97-4d24-8db2-196f65087f05",
      "name": "메모",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -32
      ],
      "parameters": {
        "width": 736,
        "height": 1440,
        "content": "## Automatically Send Monthly Sales Reports from Square via Outlook\n\n## What It Does  \nThis workflow automatically connects to the Square API and generates a **monthly** sales summary report for all your Square locations. The report matches the figures displayed in **Square Dashboard > Reports > Sales Summary**.\n\nIt's designed to run monthly and pull the **previous month’s** sales into a CSV file, which is then sent to a manager/finance team for analysis.\n\nThis workflow builds on my previous template, which allows users to automatically pull data from the Square API into n8n for processing. (See here: https://n8n.io/workflows/6358)\n\n## Prerequisites  \nTo use this workflow, you'll need:\n- A Square API credential (configured as a Header Auth credential)\n- A Microsoft Outlook credential\n\n## How to Set Up Square Credentials:  \n- Go to **Credentials > Create New**  \n- Choose **Header Auth**  \n- Set the **Name** to `Authorization`  \n- Set the **Value** to your Square Access Token (e.g., `Bearer <your-api-key>`)\n\n## How It Works  \n1. **Trigger:** The workflow runs on the **1st of every month at 8:00 AM**  \n2. **Fetch Locations:** An HTTP request retrieves all Square locations linked to your account  \n3. **Fetch Orders:** For each location, an HTTP request pulls completed orders for the **previous calendar month**  \n4. **Filter Empty Locations:** Locations with no sales are ignored  \n5. **Aggregate Sales Data:** A Code node processes the order data and produces a summary identical to Square’s built-in Sales Summary report  \n6. **Create CSV File:** A CSV file is created containing the relevant data  \n7. **Send Email:** An email is sent using Microsoft Outlook to the chosen third party  \n\n## Example Use Cases  \n- Automatically send monthly Square sales data to management for forecasting and planning  \n- Automatically send data to an external third party, such as a landlord or agent, who is paid via commission  \n- Automatically send data to a bookkeeper for entry into QuickBooks  \n\n## How to Use  \n- Configure both HTTP Request nodes to use your Square API credential  \n- Set the workflow to **Active** so it runs automatically  \n- Enter the email address of the person you want to send the report to and update the message body  \n- If you want to remove the n8n attribution, you can do so in the last node  \n\n## Customization Options  \n- Add pagination to handle locations with more than 1,000 orders per month\n- Adjust the date filters in the HTTP node to cover the full calendar month (e.g., use Luxon or JavaScript to calculate `start_date` and `end_date`)\n\n## Why It's Useful  \nThis workflow saves time, reduces manual report pulling from Square, and enables smarter automation around sales data — whether for operations, finance, or performance monitoring.\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "f635bdce-e732-405c-ace1-718d13d49885": {
      "main": [
        []
      ]
    },
    "33c85a0d-eefb-4ae5-b5f3-544aa2a4a6e3": {
      "main": [
        [
          {
            "node": "ccdf9712-ee33-4271-9d8f-7872c706446e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "850021bd-91b4-4a19-9bcc-9727131ac584": {
      "main": [
        [
          {
            "node": "3ffebacb-7d53-4fbe-8ee8-aefa4aad2473",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b9956b5b-612f-4078-a1c3-3f01da244855": {
      "main": [
        [
          {
            "node": "abc96e29-7cac-462c-83f0-199e7c43a954",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "303aa5f9-6950-4524-b166-7c57e4c3fe5c": {
      "main": [
        [
          {
            "node": "c48961b3-deef-495a-bb50-3ba3b9c5c893",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3ffebacb-7d53-4fbe-8ee8-aefa4aad2473": {
      "main": [
        [
          {
            "node": "303aa5f9-6950-4524-b166-7c57e4c3fe5c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ccdf9712-ee33-4271-9d8f-7872c706446e": {
      "main": [
        [
          {
            "node": "850021bd-91b4-4a19-9bcc-9727131ac584",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c48961b3-deef-495a-bb50-3ba3b9c5c893": {
      "main": [
        [
          {
            "node": "b9956b5b-612f-4078-a1c3-3f01da244855",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "abc96e29-7cac-462c-83f0-199e7c43a954": {
      "main": [
        [
          {
            "node": "f635bdce-e732-405c-ace1-718d13d49885",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

고급 - 문서 추출, 멀티모달 AI

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
고급
노드 수16
카테고리2
노드 유형8
난이도 설명

고급 사용자를 위한 16+개 노드의 복잡한 워크플로우

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34