Skip to content

Commit c042574

Browse files
committed
report corrections - conversions dollar amount
1 parent f7a24d8 commit c042574

7 files changed

Lines changed: 80 additions & 41 deletions

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Conversions Total Dollar Amount Report
2+
3+
Compute (monthly) the total revenue from subscriptions converting out of trial, grouped by tenant and billing period.
4+
5+
The snapshot view is: `v_report_conversions_total_dollar_monthly`
6+
7+
## Timeline 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_conversions_total_dollar_monthly",
17+
"reportType": "TIMELINE",
18+
"reportPrettyName": "Conversions Total Dollar Amount",
19+
"sourceTableName": "report_conversions_total_dollar_monthly",
20+
"refreshProcedureName": "refresh_report_conversions_total_dollar_monthly",
21+
"refreshFrequency": "DAILY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
24+
25+
## Sample Data
26+
27+
|Tenant Record Id|Day |Billing Period| Count|
28+
|--|--|--|--|
29+
|1|2025-06-01 |WEEKLY |30|
30+
|1|2025-07-01 |MONTHLY |30|
31+
|1| 2025-07-01 |QUARTERLY |70|
32+
|6| 2025-01-01 |ANNUAL|200|
33+
|1| 2025-04-01 |MONTHLY|30|
34+
35+
Here day represents the first day of the month representing that subscription's conversion month. So if the subscription converts from TRIAL to EVERGREEN phase on `2025-04-15`, the day will be `2025-04-01`.
36+
37+
## Report UI:
38+
39+
![conversion-total-dollar-amount.png](conversion-total-dollar-amount.png)
123 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_conversions_total_dollar_monthly as select * from v_report_conversions_total_dollar_monthly limit 0;
2+
3+
drop procedure if exists refresh_report_conversions_total_dollar_monthly;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_conversions_total_dollar_monthly()
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_conversions_total_dollar_monthly;
14+
insert into report_conversions_total_dollar_monthly select * from v_report_conversions_total_dollar_monthly;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
create or replace view v_report_conversions_total_dollar_monthly as
2+
select
3+
ast.tenant_record_id,
4+
date_format(next_start_date, '%Y-%m-01') day,
5+
next_billing_period billing_period,
6+
round(sum(converted_next_price)) count
7+
from analytics_subscription_transitions ast
8+
join (
9+
select distinct tenant_record_id, bundle_id
10+
from analytics_invoice_items
11+
where invoice_original_amount_charged > 0
12+
and invoice_balance = 0
13+
) paid_bundles
14+
on ast.bundle_id = paid_bundles.bundle_id
15+
and ast.tenant_record_id = paid_bundles.tenant_record_id
16+
where report_group = 'default'
17+
and next_service = 'entitlement-service'
18+
and prev_phase = 'TRIAL'
19+
and next_phase != 'TRIAL'
20+
and event not like 'STOP_ENTITLEMENT%'
21+
group by 1,2,3;

src/main/resources/reports/conversion/refresh_report_conversions_total_dollar_monthly.prc

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/resources/reports/conversion/report_conversions_total_dollar_monthly.ddl

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)