Skip to content

Commit b27bd3d

Browse files
Merge pull request #169 from reshmabidikar/additional-reports
Additional reports for accounts, bundles and payment summary.
2 parents 34b9e73 + 35ddc95 commit b27bd3d

9 files changed

Lines changed: 192 additions & 0 deletions

File tree

reports/accounts_summary/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Accounts summary report
2+
3+
Provides an account summary. Provides details like account balance, account status, currency, etc.
4+
5+
The snapshot view is: `v_report_accounts_summary`
6+
7+
## Pie chart configuration
8+
9+
```
10+
curl -v \
11+
-X POST \
12+
-u admin:password \
13+
-H "X-Killbill-ApiKey:bob" \
14+
-H "X-Killbill-ApiSecret:lazar" \
15+
-H 'Content-Type: application/json' \
16+
-d '{"reportName": "report_accounts_summary",
17+
"reportType": "TABLE",
18+
"reportPrettyName": "Accounts summary",
19+
"sourceTableName": "report_accounts_summary",
20+
"refreshProcedureName": "refresh_report_accounts_summary",
21+
"refreshFrequency": "HOURLY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_accounts_summary as select * from v_report_accounts_summary limit 0;
2+
3+
drop procedure if exists refresh_report_accounts_summary;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_accounts_summary()
6+
BEGIN
7+
8+
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
9+
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
10+
11+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
12+
START TRANSACTION;
13+
delete from report_accounts_summary;
14+
insert into report_accounts_summary select * from v_report_accounts_summary;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
create or replace view v_report_accounts_summary as
2+
select
3+
aa.tenant_record_id,
4+
aa.account_id as AccountID,
5+
aa.email as Email,
6+
aa.created_date as CreatedDate,
7+
aa.nb_active_bundles as ActiveBundlesCount,
8+
aa.balance as AccountBalance,
9+
aa.billing_cycle_day_local as BCD,
10+
aa.currency as Currency,
11+
pm.plugin_name as PaymentMethodName,
12+
aat.state as AccountStatus,
13+
date_format(aa.created_date,'%Y-%m-%d') as day,
14+
n.effective_date as NextInvoiceDate
15+
from analytics_accounts aa
16+
left join payment_methods pm
17+
on aa.payment_method_id = pm.id
18+
left join analytics_account_transitions aat
19+
on aa.account_id = aat.account_id
20+
and aat.created_date = (
21+
select max(created_date)
22+
from analytics_account_transitions
23+
where account_id = aa.account_id
24+
)
25+
left join notifications n
26+
on aa.account_record_id=n.search_key1
27+
and n.class_name='org.killbill.billing.invoice.notification.NextBillingDateNotificationKey';

reports/bundles_summary/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Bundles Summary Report
2+
3+
Provides a subscription bundle summary. Provides details like CTD, plan name, price, for the base subscription in a bundle.
4+
5+
The snapshot view is: `v_report_bundles_summary`
6+
7+
## Pie chart configuration
8+
9+
```
10+
curl -v \
11+
-X POST \
12+
-u admin:password \
13+
-H "X-Killbill-ApiKey:bob" \
14+
-H "X-Killbill-ApiSecret:lazar" \
15+
-H 'Content-Type: application/json' \
16+
-d '{"reportName": "report_bundles_summary",
17+
"reportType": "TABLE",
18+
"reportPrettyName": "Bundles summary",
19+
"sourceTableName": "report_bundles_summary",
20+
"refreshProcedureName": "refresh_report_bundles_summary",
21+
"refreshFrequency": "HOURLY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_bundles_summary as select * from v_report_bundles_summary limit 0;
2+
3+
drop procedure if exists refresh_report_bundles_summary;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_bundles_summary()
6+
BEGIN
7+
8+
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
9+
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
10+
11+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
12+
START TRANSACTION;
13+
delete from report_bundles_summary;
14+
insert into report_bundles_summary select * from v_report_bundles_summary;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
create or replace view v_report_bundles_summary as
2+
select
3+
ab.tenant_record_id,
4+
ab.bundle_id as BundleId,
5+
ab.account_id as AccountID,
6+
ab.account_external_key as AccountExternalKey,
7+
aa.email as AccountEmail,
8+
ab.created_date as CreatedDate,
9+
ab.current_start_date as StartDate,
10+
ab.charged_through_date as ChargedThroughDate,
11+
date_format(ab.created_date,'%Y-%m-%d') as day,
12+
case
13+
when ab.current_state in ('ENT_STARTED', 'START_BILLING') then 'ACTIVE'
14+
when ab.current_state = 'STOP_BILLING' then 'CANCELLED'
15+
else ab.current_state
16+
end as Status,
17+
-- Remove "-<phase>" from current_slug
18+
left(ab.current_slug, length(ab.current_slug) - length(ab.current_phase) - 1) as PlanName,
19+
ab.current_price as Price,
20+
aa.currency as Currency
21+
from analytics_bundles ab
22+
left join analytics_accounts aa
23+
on ab.account_record_id = aa.account_record_id;
24+

reports/payments_summary/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Payments Summary Report
2+
3+
Provides payment summary. Provides details like payment_id, amount, etc.
4+
5+
The snapshot view is: `v_report_payments_summary`
6+
7+
## Pie chart configuration
8+
9+
```
10+
curl -v \
11+
-X POST \
12+
-u admin:password \
13+
-H "X-Killbill-ApiKey:bob" \
14+
-H "X-Killbill-ApiSecret:lazar" \
15+
-H 'Content-Type: application/json' \
16+
-d '{"reportName": "report_payments_summary",
17+
"reportType": "TABLE",
18+
"reportPrettyName": "Payments summary",
19+
"sourceTableName": "report_payments_summary",
20+
"refreshProcedureName": "refresh_report_payments_summary",
21+
"refreshFrequency": "HOURLY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_payments_summary as select * from v_report_payments_summary limit 0;
2+
3+
drop procedure if exists refresh_report_payments_summary;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_payments_summary()
6+
BEGIN
7+
8+
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
9+
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
10+
11+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
12+
START TRANSACTION;
13+
delete from report_payments_summary;
14+
insert into report_payments_summary select * from v_report_payments_summary;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
create or replace view v_report_payments_summary as
2+
select app.payment_number as PaymentNumber,
3+
app.payment_id as PaymentID,
4+
app.created_date as PaymentDate,
5+
app.payment_transaction_status as Status,
6+
app.account_id as AccountID,
7+
aa.email as AccountEmail,
8+
app.account_external_key as AccountExternalKey,
9+
app.plugin_name as PaymentProvider,
10+
app.amount as PaymentAmount,
11+
app.currency as Currency,
12+
app.tenant_record_id,
13+
date_format(app.created_date,'%Y-%m-%d') as day
14+
from analytics_payment_purchases app
15+
left join analytics_accounts aa on app.account_id=aa.account_id

0 commit comments

Comments
 (0)