moving balances of accounts between profiles - also other things in proto files

This commit is contained in:
Priec
2026-08-04 09:31:25 +02:00
parent f248a60b07
commit 0635e3bf10
6 changed files with 587 additions and 23 deletions

Binary file not shown.

View File

@@ -1,4 +1,31 @@
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EnsureAccountRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "2")]
pub segments: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Currency accepted by source postings to the leaf account. Empty uses the
/// profile accounting currency. Missing ancestors are created in the profile
/// accounting currency.
#[prost(string, tag = "3")]
pub denomination_currency: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Account {
#[prost(int64, tag = "1")]
pub id: i64,
#[prost(int64, optional, tag = "2")]
pub parent_account_id: ::core::option::Option<i64>,
#[prost(string, tag = "3")]
pub segment: ::prost::alloc::string::String,
/// Root-to-leaf path of this account. Same shape as the request that created
/// it; the server never joins segments into a delimited code.
#[prost(string, repeated, tag = "4")]
pub segments: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "5")]
pub denomination_currency: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PostJournalRequest {
#[prost(string, tag = "1")]
@@ -7,8 +34,9 @@ pub struct PostJournalRequest {
/// an unknown id is never treated as a request to create one.
#[prost(int64, optional, tag = "2")]
pub journal_id: ::core::option::Option<i64>,
/// Required when creating. When appending, empty uses the journal currency;
/// a supplied value must match it exactly.
/// Currency of the amounts supplied by this request. Required when creating;
/// empty uses the profile accounting currency when appending. Journal amounts
/// are stored and returned in the profile accounting currency.
#[prost(string, tag = "3")]
pub currency: ::prost::alloc::string::String,
/// Applied when creating and required to be empty when appending.
@@ -210,8 +238,9 @@ pub struct JournalLine {
pub line_number: i32,
#[prost(enumeration = "JournalSide", tag = "3")]
pub side: i32,
#[prost(string, tag = "4")]
pub account_code: ::prost::alloc::string::String,
/// Root-to-leaf path of the posted account, as sent on JournalLineInput.
#[prost(string, repeated, tag = "4")]
pub account_segments: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "5")]
pub amount: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
@@ -357,8 +386,9 @@ pub struct ListPeriodBalancesRequest {
pub struct PeriodBalance {
#[prost(int64, tag = "1")]
pub period_id: i64,
#[prost(string, tag = "2")]
pub account_code: ::prost::alloc::string::String,
/// Root-to-leaf path of the account this frozen balance belongs to.
#[prost(string, repeated, tag = "2")]
pub account_segments: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "3")]
pub currency: ::prost::alloc::string::String,
/// Signed nets use debit-positive convention.
@@ -376,6 +406,81 @@ pub struct ListPeriodBalancesResponse {
#[prost(message, repeated, tag = "1")]
pub balances: ::prost::alloc::vec::Vec<PeriodBalance>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MapOpeningBalanceAccountRequest {
/// Open period whose profile receives the opening balance. Its configured
/// previous_period_id identifies the source profile and period.
#[prost(int64, tag = "1")]
pub target_period_id: i64,
#[prost(string, repeated, tag = "2")]
pub source_account_segments: ::prost::alloc::vec::Vec<
::prost::alloc::string::String,
>,
#[prost(string, repeated, tag = "3")]
pub target_account_segments: ::prost::alloc::vec::Vec<
::prost::alloc::string::String,
>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct UnmapOpeningBalanceAccountRequest {
#[prost(int64, tag = "1")]
pub target_period_id: i64,
#[prost(string, repeated, tag = "2")]
pub target_account_segments: ::prost::alloc::vec::Vec<
::prost::alloc::string::String,
>,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct UnmapOpeningBalanceAccountResponse {
#[prost(bool, tag = "1")]
pub removed: bool,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListOpeningBalanceAccountsRequest {
#[prost(int64, tag = "1")]
pub target_period_id: i64,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct OpeningBalanceAccountMapping {
#[prost(int64, tag = "1")]
pub target_period_id: i64,
#[prost(int64, tag = "2")]
pub source_period_id: i64,
#[prost(string, tag = "3")]
pub source_profile_name: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "4")]
pub source_account_segments: ::prost::alloc::vec::Vec<
::prost::alloc::string::String,
>,
#[prost(string, tag = "5")]
pub target_profile_name: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "6")]
pub target_account_segments: ::prost::alloc::vec::Vec<
::prost::alloc::string::String,
>,
#[prost(string, tag = "7")]
pub currency: ::prost::alloc::string::String,
/// Signed balances use the debit-positive convention.
#[prost(string, tag = "8")]
pub opening_balance: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
pub period_debit: ::prost::alloc::string::String,
#[prost(string, tag = "10")]
pub period_credit: ::prost::alloc::string::String,
#[prost(string, tag = "11")]
pub current_balance: ::prost::alloc::string::String,
#[prost(enumeration = "OpeningBalanceStatus", tag = "12")]
pub status: i32,
#[prost(string, tag = "13")]
pub created_at: ::prost::alloc::string::String,
#[prost(string, tag = "14")]
pub created_by_user_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListOpeningBalanceAccountsResponse {
#[prost(message, repeated, tag = "1")]
pub mappings: ::prost::alloc::vec::Vec<OpeningBalanceAccountMapping>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum JournalSide {
@@ -476,6 +581,37 @@ impl AccountingPeriodType {
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OpeningBalanceStatus {
Unspecified = 0,
/// The predecessor is still open, so its closed journal activity can change.
Provisional = 1,
/// The value comes from the predecessor's frozen period snapshot.
Final = 2,
}
impl OpeningBalanceStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "OPENING_BALANCE_STATUS_UNSPECIFIED",
Self::Provisional => "OPENING_BALANCE_STATUS_PROVISIONAL",
Self::Final => "OPENING_BALANCE_STATUS_FINAL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OPENING_BALANCE_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"OPENING_BALANCE_STATUS_PROVISIONAL" => Some(Self::Provisional),
"OPENING_BALANCE_STATUS_FINAL" => Some(Self::Final),
_ => None,
}
}
}
/// Generated client implementations.
pub mod accounting_client {
#![allow(
@@ -572,6 +708,30 @@ pub mod accounting_client {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Resolve or atomically create every node in a parsed account path.
pub async fn ensure_account(
&mut self,
request: impl tonic::IntoRequest<super::EnsureAccountRequest>,
) -> std::result::Result<tonic::Response<super::Account>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.accounting.Accounting/EnsureAccount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("komp_ac.accounting.Accounting", "EnsureAccount"),
);
self.inner.unary(req, path, codec).await
}
/// Create a journal with its first lines when journal_id is absent, or append
/// all supplied lines atomically when journal_id identifies an existing one.
pub async fn post_journal(
@@ -1016,6 +1176,95 @@ pub mod accounting_client {
);
self.inner.unary(req, path, codec).await
}
/// Administratively map one account in a predecessor profile to one account
/// in the current profile. Existing activity on the target account is allowed.
pub async fn map_opening_balance_account(
&mut self,
request: impl tonic::IntoRequest<super::MapOpeningBalanceAccountRequest>,
) -> std::result::Result<
tonic::Response<super::OpeningBalanceAccountMapping>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.accounting.Accounting/MapOpeningBalanceAccount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.accounting.Accounting",
"MapOpeningBalanceAccount",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn unmap_opening_balance_account(
&mut self,
request: impl tonic::IntoRequest<super::UnmapOpeningBalanceAccountRequest>,
) -> std::result::Result<
tonic::Response<super::UnmapOpeningBalanceAccountResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.accounting.Accounting/UnmapOpeningBalanceAccount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.accounting.Accounting",
"UnmapOpeningBalanceAccount",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn list_opening_balance_accounts(
&mut self,
request: impl tonic::IntoRequest<super::ListOpeningBalanceAccountsRequest>,
) -> std::result::Result<
tonic::Response<super::ListOpeningBalanceAccountsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.accounting.Accounting/ListOpeningBalanceAccounts",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.accounting.Accounting",
"ListOpeningBalanceAccounts",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Generated server implementations.
@@ -1031,6 +1280,11 @@ pub mod accounting_server {
/// Generated trait containing gRPC methods that should be implemented for use with AccountingServer.
#[async_trait]
pub trait Accounting: std::marker::Send + std::marker::Sync + 'static {
/// Resolve or atomically create every node in a parsed account path.
async fn ensure_account(
&self,
request: tonic::Request<super::EnsureAccountRequest>,
) -> std::result::Result<tonic::Response<super::Account>, tonic::Status>;
/// Create a journal with its first lines when journal_id is absent, or append
/// all supplied lines atomically when journal_id identifies an existing one.
async fn post_journal(
@@ -1139,6 +1393,29 @@ pub mod accounting_server {
tonic::Response<super::ListPeriodBalancesResponse>,
tonic::Status,
>;
/// Administratively map one account in a predecessor profile to one account
/// in the current profile. Existing activity on the target account is allowed.
async fn map_opening_balance_account(
&self,
request: tonic::Request<super::MapOpeningBalanceAccountRequest>,
) -> std::result::Result<
tonic::Response<super::OpeningBalanceAccountMapping>,
tonic::Status,
>;
async fn unmap_opening_balance_account(
&self,
request: tonic::Request<super::UnmapOpeningBalanceAccountRequest>,
) -> std::result::Result<
tonic::Response<super::UnmapOpeningBalanceAccountResponse>,
tonic::Status,
>;
async fn list_opening_balance_accounts(
&self,
request: tonic::Request<super::ListOpeningBalanceAccountsRequest>,
) -> std::result::Result<
tonic::Response<super::ListOpeningBalanceAccountsResponse>,
tonic::Status,
>;
}
/// Mutable informational journals. A journal may contain only debits, only
/// credits, or any non-zero balance. Balance is reported but never enforced.
@@ -1221,6 +1498,51 @@ pub mod accounting_server {
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/komp_ac.accounting.Accounting/EnsureAccount" => {
#[allow(non_camel_case_types)]
struct EnsureAccountSvc<T: Accounting>(pub Arc<T>);
impl<
T: Accounting,
> tonic::server::UnaryService<super::EnsureAccountRequest>
for EnsureAccountSvc<T> {
type Response = super::Account;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::EnsureAccountRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Accounting>::ensure_account(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = EnsureAccountSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.accounting.Accounting/PostJournal" => {
#[allow(non_camel_case_types)]
struct PostJournalSvc<T: Accounting>(pub Arc<T>);
@@ -1957,6 +2279,161 @@ pub mod accounting_server {
};
Box::pin(fut)
}
"/komp_ac.accounting.Accounting/MapOpeningBalanceAccount" => {
#[allow(non_camel_case_types)]
struct MapOpeningBalanceAccountSvc<T: Accounting>(pub Arc<T>);
impl<
T: Accounting,
> tonic::server::UnaryService<super::MapOpeningBalanceAccountRequest>
for MapOpeningBalanceAccountSvc<T> {
type Response = super::OpeningBalanceAccountMapping;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::MapOpeningBalanceAccountRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Accounting>::map_opening_balance_account(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = MapOpeningBalanceAccountSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.accounting.Accounting/UnmapOpeningBalanceAccount" => {
#[allow(non_camel_case_types)]
struct UnmapOpeningBalanceAccountSvc<T: Accounting>(pub Arc<T>);
impl<
T: Accounting,
> tonic::server::UnaryService<
super::UnmapOpeningBalanceAccountRequest,
> for UnmapOpeningBalanceAccountSvc<T> {
type Response = super::UnmapOpeningBalanceAccountResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::UnmapOpeningBalanceAccountRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Accounting>::unmap_opening_balance_account(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = UnmapOpeningBalanceAccountSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.accounting.Accounting/ListOpeningBalanceAccounts" => {
#[allow(non_camel_case_types)]
struct ListOpeningBalanceAccountsSvc<T: Accounting>(pub Arc<T>);
impl<
T: Accounting,
> tonic::server::UnaryService<
super::ListOpeningBalanceAccountsRequest,
> for ListOpeningBalanceAccountsSvc<T> {
type Response = super::ListOpeningBalanceAccountsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::ListOpeningBalanceAccountsRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Accounting>::list_opening_balance_accounts(
&inner,
request,
)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ListOpeningBalanceAccountsSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(

View File

@@ -9,10 +9,11 @@ pub struct PreviewEcbConversionRequest {
pub original_currency: ::prost::alloc::string::String,
#[prost(enumeration = "EcbConversionContext", tag = "3")]
pub conversion_context: i32,
/// ISO calendar date (YYYY-MM-DD). Its meaning is selected by
/// conversion_context: transaction, statement, or decisive date.
/// ISO calendar date (YYYY-MM-DD) from which the applicable publication date
/// is derived. Its meaning is selected by conversion_context: transaction,
/// statement, or decisive date.
#[prost(string, tag = "4")]
pub anchor_date: ::prost::alloc::string::String,
pub conversion_basis_date: ::prost::alloc::string::String,
/// Required. Profile whose rates apply. Only consulted when use_custom_rate is
/// set, but always required so a preview names the books it describes.
#[prost(string, tag = "5")]
@@ -36,7 +37,7 @@ pub struct PreviewEcbConversionResponse {
#[prost(enumeration = "EcbConversionContext", tag = "4")]
pub conversion_context: i32,
#[prost(string, tag = "5")]
pub anchor_date: ::prost::alloc::string::String,
pub conversion_basis_date: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
pub determination_method: ::prost::alloc::string::String,
#[prost(string, tag = "7")]
@@ -109,7 +110,7 @@ pub struct EcbConversionEvidence {
#[prost(string, tag = "6")]
pub conversion_context: ::prost::alloc::string::String,
#[prost(string, tag = "7")]
pub anchor_date: ::prost::alloc::string::String,
pub conversion_basis_date: ::prost::alloc::string::String,
#[prost(string, tag = "8")]
pub determination_method: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
@@ -157,7 +158,7 @@ pub struct ListEcbConversionEvidenceResponse {
#[prost(bool, tag = "3")]
pub has_more: bool,
}
/// Accounting date rule used to select an ECB publication.
/// Conversion basis rule used to select an ECB publication.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum EcbConversionContext {