How sapphirefountains/erpnext_enhancements works
1. Overall shape
- This is a Frappe/ERPNext custom app. Its architecture is organized around Frappe primitives: DocTypes, Pages, hooks, fixtures, patches, and public JS/CSS overrides.
- Most business logic lives in Python modules under erpnext_enhancements/, while UI behavior is added through desk/page scripts in public/js and per-DocType client scripts.
2. Main functional boundaries
- The codebase is split into feature areas rather than a single monolith:
- project_enhancements
- task_enhancements
- enhancements_core
- quickbooks_time_integration
- sapphire_maintenance
- travel_management
- crm_enhancements
- global_enhancements
- Each area contains its own DocTypes, pages, and support code, which makes it easier to diagram as separate subsystems sharing the same ERPNext backend.
3. ERPNext data model extensions
- The custom DocTypes are the durable state layer. Examples include:
- project and dashboard settings
- User Form Draft
- Time Kiosk Log / Job Interval
- GA4 Settings
- QuickBooks sync records and mappings
- maintenance templates, records, and results
- These DocTypes are the main persistence boundary between user-facing scripts and server-side logic.
4. Project management subsystem
- project_enhancements is one of the core domains. It adds:
- Master Project
- project dashboard settings and permitted roles
- project form/list customizations
- an interactive project_dashboard page
- helper logic for address setup and opportunity-to-project flows
- Client-side scripts in public/js/project_enhancements provide gantt, task tree, and dashboard components, so the browser-side UI is a major part of this subsystem.
5. Task and hierarchical planning
- task_enhancements adds a hierarchical task view and task-specific behavior.
- It includes both a custom page and custom task DocType script, suggesting the UI tree structure is assembled client-side, with Python backing for data retrieval and permissions.
6. Time kiosk workflow
- The time-tracking subsystem centers on enhancements_core/page/time_kiosk and the related Time Kiosk Log / Job Interval records.
- The readme describes the flow: employee uses the kiosk UI to clock in/out, selects project/task context, location is captured, and completed intervals are later consolidated into standard ERPNext timesheets.
- This is a clear ingestion-and-sync pipeline: kiosk page → server APIs → persisted interval/log records → timesheet synchronization.
7. Analytics dashboard
- GA4 Dashboard is implemented as a custom page backed by GA4 Settings.
- The dashboard pulls data from Google Analytics 4 and Google Search Console using a service account and private JSON credentials.
- The architecture is request-driven from the ERPNext page to external Google APIs; the readme explicitly notes multiple concurrent API calls per load and quota constraints, which is an important system boundary.
8. QuickBooks Online integration
- quickbooks_time_integration is a full integration subsystem with its own API layer, client, mapping, sync, webhook, task, and utility modules.
- Its DocTypes (QuickBooks Online Settings, raw payload, sync log, sync mapping) show a standard integration pattern:
- authenticate/configure in a settings record
- ingest or exchange payloads
- map external entities to ERPNext entities
- log sync activity for traceability
- This is likely asynchronous or event-driven in parts, especially given the presence of tasks and webhooks.
9. CRM and Google Drive linkage
- crm_enhancements contains Google Drive-related settings and utilities, indicating external document storage or folder management tied to CRM/project data.
- The subsystem sits at the boundary between ERPNext records and Google Drive APIs, with settings stored in a DocType and operational logic in drive_utils.py and API wrappers.
10. Global UX and behavior overrides
- global_enhancements and many files under public/js/public/css alter ERPNext behavior globally rather than in one domain.
- Examples include navigation guards, unified tab handling, mention behavior, sidebar changes, delete/unlink helpers, and UI styling fixes.
- These are cross-cutting browser-side patches that affect the whole ERPNext desk experience.
11. Fixtures, hooks, and patches
- fixtures/ contains exported ERPNext metadata such as custom fields, notifications, print formats, workflows, and workflow actions.
- patches/ contains migration scripts for schema/data changes, renames, reorderings, and cleanup; this is the repository’s upgrade path.
- hooks.py is the integration point where the app registers its overrides, asset bundles, fixtures, and lifecycle behavior.
12. Maintenance, travel, and other domain modules
- Several smaller but still self-contained modules exist:
- sapphire_maintenance for maintenance records/templates/results
- travel_management for trips, flights, accommodation, agenda, and POIs
- enhancements_core for settings, notes, reminders, kiosk logs, GA4/triton settings
- These appear as vertical slices: data model + server logic + optional client script/page.
13. Testing and verification
- The repository includes Python tests under erpnext_enhancements/tests and feature-local tests beside specific doctypes/pages.
- There are also utility scripts at the repo root for search, kiosk syncing, and verification, indicating the team validates both backend behavior and the kiosk/integration flows outside the main app surface.
14. Architecture summary for diagramming
- A good diagram would show ERPNext/Frappe at the center, with:
- server-side app modules handling business rules and integrations
- DocTypes as persistent configuration/state
- Pages and public JS/CSS as the interactive UI layer
- external services on the edges: Google APIs, QuickBooks Online, Google Drive, and any telephony/AI integrations implied by the API modules
- patches/fixtures/hooks as the deployment and customization backbone
Main entry points: js Public JS/CSS · hooks.py Hooks · project_enhancements Project enhancements · api Core APIs
Components 19
Frappe app core
App wiring, shared APIs, fixtures, patches, and cross-cutting desk behavior.
- Hooks · Registers app-level overrides, assets, fixtures, and lifecycle integration.
erpnext_enhancements/hooks.py - Fixtures · Custom fields, workflows, notifications, print formats, and property setters.
erpnext_enhancements/fixtures - Patches · Upgrade scripts for schema changes, renames, cleanup, and data reordering.
erpnext_enhancements/patches - Core APIs · Common backend endpoints for analytics, search, kiosk, drafts, comments, telephony, and workspace helpers.
erpnext_enhancements/api
Project planning
Project and task management extensions, including dashboards and hierarchical views.
- Project enhancements · Project-specific server logic, DocTypes, and helper flows around dashboards and setup.
erpnext_enhancements/project_enhancements - Project dashboard · Interactive project dashboard page backed by server-side data and client widgets.
erpnext_enhancements/project_enhancements/page/project_dashboard/project_dashboard.js - Project DocTypes · Master project, dashboard settings, permitted roles, and project customizations.
erpnext_enhancements/project_enhancements/doctype - Task enhancements · Hierarchical task view and task-specific behavior for planning workflows.
erpnext_enhancements/task_enhancements - Task tree · Custom hierarchical task view page and supporting client script.
erpnext_enhancements/task_enhancements/page/hierarchical_task_view/hierarchical_task_view.js
External integrations
Google, QuickBooks, telephony, and sync-oriented boundaries.
- QuickBooks sync · QuickBooks Online client, sync, mapping, webhook, and task modules.
erpnext_enhancements/quickbooks_time_integration - QB DocTypes · Settings, raw payload, sync log, and entity mapping records.
erpnext_enhancements/quickbooks_time_integration/doctype - GA4 dashboard · Desk page for Google Analytics 4 and Search Console reporting.
erpnext_enhancements/enhancements_core/page/ga4_dashboard/ga4_dashboard.js - Time kiosk · Clock-in/clock-out kiosk page and interval consolidation flow.
erpnext_enhancements/enhancements_core/page/time_kiosk/time_kiosk.js - Time records · Time Kiosk Log, Job Interval, and related settings/state records.
erpnext_enhancements/enhancements_core/doctype/time_kiosk_log/time_kiosk_log.json
Operational domains
Standalone business modules for maintenance, travel, and CRM support.
- CRM Drive · Google Drive settings and helpers for CRM/project document linkage.
erpnext_enhancements/crm_enhancements - Maintenance · Templates, records, consumables, visits, and results for maintenance workflows.
erpnext_enhancements/sapphire_maintenance - Travel mgmt · Trips and related itinerary entities such as flights, accommodation, agenda, and POIs.
erpnext_enhancements/travel_management
Browser overrides
Shared public JS/CSS and client scripts that reshape the ERPNext desk experience.
- Global overrides · Global desk behavior patches, widgets, and styling shared across ERPNext.
erpnext_enhancements/global_enhancements - Public JS/CSS · Desk-wide browser scripts and styles, including project, task, and integration UI behavior.
erpnext_enhancements/public/js
Connections 20
- Hooks → Fixtures: loads · Registers exported metadata used during installation and updates.
- Hooks → Patches: applies · Runs migration scripts as part of app upgrades.
- Hooks → Public JS/CSS: bundles · Serves public JavaScript and CSS overrides into the desk.
- Hooks → Global overrides: enables · Activates global behavior changes across ERPNext.
- Core APIs → Time kiosk: supports · Provides shared endpoints used by kiosk flows and related status checks.
- Core APIs → GA4 dashboard: supports · Supplies shared API helpers for dashboard requests.
- Project enhancements → Project DocTypes: persists · Stores project settings, roles, and master project state.
- Project enhancements → Project dashboard: serves · Backs the interactive dashboard page.
- Project enhancements → Public JS/CSS: extends · Adds project-specific browser behavior and dashboard widgets.
- Project dashboard → Project DocTypes: reads · Uses project dashboard settings and permitted roles.
- Task enhancements → Task tree: serves · Implements the hierarchical task page and related client logic.
- Task enhancements → Public JS/CSS: extends · Adds task tree and task form client behavior.
- QuickBooks sync → QB DocTypes: stores · Uses settings, payload, logs, and mappings for sync traceability.
- QuickBooks sync → Public JS/CSS: extends · Includes QuickBooks-specific browser assets and dashboard UI.
- Time kiosk → Time records: writes · Creates logs and intervals that later consolidate into ERPNext timesheets.
- GA4 dashboard → Core APIs: calls · Uses shared backend helpers while requesting external analytics data.
- CRM Drive → Public JS/CSS: extends · Adds CRM-facing client behavior around Drive-linked records.
- Maintenance → Public JS/CSS: extends · Uses client scripts and forms for maintenance record entry and review.
- Travel mgmt → Public JS/CSS: extends · Adds travel-related client interactions.
- Global overrides → Public JS/CSS: shapes · Implements desk-wide patches, widgets, and UI fixes.