Automated Reports
Automated reports are generated and emailed to configured recipients on demand via the admin API. All execution is synchronous — the HTTP response is returned only after all reports are generated and emails are sent.
GET /api/admin/automated/report/
GET /api/admin/automated/report/?types=daily&date=09/11/2024&formats=pdf&formats=xlsx
Authorization: Bearer <admin_token>
targetIndustryId: IND001
| Parameter | Required | Description |
|---|---|---|
targetIndustryId | Yes (header) | Industry to generate report for |
date | Yes | DD/MM/YYYY — the report date |
types | Yes | daily or monthly |
formats | Yes | Output format(s) — must be repeated params, not comma-separated |
test | No | Default false. When true, generates the file but skips email delivery |
emails | No | Extra recipient addresses (repeated param) |
warning
formats must be repeated params, not comma-separated:
# Correct
?formats=pdf&formats=xlsx
# Wrong — will not work
?formats=pdf,xlsx
Execution Flow
info
AdminAutomatedReportService(args).process()is called- The
typesparam selects the pipeline:
For daily:
- Instantiates
AutomatedReportProcessor(args, 'automatedDailyReport') - Generates a water consumption report (
DAILYtype,WATERservice) in each requested format - Sends email to industry's configured recipients with the file attached
- Then runs a second pass for the daily summary report (
'automatedDailySummaryReport'), which includes rain water summary if the industry has it enabled
For monthly:
- Instantiates
AutomatedReportProcessor(args, 'automatedMonthlyReport') - Checks per-industry feature flags to decide which report types to include:
| Flag | Report included |
|---|---|
is_executive_enabled() | Executive Summary |
is_rain_water_enabled() | Rain Water Report |
is_consumption_enabled() | Consumption Report |
is_stock_enabled() | Stock Report |
is_groundwater_enabled() | Ground Water Level Report |
is_summary_enabled() | Summary Report |
is_energy_enabled() | Energy Report |
is_quality_enabled() | Quality Report |
- Generates and attaches each enabled report type in each requested format
- Sends a single email with all attachments
-
AutomatedReportProcessor.send_mail()handles:- In-memory file generation per format
- Email delivery via Gmail API to configured recipients + any extra
emailsparams
-
When
test=true, the file is generated but email is skipped.
tip
Use test=true to verify report generation is working correctly without sending emails to real recipients.
Excluded Industries
note
Industries in MONTHLY_BATCH_PROCESS_EXCLUDED_INDUSTRY_IDS are skipped by the batch shell script but can still be triggered manually via this endpoint:
DCS2201, DCS2202, INTERNAL, DEMO2322, ADMINAPP,
DEMOAQ2, PI205, TI2404, TI2405, PI216, TI2106, TI2107
Status Codes
| Code | Meaning |
|---|---|
200 | All reports generated and emails sent (or skipped if test=true) |
1403 | targetIndustryId or date missing |
400 | Invalid types value |