From 05d8640417d24035d95116442ff636755de890f6 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Tue, 12 Mar 2024 11:22:20 +0100 Subject: [PATCH] add hardcoded rates --- seeds/schema.yaml | 42 ++++++++++++- seeds/stg_seed__hardcoded_currency_rates.csv | 65 ++++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 seeds/stg_seed__hardcoded_currency_rates.csv diff --git a/seeds/schema.yaml b/seeds/schema.yaml index 6f8c2f0..14e0f50 100644 --- a/seeds/schema.yaml +++ b/seeds/schema.yaml @@ -26,7 +26,7 @@ seeds: regex: "^[0-9]{3}$" - name: decimal_positions data_type: int - description: | + description: | The decimal positions that lead to this currency smallest unit. For example: since Japanese Yen (JPY) have no cents, this value is 0. @@ -41,4 +41,42 @@ seeds: min_value: 0 max_value: 8 strictly: False - + - name: stg_seed__hardcoded_currency_rates + description: | + A bunch of rates between currencies, taken from our invoicing cycle in February 2024. + + These are hardcoded and so will become outdated, but it's the best we have now since we don't have a live feed for exchange rates. + config: + column_types: + from_currency: varchar(3) + to_currency: varchar(3) + rate: numeric + columns: + - name: from_currency + data_type: character varying + description: The 3 character ISO 4217 code for the base currency, in Uppercase. + tests: + - not_null + - dbt_expectations.expect_column_values_to_match_regex: + regex: "^[A-Z]{3}$" + columns: + - name: to_currency + data_type: character varying + description: The 3 character ISO 4217 code for the target currency, in Uppercase. + tests: + - not_null + - dbt_expectations.expect_column_values_to_match_regex: + regex: "^[A-Z]{3}$" + - name: rate + data_type: numeric + description: | + The rate between the two currencies. You should read it as the amount of target currency you get for each unit of base currency. + + For example: for the combination EUR-GBP, a rate of 0.8 means you get 0.8 GBP for 1 EUR. + + Rates between same-currency pairs are always one. + tests: + - not_null + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0.00000000001 + max_value: 999999999999 diff --git a/seeds/stg_seed__hardcoded_currency_rates.csv b/seeds/stg_seed__hardcoded_currency_rates.csv new file mode 100644 index 0000000..3d60fb0 --- /dev/null +++ b/seeds/stg_seed__hardcoded_currency_rates.csv @@ -0,0 +1,65 @@ +from_currency,to_currency,rate +EUR,EUR,1 +USD,USD,1 +GBP,GBP,1 +CAD,CAD,1 +AUD,AUD,1 +ZAR,ZAR,1 +NZD,NZD,1 +PLN,PLN,1 +EUR,USD,1.08286 +EUR,GBP,0.85555 +EUR,CAD,1.4688 +EUR,AUD,1.66453 +EUR,ZAR,20.7993 +EUR,NZD,1.77391 +EUR,PLN,4.31113 +USD,EUR,0.92335 +USD,GBP,0.79003 +USD,CAD,1.3564 +USD,AUD,1.53701 +USD,ZAR,19.2073 +USD,NZD,1.63816 +USD,PLN,3.98085 +GBP,EUR,1.16864 +GBP,USD,1.26559 +GBP,CAD,1.71664 +GBP,AUD,1.94522 +GBP,ZAR,24.3085 +GBP,NZD,2.07323 +GBP,PLN,5.03811 +NZD,EUR,0.56352 +NZD,USD,0.6103 +NZD,GBP,0.48216 +NZD,CAD,0.82781 +NZD,AUD,0.9381 +NZD,ZAR,11.7222 +NZD,PLN,2.42951 +CAD,EUR,0.68064 +CAD,USD,0.73714 +CAD,GBP,0.58237 +CAD,AUD,1.133 +CAD,ZAR,14.1585 +CAD,NZD,1.20756 +CAD,PLN,2.93446 +AUD,EUR,0.60068 +AUD,USD,0.65049 +AUD,GBP,0.51391 +AUD,CAD,0.88232 +AUD,ZAR,12.4941 +AUD,NZD,1.06572 +AUD,PLN,2.58949 +ZAR,EUR,0.04804 +ZAR,USD,0.05203 +ZAR,GBP,0.0411 +ZAR,CAD,0.07057 +ZAR,AUD,0.07997 +ZAR,NZD,0.08523 +ZAR,PLN,0.20712 +PLN,EUR,0.23184 +PLN,USD,0.25106 +PLN,GBP,0.19835 +PLN,CAD,0.34054 +PLN,AUD,0.38588 +PLN,ZAR,4.82218 +PLN,NZD,0.41128