accounting kernel4
This commit is contained in:
@@ -4,8 +4,9 @@ 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.
|
||||
service Accounting {
|
||||
// Create an empty journal and return its generated journal_id.
|
||||
rpc CreateJournal(CreateJournalRequest) returns (Journal);
|
||||
// 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);
|
||||
|
||||
// Return journal lines and credits-minus-debits informational balance.
|
||||
rpc GetJournal(GetJournalRequest) returns (Journal);
|
||||
@@ -17,9 +18,6 @@ service Accounting {
|
||||
rpc ListUnbalancedJournals(ListUnbalancedJournalsRequest)
|
||||
returns (ListUnbalancedJournalsResponse);
|
||||
|
||||
// Append one manual debit or credit line to an existing journal.
|
||||
rpc AddJournalLine(AddJournalLineRequest) returns (Journal);
|
||||
|
||||
// Soft-delete one line while retaining it for audit display.
|
||||
rpc SoftDeleteJournalLine(SoftDeleteJournalLineRequest) returns (Journal);
|
||||
}
|
||||
@@ -34,10 +32,30 @@ enum JournalSide {
|
||||
JOURNAL_SIDE_CREDIT = 2;
|
||||
}
|
||||
|
||||
message CreateJournalRequest {
|
||||
message PostJournalRequest {
|
||||
string profile_name = 1;
|
||||
string currency = 2;
|
||||
string description = 3;
|
||||
|
||||
// Absent creates a new journal. Present must identify an existing journal;
|
||||
// an unknown id is never treated as a request to create one.
|
||||
optional int64 journal_id = 2;
|
||||
|
||||
// Required when creating. When appending, empty uses the journal currency;
|
||||
// a supplied value must match it exactly.
|
||||
string currency = 3;
|
||||
|
||||
// Applied when creating and required to be empty when appending.
|
||||
string description = 4;
|
||||
|
||||
// At least one line is required. The lines are inserted atomically and the
|
||||
// journal is allowed to remain unbalanced.
|
||||
repeated JournalLineInput lines = 5;
|
||||
}
|
||||
|
||||
message JournalLineInput {
|
||||
JournalSide side = 1;
|
||||
string account_code = 2;
|
||||
string amount = 3;
|
||||
string description = 4;
|
||||
}
|
||||
|
||||
message GetJournalRequest {
|
||||
@@ -98,15 +116,6 @@ message ListUnbalancedJournalsResponse {
|
||||
string next_page_token = 3;
|
||||
}
|
||||
|
||||
message AddJournalLineRequest {
|
||||
string profile_name = 1;
|
||||
int64 journal_id = 2;
|
||||
JournalSide side = 3;
|
||||
string account_code = 4;
|
||||
string amount = 5;
|
||||
string description = 6;
|
||||
}
|
||||
|
||||
message SoftDeleteJournalLineRequest {
|
||||
string profile_name = 1;
|
||||
int64 journal_id = 2;
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,33 @@
|
||||
// This file is @generated by prost-build.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct CreateJournalRequest {
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct PostJournalRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub currency: ::prost::alloc::string::String,
|
||||
/// Absent creates a new journal. Present must identify an existing journal;
|
||||
/// an unknown id is never treated as a request to create one.
|
||||
#[prost(int64, optional, tag = "2")]
|
||||
pub journal_id: ::core::option::Option<i64>,
|
||||
/// Required when creating. When appending, empty uses the journal currency;
|
||||
/// a supplied value must match it exactly.
|
||||
#[prost(string, tag = "3")]
|
||||
pub currency: ::prost::alloc::string::String,
|
||||
/// Applied when creating and required to be empty when appending.
|
||||
#[prost(string, tag = "4")]
|
||||
pub description: ::prost::alloc::string::String,
|
||||
/// At least one line is required. The lines are inserted atomically and the
|
||||
/// journal is allowed to remain unbalanced.
|
||||
#[prost(message, repeated, tag = "5")]
|
||||
pub lines: ::prost::alloc::vec::Vec<JournalLineInput>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct JournalLineInput {
|
||||
#[prost(enumeration = "JournalSide", tag = "1")]
|
||||
pub side: i32,
|
||||
#[prost(string, tag = "2")]
|
||||
pub account_code: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub amount: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub description: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
@@ -87,21 +109,6 @@ pub struct ListUnbalancedJournalsResponse {
|
||||
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,
|
||||
#[prost(int64, tag = "2")]
|
||||
pub journal_id: i64,
|
||||
#[prost(enumeration = "JournalSide", tag = "3")]
|
||||
pub side: i32,
|
||||
#[prost(string, tag = "4")]
|
||||
pub account_code: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub amount: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "6")]
|
||||
pub description: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct SoftDeleteJournalLineRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
@@ -283,10 +290,11 @@ pub mod accounting_client {
|
||||
self.inner = self.inner.max_encoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
/// Create an empty journal and return its generated journal_id.
|
||||
pub async fn create_journal(
|
||||
/// 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.
|
||||
pub async fn post_journal(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::CreateJournalRequest>,
|
||||
request: impl tonic::IntoRequest<super::PostJournalRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::Journal>, tonic::Status> {
|
||||
self.inner
|
||||
.ready()
|
||||
@@ -298,13 +306,11 @@ pub mod accounting_client {
|
||||
})?;
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let path = http::uri::PathAndQuery::from_static(
|
||||
"/komp_ac.accounting.Accounting/CreateJournal",
|
||||
"/komp_ac.accounting.Accounting/PostJournal",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new("komp_ac.accounting.Accounting", "CreateJournal"),
|
||||
);
|
||||
.insert(GrpcMethod::new("komp_ac.accounting.Accounting", "PostJournal"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
/// Return journal lines and credits-minus-debits informational balance.
|
||||
@@ -389,30 +395,6 @@ pub mod accounting_client {
|
||||
);
|
||||
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,
|
||||
request: impl tonic::IntoRequest<super::AddJournalLineRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::Journal>, 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/AddJournalLine",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new("komp_ac.accounting.Accounting", "AddJournalLine"),
|
||||
);
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
/// Soft-delete one line while retaining it for audit display.
|
||||
pub async fn soft_delete_journal_line(
|
||||
&mut self,
|
||||
@@ -455,10 +437,11 @@ pub mod accounting_server {
|
||||
/// Generated trait containing gRPC methods that should be implemented for use with AccountingServer.
|
||||
#[async_trait]
|
||||
pub trait Accounting: std::marker::Send + std::marker::Sync + 'static {
|
||||
/// Create an empty journal and return its generated journal_id.
|
||||
async fn create_journal(
|
||||
/// 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.
|
||||
async fn post_journal(
|
||||
&self,
|
||||
request: tonic::Request<super::CreateJournalRequest>,
|
||||
request: tonic::Request<super::PostJournalRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::Journal>, tonic::Status>;
|
||||
/// Return journal lines and credits-minus-debits informational balance.
|
||||
async fn get_journal(
|
||||
@@ -481,11 +464,6 @@ pub mod accounting_server {
|
||||
tonic::Response<super::ListUnbalancedJournalsResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
/// Append one manual debit or credit line to an existing journal.
|
||||
async fn add_journal_line(
|
||||
&self,
|
||||
request: tonic::Request<super::AddJournalLineRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::Journal>, tonic::Status>;
|
||||
/// Soft-delete one line while retaining it for audit display.
|
||||
async fn soft_delete_journal_line(
|
||||
&self,
|
||||
@@ -570,13 +548,13 @@ pub mod accounting_server {
|
||||
}
|
||||
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||
match req.uri().path() {
|
||||
"/komp_ac.accounting.Accounting/CreateJournal" => {
|
||||
"/komp_ac.accounting.Accounting/PostJournal" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct CreateJournalSvc<T: Accounting>(pub Arc<T>);
|
||||
struct PostJournalSvc<T: Accounting>(pub Arc<T>);
|
||||
impl<
|
||||
T: Accounting,
|
||||
> tonic::server::UnaryService<super::CreateJournalRequest>
|
||||
for CreateJournalSvc<T> {
|
||||
> tonic::server::UnaryService<super::PostJournalRequest>
|
||||
for PostJournalSvc<T> {
|
||||
type Response = super::Journal;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
@@ -584,11 +562,11 @@ pub mod accounting_server {
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::CreateJournalRequest>,
|
||||
request: tonic::Request<super::PostJournalRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as Accounting>::create_journal(&inner, request).await
|
||||
<T as Accounting>::post_journal(&inner, request).await
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
@@ -599,7 +577,7 @@ 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 = CreateJournalSvc(inner);
|
||||
let method = PostJournalSvc(inner);
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let mut grpc = tonic::server::Grpc::new(codec)
|
||||
.apply_compression_config(
|
||||
@@ -752,51 +730,6 @@ pub mod accounting_server {
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
"/komp_ac.accounting.Accounting/AddJournalLine" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct AddJournalLineSvc<T: Accounting>(pub Arc<T>);
|
||||
impl<
|
||||
T: Accounting,
|
||||
> tonic::server::UnaryService<super::AddJournalLineRequest>
|
||||
for AddJournalLineSvc<T> {
|
||||
type Response = super::Journal;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::AddJournalLineRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move {
|
||||
<T as Accounting>::add_journal_line(&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 = AddJournalLineSvc(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/SoftDeleteJournalLine" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct SoftDeleteJournalLineSvc<T: Accounting>(pub Arc<T>);
|
||||
|
||||
Reference in New Issue
Block a user