feat(analytics): implement currency conversion to power multi-currency aggregation (#6418)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Uzair Khan
2024-11-06 14:46:16 +05:30
committed by GitHub
parent ae4df051cc
commit 01c5216fdd
18 changed files with 273 additions and 24 deletions

View File

@ -32,7 +32,10 @@ pub mod routes {
use crate::{
consts::opensearch::SEARCH_INDEXES,
core::{api_locking, errors::user::UserErrors, verification::utils},
core::{
api_locking, currency::get_forex_exchange_rates, errors::user::UserErrors,
verification::utils,
},
db::{user::UserInterface, user_role::ListUserRolesByUserIdPayload},
routes::AppState,
services::{
@ -397,7 +400,8 @@ pub mod routes {
org_id: org_id.clone(),
merchant_ids: vec![merchant_id.clone()],
};
analytics::payments::get_metrics(&state.pool, &auth, req)
let ex_rates = get_forex_exchange_rates(state.clone()).await?;
analytics::payments::get_metrics(&state.pool, &ex_rates, &auth, req)
.await
.map(ApplicationResponse::Json)
},
@ -435,7 +439,8 @@ pub mod routes {
let auth: AuthInfo = AuthInfo::OrgLevel {
org_id: org_id.clone(),
};
analytics::payments::get_metrics(&state.pool, &auth, req)
let ex_rates = get_forex_exchange_rates(state.clone()).await?;
analytics::payments::get_metrics(&state.pool, &ex_rates, &auth, req)
.await
.map(ApplicationResponse::Json)
},
@ -480,7 +485,8 @@ pub mod routes {
merchant_id: merchant_id.clone(),
profile_ids: vec![profile_id.clone()],
};
analytics::payments::get_metrics(&state.pool, &auth, req)
let ex_rates = get_forex_exchange_rates(state.clone()).await?;
analytics::payments::get_metrics(&state.pool, &ex_rates, &auth, req)
.await
.map(ApplicationResponse::Json)
},
@ -520,7 +526,8 @@ pub mod routes {
org_id: org_id.clone(),
merchant_ids: vec![merchant_id.clone()],
};
analytics::payment_intents::get_metrics(&state.pool, &auth, req)
let ex_rates = get_forex_exchange_rates(state.clone()).await?;
analytics::payment_intents::get_metrics(&state.pool, &ex_rates, &auth, req)
.await
.map(ApplicationResponse::Json)
},
@ -558,7 +565,8 @@ pub mod routes {
let auth: AuthInfo = AuthInfo::OrgLevel {
org_id: org_id.clone(),
};
analytics::payment_intents::get_metrics(&state.pool, &auth, req)
let ex_rates = get_forex_exchange_rates(state.clone()).await?;
analytics::payment_intents::get_metrics(&state.pool, &ex_rates, &auth, req)
.await
.map(ApplicationResponse::Json)
},
@ -603,7 +611,8 @@ pub mod routes {
merchant_id: merchant_id.clone(),
profile_ids: vec![profile_id.clone()],
};
analytics::payment_intents::get_metrics(&state.pool, &auth, req)
let ex_rates = get_forex_exchange_rates(state.clone()).await?;
analytics::payment_intents::get_metrics(&state.pool, &ex_rates, &auth, req)
.await
.map(ApplicationResponse::Json)
},