diff --git a/common/proto/accounting.proto b/common/proto/accounting.proto index bc476a65..f2ad13b2 100644 --- a/common/proto/accounting.proto +++ b/common/proto/accounting.proto @@ -585,3 +585,178 @@ message ListOpeningBalanceAccountsResponse { repeated UnmappedSourceDenominationBalance unmapped_source_denomination_balances = 3; } + +// Implemented by financial_reports_basic. Module approvals and user read +// permissions for both the journal and account catalogue are required. +service FinancialReports { + rpc PreviewFinancialReports(FinancialReportRequest) returns (FinancialReportBundle); + // Saves immutable source data and results; requires a closed, reconciled period. + rpc FinalizeFinancialReports(FinancialReportRequest) returns (SavedFinancialReport); + rpc GetFinancialReport(GetFinancialReportRequest) returns (SavedFinancialReport); + rpc ListFinancialReports(ListFinancialReportsRequest) returns (ListFinancialReportsResponse); +} + +enum ReportStatementClass { + REPORT_STATEMENT_CLASS_UNSPECIFIED = 0; + REPORT_STATEMENT_CLASS_ASSETS = 1; + REPORT_STATEMENT_CLASS_EQUITY_AND_LIABILITIES = 2; + REPORT_STATEMENT_CLASS_EXPENSES = 3; + REPORT_STATEMENT_CLASS_REVENUE = 4; +} + +enum ReportBalanceSide { + REPORT_BALANCE_SIDE_UNSPECIFIED = 0; + REPORT_BALANCE_SIDE_DEBIT = 1; + REPORT_BALANCE_SIDE_CREDIT = 2; + REPORT_BALANCE_SIDE_EITHER = 3; +} + +enum FinancialReportBasis { + FINANCIAL_REPORT_BASIS_UNSPECIFIED = 0; + FINANCIAL_REPORT_BASIS_POSTED = 1; + FINANCIAL_REPORT_BASIS_BEFORE_TECHNICAL_CLOSING = 2; +} + +message FinancialReportRequest { + string profile_name = 1; + int64 period_id = 2; + // Must be chosen explicitly. The server never guesses closing journals. + FinancialReportBasis basis = 3; + // Verified technical transfers removed from all three reports. + repeated TechnicalClosingJournal closing_journals = 4; + // Zero selects period_id alone; otherwise report consecutive periods through period_id. + int64 first_period_id = 5; +} + +enum TechnicalClosingKind { + TECHNICAL_CLOSING_KIND_UNSPECIFIED = 0; + TECHNICAL_CLOSING_KIND_INCOME_TRANSFER = 1; + TECHNICAL_CLOSING_KIND_BALANCE_TRANSFER = 2; +} + +message TechnicalClosingJournal { + int64 journal_id = 1; + TechnicalClosingKind kind = 2; + // Explicit account identity, never inferred from account numbers or descriptions. + string closing_account = 3; +} + +message FinancialReportSourceRow { + repeated string account_segments = 1; + string denomination_currency = 2; + ReportStatementClass statement_class = 3; + ReportBalanceSide balance_side = 4; + // Aggregate amounts include descendants, in the profile bookkeeping currency. + string opening_balance = 5; + string period_debit = 6; + string period_credit = 7; + string closing_balance = 8; + // Direct movements of the explicitly selected closing journals only. + string excluded_debit = 9; + string excluded_credit = 10; +} + +message FinancialReportSource { + AccountingPeriod period = 1; + string currency = 2; + string account_catalogue = 3; + int64 account_catalogue_id = 4; + FinancialReportBasis basis = 5; + repeated TechnicalClosingJournal closing_journals = 6; + repeated FinancialReportSourceRow rows = 7; + // Actual period generations; period above describes their combined range. + repeated AccountingPeriod periods = 8; +} + +message FinancialStatementRow { + string account = 1; + ReportStatementClass statement_class = 2; + // Direct account amount, excluding descendants. Contra balances stay signed. + string amount = 3; +} + +message BalanceSheet { + repeated FinancialStatementRow rows = 1; + string assets = 2; + string equity_and_liabilities = 3; + // Negative N/V balances on the selected report basis. + string untransferred_result = 4; + // Assets minus equity/liabilities minus untransferred result. + string difference = 5; +} + +message ProfitAndLoss { + repeated FinancialStatementRow rows = 1; + string expenses = 2; + string revenue = 3; + string result = 4; +} + +enum FinancialReportIssueKind { + FINANCIAL_REPORT_ISSUE_KIND_UNSPECIFIED = 0; + FINANCIAL_REPORT_ISSUE_KIND_UNEXPECTED_BALANCE_SIDE = 1; + FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_OPENING = 2; + FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_MOVEMENT = 3; + FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_CLOSING = 4; + FINANCIAL_REPORT_ISSUE_KIND_UNADJUSTED_OPEN_PERIOD = 5; +} + +message FinancialReportIssue { + FinancialReportIssueKind kind = 1; + string account = 2; + string message = 3; +} + +message FinancialReportBundle { + uint32 calculation_version = 1; + FinancialReportSource source = 2; + GetTrialBalanceResponse trial_balance = 3; + BalanceSheet balance_sheet = 4; + ProfitAndLoss profit_and_loss = 5; + repeated FinancialReportIssue issues = 6; +} + +enum FinancialReportPeriodState { + FINANCIAL_REPORT_PERIOD_STATE_UNSPECIFIED = 0; + FINANCIAL_REPORT_PERIOD_STATE_SAME_CLOSED_PERIOD = 1; + FINANCIAL_REPORT_PERIOD_STATE_REOPENED_OR_CHANGED = 2; + FINANCIAL_REPORT_PERIOD_STATE_REMOVED = 3; +} + +message SavedFinancialReport { + int64 id = 1; + string created_at = 2; + string created_by_user_id = 3; + FinancialReportBundle report = 4; + // Only describes the period generation. Saved classifications are immutable + // even when the current account catalogue is edited later. + FinancialReportPeriodState period_state = 5; +} + +message GetFinancialReportRequest { + string profile_name = 1; + int64 report_id = 2; +} + +message ListFinancialReportsRequest { + string profile_name = 1; + // Exclusive cursor; zero starts at the newest report. + int64 before_id = 2; + uint32 limit = 3; +} + +message FinancialReportSummary { + int64 id = 1; + int64 period_id = 2; + string period_start = 3; + string period_end = 4; + string created_at = 5; + string created_by_user_id = 6; + uint32 calculation_version = 7; +} + +message ListFinancialReportsResponse { + repeated FinancialReportSummary reports = 1; + // Pass as before_id for the next page; zero when no more rows remain. + int64 next_before_id = 2; +} diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index b711dd99..589dddf9 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 4707807e..94ad863e 100644 --- a/common/src/proto/komp_ac.accounting.rs +++ b/common/src/proto/komp_ac.accounting.rs @@ -724,6 +724,208 @@ pub struct ListOpeningBalanceAccountsResponse { >, } #[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FinancialReportRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub period_id: i64, + /// Must be chosen explicitly. The server never guesses closing journals. + #[prost(enumeration = "FinancialReportBasis", tag = "3")] + pub basis: i32, + /// Verified technical transfers removed from all three reports. + #[prost(message, repeated, tag = "4")] + pub closing_journals: ::prost::alloc::vec::Vec, + /// Zero selects period_id alone; otherwise report consecutive periods through period_id. + #[prost(int64, tag = "5")] + pub first_period_id: i64, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct TechnicalClosingJournal { + #[prost(int64, tag = "1")] + pub journal_id: i64, + #[prost(enumeration = "TechnicalClosingKind", tag = "2")] + pub kind: i32, + /// Explicit account identity, never inferred from account numbers or descriptions. + #[prost(string, tag = "3")] + pub closing_account: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FinancialReportSourceRow { + #[prost(string, repeated, tag = "1")] + pub account_segments: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag = "2")] + pub denomination_currency: ::prost::alloc::string::String, + #[prost(enumeration = "ReportStatementClass", tag = "3")] + pub statement_class: i32, + #[prost(enumeration = "ReportBalanceSide", tag = "4")] + pub balance_side: i32, + /// Aggregate amounts include descendants, in the profile bookkeeping currency. + #[prost(string, tag = "5")] + pub opening_balance: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub period_debit: ::prost::alloc::string::String, + #[prost(string, tag = "7")] + pub period_credit: ::prost::alloc::string::String, + #[prost(string, tag = "8")] + pub closing_balance: ::prost::alloc::string::String, + /// Direct movements of the explicitly selected closing journals only. + #[prost(string, tag = "9")] + pub excluded_debit: ::prost::alloc::string::String, + #[prost(string, tag = "10")] + pub excluded_credit: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FinancialReportSource { + #[prost(message, optional, tag = "1")] + pub period: ::core::option::Option, + #[prost(string, tag = "2")] + pub currency: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub account_catalogue: ::prost::alloc::string::String, + #[prost(int64, tag = "4")] + pub account_catalogue_id: i64, + #[prost(enumeration = "FinancialReportBasis", tag = "5")] + pub basis: i32, + #[prost(message, repeated, tag = "6")] + pub closing_journals: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "7")] + pub rows: ::prost::alloc::vec::Vec, + /// Actual period generations; period above describes their combined range. + #[prost(message, repeated, tag = "8")] + pub periods: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FinancialStatementRow { + #[prost(string, tag = "1")] + pub account: ::prost::alloc::string::String, + #[prost(enumeration = "ReportStatementClass", tag = "2")] + pub statement_class: i32, + /// Direct account amount, excluding descendants. Contra balances stay signed. + #[prost(string, tag = "3")] + pub amount: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BalanceSheet { + #[prost(message, repeated, tag = "1")] + pub rows: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub assets: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub equity_and_liabilities: ::prost::alloc::string::String, + /// Negative N/V balances on the selected report basis. + #[prost(string, tag = "4")] + pub untransferred_result: ::prost::alloc::string::String, + /// Assets minus equity/liabilities minus untransferred result. + #[prost(string, tag = "5")] + pub difference: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProfitAndLoss { + #[prost(message, repeated, tag = "1")] + pub rows: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub expenses: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub revenue: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub result: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FinancialReportIssue { + #[prost(enumeration = "FinancialReportIssueKind", tag = "1")] + pub kind: i32, + #[prost(string, tag = "2")] + pub account: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub message: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FinancialReportBundle { + #[prost(uint32, tag = "1")] + pub calculation_version: u32, + #[prost(message, optional, tag = "2")] + pub source: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub trial_balance: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub balance_sheet: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub profit_and_loss: ::core::option::Option, + #[prost(message, repeated, tag = "6")] + pub issues: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SavedFinancialReport { + #[prost(int64, tag = "1")] + pub id: i64, + #[prost(string, tag = "2")] + pub created_at: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub created_by_user_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "4")] + pub report: ::core::option::Option, + /// Only describes the period generation. Saved classifications are immutable + /// even when the current account catalogue is edited later. + #[prost(enumeration = "FinancialReportPeriodState", tag = "5")] + pub period_state: i32, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetFinancialReportRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub report_id: i64, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ListFinancialReportsRequest { + #[prost(string, tag = "1")] + pub profile_name: ::prost::alloc::string::String, + /// Exclusive cursor; zero starts at the newest report. + #[prost(int64, tag = "2")] + pub before_id: i64, + #[prost(uint32, tag = "3")] + pub limit: u32, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FinancialReportSummary { + #[prost(int64, tag = "1")] + pub id: i64, + #[prost(int64, tag = "2")] + pub period_id: i64, + #[prost(string, tag = "3")] + pub period_start: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub period_end: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub created_at: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub created_by_user_id: ::prost::alloc::string::String, + #[prost(uint32, tag = "7")] + pub calculation_version: u32, +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListFinancialReportsResponse { + #[prost(message, repeated, tag = "1")] + pub reports: ::prost::alloc::vec::Vec, + /// Pass as before_id for the next page; zero when no more rows remain. + #[prost(int64, tag = "2")] + pub next_before_id: i64, +} +#[derive(serde::Serialize, serde::Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum JournalSide { @@ -858,6 +1060,233 @@ impl OpeningBalanceStatus { } } } +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ReportStatementClass { + Unspecified = 0, + Assets = 1, + EquityAndLiabilities = 2, + Expenses = 3, + Revenue = 4, +} +impl ReportStatementClass { + /// 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 => "REPORT_STATEMENT_CLASS_UNSPECIFIED", + Self::Assets => "REPORT_STATEMENT_CLASS_ASSETS", + Self::EquityAndLiabilities => "REPORT_STATEMENT_CLASS_EQUITY_AND_LIABILITIES", + Self::Expenses => "REPORT_STATEMENT_CLASS_EXPENSES", + Self::Revenue => "REPORT_STATEMENT_CLASS_REVENUE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "REPORT_STATEMENT_CLASS_UNSPECIFIED" => Some(Self::Unspecified), + "REPORT_STATEMENT_CLASS_ASSETS" => Some(Self::Assets), + "REPORT_STATEMENT_CLASS_EQUITY_AND_LIABILITIES" => { + Some(Self::EquityAndLiabilities) + } + "REPORT_STATEMENT_CLASS_EXPENSES" => Some(Self::Expenses), + "REPORT_STATEMENT_CLASS_REVENUE" => Some(Self::Revenue), + _ => None, + } + } +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ReportBalanceSide { + Unspecified = 0, + Debit = 1, + Credit = 2, + Either = 3, +} +impl ReportBalanceSide { + /// 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 => "REPORT_BALANCE_SIDE_UNSPECIFIED", + Self::Debit => "REPORT_BALANCE_SIDE_DEBIT", + Self::Credit => "REPORT_BALANCE_SIDE_CREDIT", + Self::Either => "REPORT_BALANCE_SIDE_EITHER", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "REPORT_BALANCE_SIDE_UNSPECIFIED" => Some(Self::Unspecified), + "REPORT_BALANCE_SIDE_DEBIT" => Some(Self::Debit), + "REPORT_BALANCE_SIDE_CREDIT" => Some(Self::Credit), + "REPORT_BALANCE_SIDE_EITHER" => Some(Self::Either), + _ => None, + } + } +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum FinancialReportBasis { + Unspecified = 0, + Posted = 1, + BeforeTechnicalClosing = 2, +} +impl FinancialReportBasis { + /// 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 => "FINANCIAL_REPORT_BASIS_UNSPECIFIED", + Self::Posted => "FINANCIAL_REPORT_BASIS_POSTED", + Self::BeforeTechnicalClosing => { + "FINANCIAL_REPORT_BASIS_BEFORE_TECHNICAL_CLOSING" + } + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "FINANCIAL_REPORT_BASIS_UNSPECIFIED" => Some(Self::Unspecified), + "FINANCIAL_REPORT_BASIS_POSTED" => Some(Self::Posted), + "FINANCIAL_REPORT_BASIS_BEFORE_TECHNICAL_CLOSING" => { + Some(Self::BeforeTechnicalClosing) + } + _ => None, + } + } +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum TechnicalClosingKind { + Unspecified = 0, + IncomeTransfer = 1, + BalanceTransfer = 2, +} +impl TechnicalClosingKind { + /// 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 => "TECHNICAL_CLOSING_KIND_UNSPECIFIED", + Self::IncomeTransfer => "TECHNICAL_CLOSING_KIND_INCOME_TRANSFER", + Self::BalanceTransfer => "TECHNICAL_CLOSING_KIND_BALANCE_TRANSFER", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "TECHNICAL_CLOSING_KIND_UNSPECIFIED" => Some(Self::Unspecified), + "TECHNICAL_CLOSING_KIND_INCOME_TRANSFER" => Some(Self::IncomeTransfer), + "TECHNICAL_CLOSING_KIND_BALANCE_TRANSFER" => Some(Self::BalanceTransfer), + _ => None, + } + } +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum FinancialReportIssueKind { + Unspecified = 0, + UnexpectedBalanceSide = 1, + UnbalancedOpening = 2, + UnbalancedMovement = 3, + UnbalancedClosing = 4, + UnadjustedOpenPeriod = 5, +} +impl FinancialReportIssueKind { + /// 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 => "FINANCIAL_REPORT_ISSUE_KIND_UNSPECIFIED", + Self::UnexpectedBalanceSide => { + "FINANCIAL_REPORT_ISSUE_KIND_UNEXPECTED_BALANCE_SIDE" + } + Self::UnbalancedOpening => "FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_OPENING", + Self::UnbalancedMovement => "FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_MOVEMENT", + Self::UnbalancedClosing => "FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_CLOSING", + Self::UnadjustedOpenPeriod => { + "FINANCIAL_REPORT_ISSUE_KIND_UNADJUSTED_OPEN_PERIOD" + } + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "FINANCIAL_REPORT_ISSUE_KIND_UNSPECIFIED" => Some(Self::Unspecified), + "FINANCIAL_REPORT_ISSUE_KIND_UNEXPECTED_BALANCE_SIDE" => { + Some(Self::UnexpectedBalanceSide) + } + "FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_OPENING" => { + Some(Self::UnbalancedOpening) + } + "FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_MOVEMENT" => { + Some(Self::UnbalancedMovement) + } + "FINANCIAL_REPORT_ISSUE_KIND_UNBALANCED_CLOSING" => { + Some(Self::UnbalancedClosing) + } + "FINANCIAL_REPORT_ISSUE_KIND_UNADJUSTED_OPEN_PERIOD" => { + Some(Self::UnadjustedOpenPeriod) + } + _ => None, + } + } +} +#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum FinancialReportPeriodState { + Unspecified = 0, + SameClosedPeriod = 1, + ReopenedOrChanged = 2, + Removed = 3, +} +impl FinancialReportPeriodState { + /// 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 => "FINANCIAL_REPORT_PERIOD_STATE_UNSPECIFIED", + Self::SameClosedPeriod => "FINANCIAL_REPORT_PERIOD_STATE_SAME_CLOSED_PERIOD", + Self::ReopenedOrChanged => { + "FINANCIAL_REPORT_PERIOD_STATE_REOPENED_OR_CHANGED" + } + Self::Removed => "FINANCIAL_REPORT_PERIOD_STATE_REMOVED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "FINANCIAL_REPORT_PERIOD_STATE_UNSPECIFIED" => Some(Self::Unspecified), + "FINANCIAL_REPORT_PERIOD_STATE_SAME_CLOSED_PERIOD" => { + Some(Self::SameClosedPeriod) + } + "FINANCIAL_REPORT_PERIOD_STATE_REOPENED_OR_CHANGED" => { + Some(Self::ReopenedOrChanged) + } + "FINANCIAL_REPORT_PERIOD_STATE_REMOVED" => Some(Self::Removed), + _ => None, + } + } +} /// Generated client implementations. pub mod accounting_client { #![allow( @@ -2976,3 +3405,572 @@ pub mod accounting_server { const NAME: &'static str = SERVICE_NAME; } } +/// Generated client implementations. +pub mod financial_reports_client { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + /// Implemented by financial_reports_basic. Module approvals and user read + /// permissions for both the journal and account catalogue are required. + #[derive(Debug, Clone)] + pub struct FinancialReportsClient { + inner: tonic::client::Grpc, + } + impl FinancialReportsClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl FinancialReportsClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + std::marker::Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> FinancialReportsClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, + { + FinancialReportsClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn preview_financial_reports( + &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.FinancialReports/PreviewFinancialReports", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.FinancialReports", + "PreviewFinancialReports", + ), + ); + self.inner.unary(req, path, codec).await + } + /// Saves immutable source data and results; requires a closed, reconciled period. + pub async fn finalize_financial_reports( + &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.FinancialReports/FinalizeFinancialReports", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.FinancialReports", + "FinalizeFinancialReports", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_financial_report( + &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.FinancialReports/GetFinancialReport", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.FinancialReports", + "GetFinancialReport", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn list_financial_reports( + &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.FinancialReports/ListFinancialReports", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "komp_ac.accounting.FinancialReports", + "ListFinancialReports", + ), + ); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod financial_reports_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with FinancialReportsServer. + #[async_trait] + pub trait FinancialReports: std::marker::Send + std::marker::Sync + 'static { + async fn preview_financial_reports( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Saves immutable source data and results; requires a closed, reconciled period. + async fn finalize_financial_reports( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_financial_report( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn list_financial_reports( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + /// Implemented by financial_reports_basic. Module approvals and user read + /// permissions for both the journal and account catalogue are required. + #[derive(Debug)] + pub struct FinancialReportsServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl FinancialReportsServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for FinancialReportsServer + where + T: FinancialReports, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + match req.uri().path() { + "/komp_ac.accounting.FinancialReports/PreviewFinancialReports" => { + #[allow(non_camel_case_types)] + struct PreviewFinancialReportsSvc(pub Arc); + impl< + T: FinancialReports, + > tonic::server::UnaryService + for PreviewFinancialReportsSvc { + type Response = super::FinancialReportBundle; + 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 { + ::preview_financial_reports( + &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 = PreviewFinancialReportsSvc(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.FinancialReports/FinalizeFinancialReports" => { + #[allow(non_camel_case_types)] + struct FinalizeFinancialReportsSvc(pub Arc); + impl< + T: FinancialReports, + > tonic::server::UnaryService + for FinalizeFinancialReportsSvc { + type Response = super::SavedFinancialReport; + 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 { + ::finalize_financial_reports( + &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 = FinalizeFinancialReportsSvc(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.FinancialReports/GetFinancialReport" => { + #[allow(non_camel_case_types)] + struct GetFinancialReportSvc(pub Arc); + impl< + T: FinancialReports, + > tonic::server::UnaryService + for GetFinancialReportSvc { + type Response = super::SavedFinancialReport; + 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_financial_report( + &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 = GetFinancialReportSvc(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.FinancialReports/ListFinancialReports" => { + #[allow(non_camel_case_types)] + struct ListFinancialReportsSvc(pub Arc); + impl< + T: FinancialReports, + > tonic::server::UnaryService + for ListFinancialReportsSvc { + type Response = super::ListFinancialReportsResponse; + 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_financial_reports( + &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 = ListFinancialReportsSvc(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( + tonic::body::Body::default(), + ); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } + } + } + } + impl Clone for FinancialReportsServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "komp_ac.accounting.FinancialReports"; + impl tonic::server::NamedService for FinancialReportsServer { + const NAME: &'static str = SERVICE_NAME; + } +}