map invoice with multioption select

This commit is contained in:
Priec
2026-07-21 22:55:25 +02:00
parent 2dc719e55b
commit 7c022daab5
6 changed files with 203 additions and 2 deletions

Binary file not shown.

View File

@@ -50,6 +50,58 @@ pub struct PostTableDefinitionRequest {
#[prost(string, tag = "7")]
pub row_display_column: ::prost::alloc::string::String,
}
/// Defines the input for explicitly creating a table backed by one invoice
/// template. typst_source must contain exactly one declaration of the form:
///
/// \#let komp_ac_fields = (
/// "invoice.number": (source: "local", field_type: "TEXT", write: "user"),
/// "items\[\].product": (source: "reference", table: "stock", required: true),
/// "items\[\].quantity": (source: "local", field_type: "DECIMAL(12,3)", write: "user"),
/// "items\[\].total": (source: "local", field_type: "MONEY", write: "script"),
/// )
///
/// Root fields create columns and references on table_name. Every \[\] collection
/// creates a child table with a required FK to its immediate parent; fields in
/// that collection create columns and references on the child table. Multiple
/// template paths in one scope may reuse the same reference.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CreateInvoiceTemplateTableRequest {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub table_name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub typst_source: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub base_currency: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub row_display_column: ::prost::alloc::string::String,
}
/// One physical dynamic table created for an invoice template scope. The root
/// has an empty collection_path and parent_table_name. Each \[\] scope names its
/// collection and the generated table that owns those repeated rows.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GeneratedInvoiceTemplateTable {
#[prost(string, tag = "1")]
pub table_name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub collection_path: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub parent_table_name: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub sql: ::prost::alloc::string::String,
}
/// Reports the complete table bundle created from one invoice template.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateInvoiceTemplateTableResponse {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(message, repeated, tag = "2")]
pub tables: ::prost::alloc::vec::Vec<GeneratedInvoiceTemplateTable>,
}
/// Defines append-only column additions for an existing table.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -481,6 +533,38 @@ pub mod table_definition_client {
);
self.inner.unary(req, path, codec).await
}
/// Creates a regular user-table bundle from the restricted komp_ac_fields
/// contract embedded in a Typst invoice template. This is invoked explicitly
/// by the user; templates do not provision tables merely by existing.
pub async fn create_invoice_template_table(
&mut self,
request: impl tonic::IntoRequest<super::CreateInvoiceTemplateTableRequest>,
) -> std::result::Result<
tonic::Response<super::CreateInvoiceTemplateTableResponse>,
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.table_definition.TableDefinition/CreateInvoiceTemplateTable",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"komp_ac.table_definition.TableDefinition",
"CreateInvoiceTemplateTable",
),
);
self.inner.unary(req, path, codec).await
}
/// Appends new user-defined columns to an existing table.
/// Existing columns, links, and table logic are never changed by this call.
pub async fn add_table_columns(
@@ -719,6 +803,16 @@ pub mod table_definition_server {
tonic::Response<super::TableDefinitionResponse>,
tonic::Status,
>;
/// Creates a regular user-table bundle from the restricted komp_ac_fields
/// contract embedded in a Typst invoice template. This is invoked explicitly
/// by the user; templates do not provision tables merely by existing.
async fn create_invoice_template_table(
&self,
request: tonic::Request<super::CreateInvoiceTemplateTableRequest>,
) -> std::result::Result<
tonic::Response<super::CreateInvoiceTemplateTableResponse>,
tonic::Status,
>;
/// Appends new user-defined columns to an existing table.
/// Existing columns, links, and table logic are never changed by this call.
async fn add_table_columns(
@@ -908,6 +1002,58 @@ pub mod table_definition_server {
};
Box::pin(fut)
}
"/komp_ac.table_definition.TableDefinition/CreateInvoiceTemplateTable" => {
#[allow(non_camel_case_types)]
struct CreateInvoiceTemplateTableSvc<T: TableDefinition>(pub Arc<T>);
impl<
T: TableDefinition,
> tonic::server::UnaryService<
super::CreateInvoiceTemplateTableRequest,
> for CreateInvoiceTemplateTableSvc<T> {
type Response = super::CreateInvoiceTemplateTableResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::CreateInvoiceTemplateTableRequest,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TableDefinition>::create_invoice_template_table(
&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 = CreateInvoiceTemplateTableSvc(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.table_definition.TableDefinition/AddTableColumns" => {
#[allow(non_camel_case_types)]
struct AddTableColumnsSvc<T: TableDefinition>(pub Arc<T>);