mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
71 lines
2.6 KiB
SQL
71 lines
2.6 KiB
SQL
-- IMPORTS
|
|
WITH transactions AS (
|
|
SELECT * FROM {{ source('src_exchange_mysql', 'transactions') }}
|
|
),
|
|
|
|
|
|
-- LOGIC
|
|
transactions_rename AS (
|
|
|
|
SELECT
|
|
transactions.id,
|
|
transactions.owner_type,
|
|
transactions.owner_id,
|
|
transactions.type AS transaction_type,
|
|
transactions.issuer AS issued_by,
|
|
transactions.receiver AS received_by,
|
|
transactions.recipient_bank_account_id,
|
|
transactions.payment_method,
|
|
transactions.payment_reference,
|
|
transactions.bill_no,
|
|
transactions.amount AS base_value,
|
|
transactions.original_amount AS quote_value,
|
|
transactions.currency_id AS base_currency_id,
|
|
transactions.original_currency_id AS quote_currency_id,
|
|
transactions.currency_rate AS base_to_quote_currency_exchange_rate,
|
|
transactions.tax AS base_tax,
|
|
transactions.service_charge AS base_service_charge,
|
|
transactions.expires_on AS expired_at,
|
|
transactions.status,
|
|
transactions.deleted_at,
|
|
transactions.created_at,
|
|
transactions.updated_at,
|
|
current_timestamp() AS _dbt_ran_at
|
|
|
|
FROM transactions
|
|
),
|
|
|
|
|
|
-- FINAL
|
|
final__base_exchange__transactions AS (
|
|
|
|
SELECT
|
|
id,
|
|
owner_type,
|
|
owner_id,
|
|
transaction_type,
|
|
issued_by,
|
|
received_by,
|
|
recipient_bank_account_id,
|
|
payment_method,
|
|
payment_reference,
|
|
bill_no,
|
|
base_value,
|
|
quote_value,
|
|
base_currency_id,
|
|
quote_currency_id,
|
|
base_to_quote_currency_exchange_rate,
|
|
base_tax,
|
|
base_service_charge,
|
|
expired_at,
|
|
status,
|
|
deleted_at,
|
|
created_at,
|
|
updated_at,
|
|
_dbt_ran_at
|
|
|
|
FROM transactions_rename
|
|
|
|
)
|
|
|
|
SELECT * FROM final__base_exchange__transactions |