diff --git a/common/proto/accounting.proto b/common/proto/accounting.proto index 2671953..c61f0d8 100644 --- a/common/proto/accounting.proto +++ b/common/proto/accounting.proto @@ -8,6 +8,10 @@ service Accounting { // all supplied lines atomically when journal_id identifies an existing one. rpc PostJournal(PostJournalRequest) returns (Journal); + // Permanently lock a balanced journal. This is an explicit action; becoming + // balanced never locks a journal automatically. + rpc LockJournal(LockJournalRequest) returns (Journal); + // Return journal lines and credits-minus-debits informational balance. rpc GetJournal(GetJournalRequest) returns (Journal); @@ -58,6 +62,11 @@ message JournalLineInput { string description = 4; } +message LockJournalRequest { + string profile_name = 1; + int64 journal_id = 2; +} + message GetJournalRequest { string profile_name = 1; int64 journal_id = 2; @@ -149,4 +158,7 @@ message Journal { string total_credit = 8; // Informational difference calculated as credits minus debits. string balance = 9; + bool locked = 10; + string locked_at = 11; + string locked_by_user_id = 12; } diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index 57d2f0b..8346d4a 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 00f9434..2b83439 100644 --- a/common/src/proto/komp_ac.accounting.rs +++ b/common/src/proto/komp_ac.accounting.rs @@ -31,6 +31,13 @@ pub struct JournalLineInput { pub description: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct LockJournalRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub journal_id: i64, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetJournalRequest { #[prost(string, tag = "1")] pub profile_name: ::prost::alloc::string::String, @@ -167,6 +174,12 @@ pub struct Journal { /// Informational difference calculated as credits minus debits. #[prost(string, tag = "9")] pub balance: ::prost::alloc::string::String, + #[prost(bool, tag = "10")] + pub locked: bool, + #[prost(string, tag = "11")] + pub locked_at: ::prost::alloc::string::String, + #[prost(string, tag = "12")] + pub locked_by_user_id: ::prost::alloc::string::String, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] @@ -313,6 +326,29 @@ pub mod accounting_client { .insert(GrpcMethod::new("komp_ac.accounting.Accounting", "PostJournal")); self.inner.unary(req, path, codec).await } + /// Permanently lock a balanced journal. This is an explicit action; becoming + /// balanced never locks a journal automatically. + pub async fn lock_journal( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, 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/LockJournal", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("komp_ac.accounting.Accounting", "LockJournal")); + self.inner.unary(req, path, codec).await + } /// Return journal lines and credits-minus-debits informational balance. pub async fn get_journal( &mut self, @@ -443,6 +479,12 @@ pub mod accounting_server { &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; + /// Permanently lock a balanced journal. This is an explicit action; becoming + /// balanced never locks a journal automatically. + async fn lock_journal( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; /// Return journal lines and credits-minus-debits informational balance. async fn get_journal( &self, @@ -593,6 +635,51 @@ pub mod accounting_server { }; Box::pin(fut) } + "/komp_ac.accounting.Accounting/LockJournal" => { + #[allow(non_camel_case_types)] + struct LockJournalSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for LockJournalSvc { + type Response = super::Journal; + 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 { + ::lock_journal(&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 = LockJournalSvc(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/GetJournal" => { #[allow(non_camel_case_types)] struct GetJournalSvc(pub Arc); diff --git a/server b/server index 3d145bf..58f10e0 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 3d145bfc4b79c9e96fc25bff21c645d869ef7f3f +Subproject commit 58f10e086a4c6b245748d0a031fce4c2c98daa9b diff --git a/tui-pages b/tui-pages index 5ff36b0..e0f2ccb 160000 --- a/tui-pages +++ b/tui-pages @@ -1 +1 @@ -Subproject commit 5ff36b0aea5d3b7fb5918da8d51997e6f1d4429a +Subproject commit e0f2ccb3be92d3baaff532bbfbd217b936ea3fc1