mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
Build cash flow analysis
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user