The billing engine aggregates matched billable CDRs for a time period, generates invoices with line items, creates PDF invoices, and marks CDRs as invoiced.
https://billing.yealin.com.au/billing-runsTOKEN=$(curl -s -X POST https://billing.yealin.com.au/api/auth/token/ \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"YOUR_PASS"}' \
| python3 -c "import sys,json; print(json.load(sys.stdin)['access'])")
curl -s -X POST https://billing.yealin.com.au/api/billing-runs/execute/ \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"period_start": "2026-05-01", "period_end": "2026-05-31"}'
For each active customer:
1. Find all CallRecords where:
- customer = this customer
- billable = True
- invoiced = False
- start_time between period_start and period_end
2. Group by destination type
3. Calculate:
- Voice charges: (duration_minutes × sell_rate_per_min) + connection_fee
- Service charges: fixed charges from ServiceCharge model
4. Create Invoice with line items
5. Calculate subtotal, GST (10%), total
6. Generate PDF via WeasyPrint
7. Mark all included CDRs as invoiced = True
8. Invoice status = 'draft'
Invoices use the format YC-YYYY-NNNN:
YC — Yealin Communications prefixYYYY — year of issueNNNN — sequential number within the year (zero-padded to 4 digits)Examples: YC-2026-0001, YC-2026-0042, YC-2027-0001
| Status | Description |
|---|---|
| draft | Created by billing run, not yet sent |
| sent | Email sent to customer |
| paid | Payment received (Stripe or manual) |
| overdue | Past due date, not paid |
| void | Cancelled/voided |
https://billing.yealin.com.au/invoicesIf the PDF is corrupted or missing:
TOKEN=$(...)
curl -s -X POST https://billing.yealin.com.au/api/invoices/INVOICE-UUID/regenerate-pdf/ \
-H "Authorization: Bearer $TOKEN"
For bank transfers, cheques etc:
https://billing.yealin.com.au/paymentsGST is calculated as 10% of the subtotal:
Non-taxable line items (credits, adjustments) can be configured per line item.
PDFs are generated using WeasyPrint and stored at:
/var/www/yealinbilling/media/invoices/YC-2026-0001.pdf
The PDF includes:
Note: Charts in PDFs use inline SVG — never use JavaScript charting libraries as WeasyPrint cannot render JavaScript.