|
| 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'; |
0 commit comments