Skip to main content

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
ParameterRequiredDescription
targetIndustryIdYes (header)Industry to generate report for
dateYesDD/MM/YYYY — the report date
typesYesdaily or monthly
formatsYesOutput format(s) — must be repeated params, not comma-separated
testNoDefault false. When true, generates the file but skips email delivery
emailsNoExtra 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
  1. AdminAutomatedReportService(args).process() is called
  2. The types param selects the pipeline:

For daily:

  • Instantiates AutomatedReportProcessor(args, 'automatedDailyReport')
  • Generates a water consumption report (DAILY type, WATER service) 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:
FlagReport 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
  1. AutomatedReportProcessor.send_mail() handles:

    • In-memory file generation per format
    • Email delivery via Gmail API to configured recipients + any extra emails params
  2. 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

CodeMeaning
200All reports generated and emails sent (or skipped if test=true)
1403targetIndustryId or date missing
400Invalid types value