Build cash flow analysis

This commit is contained in:
CIEF ACC1
2024-03-12 01:08:06 +00:00
parent dd42248cdd
commit 3c0ced171a
4 changed files with 116 additions and 2 deletions
@@ -37,8 +37,8 @@ final__base_exchange__wallet_logs AS (
currency_id, currency_id,
-- dimensions -- dimensions
owner_type,
code, code,
owner_type,
-- measures -- measures
amount, amount,
@@ -35,8 +35,8 @@ final__base_exchange__wallets AS (
currency_id, currency_id,
-- dimensions -- dimensions
owner_type,
code, code,
owner_type,
-- measures -- measures
amount, amount,
@@ -0,0 +1,58 @@
-- IMPORT
WITH wallet_logs AS (
SELECT * FROM {{ ref('base_exchange__wallet_logs') }}
),
-- LOGIC
renamed AS (
SELECT
wallet_log_id,
wallet_id,
owner_id AS company_id,
currency_id,
code,
amount AS wallet_balance,
created_datetime,
updated_datetime,
deleted_datetime,
'{{ modules.datetime.datetime.now(modules.pytz.timezone("Asia/Kuala_Lumpur")) }}' AS _dbt_ran_datetime
FROM wallet_logs
WHERE owner_type = 'App\\Models\\Company'
),
-- FINAL
final__base_exchange__wallet_logs AS (
SELECT
--ids
wallet_log_id,
wallet_id,
company_id,
currency_id,
--dimensions
code,
--measures
wallet_balance,
--date/times
created_datetime,
updated_datetime,
deleted_datetime,
--metadata
_dbt_ran_datetime
FROM renamed
)
SELECT * FROM final__base_exchange__wallet_logs
@@ -0,0 +1,56 @@
-- IMPORT
WITH wallets AS (
SELECT * FROM {{ ref('base_exchange__wallets') }}
),
-- LOGIC
renamed AS (
SELECT
wallet_id,
owner_id AS company_id,
currency_id,
code,
amount AS wallet_balance,
created_datetime,
updated_datetime,
deleted_datetime,
'{{ modules.datetime.datetime.now(modules.pytz.timezone("Asia/Kuala_Lumpur")) }}' AS _dbt_ran_datetime
FROM wallets
WHERE owner_type = 'App\\Models\\Company'
),
-- FINAL
final__stg__exchange__wallets AS (
SELECT
--ids
wallet_id,
company_id,
currency_id,
--dimensions
code,
--measures
wallet_balance,
--date/times
created_datetime,
updated_datetime,
deleted_datetime,
--metadata
_dbt_ran_datetime
FROM renamed
)
SELECT * FROM final__stg__exchange__wallets