Billing flow
Purpose
Section titled “Purpose”Explain what happens when a Billing document is created and how payment success triggers customer emails.
Scope in codebase
Section titled “Scope in codebase”leekimerp/hooks.py—"Billing": {"after_insert": "leekimerp.tasks.handle_billing"}leekimerp/tasks.py—handle_billing,send_payment_success_email,send_company_related_emails
sequenceDiagram participant B as Billing after_insert participant H as handle_billing participant S as send_payment_success_email participant M as send_template_mail B->>H: doc, method H->>S: doc_dict alt status Paid + Incorporation S->>M: Incorporate Success template else status Paid + Additional Services S->>M: Additional Service Payment Success template endLogic summary
Section titled “Logic summary”handle_billingruns only forafter_insert, converts the document todict, and callssend_payment_success_email.send_payment_success_emailloads Application viapayment_for, loads User, and picks Email Templates Configuration byservice_type(IncorporationvsAdditional Services) whenstatus == "Paid".
Entry points
Section titled “Entry points”- Desk: Creating/submitting Billing per your workflow
- Hook: No direct HTTP API required for this path
Dependencies
Section titled “Dependencies”- Email Templates Configuration DocTypes named above must exist and be valid.
Operational notes
Section titled “Operational notes”- If emails do not send, verify Billing field values (
status,service_type,payment_for) and template documents.
Related
Section titled “Related”- Application lifecycle for broader Application context.