Skip to content
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
23 changes: 23 additions & 0 deletions reports/accounts_summary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Accounts summary report

Provides an account summary. Provides details like account balance, account status, currency, etc.

The snapshot view is: `v_report_accounts_summary`

## Pie chart configuration

```
curl -v \
-X POST \
-u admin:password \
-H "X-Killbill-ApiKey:bob" \
-H "X-Killbill-ApiSecret:lazar" \
-H 'Content-Type: application/json' \
-d '{"reportName": "report_accounts_summary",
"reportType": "TABLE",
"reportPrettyName": "Accounts summary",
"sourceTableName": "report_accounts_summary",
"refreshProcedureName": "refresh_report_accounts_summary",
"refreshFrequency": "HOURLY"}' \
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
```
19 changes: 19 additions & 0 deletions reports/accounts_summary/report_accounts_summary.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create table report_accounts_summary as select * from v_report_accounts_summary limit 0;

drop procedure if exists refresh_report_accounts_summary;
DELIMITER //
CREATE PROCEDURE refresh_report_accounts_summary()
BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
START TRANSACTION;
delete from report_accounts_summary;
insert into report_accounts_summary select * from v_report_accounts_summary;
COMMIT;

END;
//
DELIMITER ;
27 changes: 27 additions & 0 deletions reports/accounts_summary/v_report_account_summary.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
create or replace view v_report_accounts_summary as
select
aa.tenant_record_id,
aa.account_id as AccountID,
aa.email as Email,
aa.created_date as CreatedDate,
aa.nb_active_bundles as ActiveBundlesCount,
aa.balance as AccountBalance,
aa.billing_cycle_day_local as BCD,
aa.currency as Currency,
pm.plugin_name as PaymentMethodName,
aat.state as AccountStatus,
date_format(aa.created_date,'%Y-%m-%d') as day,
n.effective_date as NextInvoiceDate
from analytics_accounts aa
left join payment_methods pm
on aa.payment_method_id = pm.id
left join analytics_account_transitions aat
on aa.account_id = aat.account_id
and aat.created_date = (
select max(created_date)
from analytics_account_transitions
where account_id = aa.account_id
)
left join notifications n
on aa.account_record_id=n.search_key1
and n.class_name='org.killbill.billing.invoice.notification.NextBillingDateNotificationKey';
23 changes: 23 additions & 0 deletions reports/bundles_summary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Bundles Summary Report

Provides a subscription bundle summary. Provides details like CTD, plan name, price, for the base subscription in a bundle.

The snapshot view is: `v_report_bundles_summary`

## Pie chart configuration

```
curl -v \
-X POST \
-u admin:password \
-H "X-Killbill-ApiKey:bob" \
-H "X-Killbill-ApiSecret:lazar" \
-H 'Content-Type: application/json' \
-d '{"reportName": "report_bundles_summary",
"reportType": "TABLE",
"reportPrettyName": "Bundles summary",
"sourceTableName": "report_bundles_summary",
"refreshProcedureName": "refresh_report_bundles_summary",
"refreshFrequency": "HOURLY"}' \
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
```
19 changes: 19 additions & 0 deletions reports/bundles_summary/report_bundles_summary.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create table report_bundles_summary as select * from v_report_bundles_summary limit 0;

drop procedure if exists refresh_report_bundles_summary;
DELIMITER //
CREATE PROCEDURE refresh_report_bundles_summary()
BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
START TRANSACTION;
delete from report_bundles_summary;
insert into report_bundles_summary select * from v_report_bundles_summary;
COMMIT;

END;
//
DELIMITER ;
24 changes: 24 additions & 0 deletions reports/bundles_summary/v_report_bundles_summary.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
create or replace view v_report_bundles_summary as
select
ab.tenant_record_id,
ab.bundle_id as BundleId,
ab.account_id as AccountID,
ab.account_external_key as AccountExternalKey,
aa.email as AccountEmail,
ab.created_date as CreatedDate,
ab.current_start_date as StartDate,
ab.charged_through_date as ChargedThroughDate,
date_format(ab.created_date,'%Y-%m-%d') as day,
case
when ab.current_state in ('ENT_STARTED', 'START_BILLING') then 'ACTIVE'
when ab.current_state = 'STOP_BILLING' then 'CANCELLED'
else ab.current_state
end as Status,
-- Remove "-<phase>" from current_slug
left(ab.current_slug, length(ab.current_slug) - length(ab.current_phase) - 1) as PlanName,
ab.current_price as Price,
aa.currency as Currency
from analytics_bundles ab
left join analytics_accounts aa
on ab.account_record_id = aa.account_record_id;

23 changes: 23 additions & 0 deletions reports/payments_summary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Payments Summary Report

Provides payment summary. Provides details like payment_id, amount, etc.

The snapshot view is: `v_report_payments_summary`

## Pie chart configuration

```
curl -v \
-X POST \
-u admin:password \
-H "X-Killbill-ApiKey:bob" \
-H "X-Killbill-ApiSecret:lazar" \
-H 'Content-Type: application/json' \
-d '{"reportName": "report_payments_summary",
"reportType": "TABLE",
"reportPrettyName": "Payments summary",
"sourceTableName": "report_payments_summary",
"refreshProcedureName": "refresh_report_payments_summary",
"refreshFrequency": "HOURLY"}' \
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
```
19 changes: 19 additions & 0 deletions reports/payments_summary/report_payments_summary.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create table report_payments_summary as select * from v_report_payments_summary limit 0;

drop procedure if exists refresh_report_payments_summary;
DELIMITER //
CREATE PROCEDURE refresh_report_payments_summary()
BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
START TRANSACTION;
delete from report_payments_summary;
insert into report_payments_summary select * from v_report_payments_summary;
COMMIT;

END;
//
DELIMITER ;
15 changes: 15 additions & 0 deletions reports/payments_summary/v_payments_summary.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
create or replace view v_report_payments_summary as
select app.payment_number as PaymentNumber,
app.payment_id as PaymentID,
app.created_date as PaymentDate,
app.payment_transaction_status as Status,
app.account_id as AccountID,
aa.email as AccountEmail,
app.account_external_key as AccountExternalKey,
app.plugin_name as PaymentProvider,
app.amount as PaymentAmount,
app.currency as Currency,
app.tenant_record_id,
date_format(app.created_date,'%Y-%m-%d') as day
from analytics_payment_purchases app
left join analytics_accounts aa on app.account_id=aa.account_id