Skip to content

Commit c56d7cb

Browse files
Merge pull request #171 from reshmabidikar/work-for-ts-54
Work for TS#54 (Round 2).
2 parents ad91907 + a980896 commit c56d7cb

34 files changed

Lines changed: 316 additions & 2576 deletions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Daily Invoice Credits Report
2+
3+
Total of invoice credits per tenant, per currency and per day.
4+
5+
So if there is an unpaid invoice for `$20` on `2025-09-22`, and an account credit is added for `$100` on the same day, there is a invoice credit of `$80` which will be shown on this report. If however, a new charge of `$200` is created later on on the same day, the `$80` credit is consumed so the total credit displayed by the report for `2025-09-22` is now `$0`.
6+
7+
The snapshot view is: [v_report_invoice_item_credits_daily](v_report_invoice_item_credits_daily.ddl)
8+
9+
## Timeline configuration
10+
11+
```
12+
curl -v \
13+
-X POST \
14+
-u admin:password \
15+
-H "X-Killbill-ApiKey:bob" \
16+
-H "X-Killbill-ApiSecret:lazar" \
17+
-H 'Content-Type: application/json' \
18+
-d '{"reportName": "report_daily_invoice_credits",
19+
"reportType": "TIMELINE",
20+
"reportPrettyName": "Invoice Credits Daily",
21+
"sourceTableName": "report_invoice_credits_daily",
22+
"refreshProcedureName": "refresh_report_invoice_credits_daily",
23+
"refreshFrequency": "DAILY"}' \
24+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
25+
```
26+
27+
## Sample Data
28+
29+
| Tenant Record Id | Currency | Day | Count |
30+
|------------------|----------|------------|----------|
31+
| 1 | USD | 2025-05-05 | 0.0000 |
32+
| 1 | USD | 2025-09-19 | 80.0000 |
33+
| 22 | USD | 2025-09-19 | 125.0000 |
34+
| 22 | EUR | 2025-09-22 | 45.0000 |
35+
| 22 | USD | 2025-09-18 | -10.0000 |
36+
37+
This means that on `2025-09-19`, there was a total invoice credit of `$80` for the tenant_record_id=1.
38+
39+
40+
## Report UI:
41+
42+
![invoice-credits-daily.png](invoice-credits-daily.png)
112 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_invoice_credits_daily as select * from v_report_invoice_credits_daily limit 0;
2+
3+
drop procedure if exists refresh_report_invoice_credits_daily;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_invoice_credits_daily()
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_invoice_credits_daily;
14+
insert into report_invoice_credits_daily select * from v_report_invoice_credits_daily;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;

src/main/resources/reports/v_report_invoice_item_credits_daily.ddl renamed to src/main/resources/reports/invoice_credits_daily/v_report_invoice_credits_daily.ddl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace view v_report_invoice_item_credits_daily as
1+
create or replace view v_report_invoice_credits_daily as
22
select
33
aic.tenant_record_id
44
, aic.currency
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Daily Invoice Item Adjustments report
2+
3+
Total of invoice item adjustments per tenant, per currency and per day.
4+
5+
So if there is an invoice for `$100` created on `2025-09-21` and the invoice is adjusted for `$20`, this report will show a value of `-20` for the date `2025-09-21` for the particular tenant. If there are multiple invoice item adjustments for the tenant on the same day, they will be added up.
6+
7+
The snapshot view is: [v_report_invoice_item_adjustments_daily](v_report_invoice_item_adjustments_daily.ddl)
8+
9+
## Timeline configuration
10+
11+
```
12+
curl -v \
13+
-X POST \
14+
-u admin:password \
15+
-H "X-Killbill-ApiKey:bob" \
16+
-H "X-Killbill-ApiSecret:lazar" \
17+
-H 'Content-Type: application/json' \
18+
-d '{"reportName": "report_daily_invoice_item_adjustments",
19+
"reportType": "TIMELINE",
20+
"reportPrettyName": "Invoice Item Adjustments Daily",
21+
"sourceTableName": "report_invoice_item_adjustments_daily",
22+
"refreshProcedureName": "refresh_report_invoice_item_adjustments_daily",
23+
"refreshFrequency": "DAILY"}' \
24+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
25+
```
26+
27+
## Sample Data
28+
29+
| Tenant Record Id | Currency | Date | Count |
30+
|------------------|----------|------------|-----------|
31+
| 1 | EUR | 2025-08-28 | -10.0000 |
32+
| 1 | USD | 2025-08-29 | |
33+
| 1 | EUR | 2025-08-29 | -50.0000 |
34+
| 1 | EUR | 2025-09-01 | -16.0000 |
35+
| 1 | USD | 2025-09-16 | |
36+
| 1 | EUR | 2025-09-02 | -19.9500 |
37+
| 5 | USD | 2025-09-05 | -109.9500 |
38+
| 1 | USD | 2025-09-19 | -19.3100 |
39+
| 489 | USD | 2025-09-19 | -10.0000 |
40+
41+
This means that on the date `2025-08-28`, the tenant with record id=1 had a total invoice adjustments of EUR 10.
42+
43+
## Report UI:
44+
45+
![invoice_item_adjustments_daily.png](invoice_item_adjustments_daily.png)
143 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_invoice_item_adjustments_daily as select * from v_report_invoice_item_adjustments_daily limit 0;
2+
3+
drop procedure if exists refresh_report_invoice_item_adjustments_daily;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_invoice_item_adjustments_daily()
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_invoice_item_adjustments_daily;
14+
insert into report_invoice_item_adjustments_daily select * from v_report_invoice_item_adjustments_daily;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;

src/main/resources/reports/v_report_invoice_item_adjustments_daily.ddl renamed to src/main/resources/reports/invoice_item_adjustments_daily/v_report_invoice_item_adjustments_daily.ddl

File renamed without changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Daily Overdue Count Report
2+
3+
Count of overdue states per tenant and per day.
4+
5+
The snapshot view is: [v_report_overdue_states_count_daily](v_report_overdue_states_count_daily.ddl)
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_overdue_states_count_daily",
17+
"reportType": "TIMELINE",
18+
"reportPrettyName": "Daily Overdue Count",
19+
"sourceTableName": "report_overdue_states_count_daily",
20+
"refreshProcedureName": "refresh_report_overdue_states_count_daily",
21+
"refreshFrequency": "HOURLY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
24+
25+
## Sample Data
26+
27+
| Tenant Record Id | State | Day | Count |
28+
|------------------|--------------|------------|-------|
29+
| 1 | BLOCKED | 2025-09-15 | 5 |
30+
| 1 | BLOCKED | 2025-09-16 | 5 |
31+
| 22 | BLOCKED | 2025-09-17 | 6 |
32+
| 22 | CANCELLATION | 2025-09-18 | 3 |
33+
| 1 | BLOCKED | 2025-09-18 | 1 |
34+
| 23 | BLOCKED | 2025-09-19 | 7 |
35+
| 45 | CANCELLATION | 2025-09-19 | 5 |
36+
37+
This means that on `2025-09-15`, 5 accounts were in `BLOCKED` overdue state for the tenant_record_id=1.
38+
39+
## Report UI:
40+
41+
![overdue-states-count-daily.png](overdue-states-count-daily.png)
42+
43+
44+
162 KB
Loading

0 commit comments

Comments
 (0)