Think of this as a “robot emailer” that sends your reps a weekly list of what you have in stock. It runs in the background, grabs inventory data, calculates a few totals, and emails each rep. You don’t need to touch your live Wix site pages to make it work.
The goal is to:
- Generate per-rep inventory counts, prices, stock-out dates, last-sold dates, images, and total value/COGS.
- Send those reports via email on a schedule.
- Keep the logic testable outside Wix while integrating with Wix services in production.
You can do this via Wix APIs using Velo:
- Data source: store inventory and rep assignments in Wix Data collections or pull from an external system.
- Report generation: use backend modules or an external service to compute the report.
- Email delivery: use Wix CRM Triggered Emails or an external email provider.
- Scheduling: use Wix Scheduled Jobs (weekly) to trigger report generation and sending.
See docs/wix-inventory-report.md for a detailed plan.
- Security: report logic runs server-side only, keeping inventory and pricing data out of the browser.
- Testability: core calculation code lives in
src/and can be tested with Node's built-in test runner. - Portability: the core logic can be used in Wix Velo or in an external server.
- Centralized config: update API endpoints or toggles in
src/reportConfig.jsonce instead of hunting through code.
It runs on the server inside Wix (Velo backend + Scheduled Jobs). You don’t run it on your laptop. Wix’s scheduler triggers it automatically (weekly, or whatever schedule you choose).
Pick one:
- Wix Data (recommended if you already store inventory in Wix).
- External API (use
REPORT_CONFIG.apiBaseUrl).
Open src/reportConfig.js and update:
reportEnabled→trueto send,falseto stop sending.timeZone→ your timezone (or keepUTC).apiBaseUrl→ your external API base URL (only if not using Wix Data).
Add default recipients in DEFAULT_RECIPIENTS and add any new recipients using
the buildRecipientList helper.
Create a Scheduled Job in Wix that runs weekly. That job should:
- Fetch inventory data from Wix APIs (or your external API).
- Convert the data to JSON in the format expected by
buildInventoryReport. - Format the email body with
formatRepEmail. - Send a Wix Triggered Email to each rep.
- Exit early if
reportEnabledisfalse.
In the Wix editor (Velo):
- Open Backend in the left sidebar.
- Create a file under Backend →
reportRunner.jsw(shared backend module). - Create a file under Backend → Jobs →
weeklyReport.js.
Your backend module (reportRunner.jsw) holds the reusable logic:
- Fetch inventory data from Wix APIs.
- Call
buildInventoryReportandformatRepEmail. - Send Wix Triggered Emails.
Your job file (backend/jobs/weeklyReport.js) runs on a schedule and calls the backend module.
This is what makes the report send automatically each week.
npm test- Pull the latest commits from the repo (or refresh your GitHub view).
- Confirm
README.mdwas updated in the most recent commit. - If you still don’t see the updates, re-open this file locally and verify the “Step-by-step setup” section exists.
- Node.js 18+
No dependencies are required beyond Node.js.
- No secrets in code. Use Wix Secrets Manager or environment variables in external services.
- Input validation is required for all external data sources.
- Kill switch: use
REPORT_CONFIG.reportEnabledto disable sending without code edits. - Recipients: store default recipients in
DEFAULT_RECIPIENTSand extend usingbuildRecipientList. - API base URL: configure
REPORT_CONFIG.apiBaseUrlif you are pulling inventory from an external API.
- If tests fail with a Node version error, upgrade to Node 18+.
- If report dates look off, verify
asOfDateand ensure UTC is used consistently.