Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reporting): fix some minor bugs and failing assertions #1265

Merged
merged 2 commits into from
Jan 17, 2025
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
22 changes: 7 additions & 15 deletions definitions/intermediate/int_accounts.sqlx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ WITH all_accounts AS (

), credit_facilities AS (

SELECT credit_facility_key,
on_balance_sheet_deposit_account_id,
SELECT DISTINCT credit_facility_key,
collateral_account_id,
disbursed_receivable_account_id,
facility_account_id,
Expand All @@ -38,49 +37,42 @@ WITH all_accounts AS (

), credit_facility_accounts AS (

SELECT credit_facility_key,
on_balance_sheet_deposit_account_id AS account_id,
"on_balance_sheet_deposit_account" AS account_type,
FROM credit_facilities

UNION DISTINCT

SELECT credit_facility_key,
SELECT DISTINCT credit_facility_key,
collateral_account_id AS account_id,
"collateral_account" AS account_type,
FROM credit_facilities

UNION DISTINCT

SELECT credit_facility_key,
SELECT DISTINCT credit_facility_key,
disbursed_receivable_account_id AS account_id,
"disbursed_receivable_account" AS account_type,
FROM credit_facilities

UNION DISTINCT

SELECT credit_facility_key,
SELECT DISTINCT credit_facility_key,
facility_account_id AS account_id,
"facility_account" AS account_type,
FROM credit_facilities

UNION DISTINCT

SELECT credit_facility_key,
SELECT DISTINCT credit_facility_key,
fee_income_account_id AS account_id,
"fee_income_account" AS account_type,
FROM credit_facilities

UNION DISTINCT

SELECT credit_facility_key,
SELECT DISTINCT credit_facility_key,
interest_account_id AS account_id,
"interest_account" AS account_type,
FROM credit_facilities

UNION DISTINCT

SELECT credit_facility_key,
SELECT DISTINCT credit_facility_key,
interest_receivable_account_id AS account_id,
"interest_receivable_account" AS account_type,
FROM credit_facilities
Expand Down
4 changes: 2 additions & 2 deletions definitions/intermediate/int_approved_credit_facilities.sqlx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ WITH approved AS (
})}

WHERE recorded_at < asof
AND event_type = "interest_incurred"
AND event_type = "interest_accrual_concluded"

GROUP BY credit_facility_id

Expand Down Expand Up @@ -136,7 +136,7 @@ WITH approved AS (
})}

WHERE recorded_at < asof
AND event_type = "disbursement_initiated"
AND event_type = "disbursal_initiated"

GROUP BY credit_facility_id

Expand Down
51 changes: 1 addition & 50 deletions definitions/outputs/dim_credit_facilities.sqlx
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,6 @@ config {

SELECT credit_facilities.* EXCEPT (credit_facility_id, customer_id),
customer_key,
on_balance_sheet_deposit_account_key,
collateral_account_key,
disbursed_receivable_account_key,
facility_account_key,
fee_income_account_key,
interest_account_key,
interest_receivable_account_key,

FROM ${ref("int_approved_credit_facilities")}(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY)) AS credit_facilities
JOIN ${ref("int_customers")} USING (customer_id, on_balance_sheet_deposit_account_id)
JOIN (
SELECT
account_id AS on_balance_sheet_deposit_account_id,
account_key AS on_balance_sheet_deposit_account_key,
FROM ${ref("int_accounts")}
) USING (on_balance_sheet_deposit_account_id)
JOIN (
SELECT
account_id AS collateral_account_id,
account_key AS collateral_account_key,
FROM ${ref("int_accounts")}
) USING (collateral_account_id)
JOIN (
SELECT
account_id AS disbursed_receivable_account_id,
account_key AS disbursed_receivable_account_key,
FROM ${ref("int_accounts")}
) USING (disbursed_receivable_account_id)
JOIN (
SELECT
account_id AS facility_account_id,
account_key AS facility_account_key,
FROM ${ref("int_accounts")}
) USING (facility_account_id)
JOIN (
SELECT
account_id AS fee_income_account_id,
account_key AS fee_income_account_key,
FROM ${ref("int_accounts")}
) USING (fee_income_account_id)
JOIN (
SELECT
account_id AS interest_account_id,
account_key AS interest_account_key,
FROM ${ref("int_accounts")}
) USING (interest_account_id)
JOIN (
SELECT
account_id AS interest_receivable_account_id,
account_key AS interest_receivable_account_key,
FROM ${ref("int_accounts")}
) USING (interest_receivable_account_id)
JOIN ${ref("int_customers")} USING (customer_id)
Loading