Skip to content

cprichard92/vneInventoryManagement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VNE Inventory Reporting (Wix)

Overview (ELI5)

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.

How this maps to Wix

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.

Why this design

  • 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.js once instead of hunting through code.

Step-by-step setup (newbie friendly)

Where does this run?

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).

Step 1: Decide where your inventory data lives

Pick one:

  • Wix Data (recommended if you already store inventory in Wix).
  • External API (use REPORT_CONFIG.apiBaseUrl).

Step 2: Set your config values

Open src/reportConfig.js and update:

  1. reportEnabledtrue to send, false to stop sending.
  2. timeZone → your timezone (or keep UTC).
  3. apiBaseUrl → your external API base URL (only if not using Wix Data).

Step 3: Set your email list

Add default recipients in DEFAULT_RECIPIENTS and add any new recipients using the buildRecipientList helper.

Step 4: Add your Wix Scheduled Job

Create a Scheduled Job in Wix that runs weekly. That job should:

  1. Fetch inventory data from Wix APIs (or your external API).
  2. Convert the data to JSON in the format expected by buildInventoryReport.
  3. Format the email body with formatRepEmail.
  4. Send a Wix Triggered Email to each rep.
  5. Exit early if reportEnabled is false.

Step 4a: Where to put the Wix code (exact file locations)

In the Wix editor (Velo):

  1. Open Backend in the left sidebar.
  2. Create a file under BackendreportRunner.jsw (shared backend module).
  3. Create a file under BackendJobsweeklyReport.js.

Your backend module (reportRunner.jsw) holds the reusable logic:

  • Fetch inventory data from Wix APIs.
  • Call buildInventoryReport and formatRepEmail.
  • 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.

Step 5: Test locally (optional but recommended)

npm test

If you don’t see the changes

  1. Pull the latest commits from the repo (or refresh your GitHub view).
  2. Confirm README.md was updated in the most recent commit.
  3. If you still don’t see the updates, re-open this file locally and verify the “Step-by-step setup” section exists.

Getting started

Prerequisites

  • Node.js 18+

Install

No dependencies are required beyond Node.js.

Configuration

  • 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.reportEnabled to disable sending without code edits.
  • Recipients: store default recipients in DEFAULT_RECIPIENTS and extend using buildRecipientList.
  • API base URL: configure REPORT_CONFIG.apiBaseUrl if you are pulling inventory from an external API.

Troubleshooting

  • If tests fail with a Node version error, upgrade to Node 18+.
  • If report dates look off, verify asOfDate and ensure UTC is used consistently.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors