Jump to content

Repo comfac-hrms EntryPoints

From Game in the Brain Wiki
Revision as of 16:33, 9 March 2026 by Ocjustin260223 (talk | contribs) ("Repo analysis: comfac-hrms and comfac-webshop (14 pages)")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Repo:comfac-hrms/EntryPoints — Entry Points & Configuration

How This App Starts

Installation & Startup

Frappe apps are started by the Frappe Framework (via bench). The app itself doesn't have a traditional "main()" entry point. Instead:

  1. Bench loads the app via hrms/__init__.py
  2. Hooks (hrms/hooks.py) register the app with Frappe
  3. DocType definitions are loaded from JSON files
  4. Controllers (Python classes) are imported when needed

Key Commands

Command Purpose
bench --site [site] install-app hrms Install HRMS on a site
bench --site [site] migrate Run patches, sync DocTypes
bench start Start development server
bench build Compile frontend assets

Main Config Files

hooks.py

Location: hrms/hooks.py

This is the most important file for understanding entry points. Key sections:

Config Section What It Controls
app_name, required_apps App identity and dependencies
doctype_js Client scripts attached to ERPNext DocTypes
override_doctype_class Python class overrides (Employee, Timesheet, etc.)
doc_events Server-side event handlers (validate, on_update, on_submit)
scheduler_events Background jobs (hourly, daily, weekly, monthly)
website_route_rules URL routing for web views

modules.txt

Location: hrms/modules.txt

Lists the modules: HR and Payroll. Controls how DocTypes are organized in the Frappe desk.

patches.txt

Location: hrms/patches.txt

List of database migration scripts that run during bench migrate.

Environment Variables

Standard Frappe environment variables affect this app:

Variable Purpose
FRAPPE_BENCH_ROOT Path to bench installation
MARIADB_ROOT_PASSWORD Database credentials (Docker setups)
SITE_NAME Default site for commands

How to Verify It's Running Correctly

Health Checks

  1. Desk Access: Navigate to /desk — HR module should appear in the sidebar
  2. HR Module: Click "HR" — should see: Employee, Leave, Attendance, Expense Claims, etc.
  3. Payroll Module: Click "Payroll" — should see: Salary Slip, Payroll Entry, etc.

Log Locations

Log Type Location (Docker) Location (Local)
Frappe web logs docker logs [container] logs/web.log
Scheduler logs docker logs [worker] logs/worker.log
Bench console Terminal running bench start Terminal running bench start

What Healthy Startup Looks Like

  • No import errors in logs
  • HR and Payroll modules visible in desk sidebar
  • DocTypes load without "Missing controller" errors
  • Scheduled jobs registered (check _rq_job table or RQ dashboard)

Request/Task Flow

Example: Submitting a Leave Application

  1. User Action: Clicks "Submit" on Leave Application form
  2. Client-Side: JavaScript validates fields (leave_application.js)
  3. API Call: frappe.desk.form.save endpoint called
  4. Server-Side (Controller): LeaveApplication.validate() runs
  5. Server-Side (Hooks): doc_events in hooks.py fire
  6. Database: Document saved, status changed to "Open" or "Approved"
  7. Background Job: Email notification queued (if configured)
  8. Response: Success message returned to client

Example: Payroll Entry Processing

  1. User Action: Creates Payroll Entry, clicks "Create Salary Slips"
  2. Controller: PayrollEntry.create_salary_slips() called
  3. Background Job: Salary slip creation queued (hourly_long queue)
  4. Individual Slips: Each SalarySlip.calculate_net_pay() runs
  5. Accounting: Journal Entry created (if configured)
  6. Status Update: Payroll Entry status changes to "Submitted"

Integration Points

ERPNext Integration

  • Expense Claims → Journal Entries (Accounting)
  • Payroll → Bank Transactions (Payments)
  • Employee → User (Access control)
  • Timesheet → Projects (Billing)

Web Routes

  • /hrms — HRMS frontend (Vue.js SPA)
  • /hr — Roster module
  • Job openings published via website_generators