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¶
- 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
- Database Storage: All received data is inserted into the
dailyProfitTrackingtable in PostgreSQL, with additional fields initialized to zero for future calculations - Profit Calculation: A basic profit calculation is performed (sales minus all costs) and added to the data flow
- 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 activityphoneNumber(string): User's phone number identifiersales(number): Total sales amount for the daystockingCost(number): Cost of inventory/stock for the daytransportCost(number): Transportation expensesotherCost(number): Miscellaneous business costsMicro 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
dailyProfitTrackingtable inpublicschema
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 | |
Output Data¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
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
Related Workflows¶
This workflow is designed to be called by other workflows that collect user input, likely through forms, chatbots, or mobile applications.
Setup Instructions¶
-
Import the Workflow
- Copy the workflow JSON
- Import into your n8n instance
-
Configure Database Connection
- Set up PostgreSQL credentials named "PostgresOnSupabase"
- Ensure connection to database with
dailyProfitTrackingtable
-
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 ); -
Test the Workflow
- Create a test workflow that calls this one with sample data
- Verify data is correctly stored in the database
-
Activate the Workflow
- Ensure the workflow is active to receive calls from other workflows