Skip to content

Daily Sales Data Collection

This workflow collects daily business data from users and stores it in a PostgreSQL database for profit tracking and business analysis. It captures sales figures, various cost categories, and micro-actions, then calculates basic profit metrics before storing the complete record.

Purpose

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

This workflow appears to be part of a business coaching or entrepreneurship program that helps users track their daily business performance. It collects essential financial data including sales revenue and various cost categories, enabling users to monitor their business profitability on a daily basis.

How It Works

  1. Data Reception: The workflow receives daily business data from another workflow, including date, phone number, sales amount, and three cost categories (stocking, transport, and other costs), plus micro-actions taken
  2. Database Storage: All received data is inserted into the dailyProfitTracking table in PostgreSQL, with additional fields initialized to zero for future calculations
  3. Profit Calculation: A basic profit calculation is performed (sales minus all costs) and added to the data flow
  4. Completion: The workflow completes with the enriched data available for further processing

Workflow Diagram

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

    A --> |"date, phoneNumber, sales,<br/>stockingCost, transportCost,<br/>otherCost, Micro actions"| B
    B --> |"Database record created"| C
    C --> |"Profit calculated"| D[End]

Trigger

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

  • date (string): Date of business activity
  • phoneNumber (string): User's phone number identifier
  • sales (number): Total sales amount for the day
  • stockingCost (number): Cost of inventory/stock for the day
  • transportCost (number): Transportation expenses
  • otherCost (number): Miscellaneous business costs
  • Micro actions (string): Description of small actions taken

Nodes Used

Node Type Node Name Purpose
Execute Workflow Trigger When Executed by Another Workflow Receives input data from calling workflow
PostgreSQL Insert rows in a table Stores daily business data in database
Set Edit Fields Calculates profit from sales and costs

External Services & Credentials Required

PostgreSQL Database

  • Credential Name: PostgresOnSupabase
  • Purpose: Stores daily profit tracking data
  • Required Access: Read/write access to dailyProfitTracking table in public schema

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) - totalDailyCosts (number) - creditRecoveredToday (number) - creditGivenToday (number) - durableCostDeducted (number) - dailyFixedCost (number) - profit (number) - isPractice (boolean)

Environment Variables

No environment variables are used in this workflow.

Data Flow

Input Data

1
2
3
4
5
6
7
8
9
{
  "date": "2026-03-11",
  "phoneNumber": "+1234567890",
  "sales": 1500,
  "stockingCost": 800,
  "transportCost": 100,
  "otherCost": 50,
  "Micro actions": "Called 5 new customers, updated inventory"
}

Output Data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
  "phoneNumber": "+1234567890",
  "dateOfBusiness": "2026-03-11",
  "sales": 1500,
  "stockingCost": 800,
  "transportCost": 100,
  "otherCost": 50,
  "microActions": "Called 5 new customers, updated inventory",
  "profit": 550,
  "totalDailyCosts": 0,
  "creditRecoveredToday": 0,
  "creditGivenToday": 0,
  "durableCostDeducted": 0,
  "dailyFixedCost": 0
}

Error Handling

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

  • Database connection issues
  • Invalid input data types
  • Missing required fields
  • Database constraint violations (e.g., duplicate entries)

Consider adding error handling nodes for production use.

Known Limitations

  • No validation of input data ranges or business rules
  • Basic profit calculation doesn't account for all cost categories stored in the database
  • No duplicate entry prevention based on phone number and date combination
  • Missing error handling for database operations

This workflow is designed to be called by other workflows that collect user input, likely through forms, chatbots, or mobile applications.

Setup Instructions

  1. Import the Workflow

    • Copy the workflow JSON
    • Import into your n8n instance
  2. Configure Database Connection

    • Set up PostgreSQL credentials named "PostgresOnSupabase"
    • Ensure connection to database with dailyProfitTracking table
  3. Create Database Table

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    CREATE TABLE public.dailyProfitTracking (
      id SERIAL PRIMARY KEY,
      created_at TIMESTAMP DEFAULT NOW(),
      phoneNumber VARCHAR(20),
      dateOfBusiness DATE,
      sales DECIMAL(10,2),
      stockingCost DECIMAL(10,2),
      transportCost DECIMAL(10,2),
      otherCost DECIMAL(10,2),
      microActions TEXT,
      totalDailyCosts DECIMAL(10,2) DEFAULT 0,
      creditRecoveredToday DECIMAL(10,2) DEFAULT 0,
      creditGivenToday DECIMAL(10,2) DEFAULT 0,
      durableCostDeducted DECIMAL(10,2) DEFAULT 0,
      dailyFixedCost DECIMAL(10,2) DEFAULT 0,
      profit DECIMAL(10,2) DEFAULT 0,
      isPractice BOOLEAN DEFAULT FALSE
    );
    

  4. Test the Workflow

    • Create a test workflow that calls this one with sample data
    • Verify data is correctly stored in the database
  5. Activate the Workflow

    • Ensure the workflow is active to receive calls from other workflows