/admin/reports
Path: /admin/reports
Namespace: admin
Resource: reports
Overview
The Reports section provides business intelligence and analytics including sales reports, daily sales tracking, usage reports, and accounting turnover reports.
ERPax provides several reporting endpoints for business intelligence:
- Daily Sales - Daily sales tracking and analytics
- Sales Report - Comprehensive sales reporting
- Usage Report - System usage and activity reporting
- Accounting Turnover Report - Accounting turnover and financial reporting
All report resources support standard REST operations (GET, POST, PATCH, DELETE).
Relationships
DailySales Relationships
Model Associations
DailySales connects to the following resources:
Address
- Type:
belongs_toviaaddress_id - Field:
address_id - Description: Address (seller, buyer, or supplier) for which daily sales are tracked. Daily sales are tracked per address.
- Reverse: Address has many daily sales (
address.daily_sales) - API Access:
- Direct: Included in daily sales response as
address_id - Filter:
GET /admin/daily_sales.json?q[address_id_eq]=123
- Direct: Included in daily sales response as
- Related Documentation: Addresses
- Example: Get all daily sales for an address:javascript
const dailySales = await fetch('/admin/daily_sales.json?q[address_id_eq]=123', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
Domain
- Type:
belongs_toviahost_id - Field:
host_id - Description: Tenant domain for multi-tenant scoping. All daily sales belong to a domain.
- Reverse: Domain has many daily sales (
domain.daily_sales) - API Access:
- Direct: Included in daily sales response as
host_id - Filter:
GET /admin/daily_sales.json?q[host_id_eq]=1
- Direct: Included in daily sales response as
- Related Documentation: Domains
SalesReport Relationships
Model Associations
SalesReport connects to the following resources:
Domain
- Type:
belongs_toviahost_id - Field:
host_id - Description: Tenant domain for multi-tenant scoping. All sales reports belong to a domain.
- API Access:
- Direct: Included in sales report response as
host_id - Filter:
GET /admin/sales_reports.json?q[host_id_eq]=1
- Direct: Included in sales report response as
- Related Documentation: Domains
Invoice[] (Data Source)
- Type: Indirect relationship via report data aggregation
- Description: Sales reports aggregate data from invoices. Reports analyze invoice data for sales performance.
- API Access:
- Filter:
GET /admin/invoices.json?q[date_gteq]=2024-01-01&q[date_lteq]=2024-12-31(data source for reports)
- Filter:
- Related Documentation: Invoices
UsageReport Relationships
Model Associations
UsageReport connects to the following resources:
Domain
- Type:
belongs_toviahost_id - Field:
host_id - Description: Tenant domain for multi-tenant scoping. All usage reports belong to a domain.
- API Access:
- Direct: Included in usage report response as
host_id - Filter:
GET /admin/usage_reports.json?q[host_id_eq]=1
- Direct: Included in usage report response as
- Related Documentation: Domains
User[] (Data Source)
- Type: Indirect relationship via report data aggregation
- Description: Usage reports aggregate data from user activity and system usage. Reports analyze user logs and activity.
- API Access:
- Filter:
GET /admin/user_logs.json?q[created_at_gteq]=2024-01-01(data source for reports)
- Filter:
- Related Documentation: Users
AccountingTurnoverReport Relationships
Model Associations
AccountingTurnoverReport connects to the following resources:
Domain
- Type:
belongs_toviahost_id - Field:
host_id - Description: Tenant domain for multi-tenant scoping. All accounting turnover reports belong to a domain.
- API Access:
- Direct: Included in accounting turnover report response as
host_id - Filter:
GET /admin/accounting_turnover_reports.json?q[host_id_eq]=1
- Direct: Included in accounting turnover report response as
- Related Documentation: Domains
AccountingEntry[] (Data Source)
- Type: Indirect relationship via report data aggregation
- Description: Accounting turnover reports aggregate data from accounting entries. Reports analyze accounting transactions for financial reporting.
- API Access:
- Filter:
GET /admin/accounting_entries.json?q[created_at_gteq]=2024-01-01(data source for reports)
- Filter:
- Related Documentation: Accounting
Relationship Patterns
Generating Daily Sales for Address
- Use Case: Track daily sales performance for a specific address
- Example: Get daily sales for an address:javascript
const dailySales = await fetch('/admin/daily_sales.json?q[address_id_eq]=123&q[date_gteq]=2024-01-01', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
Sales Report Data Aggregation
- Use Case: Generate sales report by aggregating invoice data
- Example: Get invoice data for sales report:javascript
const invoices = await fetch('/admin/invoices.json?q[date_gteq]=2024-01-01&q[date_lteq]=2024-12-31&q[invoice_type_eq]=invoice', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json()); // Aggregate invoice data for sales report
Accounting Turnover Report from Entries
- Use Case: Generate accounting turnover report from accounting entries
- Example: Get accounting entries for turnover report:javascript
const entries = await fetch('/admin/accounting_entries.json?q[created_at_gteq]=2024-01-01&q[created_at_lteq]=2024-12-31', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json()); // Aggregate entries by account for turnover report
Key Features
- Sales Analytics: Track sales performance and generate sales reports
- Daily Sales Tracking: Monitor daily sales by address and other dimensions
- System Usage: Track system usage and activity
- Financial Reporting: Generate accounting turnover and financial reports
Daily Sales
Path: /admin/daily_sales
Overview
The DailySales resource provides daily sales tracking and analytics. Track sales performance by day, address, and other dimensions.
Available Operations
List Daily Sales (GET)
Endpoint: GET /admin/daily_sales.json
Request Examples:
curl -X GET "https://your-company.erpax.com/admin/daily_sales.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"curl -X GET "https://your-company.erpax.com/admin/daily_sales.json?q[date_gteq]=2024-01-01" \
-H "Accept: application/json"curl -X GET "https://your-company.erpax.com/admin/daily_sales.json?q[address_id_eq]=123" \
-H "Accept: application/json"JavaScript Example:
const response = await fetch('/admin/daily_sales.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"daily_sales": [
{
"id": 1,
"date": "2024-01-15",
"address_id": 123,
"total_sales_cents": 100000,
"total_quantity": 10,
"created_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"per_page": 25,
"total_pages": 1,
"total_count": 5
}
}Show Daily Sales (GET /:id)
Endpoint: GET /admin/daily_sales/:id.json
Request Example:
curl -X GET "https://your-company.erpax.com/admin/daily_sales/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/daily_sales/123.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"daily_sale": {
"id": 123,
"date": "2024-01-15",
"address_id": 123,
"total_sales_cents": 100000,
"total_quantity": 10,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T12:00:00Z"
}
}Create Daily Sales (POST)
Endpoint: POST /admin/daily_sales.json
Note: Daily sales are typically generated automatically. Manual creation may be used for data correction or historical data import.
Request Example:
curl -X POST "https://your-company.erpax.com/admin/daily_sales.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"daily_sale": {
"date": "2024-01-16",
"address_id": 123,
"total_sales_cents": 150000,
"total_quantity": 15
}
}'JavaScript Example:
const response = await fetch('/admin/daily_sales.json', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
daily_sale: {
date: '2024-01-16',
address_id: 123,
total_sales_cents: 150000,
total_quantity: 15
}
})
});
const data = await response.json();Response (201 Created):
{
"daily_sale": {
"id": 124,
"date": "2024-01-16",
"address_id": 123,
"total_sales_cents": 150000,
"total_quantity": 15,
"created_at": "2024-01-16T10:00:00Z"
}
}Update Daily Sales (PATCH /:id)
Endpoint: PATCH /admin/daily_sales/:id.json
Request Example:
curl -X PATCH "https://your-company.erpax.com/admin/daily_sales/123.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"daily_sale": {
"total_sales_cents": 110000,
"total_quantity": 11
}
}'JavaScript Example:
const response = await fetch('/admin/daily_sales/123.json', {
method: 'PATCH',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
daily_sale: {
total_sales_cents: 110000,
total_quantity: 11
}
})
});
const data = await response.json();Response (200 OK):
{
"daily_sale": {
"id": 123,
"total_sales_cents": 110000,
"total_quantity": 11,
"updated_at": "2024-01-15T15:00:00Z"
}
}Delete Daily Sales (DELETE /:id)
Endpoint: DELETE /admin/daily_sales/:id.json
Request Example:
curl -X DELETE "https://your-company.erpax.com/admin/daily_sales/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/daily_sales/123.json', {
method: 'DELETE',
credentials: 'include',
headers: { 'Accept': 'application/json' }
});Response (204 No Content):
(empty response)Nested Resources
Daily Sales can be accessed through Addresses:
- Address Daily Sales -
/admin/addresses/:id/daily_sales- Daily sales for a specific address
Sales Report
Path: /admin/sales_report
Overview
The SalesReport resource provides comprehensive sales reporting and analytics. Generate detailed sales reports with various filters and aggregations.
Available Operations
List Sales Reports (GET)
Endpoint: GET /admin/sales_report.json
Request Examples:
curl -X GET "https://your-company.erpax.com/admin/sales_report.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"curl -X GET "https://your-company.erpax.com/admin/sales_report.json?q[date_range]=2024-01-01..2024-12-31" \
-H "Accept: application/json"JavaScript Example:
const response = await fetch('/admin/sales_report.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"sales_reports": [
{
"id": 1,
"date_range": "2024-01-01..2024-12-31",
"total_sales_cents": 1000000,
"total_quantity": 100,
"created_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"per_page": 25,
"total_pages": 1,
"total_count": 1
}
}Show Sales Report (GET /:id)
Endpoint: GET /admin/sales_report/:id.json
Request Example:
curl -X GET "https://your-company.erpax.com/admin/sales_report/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/sales_report/123.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"sales_report": {
"id": 123,
"date_range": "2024-01-01..2024-12-31",
"total_sales_cents": 1000000,
"total_quantity": 100,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T12:00:00Z"
}
}Create Sales Report (POST)
Endpoint: POST /admin/sales_report.json
Note: Sales reports are typically generated automatically. Manual creation may be used for custom reports or data correction.
Request Example:
curl -X POST "https://your-company.erpax.com/admin/sales_report.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"sales_report": {
"date_range": "2024-02-01..2024-02-29",
"total_sales_cents": 500000,
"total_quantity": 50
}
}'JavaScript Example:
const response = await fetch('/admin/sales_report.json', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
sales_report: {
date_range: '2024-02-01..2024-02-29',
total_sales_cents: 500000,
total_quantity: 50
}
})
});
const data = await response.json();Response (201 Created):
{
"sales_report": {
"id": 124,
"date_range": "2024-02-01..2024-02-29",
"total_sales_cents": 500000,
"total_quantity": 50,
"created_at": "2024-02-01T10:00:00Z"
}
}Update Sales Report (PATCH /:id)
Endpoint: PATCH /admin/sales_report/:id.json
Request Example:
curl -X PATCH "https://your-company.erpax.com/admin/sales_report/123.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"sales_report": {
"total_sales_cents": 1100000,
"total_quantity": 110
}
}'JavaScript Example:
const response = await fetch('/admin/sales_report/123.json', {
method: 'PATCH',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
sales_report: {
total_sales_cents: 1100000,
total_quantity: 110
}
})
});
const data = await response.json();Response (200 OK):
{
"sales_report": {
"id": 123,
"total_sales_cents": 1100000,
"total_quantity": 110,
"updated_at": "2024-01-15T15:00:00Z"
}
}Delete Sales Report (DELETE /:id)
Endpoint: DELETE /admin/sales_report/:id.json
Request Example:
curl -X DELETE "https://your-company.erpax.com/admin/sales_report/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/sales_report/123.json', {
method: 'DELETE',
credentials: 'include',
headers: { 'Accept': 'application/json' }
});Response (204 No Content):
(empty response)Usage Report
Path: /admin/usage_report
Overview
The UsageReport resource provides system usage and activity reporting. Track system usage, user activity, and resource consumption.
Available Operations
List Usage Reports (GET)
Endpoint: GET /admin/usage_report.json
Request Examples:
curl -X GET "https://your-company.erpax.com/admin/usage_report.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"curl -X GET "https://your-company.erpax.com/admin/usage_report.json?q[date_range]=2024-01-01..2024-12-31" \
-H "Accept: application/json"JavaScript Example:
const response = await fetch('/admin/usage_report.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"usage_reports": [
{
"id": 1,
"date_range": "2024-01-01..2024-12-31",
"total_users": 50,
"total_requests": 10000,
"created_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"per_page": 25,
"total_pages": 1,
"total_count": 1
}
}Show Usage Report (GET /:id)
Endpoint: GET /admin/usage_report/:id.json
Request Example:
curl -X GET "https://your-company.erpax.com/admin/usage_report/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/usage_report/123.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"usage_report": {
"id": 123,
"date_range": "2024-01-01..2024-12-31",
"total_users": 50,
"total_requests": 10000,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T12:00:00Z"
}
}Create Usage Report (POST)
Endpoint: POST /admin/usage_report.json
Note: Usage reports are typically generated automatically. Manual creation may be used for custom reports or data correction.
Request Example:
curl -X POST "https://your-company.erpax.com/admin/usage_report.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"usage_report": {
"date_range": "2024-02-01..2024-02-29",
"total_users": 55,
"total_requests": 12000
}
}'JavaScript Example:
const response = await fetch('/admin/usage_report.json', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
usage_report: {
date_range: '2024-02-01..2024-02-29',
total_users: 55,
total_requests: 12000
}
})
});
const data = await response.json();Response (201 Created):
{
"usage_report": {
"id": 124,
"date_range": "2024-02-01..2024-02-29",
"total_users": 55,
"total_requests": 12000,
"created_at": "2024-02-01T10:00:00Z"
}
}Update Usage Report (PATCH /:id)
Endpoint: PATCH /admin/usage_report/:id.json
Request Example:
curl -X PATCH "https://your-company.erpax.com/admin/usage_report/123.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"usage_report": {
"total_users": 52,
"total_requests": 11000
}
}'JavaScript Example:
const response = await fetch('/admin/usage_report/123.json', {
method: 'PATCH',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
usage_report: {
total_users: 52,
total_requests: 11000
}
})
});
const data = await response.json();Response (200 OK):
{
"usage_report": {
"id": 123,
"total_users": 52,
"total_requests": 11000,
"updated_at": "2024-01-15T15:00:00Z"
}
}Delete Usage Report (DELETE /:id)
Endpoint: DELETE /admin/usage_report/:id.json
Request Example:
curl -X DELETE "https://your-company.erpax.com/admin/usage_report/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/usage_report/123.json', {
method: 'DELETE',
credentials: 'include',
headers: { 'Accept': 'application/json' }
});Response (204 No Content):
(empty response)Accounting Turnover Report
Path: /admin/accounting_turnover_reports
Overview
The AccountingTurnoverReport resource provides accounting turnover and financial reporting. Generate financial reports showing account turnover, balances, and transactions.
Available Operations
List Accounting Turnover Reports (GET)
Endpoint: GET /admin/accounting_turnover_reports.json
Request Examples:
curl -X GET "https://your-company.erpax.com/admin/accounting_turnover_reports.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"curl -X GET "https://your-company.erpax.com/admin/accounting_turnover_reports.json?q[date_range]=2024-01-01..2024-12-31" \
-H "Accept: application/json"curl -X GET "https://your-company.erpax.com/admin/accounting_turnover_reports.json?q[account_id_eq]=123" \
-H "Accept: application/json"JavaScript Example:
const response = await fetch('/admin/accounting_turnover_reports.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"accounting_turnover_reports": [
{
"id": 1,
"date_range": "2024-01-01..2024-12-31",
"account_id": 123,
"debit_turnover_cents": 500000,
"credit_turnover_cents": 400000,
"balance_cents": 100000,
"created_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"current_page": 1,
"per_page": 25,
"total_pages": 1,
"total_count": 1
}
}Show Accounting Turnover Report (GET /:id)
Endpoint: GET /admin/accounting_turnover_reports/:id.json
Request Example:
curl -X GET "https://your-company.erpax.com/admin/accounting_turnover_reports/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/accounting_turnover_reports/123.json', {
credentials: 'include',
headers: { 'Accept': 'application/json' }
});
const data = await response.json();Response (200 OK):
{
"accounting_turnover_report": {
"id": 123,
"date_range": "2024-01-01..2024-12-31",
"account_id": 123,
"debit_turnover_cents": 500000,
"credit_turnover_cents": 400000,
"balance_cents": 100000,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T12:00:00Z"
}
}Create Accounting Turnover Report (POST)
Endpoint: POST /admin/accounting_turnover_reports.json
Note: Accounting turnover reports are typically generated automatically. Manual creation may be used for custom reports or data correction.
Request Example:
curl -X POST "https://your-company.erpax.com/admin/accounting_turnover_reports.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"accounting_turnover_report": {
"date_range": "2024-02-01..2024-02-29",
"account_id": 123,
"debit_turnover_cents": 250000,
"credit_turnover_cents": 200000,
"balance_cents": 50000
}
}'JavaScript Example:
const response = await fetch('/admin/accounting_turnover_reports.json', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
accounting_turnover_report: {
date_range: '2024-02-01..2024-02-29',
account_id: 123,
debit_turnover_cents: 250000,
credit_turnover_cents: 200000,
balance_cents: 50000
}
})
});
const data = await response.json();Response (201 Created):
{
"accounting_turnover_report": {
"id": 124,
"date_range": "2024-02-01..2024-02-29",
"account_id": 123,
"debit_turnover_cents": 250000,
"credit_turnover_cents": 200000,
"balance_cents": 50000,
"created_at": "2024-02-01T10:00:00Z"
}
}Update Accounting Turnover Report (PATCH /:id)
Endpoint: PATCH /admin/accounting_turnover_reports/:id.json
Request Example:
curl -X PATCH "https://your-company.erpax.com/admin/accounting_turnover_reports/123.json" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie" \
-d '{
"accounting_turnover_report": {
"debit_turnover_cents": 510000,
"credit_turnover_cents": 410000,
"balance_cents": 100000
}
}'JavaScript Example:
const response = await fetch('/admin/accounting_turnover_reports/123.json', {
method: 'PATCH',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
accounting_turnover_report: {
debit_turnover_cents: 510000,
credit_turnover_cents: 410000,
balance_cents: 100000
}
})
});
const data = await response.json();Response (200 OK):
{
"accounting_turnover_report": {
"id": 123,
"debit_turnover_cents": 510000,
"credit_turnover_cents": 410000,
"balance_cents": 100000,
"updated_at": "2024-01-15T15:00:00Z"
}
}Delete Accounting Turnover Report (DELETE /:id)
Endpoint: DELETE /admin/accounting_turnover_reports/:id.json
Request Example:
curl -X DELETE "https://your-company.erpax.com/admin/accounting_turnover_reports/123.json" \
-H "Accept: application/json" \
-H "Cookie: session_cookie"JavaScript Example:
const response = await fetch('/admin/accounting_turnover_reports/123.json', {
method: 'DELETE',
credentials: 'include',
headers: { 'Accept': 'application/json' }
});Response (204 No Content):
(empty response)Business Rules
- Report Generation: Reports are generated based on source data (invoices, accounting entries, etc.)
- Date Ranges: Reports support date range filtering for time-based analysis
- Aggregation: Reports aggregate data from multiple sources
- Real-Time Data: Reports reflect current system state
Related Resources
- Invoices - Source data for sales reports
- Addresses - Customer/supplier data for reports
- Accounting - Source data for accounting reports