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¶
- Data Reception: The workflow receives daily business data including sales figures, costs, and operational notes from another workflow
- Database Storage: All input data is inserted into the
dailyProfitTrackingtable in PostgreSQL - Profit Calculation: After storage, the workflow calculates profit by subtracting all costs from sales revenue
- 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 datephoneNumber(string): Entrepreneur's phone numbersales(number): Total sales amountstockingCost(number): Cost of inventory/stocktransportCost(number): Transportation expensesotherCost(number): Other miscellaneous costsMicro actions(string): Notes about small business actions takenisPractice?(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
dailyProfitTrackingtable - 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 | |
Output Data¶
The workflow outputs the original data plus a calculated profit field:
1 2 3 4 5 6 7 8 9 10 11 | |
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
Related Workflows¶
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¶
-
Import the Workflow
- Copy the workflow JSON
- Import into your n8n instance
-
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
-
Verify Database Schema
- Ensure the
dailyProfitTrackingtable exists in your database - Verify all required columns are present with correct data types
- Ensure the
-
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
-
Integration
- Configure other workflows to call this workflow using the Execute Workflow node
- Ensure calling workflows pass all required parameters in the correct format
-
Activate
- Activate the workflow to make it available for execution by other workflows