conversions7

This commit is contained in:
Filipriec
2026-08-23 22:28:53 +02:00
parent 6666f7a5b1
commit 8dacb981bf
15 changed files with 75 additions and 47 deletions

View File

@@ -22,6 +22,10 @@ message ExchangeRateSelection {
optional string specific_rate_date = 3;
optional string manual_foreign_units = 4;
string reason = 5;
// Omit to use the profile's current default source for the currency.
// An explicit different source must be enabled for the same direct pair and
// is recorded as an audited per-event override.
optional string rate_source_id = 6;
}
service ExchangeRateService {
@@ -31,7 +35,7 @@ service ExchangeRateService {
returns (ListConversionEvidenceResponse);
rpc GetProfileExchangeRateSettings(GetProfileExchangeRateSettingsRequest)
returns (ProfileExchangeRateSettings);
rpc AddProfileForeignCurrency(AddProfileForeignCurrencyRequest)
rpc AddProfileCurrencySource(AddProfileCurrencySourceRequest)
returns (ProfileForeignCurrency);
}
@@ -121,6 +125,12 @@ message GetProfileExchangeRateSettingsRequest { string profile_name = 1; }
message ProfileForeignCurrency {
string currency = 1;
string default_source_id = 2;
repeated ProfileCurrencySource sources = 3;
}
message ProfileCurrencySource {
string source_id = 1;
bool coverage_complete = 2;
optional string verified_from_date = 3;
optional string verified_through_date = 4;
@@ -129,11 +139,13 @@ message ProfileForeignCurrency {
message ProfileExchangeRateSettings {
string profile_name = 1;
string accounting_currency = 2;
string rate_source_id = 3;
repeated string enabled_source_ids = 3;
repeated ProfileForeignCurrency foreign_currencies = 4;
}
message AddProfileForeignCurrencyRequest {
message AddProfileCurrencySourceRequest {
string profile_name = 1;
string currency = 2;
string source_id = 3;
bool make_default = 4;
}

View File

@@ -104,8 +104,8 @@ message PostTableDefinitionRequest {
// to this one when they reach the ledger.
string accounting_currency = 8;
// Compiled direct-rate provider selected when the profile is created.
// The server validates this identifier against its compiled provider registry.
// Initial compiled direct-rate provider. It is enabled for each initial
// foreign currency below; more provider/currency bindings may be appended later.
string rate_source_id = 11;
// Append-only foreign currencies initially enabled for this profile.

Binary file not shown.

View File

@@ -11,6 +11,11 @@ pub struct ExchangeRateSelection {
pub manual_foreign_units: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, tag = "5")]
pub reason: ::prost::alloc::string::String,
/// Omit to use the profile's current default source for the currency.
/// An explicit different source must be enabled for the same direct pair and
/// is recorded as an audited per-event override.
#[prost(string, optional, tag = "6")]
pub rate_source_id: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PreviewDirectConversionRequest {
@@ -166,10 +171,19 @@ pub struct GetProfileExchangeRateSettingsRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProfileForeignCurrency {
#[prost(string, tag = "1")]
pub currency: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub default_source_id: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub sources: ::prost::alloc::vec::Vec<ProfileCurrencySource>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ProfileCurrencySource {
#[prost(string, tag = "1")]
pub source_id: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub coverage_complete: bool,
#[prost(string, optional, tag = "3")]
@@ -183,17 +197,21 @@ pub struct ProfileExchangeRateSettings {
pub profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub accounting_currency: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub rate_source_id: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "3")]
pub enabled_source_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, repeated, tag = "4")]
pub foreign_currencies: ::prost::alloc::vec::Vec<ProfileForeignCurrency>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AddProfileForeignCurrencyRequest {
pub struct AddProfileCurrencySourceRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub currency: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub source_id: ::prost::alloc::string::String,
#[prost(bool, tag = "4")]
pub make_default: bool,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
@@ -445,9 +463,9 @@ pub mod exchange_rate_service_client {
);
self.inner.unary(req, path, codec).await
}
pub async fn add_profile_foreign_currency(
pub async fn add_profile_currency_source(
&mut self,
request: impl tonic::IntoRequest<super::AddProfileForeignCurrencyRequest>,
request: impl tonic::IntoRequest<super::AddProfileCurrencySourceRequest>,
) -> std::result::Result<
tonic::Response<super::ProfileForeignCurrency>,
tonic::Status,
@@ -462,14 +480,14 @@ pub mod exchange_rate_service_client {
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.exchange_rates.ExchangeRateService/AddProfileForeignCurrency",
"/komp_ac.exchange_rates.ExchangeRateService/AddProfileCurrencySource",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.exchange_rates.ExchangeRateService",
"AddProfileForeignCurrency",
"AddProfileCurrencySource",
),
);
self.inner.unary(req, path, codec).await
@@ -510,9 +528,9 @@ pub mod exchange_rate_service_server {
tonic::Response<super::ProfileExchangeRateSettings>,
tonic::Status,
>;
async fn add_profile_foreign_currency(
async fn add_profile_currency_source(
&self,
request: tonic::Request<super::AddProfileForeignCurrencyRequest>,
request: tonic::Request<super::AddProfileCurrencySourceRequest>,
) -> std::result::Result<
tonic::Response<super::ProfileForeignCurrency>,
tonic::Status,
@@ -750,16 +768,15 @@ pub mod exchange_rate_service_server {
};
Box::pin(fut)
}
"/komp_ac.exchange_rates.ExchangeRateService/AddProfileForeignCurrency" => {
"/komp_ac.exchange_rates.ExchangeRateService/AddProfileCurrencySource" => {
#[allow(non_camel_case_types)]
struct AddProfileForeignCurrencySvc<T: ExchangeRateService>(
struct AddProfileCurrencySourceSvc<T: ExchangeRateService>(
pub Arc<T>,
);
impl<
T: ExchangeRateService,
> tonic::server::UnaryService<
super::AddProfileForeignCurrencyRequest,
> for AddProfileForeignCurrencySvc<T> {
> tonic::server::UnaryService<super::AddProfileCurrencySourceRequest>
for AddProfileCurrencySourceSvc<T> {
type Response = super::ProfileForeignCurrency;
type Future = BoxFuture<
tonic::Response<Self::Response>,
@@ -768,12 +785,12 @@ pub mod exchange_rate_service_server {
fn call(
&mut self,
request: tonic::Request<
super::AddProfileForeignCurrencyRequest,
super::AddProfileCurrencySourceRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ExchangeRateService>::add_profile_foreign_currency(
<T as ExchangeRateService>::add_profile_currency_source(
&inner,
request,
)
@@ -788,7 +805,7 @@ pub mod exchange_rate_service_server {
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = AddProfileForeignCurrencySvc(inner);
let method = AddProfileCurrencySourceSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(

View File

@@ -51,8 +51,8 @@ pub struct PostTableDefinitionRequest {
/// to this one when they reach the ledger.
#[prost(string, tag = "8")]
pub accounting_currency: ::prost::alloc::string::String,
/// Compiled direct-rate provider selected when the profile is created.
/// The server validates this identifier against its compiled provider registry.
/// Initial compiled direct-rate provider. It is enabled for each initial
/// foreign currency below; more provider/currency bindings may be appended later.
#[prost(string, tag = "11")]
pub rate_source_id: ::prost::alloc::string::String,
/// Append-only foreign currencies initially enabled for this profile.