Skip to content

Daily Sales Data Collection Workflow

This workflow collects daily business performance data from entrepreneurs and stores it in a PostgreSQL database for profit tracking and business analysis. It captures sales figures, various cost categories, and micro-actions while calculating basic profit metrics.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Data Reception: The workflow receives daily business data including sales figures, costs, and operational notes from another workflow
  2. Database Storage: All input data is inserted into the dailyProfitTracking table in PostgreSQL
  3. Profit Calculation: After storage, the workflow calculates profit by subtracting all costs from sales revenue
  4. Data Enhancement: The calculated profit is added to the data flow for potential use by downstream processes

Workflow Diagram

graph TD
    A[When Executed by Another Workflow] --> B[Insert rows in a table]
    B --> C[Edit Fields - Calculate Profit]

Trigger

Execute Workflow Trigger: This workflow is designed to be called by other workflows, not triggered directly. It expects the following input parameters:

  • date (string): Business date
  • phoneNumber (string): Entrepreneur's phone number
  • sales (number): Total sales amount
  • stockingCost (number): Cost of inventory/stock
  • transportCost (number): Transportation expenses
  • otherCost (number): Other miscellaneous costs
  • Micro actions (string): Notes about small business actions taken
  • isPractice? (boolean): Whether this is practice data or real business data

Nodes Used

Node Type Node Name Purpose
Execute Workflow Trigger When Executed by Another Workflow Receives input data from calling workflows
PostgreSQL Insert rows in a table Stores business data in the dailyProfitTracking database table
Edit Fields Edit Fields Calculates profit by subtracting costs from sales

External Services & Credentials Required

PostgreSQL Database

  • Credential Name: PostgresOnSupabase
  • Purpose: Stores daily business tracking data
  • Required Access: Read/Write permissions on the dailyProfitTracking table
  • Connection Details: Supabase-hosted PostgreSQL instance

Database Schema

The workflow expects a dailyProfitTracking table with these columns: - phoneNumber (string) - dateOfBusiness (datetime) - sales (number) - stockingCost (number) - transportCost (number) - otherCost (number) - microActions (string) - isPractice (boolean)

Environment Variables

No environment variables are used in this workflow. All configuration is handled through n8n credentials and node parameters.

Data Flow

Input Data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "date": "2026-03-16",
  "phoneNumber": "+254115558547",
  "sales": 1800,
  "stockingCost": 420,
  "transportCost": 0,
  "otherCost": 100,
  "Micro actions": "",
  "isPractice?": true
}

Output Data

The workflow outputs the original data plus a calculated profit field:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "date": "2026-03-16",
  "phoneNumber": "+254115558547",
  "sales": 1800,
  "stockingCost": 420,
  "transportCost": 0,
  "otherCost": 100,
  "Micro actions": "",
  "isPractice?": true,
  "profit": 1280
}

Profit Calculation

profit = sales - stockingCost - transportCost - otherCost

Error Handling

This workflow does not implement explicit error handling. Potential failure points include:

  • Database connection issues
  • Invalid input data types
  • Missing required database table or columns
  • Network connectivity problems with Supabase

If errors occur, the workflow will fail and stop execution. Consider adding error handling nodes for production use.

Known Limitations

  • No data validation on input parameters
  • No duplicate record checking (could insert the same data multiple times)
  • No error handling or retry logic
  • Profit calculation is basic and doesn't account for more complex business metrics
  • No data transformation or cleaning before database insertion

This workflow is designed to be called by other workflows that collect business data from entrepreneurs, likely through forms, chatbots, or mobile applications.

Setup Instructions

  1. Import the Workflow

    • Copy the workflow JSON
    • Import into your n8n instance
  2. Configure PostgreSQL Credentials

    • Create a new PostgreSQL credential named "PostgresOnSupabase"
    • Configure connection to your Supabase PostgreSQL instance
    • Ensure the credential has read/write access to the target database
  3. Verify Database Schema

    • Ensure the dailyProfitTracking table exists in your database
    • Verify all required columns are present with correct data types
  4. Test the Workflow

    • Use the pinned test data to verify the workflow functions correctly
    • Check that data is properly inserted into the database
    • Verify profit calculation is working as expected
  5. Integration

    • Configure other workflows to call this workflow using the Execute Workflow node
    • Ensure calling workflows pass all required parameters in the correct format
  6. Activate

    • Activate the workflow to make it available for execution by other workflows