> ## Documentation Index
> Fetch the complete documentation index at: https://docs.togai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Reports

export const dataSources = {
  sources: [{
    name: 'accounts',
    columns: [{
      name: 'account_id',
      type: 'String',
      description: 'The unique identifier of the account.'
    }, {
      name: 'customer_id',
      type: 'String',
      description: 'The unique identifier of the customer.'
    }, {
      name: 'name',
      type: 'String',
      description: 'The name of the account.'
    }, {
      name: 'created_at',
      type: 'LocalDateTime',
      description: 'The date and time when the account was created.'
    }, {
      name: 'invoice_currency',
      type: 'String',
      description: 'The currency of the account.'
    }, {
      name: 'primary_email',
      type: 'String',
      description: 'The primary email of the account.'
    }, {
      name: 'tags',
      type: 'String[]',
      description: 'The tags of the account.'
    }],
    relations: ['customers']
  }, {
    name: 'customers',
    columns: [{
      name: 'id',
      type: 'String',
      description: 'The unique identifier of the customer.'
    }, {
      name: 'name',
      type: 'String',
      description: 'The name of the customer.'
    }],
    relations: []
  }, {
    name: 'usage',
    columns: [{
      name: 'account_id',
      type: 'String',
      description: 'The unique identifier of the account.'
    }, {
      name: 'customer_id',
      type: 'String',
      description: 'The unique identifier of the customer.'
    }, {
      name: 'billable_id',
      type: 'String',
      description: 'The unique identifier of the billable.'
    }, {
      name: 'event_time',
      type: 'LocalDateTime',
      description: 'The date and time when the usage event occurred.'
    }, {
      name: 'usage_units',
      type: 'String',
      description: 'The usage units of the usage event.'
    }]
  }, {
    name: 'events',
    columns: [{
      name: 'event_id',
      type: 'String',
      description: 'The unique identifier of the event.'
    }, {
      name: 'account_id',
      type: 'String',
      description: 'The unique identifier of the account.'
    }, {
      name: 'customer_id',
      type: 'String',
      description: 'The unique identifier of the customer.'
    }, {
      name: 'event_source_time',
      type: 'LocalDateTime',
      description: 'The date and time when the event occurred.'
    }, {
      name: 'ingestion_status',
      type: 'String',
      description: 'The ingestion status of the event.'
    }]
  }, {
    name: 'invoices',
    columns: [{
      name: 'id',
      type: 'String',
      description: 'The unique identifier of the invoice.'
    }, {
      name: 'owner_id',
      type: 'String',
      description: 'The unique identifier of the owner.'
    }, {
      name: 'total_amount',
      type: 'Number',
      description: 'The total amount of the invoice.'
    }, {
      name: 'status',
      type: 'String',
      description: 'The status of the invoice.'
    }, {
      name: 'due_date',
      type: 'LocalDateTime',
      description: 'The date and time when the invoice is due.'
    }, {
      name: 'class',
      type: 'String',
      description: 'The class of the invoice.'
    }, {
      name: 'created_at',
      type: 'LocalDateTime',
      description: 'The date and time when the invoice was created.'
    }]
  }, {
    name: "license_entries",
    columns: [{
      name: "account_id",
      type: "String",
      description: "The unique identifier of the account."
    }, {
      name: "license_id",
      type: "String",
      description: "The unique identifier of the license."
    }, {
      name: "effective_from",
      type: "LocalDateTime",
      description: "The date and time when the license became effective."
    }, {
      name: "quantity",
      type: "BigDecimal",
      description: "The quantity of the license."
    }, {
      name: "created_at",
      type: "LocalDateTime",
      description: "The date and time when the license was created."
    }]
  }, {
    name: "revenue",
    columns: [{
      name: "account_id",
      type: "String",
      description: "The unique identifier of the account."
    }, {
      name: "customer_id",
      type: "String",
      description: "The unique identifier of the customer."
    }, {
      name: "revenue_time",
      type: "LocalDateTime",
      description: "The date and time when the revenue occurred."
    }, {
      name: "revenue_invoice_currency",
      type: "String",
      description: "The currency of the revenue."
    }, {
      name: "billable_id",
      type: "String",
      description: "The unique identifier of the billable."
    }, {
      name: "revenue_base_currency",
      type: "String",
      description: "The base currency of the revenue."
    }]
  }]
};

export const DataSourceInfo = ({data_sources, data_source: ds}) => {
  let data_source = data_sources.find(source => source.name === ds);
  return <div>
    <table>
      <thead>
          <th>Field Name</th>
          <th>Type</th>
          <th>Description</th>
      </thead>
      <tbody>
        {data_source.columns.map(col => <tr key={col.name}>
            <td>{col.name}</td>
            <td>{col.type}</td>
            <td>{col?.description}</td>
          </tr>)}
      </tbody>
    </table>
  </div>;
};

## How reporting works in Togai?

Togai has an extensive reporting capability that allows you to create reports and report templates. These can be used to generate ad hoc one-time reports for download or pushed to an external data source. Customers can also set up scheduled reports that can be auto-generated hourly, daily or monthly and exported or sent to an external data source.

<Frame caption="How reports work in Togai">
  <img src="https://mintcdn.com/zuora-togai/NTusvtQkLYBvjV74/docs/images/reports.png?fit=max&auto=format&n=NTusvtQkLYBvjV74&q=85&s=02bd5c569676419a6ecf42de32cc3362" width="1080" height="876" data-path="docs/images/reports.png" />
</Frame>

## Tables and entities

### Accounts

<DataSourceInfo data_sources={dataSources.sources} data_source="accounts" />

### Customers

<DataSourceInfo data_sources={dataSources.sources} data_source="customers" />

### Events

<DataSourceInfo data_sources={dataSources.sources} data_source="events" />

### Invoices

<DataSourceInfo data_sources={dataSources.sources} data_source="invoices" />

### License Entries

<DataSourceInfo data_sources={dataSources.sources} data_source="license_entries" />

### Usage

<DataSourceInfo data_sources={dataSources.sources} data_source="usage" />

### Revenue

<DataSourceInfo data_sources={dataSources.sources} data_source="revenue" />

## Supported functions

```
DateTruncate - "date_trunc"
ABS - "abs"`
```

## Supported aggregations

```
Sum - "sum"
Count - "count"
Avg - "avg"
Min - "min"
Max - "max"
```

## Supported relative operators

```
> - "gt"
< - "lt"
>= - "gte"
<= - "lte"
== - "eq"
!= - "neq"
In - "in"
Not In - "nin"
```

## Report templates

Togai also provides an on-demand reporting template option which can be used to create a custom dashboard with various drag & drop widgets that can be used for business analytics to take data driven decisions around pricing.

<Frame caption="Report templates and dashboard">
  <img src="https://mintcdn.com/zuora-togai/NTusvtQkLYBvjV74/docs/images/report-templates.png?fit=max&auto=format&n=NTusvtQkLYBvjV74&q=85&s=286572a5b95e2a88b54dc243c459ef2e" width="1200" height="572" data-path="docs/images/report-templates.png" />
</Frame>
