AstroBaaS

Operations & platform

Scheduled sales execution on schedule

Free — GPL coresize Splanned, not built

Generated from docs/plan/core/scheduled-sales-execution-on-schedule/PLAN.md in the AstroBaaS repository. Nothing described below is implemented — it is the written plan for it.

Scheduled product discounts and sales stay at old prices until manually saved. This feature ensures that scheduled prices execute automatically at the scheduled time without manual intervention.

The problem

I schedule a Black Friday sale for tomorrow morning, but the discount doesn’t apply until someone manually saves the product. I need prices to change automatically when the schedule says.

What it does

  • Schedule entity: product_id, field (price / discount / visibility), value, scheduled_time, executed_at (null until run)
  • Execution: scheduled tasks (built-in scheduler) evaluates due schedules once per minute, applies changes, marks executed_at
  • Rollback: schedule can optionally include ‘undo’ value for time-limited sales (apply price at time A, revert to old price at time B)
  • Admin UI: product editor, ‘Schedules’ tab showing future schedules, create new schedule, edit/delete pending schedules
  • API endpoints: list product schedules, create schedule, delete schedule (if not yet executed)

What it deliberately does NOT do

Each boundary carries its reason. A boundary without a reason gets crossed by the next person who reads this.

  • Dependent schedules (schedule A triggers schedule B) — single-level scheduling only
  • Complex conditions (apply discount only if stock > 10) — time-only, no conditions
  • Scheduled visibility changes (show product only on certain dates) — this is a UI feature, lower priority

Data model

New entity: ProductSchedule {id, product_id, field_name, new_value, old_value (for rollback), scheduled_at, executed_at (nullable), rollback_at (nullable), rollback_value (nullable), created_at}.

API

  • GET /api/products/:id/schedules — list all schedules for product
  • POST /api/products/:id/schedules — create schedule
  • DELETE /api/products/:id/schedules/:schedule_id — delete pending schedule

Every route added here must also appear in src/pages/openapi.json.ts — a test fails the build if it does not.

Admin

Product editor, Schedules tab: table of future price/discount changes with time. Create Schedule button: date/time picker, field selector (price/discount), new value, optional rollback time/value. Edit: only if not yet executed.

The seam — why this is core

Core owns the schedule model, execution logic, and API. All scheduling is within core — no third-party tool.

Scheduled operations are table-stakes. Broken scheduler is a data-integrity issue.

Dependencies

  • Scheduler (core must have a way to run jobs periodically)
  • Product entity and price field (already shipped)

Acceptance checks

Each of these must be able to fail. Before claiming this is done, break the code deliberately and watch each one go red.

  • A schedule can be created: product, new price €50, execute 2026-11-29 06:00 UTC
  • At the scheduled time, the product price is updated to €50 automatically
  • scheduled_at timestamp is recorded; executed_at is set after execution
  • A schedule with rollback can be created: price €50 at time A, revert to €100 at time B
  • At time A, price becomes €50; at time B, it reverts to €100; both executed_at timestamps are recorded
  • A schedule can be deleted before it is executed; after execution, it is immutable (for audit trail)

Risks

Execution timing must be exact; if scheduler misses a slot (downtime), schedule must catch up when scheduler restarts. Overlapping schedules on the same field could conflict (schedule says €50, another says €75 for the same time); last-write-wins or reject conflicting schedules. Reverting price must use the old_value field, not re-fetch from product (product may have been edited since schedule was created).

Commercial context

Suggested priceCore
Rival anchorMagento Open Source: automatic scheduled execution.

The anchor is what the nearest equivalent charges on Shopify or Magento today. It is context for a pricing decision, not the decision.


Generated from the commerce plan. See docs/COMMERCE-PLAN.md for the full catalogue and ../../AI-GUIDE.md for how to work on this repository.