How sowaan/quotation_profitability works
Project type and purpose
• This is a Frappe/ERPNext “app” (a plugin) named “quotation_profitability.”
• Its goal is to enhance the Quotation DocType in ERPNext by adding profitability calculations and UI‐level enhancements.
File structure
• Top‐level:
• pyproject.toml – project definition
• README.md, license.txt, .gitignore
• quotation_profitability/
• config/ – app configuration (hooks, docs)
• fixtures/ – JSON definitions for new custom fields
• modules.txt – module loading order
• patches.txt – database patches/migrations
• hooks.py – Frappe hook definitions (event bindings)
• public/ – static assets (CSS/JS/img)
• quotation_profitability/quotation_profitability/
• client_scripts/ – front‐end JS for the Quotation form
• events/ – Python functions handling DocType events
• templates/pages/ – custom web pages or form enhancements
Key README insights
• Minimal README; confirms it’s an ERPNext extension focused on quotation profitability.
a. Client (Browser)
b. Web Server (NGINX or built‐in Frappe server)
c. Frappe Application Server
– Core Frappe framework
– ERPNext modules
– quotation_profitability app
d. Database (MariaDB)
e. Caching & Queues (Redis for real‐time / background jobs)
f. Background Workers (Celery/bench worker)
Relationships & interactions
1. User opens a Quotation in the browser → HTTP(S) request → Web Server
2. Web Server routes to Frappe Application Server
3. Frappe Server loads:
• Core framework
• ERPNext DocType definitions
• Custom app via modules.txt, fixtures, patches
• hook bindings from hooks.py
4. Browser loads client_scripts/quotation.js → UI enhancements, field watchers
5. On Quotation save/validate → server‐side event (events/quotation_profitability.py)
6. Server computes profitability → updates DocType custom fields (from fixtures) → writes to MariaDB
7. If any background tasks (e.g., large calculations, reports), they’re enqueued to Redis → processed by background workers
8. Responses flow back to client; UI updates with profitability figures
Architectural patterns & principles
• Plugin architecture: hooks + event‐driven customization
• MVC:
• Model = Quotation DocType + custom fields (fixtures)
• View = client script UI + Jinja templates/pages
• Controller = hook handlers in Python (events)
• Separation of concerns: static assets under public, migrations under patches, hooking under hooks.py.
• Labels on all components (e.g., “Frappe App Server,” “quotation_profitability hooks”)