diff --git a/common/proto/accounting.proto b/common/proto/accounting.proto index 82e0a46..5ad5851 100644 --- a/common/proto/accounting.proto +++ b/common/proto/accounting.proto @@ -10,6 +10,13 @@ service Accounting { // Return journal lines and credits-minus-debits informational balance. rpc GetJournal(GetJournalRequest) returns (Journal); + // Return the profile-wide count of balanced and unbalanced journals. + rpc GetAccountingStatus(GetAccountingStatusRequest) returns (AccountingStatus); + + // Return an oldest-first, paginated queue of unbalanced journals. + rpc ListUnbalancedJournals(ListUnbalancedJournalsRequest) + returns (ListUnbalancedJournalsResponse); + // Append one manual debit or credit line to an existing journal. rpc AddJournalLine(AddJournalLineRequest) returns (Journal); @@ -39,6 +46,55 @@ message GetJournalRequest { bool include_deleted = 3; } +message GetAccountingStatusRequest { + string profile_name = 1; +} + +message AccountingStatus { + bool all_journals_balanced = 1; + int64 journal_count = 2; + int64 balanced_journal_count = 3; + int64 unbalanced_journal_count = 4; + string calculated_at = 5; +} + +message ListUnbalancedJournalsRequest { + string profile_name = 1; + + // Zero uses 50. The maximum is 500. + int32 page_size = 2; + + // Opaque cursor returned by the previous response. Empty starts at the + // oldest unbalanced journal. + string page_token = 3; + + // Optional ISO 4217 currency filter. Empty includes every currency. + string currency = 4; +} + +message UnbalancedJournalSummary { + int64 journal_id = 1; + string description = 2; + string currency = 3; + string total_debit = 4; + string total_credit = 5; + + // Signed credits-minus-debits difference. + string balance = 6; + + // Side and positive amount needed to make the journal balance zero. + JournalSide missing_side = 7; + string missing_amount = 8; + int64 active_line_count = 9; + string created_at = 10; +} + +message ListUnbalancedJournalsResponse { + repeated UnbalancedJournalSummary journals = 1; + int64 total_unbalanced_count = 2; + string next_page_token = 3; +} + message AddJournalLineRequest { string profile_name = 1; int64 journal_id = 2; diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 3e26fae..dc71e2f 100644 Binary files a/common/src/proto/descriptor.bin and b/common/src/proto/descriptor.bin differ diff --git a/common/src/proto/komp_ac.accounting.rs b/common/src/proto/komp_ac.accounting.rs index 7839d8c..e83e445 100644 --- a/common/src/proto/komp_ac.accounting.rs +++ b/common/src/proto/komp_ac.accounting.rs @@ -18,6 +18,73 @@ pub struct GetJournalRequest { pub include_deleted: bool, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetAccountingStatusRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct AccountingStatus { + #[prost(bool, tag = "1")] + pub all_journals_balanced: bool, + #[prost(int64, tag = "2")] + pub journal_count: i64, + #[prost(int64, tag = "3")] + pub balanced_journal_count: i64, + #[prost(int64, tag = "4")] + pub unbalanced_journal_count: i64, + #[prost(string, tag = "5")] + pub calculated_at: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ListUnbalancedJournalsRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + /// Zero uses 50. The maximum is 500. + #[prost(int32, tag = "2")] + pub page_size: i32, + /// Opaque cursor returned by the previous response. Empty starts at the + /// oldest unbalanced journal. + #[prost(string, tag = "3")] + pub page_token: ::prost::alloc::string::String, + /// Optional ISO 4217 currency filter. Empty includes every currency. + #[prost(string, tag = "4")] + pub currency: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct UnbalancedJournalSummary { + #[prost(int64, tag = "1")] + pub journal_id: i64, + #[prost(string, tag = "2")] + pub description: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub currency: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub total_debit: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub total_credit: ::prost::alloc::string::String, + /// Signed credits-minus-debits difference. + #[prost(string, tag = "6")] + pub balance: ::prost::alloc::string::String, + /// Side and positive amount needed to make the journal balance zero. + #[prost(enumeration = "JournalSide", tag = "7")] + pub missing_side: i32, + #[prost(string, tag = "8")] + pub missing_amount: ::prost::alloc::string::String, + #[prost(int64, tag = "9")] + pub active_line_count: i64, + #[prost(string, tag = "10")] + pub created_at: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListUnbalancedJournalsResponse { + #[prost(message, repeated, tag = "1")] + pub journals: ::prost::alloc::vec::Vec, + #[prost(int64, tag = "2")] + pub total_unbalanced_count: i64, + #[prost(string, tag = "3")] + pub next_page_token: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct AddJournalLineRequest { #[prost(string, tag = "1")] pub profile_name: ::prost::alloc::string::String, @@ -260,6 +327,66 @@ pub mod accounting_client { .insert(GrpcMethod::new("komp_ac.accounting.Accounting", "GetJournal")); 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, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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/GetAccountingStatus", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "GetAccountingStatus", + ), + ); + self.inner.unary(req, path, codec).await + } + /// Return an oldest-first, paginated queue of unbalanced journals. + pub async fn list_unbalanced_journals( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + 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/ListUnbalancedJournals", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "ListUnbalancedJournals", + ), + ); + self.inner.unary(req, path, codec).await + } /// Append one manual debit or credit line to an existing journal. pub async fn add_journal_line( &mut self, @@ -336,6 +463,22 @@ pub mod accounting_server { &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; + /// Return the profile-wide count of balanced and unbalanced journals. + async fn get_accounting_status( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Return an oldest-first, paginated queue of unbalanced journals. + async fn list_unbalanced_journals( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Append one manual debit or credit line to an existing journal. async fn add_journal_line( &self, @@ -515,6 +658,98 @@ pub mod accounting_server { }; Box::pin(fut) } + "/komp_ac.accounting.Accounting/GetAccountingStatus" => { + #[allow(non_camel_case_types)] + struct GetAccountingStatusSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for GetAccountingStatusSvc { + type Response = super::AccountingStatus; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_accounting_status(&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 = GetAccountingStatusSvc(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/ListUnbalancedJournals" => { + #[allow(non_camel_case_types)] + struct ListUnbalancedJournalsSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for ListUnbalancedJournalsSvc { + type Response = super::ListUnbalancedJournalsResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::list_unbalanced_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 = ListUnbalancedJournalsSvc(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/AddJournalLine" => { #[allow(non_camel_case_types)] struct AddJournalLineSvc(pub Arc);