accounting name

This commit is contained in:
Priec
2026-07-21 10:11:46 +02:00
parent 6ab03aae94
commit a96d95f1b2
4 changed files with 179 additions and 5 deletions

Binary file not shown.

View File

@@ -18,6 +18,10 @@ pub struct PostJournalRequest {
/// journal is allowed to remain unbalanced.
#[prost(message, repeated, tag = "5")]
pub lines: ::prost::alloc::vec::Vec<JournalLineInput>,
/// Required and unique within the profile when creating. Must be empty when
/// appending to an existing journal selected by journal_id.
#[prost(string, tag = "6")]
pub journal_name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct JournalLineInput {
@@ -54,6 +58,52 @@ pub struct GetAccountingStatusRequest {
pub profile_name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SearchJournalsRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
/// Case-insensitive literal substring. Empty returns all profile journals.
#[prost(string, tag = "2")]
pub name_query: ::prost::alloc::string::String,
/// Zero uses 50. The maximum is 500.
#[prost(int32, tag = "3")]
pub page_size: i32,
/// Opaque cursor returned by the previous response.
#[prost(string, tag = "4")]
pub page_token: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct JournalSummary {
#[prost(int64, tag = "1")]
pub journal_id: i64,
#[prost(string, tag = "2")]
pub journal_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub currency: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub description: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub total_debit: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
pub total_credit: ::prost::alloc::string::String,
#[prost(string, tag = "7")]
pub balance: ::prost::alloc::string::String,
#[prost(int64, tag = "8")]
pub active_line_count: i64,
#[prost(bool, tag = "9")]
pub locked: bool,
#[prost(string, tag = "10")]
pub created_at: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SearchJournalsResponse {
#[prost(message, repeated, tag = "1")]
pub journals: ::prost::alloc::vec::Vec<JournalSummary>,
#[prost(int64, tag = "2")]
pub total_count: i64,
#[prost(string, tag = "3")]
pub next_page_token: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AccountingStatus {
#[prost(bool, tag = "1")]
pub all_journals_balanced: bool,
@@ -105,6 +155,8 @@ pub struct UnbalancedJournalSummary {
pub active_line_count: i64,
#[prost(string, tag = "10")]
pub created_at: ::prost::alloc::string::String,
#[prost(string, tag = "11")]
pub journal_name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListUnbalancedJournalsResponse {
@@ -180,6 +232,8 @@ pub struct Journal {
pub locked_at: ::prost::alloc::string::String,
#[prost(string, tag = "12")]
pub locked_by_user_id: ::prost::alloc::string::String,
#[prost(string, tag = "13")]
pub journal_name: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
@@ -371,6 +425,34 @@ pub mod accounting_client {
.insert(GrpcMethod::new("komp_ac.accounting.Accounting", "GetJournal"));
self.inner.unary(req, path, codec).await
}
/// Search profile journals by user-facing name while retaining journal ids
/// as the stable relationship keys.
pub async fn search_journals(
&mut self,
request: impl tonic::IntoRequest<super::SearchJournalsRequest>,
) -> std::result::Result<
tonic::Response<super::SearchJournalsResponse>,
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/SearchJournals",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("komp_ac.accounting.Accounting", "SearchJournals"),
);
self.inner.unary(req, path, codec).await
}
/// Return the profile-wide count of balanced and unbalanced journals.
pub async fn get_accounting_status(
&mut self,
@@ -490,6 +572,15 @@ pub mod accounting_server {
&self,
request: tonic::Request<super::GetJournalRequest>,
) -> std::result::Result<tonic::Response<super::Journal>, tonic::Status>;
/// Search profile journals by user-facing name while retaining journal ids
/// as the stable relationship keys.
async fn search_journals(
&self,
request: tonic::Request<super::SearchJournalsRequest>,
) -> std::result::Result<
tonic::Response<super::SearchJournalsResponse>,
tonic::Status,
>;
/// Return the profile-wide count of balanced and unbalanced journals.
async fn get_accounting_status(
&self,
@@ -725,6 +816,51 @@ pub mod accounting_server {
};
Box::pin(fut)
}
"/komp_ac.accounting.Accounting/SearchJournals" => {
#[allow(non_camel_case_types)]
struct SearchJournalsSvc<T: Accounting>(pub Arc<T>);
impl<
T: Accounting,
> tonic::server::UnaryService<super::SearchJournalsRequest>
for SearchJournalsSvc<T> {
type Response = super::SearchJournalsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::SearchJournalsRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Accounting>::search_journals(&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 = SearchJournalsSvc(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/GetAccountingStatus" => {
#[allow(non_camel_case_types)]
struct GetAccountingStatusSvc<T: Accounting>(pub Arc<T>);