-- IMPORTS
WITH transaction_costs AS (
    SELECT * FROM {{ ref('int_exchange__transaction_costs_remove_duplicate_row') }}
),


-- LOGICS
transaction_costs_lists AS (
    SELECT 
        id,
        transaction_order_id,
        supplier_company_id,
        bank_id,
        buyer_company_id,
        status,
        status_name,
        transaction_type,
        transaction_type_name,
        payment_method,
        payment_method_name,
        base_currency_id,
        base_currency_name,
        quote_currency_id,
        quote_currency_name,
        base_to_quote_currency_exchange_rate,
        
        base_value,
        quote_value,
        -- use for future if base currency id other from '1'
        IFF(base_currency_id = '1', 
           base_value,
           99999999)                                                                                AS transaction_value_rm, 
            
        base_tax                                                                                    AS transaction_base_tax,
        -- use for future if base currency id other from '1'
        IFF(base_currency_id = '1', 
           base_tax,
           99999999)                                                                                AS transaction_tax_rm, 
                   
        base_service_charge,
        -- use for future if base currency id other from '1'
        IFF(base_currency_id = '1', 
           base_service_charge,
           99999999)                                                                                AS transaction_service_charge_rm, 


        deleted_at,
        created_at,
        updated_at
    
    FROM transaction_costs 
),


-- FINAL
final__fct_exchange__transaction_costs AS (
    SELECT * FROM transaction_costs_lists
)

SELECT * FROM final__fct_exchange__transaction_costs