Frappoint

Frappoint

Sample Data Internals

The sample data feature (frappoint/sample_data/) builds a working spa and hotel for demos and testing, and removes them exactly. This page explains how it works, for developers changing it. For using it, see Try it with sample data.

Modules

Module What it does
api.py Whitelisted generate(scope), remove() and get_status(). Only System Managers can generate or remove. Both run as background jobs on the long queue, with a three-hour timeout, and publish progress over realtime.
company.py Creates Frappoint Sample Company (abbreviation FSC) through ERPNext, with fiscal years around today.
services.py Four treatments with their Items and prices, three rooms, three therapists on a shift, four customers, and a week of bookings made through the Booking Desk's own API functions.
hotel.py Sample Lakeside Hotel (code SAMPLE): 20 rooms in three room types, charge codes, tax, a rate plan with a season, policies, house accounts and 40 guest profiles. Then simulate() lives through 14 days at about 70% occupancy, and front_office() sets up today's work.
clock.py Moves the property's business date while simulating history.
tracker.py Logs every document inserted while generating.
removal.py Deletes what the sample made.

State lives in the single DocType Sample Data (status, scope, company, property, message). The status is Generating, Ready, Removing or Failed.

Deterministic

The hotel is generated with a fixed random seed, so the same site always gets the same guests, stays and history. Bookings, check-ins, charges, payments and night audits all go through the same service functions the desk uses, so every count and ledger entry agrees.

Tracking and removal

While generation runs, tracker.recording() is active and the * → after_insert doc event (tracker.record) logs each new document as a Sample Data Record. Outside generation the hook does nothing.

Removal:

  1. deletes the sample company's transactions with ERPNext's Transaction Deletion Record;
  2. deletes the hotel's records that carry the sample property but no company;
  3. deletes the logged documents in reverse order, keeping any master that another, non-sample record now uses (they are reported as kept);
  4. deletes the company, its chart of accounts, cost centres and warehouses;
  5. clears the sample's search index entries and its availability counters.

Known issue

services.book_week() creates bookings through booking_desk.create_draft_service_booking, which takes the company from the running user's default company (or Global Defaults), not the sample company. On a site with a default company, the spa sample's bookings, appointments and payments are recorded in that company. They are still logged, so removal deletes them, but the sample should pass its own company explicitly.

Last updated 5 days ago
Was this helpful?
Thanks!