diff --git a/common/proto/accounting.proto b/common/proto/accounting.proto index 37bfa0e..10fc82a 100644 --- a/common/proto/accounting.proto +++ b/common/proto/accounting.proto @@ -3,14 +3,18 @@ package komp_ac.accounting; // Mutable informational journals. A journal may contain only debits, only // credits, or any non-zero balance. Balance is reported but never enforced. +// Accounting periods close date ranges inside a profile and freeze account sums +// without replacing the live accounts projection. Closed periods can be reopened; +// approved periods are final. service Accounting { // 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. 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); + // Close a balanced journal. Closed journals can be reopened while their + // accounting period is open. + rpc CloseJournal(CloseJournalRequest) returns (Journal); + rpc ReopenJournal(ReopenJournalRequest) returns (Journal); // Return journal lines and credits-minus-debits informational balance. rpc GetJournal(GetJournalRequest) returns (Journal); @@ -28,6 +32,22 @@ service Accounting { // Soft-delete one line while retaining it for audit display. rpc SoftDeleteJournalLine(SoftDeleteJournalLineRequest) returns (Journal); + + // Create an open accounting period for a profile. Periods may be any length + // (month, half-year, year). Overlapping ranges for the same profile are rejected. + rpc ConfigureAccountingPeriod(ConfigureAccountingPeriodRequest) + returns (AccountingPeriod); + + // Closing snapshots balances and blocks mutations through the period end. + // A closed period may be reopened; approval makes it final. + rpc CloseAccountingPeriod(CloseAccountingPeriodRequest) returns (AccountingPeriod); + rpc ReopenAccountingPeriod(ReopenAccountingPeriodRequest) returns (AccountingPeriod); + rpc ApproveAccountingPeriod(ApproveAccountingPeriodRequest) returns (AccountingPeriod); + + rpc GetAccountingPeriod(GetAccountingPeriodRequest) returns (AccountingPeriod); + rpc ListAccountingPeriods(ListAccountingPeriodsRequest) + returns (ListAccountingPeriodsResponse); + rpc ListPeriodBalances(ListPeriodBalancesRequest) returns (ListPeriodBalancesResponse); } enum JournalSide { @@ -36,6 +56,13 @@ enum JournalSide { JOURNAL_SIDE_CREDIT = 2; } +enum AccountingPeriodStatus { + ACCOUNTING_PERIOD_STATUS_UNSPECIFIED = 0; + ACCOUNTING_PERIOD_STATUS_OPEN = 1; + ACCOUNTING_PERIOD_STATUS_CLOSED = 2; + ACCOUNTING_PERIOD_STATUS_APPROVED = 3; +} + message PostJournalRequest { string profile_name = 1; @@ -58,6 +85,11 @@ message PostJournalRequest { // creating. Must be empty when appending to an existing journal selected by // journal_id. string journal_name = 6; + + // Accounting date in YYYY-MM-DD. Empty defaults to the current UTC date when + // creating. Must be empty when appending. Rejected when it falls at or before + // the latest closed or approved accounting boundary for the profile. + string accounting_date = 7; } message JournalLineInput { @@ -67,7 +99,12 @@ message JournalLineInput { string description = 4; } -message LockJournalRequest { +message CloseJournalRequest { + string profile_name = 1; + int64 journal_id = 2; +} + +message ReopenJournalRequest { string profile_name = 1; int64 journal_id = 2; } @@ -107,8 +144,9 @@ message JournalSummary { string total_credit = 6; string balance = 7; int64 active_line_count = 8; - bool locked = 9; + bool closed = 9; string created_at = 10; + string accounting_date = 11; } message SearchJournalsResponse { @@ -155,6 +193,7 @@ message UnbalancedJournalSummary { int64 active_line_count = 9; string created_at = 10; string journal_name = 11; + string accounting_date = 12; } message ListUnbalancedJournalsResponse { @@ -196,8 +235,74 @@ 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; + bool closed = 10; + string closed_at = 11; + string closed_by_user_id = 12; string journal_name = 13; + string accounting_date = 14; +} + +message ConfigureAccountingPeriodRequest { + string profile_name = 1; + // Inclusive range in YYYY-MM-DD. + string period_start = 2; + string period_end = 3; + // Optional link to the preceding period in a carry chain. + optional int64 previous_period_id = 4; +} + +message CloseAccountingPeriodRequest { + int64 period_id = 1; +} + +message ReopenAccountingPeriodRequest { + int64 period_id = 1; +} + +message ApproveAccountingPeriodRequest { + int64 period_id = 1; +} + +message GetAccountingPeriodRequest { + int64 period_id = 1; +} + +message ListAccountingPeriodsRequest { + string profile_name = 1; +} + +message ListAccountingPeriodsResponse { + repeated AccountingPeriod periods = 1; +} + +message AccountingPeriod { + int64 id = 1; + string profile_name = 2; + string period_start = 3; + string period_end = 4; + AccountingPeriodStatus status = 5; + int64 previous_period_id = 6; + string closed_at = 7; + string closed_by_user_id = 8; + string approved_at = 9; + string approved_by_user_id = 10; +} + +message ListPeriodBalancesRequest { + int64 period_id = 1; +} + +message PeriodBalance { + int64 period_id = 1; + string account_code = 2; + string currency = 3; + // Signed nets use debit-positive convention. + string opening_balance = 4; + string period_debit = 5; + string period_credit = 6; + string closing_balance = 7; +} + +message ListPeriodBalancesResponse { + repeated PeriodBalance balances = 1; } diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index abffa43..2c09d32 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 5530fc4..d92a5e7 100644 --- a/common/src/proto/komp_ac.accounting.rs +++ b/common/src/proto/komp_ac.accounting.rs @@ -23,6 +23,11 @@ pub struct PostJournalRequest { /// journal_id. #[prost(string, tag = "6")] pub journal_name: ::prost::alloc::string::String, + /// Accounting date in YYYY-MM-DD. Empty defaults to the current UTC date when + /// creating. Must be empty when appending. Rejected when it falls at or before + /// the latest closed or approved accounting boundary for the profile. + #[prost(string, tag = "7")] + pub accounting_date: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct JournalLineInput { @@ -36,7 +41,14 @@ pub struct JournalLineInput { pub description: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct LockJournalRequest { +pub struct CloseJournalRequest { + #[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 ReopenJournalRequest { #[prost(string, tag = "1")] pub profile_name: ::prost::alloc::string::String, #[prost(int64, tag = "2")] @@ -91,9 +103,11 @@ pub struct JournalSummary { #[prost(int64, tag = "8")] pub active_line_count: i64, #[prost(bool, tag = "9")] - pub locked: bool, + pub closed: bool, #[prost(string, tag = "10")] pub created_at: ::prost::alloc::string::String, + #[prost(string, tag = "11")] + pub accounting_date: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchJournalsResponse { @@ -158,6 +172,8 @@ pub struct UnbalancedJournalSummary { pub created_at: ::prost::alloc::string::String, #[prost(string, tag = "11")] pub journal_name: ::prost::alloc::string::String, + #[prost(string, tag = "12")] + pub accounting_date: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListUnbalancedJournalsResponse { @@ -226,13 +242,109 @@ pub struct Journal { #[prost(string, tag = "9")] pub balance: ::prost::alloc::string::String, #[prost(bool, tag = "10")] - pub locked: bool, + pub closed: bool, #[prost(string, tag = "11")] - pub locked_at: ::prost::alloc::string::String, + pub closed_at: ::prost::alloc::string::String, #[prost(string, tag = "12")] - pub locked_by_user_id: ::prost::alloc::string::String, + pub closed_by_user_id: ::prost::alloc::string::String, #[prost(string, tag = "13")] pub journal_name: ::prost::alloc::string::String, + #[prost(string, tag = "14")] + pub accounting_date: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ConfigureAccountingPeriodRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + /// Inclusive range in YYYY-MM-DD. + #[prost(string, tag = "2")] + pub period_start: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub period_end: ::prost::alloc::string::String, + /// Optional link to the preceding period in a carry chain. + #[prost(int64, optional, tag = "4")] + pub previous_period_id: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CloseAccountingPeriodRequest { + #[prost(int64, tag = "1")] + pub period_id: i64, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ReopenAccountingPeriodRequest { + #[prost(int64, tag = "1")] + pub period_id: i64, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ApproveAccountingPeriodRequest { + #[prost(int64, tag = "1")] + pub period_id: i64, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetAccountingPeriodRequest { + #[prost(int64, tag = "1")] + pub period_id: i64, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ListAccountingPeriodsRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListAccountingPeriodsResponse { + #[prost(message, repeated, tag = "1")] + pub periods: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct AccountingPeriod { + #[prost(int64, tag = "1")] + pub id: i64, + #[prost(string, tag = "2")] + pub profile_name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub period_start: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub period_end: ::prost::alloc::string::String, + #[prost(enumeration = "AccountingPeriodStatus", tag = "5")] + pub status: i32, + #[prost(int64, tag = "6")] + pub previous_period_id: i64, + #[prost(string, tag = "7")] + pub closed_at: ::prost::alloc::string::String, + #[prost(string, tag = "8")] + pub closed_by_user_id: ::prost::alloc::string::String, + #[prost(string, tag = "9")] + pub approved_at: ::prost::alloc::string::String, + #[prost(string, tag = "10")] + pub approved_by_user_id: ::prost::alloc::string::String, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ListPeriodBalancesRequest { + #[prost(int64, tag = "1")] + pub period_id: i64, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct PeriodBalance { + #[prost(int64, tag = "1")] + pub period_id: i64, + #[prost(string, tag = "2")] + pub account_code: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub currency: ::prost::alloc::string::String, + /// Signed nets use debit-positive convention. + #[prost(string, tag = "4")] + pub opening_balance: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub period_debit: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub period_credit: ::prost::alloc::string::String, + #[prost(string, tag = "7")] + pub closing_balance: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListPeriodBalancesResponse { + #[prost(message, repeated, tag = "1")] + pub balances: ::prost::alloc::vec::Vec, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] @@ -263,6 +375,38 @@ impl JournalSide { } } } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum AccountingPeriodStatus { + Unspecified = 0, + Open = 1, + Closed = 2, + Approved = 3, +} +impl AccountingPeriodStatus { + /// 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 => "ACCOUNTING_PERIOD_STATUS_UNSPECIFIED", + Self::Open => "ACCOUNTING_PERIOD_STATUS_OPEN", + Self::Closed => "ACCOUNTING_PERIOD_STATUS_CLOSED", + Self::Approved => "ACCOUNTING_PERIOD_STATUS_APPROVED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ACCOUNTING_PERIOD_STATUS_UNSPECIFIED" => Some(Self::Unspecified), + "ACCOUNTING_PERIOD_STATUS_OPEN" => Some(Self::Open), + "ACCOUNTING_PERIOD_STATUS_CLOSED" => Some(Self::Closed), + "ACCOUNTING_PERIOD_STATUS_APPROVED" => Some(Self::Approved), + _ => None, + } + } +} /// Generated client implementations. pub mod accounting_client { #![allow( @@ -276,6 +420,9 @@ pub mod accounting_client { use tonic::codegen::http::Uri; /// Mutable informational journals. A journal may contain only debits, only /// credits, or any non-zero balance. Balance is reported but never enforced. + /// Accounting periods close date ranges inside a profile and freeze account sums + /// without replacing the live accounts projection. Closed periods can be reopened; + /// approved periods are final. #[derive(Debug, Clone)] pub struct AccountingClient { inner: tonic::client::Grpc, @@ -379,11 +526,11 @@ 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( + /// Close a balanced journal. Closed journals can be reopened while their + /// accounting period is open. + pub async fn close_journal( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { self.inner .ready() @@ -395,11 +542,36 @@ pub mod accounting_client { })?; let codec = tonic_prost::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/komp_ac.accounting.Accounting/LockJournal", + "/komp_ac.accounting.Accounting/CloseJournal", ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("komp_ac.accounting.Accounting", "LockJournal")); + .insert( + GrpcMethod::new("komp_ac.accounting.Accounting", "CloseJournal"), + ); + self.inner.unary(req, path, codec).await + } + pub async fn reopen_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/ReopenJournal", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("komp_ac.accounting.Accounting", "ReopenJournal"), + ); self.inner.unary(req, path, codec).await } /// Return journal lines and credits-minus-debits informational balance. @@ -539,6 +711,213 @@ pub mod accounting_client { ); self.inner.unary(req, path, codec).await } + /// Create an open accounting period for a profile. Periods may be any length + /// (month, half-year, year). Overlapping ranges for the same profile are rejected. + pub async fn configure_accounting_period( + &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/ConfigureAccountingPeriod", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "ConfigureAccountingPeriod", + ), + ); + self.inner.unary(req, path, codec).await + } + /// Closing snapshots balances and blocks mutations through the period end. + /// A closed period may be reopened; approval makes it final. + pub async fn close_accounting_period( + &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/CloseAccountingPeriod", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "CloseAccountingPeriod", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn reopen_accounting_period( + &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/ReopenAccountingPeriod", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "ReopenAccountingPeriod", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn approve_accounting_period( + &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/ApproveAccountingPeriod", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "ApproveAccountingPeriod", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_accounting_period( + &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/GetAccountingPeriod", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "GetAccountingPeriod", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn list_accounting_periods( + &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/ListAccountingPeriods", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "ListAccountingPeriods", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn list_period_balances( + &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/ListPeriodBalances", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.Accounting", + "ListPeriodBalances", + ), + ); + self.inner.unary(req, path, codec).await + } } } /// Generated server implementations. @@ -560,11 +939,15 @@ 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( + /// Close a balanced journal. Closed journals can be reopened while their + /// accounting period is open. + async fn close_journal( &self, - request: tonic::Request, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + async fn reopen_journal( + &self, + request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Return journal lines and credits-minus-debits informational balance. async fn get_journal( @@ -601,9 +984,65 @@ pub mod accounting_server { &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; + /// Create an open accounting period for a profile. Periods may be any length + /// (month, half-year, year). Overlapping ranges for the same profile are rejected. + async fn configure_accounting_period( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Closing snapshots balances and blocks mutations through the period end. + /// A closed period may be reopened; approval makes it final. + async fn close_accounting_period( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn reopen_accounting_period( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn approve_accounting_period( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_accounting_period( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn list_accounting_periods( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn list_period_balances( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } /// Mutable informational journals. A journal may contain only debits, only /// credits, or any non-zero balance. Balance is reported but never enforced. + /// Accounting periods close date ranges inside a profile and freeze account sums + /// without replacing the live accounts projection. Closed periods can be reopened; + /// approved periods are final. #[derive(Debug)] pub struct AccountingServer { inner: Arc, @@ -725,13 +1164,13 @@ pub mod accounting_server { }; Box::pin(fut) } - "/komp_ac.accounting.Accounting/LockJournal" => { + "/komp_ac.accounting.Accounting/CloseJournal" => { #[allow(non_camel_case_types)] - struct LockJournalSvc(pub Arc); + struct CloseJournalSvc(pub Arc); impl< T: Accounting, - > tonic::server::UnaryService - for LockJournalSvc { + > tonic::server::UnaryService + for CloseJournalSvc { type Response = super::Journal; type Future = BoxFuture< tonic::Response, @@ -739,11 +1178,11 @@ pub mod accounting_server { >; fn call( &mut self, - request: tonic::Request, + request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::lock_journal(&inner, request).await + ::close_journal(&inner, request).await }; Box::pin(fut) } @@ -754,7 +1193,52 @@ pub mod accounting_server { let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { - let method = LockJournalSvc(inner); + let method = CloseJournalSvc(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/ReopenJournal" => { + #[allow(non_camel_case_types)] + struct ReopenJournalSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for ReopenJournalSvc { + 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 { + ::reopen_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 = ReopenJournalSvc(inner); let codec = tonic_prost::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config( @@ -998,6 +1482,339 @@ pub mod accounting_server { }; Box::pin(fut) } + "/komp_ac.accounting.Accounting/ConfigureAccountingPeriod" => { + #[allow(non_camel_case_types)] + struct ConfigureAccountingPeriodSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService< + super::ConfigureAccountingPeriodRequest, + > for ConfigureAccountingPeriodSvc { + type Response = super::AccountingPeriod; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::ConfigureAccountingPeriodRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::configure_accounting_period( + &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 = ConfigureAccountingPeriodSvc(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/CloseAccountingPeriod" => { + #[allow(non_camel_case_types)] + struct CloseAccountingPeriodSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for CloseAccountingPeriodSvc { + type Response = super::AccountingPeriod; + 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 { + ::close_accounting_period(&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 = CloseAccountingPeriodSvc(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/ReopenAccountingPeriod" => { + #[allow(non_camel_case_types)] + struct ReopenAccountingPeriodSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for ReopenAccountingPeriodSvc { + type Response = super::AccountingPeriod; + 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 { + ::reopen_accounting_period(&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 = ReopenAccountingPeriodSvc(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/ApproveAccountingPeriod" => { + #[allow(non_camel_case_types)] + struct ApproveAccountingPeriodSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for ApproveAccountingPeriodSvc { + type Response = super::AccountingPeriod; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::ApproveAccountingPeriodRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::approve_accounting_period( + &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 = ApproveAccountingPeriodSvc(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/GetAccountingPeriod" => { + #[allow(non_camel_case_types)] + struct GetAccountingPeriodSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for GetAccountingPeriodSvc { + type Response = super::AccountingPeriod; + 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_period(&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 = GetAccountingPeriodSvc(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/ListAccountingPeriods" => { + #[allow(non_camel_case_types)] + struct ListAccountingPeriodsSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for ListAccountingPeriodsSvc { + type Response = super::ListAccountingPeriodsResponse; + 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_accounting_periods(&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 = ListAccountingPeriodsSvc(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/ListPeriodBalances" => { + #[allow(non_camel_case_types)] + struct ListPeriodBalancesSvc(pub Arc); + impl< + T: Accounting, + > tonic::server::UnaryService + for ListPeriodBalancesSvc { + type Response = super::ListPeriodBalancesResponse; + 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_period_balances(&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 = ListPeriodBalancesSvc(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( diff --git a/server b/server index 3eda197..454acc6 160000 --- a/server +++ b/server @@ -1 +1 @@ -Subproject commit 3eda197a1fd2128273f8413ed0feb4683ec23da8 +Subproject commit 454acc6f2b0286b165188236f64b436dfa4a5555