Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Invoices table #122

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions docs/tables/scaleway_invoices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: "Steampipe Table: scaleway_invoice - Query Scaleway Invoices using SQL"
description: "Allows users to query Scaleway Invoices, providing detailed information about billing and usage for Scaleway services."
---

# Table: scaleway_invoice - Query Scaleway Invoices using SQL

Scaleway Invoices are detailed records of charges for the use of Scaleway's cloud services. These invoices provide a comprehensive breakdown of costs associated with various resources and services used within a Scaleway account.

## Table Usage Guide

The `scaleway_invoice` table provides insights into billing information within Scaleway. As a finance manager or cloud administrator, explore invoice-specific details through this table, including total amounts, billing periods, and associated organizations. Utilize it to track expenses, verify charges, and manage cloud spending across different projects and timeframes.

## Examples

### Basic info
Explore the basic details of your Scaleway invoices, including their unique identifiers, associated organizations, and billing periods. This can help in tracking and managing your cloud expenses effectively.

```sql
SELECT
id,
organization_id,
billing_period,
total_taxed_amount,
state,
currency
FROM
scaleway_invoices;
```

### Get total billed amount for each organization
Calculate the total amount billed to each organization. This provides an overview of cloud spending across different entities within your Scaleway account.

```sql
SELECT
organization_id,
SUM(total_taxed_amount) as total_billed,
currency
FROM
scaleway_invoices
GROUP BY
organization_id,
currency;
```

### Find invoices with high discount amounts
Identify invoices with significant discounts. This can help in understanding which billing periods or services are providing the most cost savings.

```sql
SELECT
id,
billing_period,
total_discount_amount,
total_taxed_amount,
currency
FROM
scaleway_invoices
WHERE
total_discount_amount > 1000
ORDER BY
total_discount_amount DESC;
```

### List invoices for a specific date range
Retrieve invoices within a specific time frame. This is useful for periodic financial reviews or audits.

```sql
SELECT
id,
billing_period,
total_taxed_amount,
issued_date,
currency
FROM
scaleway_invoices
WHERE
issued_date BETWEEN '2023-01-01' AND '2023-12-31'
ORDER BY
issued_date;
```

### Get the average invoice amount by month
Calculate the average invoice amount for each month. This helps in understanding monthly spending patterns and budgeting for cloud services.

```sql
SELECT
DATE_TRUNC('month', issued_date) AS month,
AVG(total_taxed_amount) AS average_invoice_amount,
currency
FROM
scaleway_invoices
GROUP BY
DATE_TRUNC('month', issued_date),
currency
ORDER BY
month;
```

### Compare total taxed and untaxed amounts
Analyze the difference between taxed and untaxed amounts for each invoice to understand the tax impact on your cloud spending.

```sql
SELECT
id,
total_untaxed_amount,
total_taxed_amount,
total_taxed_amount - total_untaxed_amount AS tax_amount,
currency
FROM
scaleway_invoices
ORDER BY
tax_amount DESC;
```

### Examine discounts and their impact
Investigate how discounts affect your invoices by comparing the undiscounted amount to the final taxed amount.

```sql
SELECT
id,
total_undiscount_amount,
total_discount_amount,
total_taxed_amount,
total_discount_amount / total_undiscount_amount * 100 AS discount_percentage,
currency
FROM
scaleway_invoices
WHERE
total_discount_amount > 0
ORDER BY
discount_percentage DESC;
```
1 change: 1 addition & 0 deletions scaleway/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"scaleway_instance_server": tableScalewayInstanceServer(ctx),
"scaleway_instance_snapshot": tableScalewayInstanceSnapshot(ctx),
"scaleway_instance_volume": tableScalewayInstanceVolume(ctx),
"scaleway_invoices": tableScalewayInvoices(ctx),
"scaleway_kubernetes_cluster": tableScalewayKubernetesCluster(ctx),
"scaleway_kubernetes_node": tableScalewayKubernetesNode(ctx),
"scaleway_kubernetes_pool": tableScalewayKubernetesPool(ctx),
Expand Down
Loading
Loading