currency per column in table definition

This commit is contained in:
Priec
2026-08-03 15:48:21 +02:00
parent 023f8c9dcb
commit 050f93e1fd
16 changed files with 87 additions and 105 deletions

View File

@@ -30,7 +30,6 @@ message AnalyticsTable {
string name = 2;
repeated AnalyticsCatalogColumn columns = 3;
repeated AnalyticsTableLink links = 4;
string base_currency = 5;
}
message AnalyticsCatalogColumn {
@@ -39,6 +38,8 @@ message AnalyticsCatalogColumn {
string field_type = 2;
bool is_system = 3;
string rounding = 4;
// Canonical ISO-4217 code for MONEY; empty for every other type.
string currency = 5;
}
message AnalyticsTableLink {

View File

@@ -83,9 +83,6 @@ message PostTableDefinitionRequest {
// like "public", "information_schema", or ones starting with "pg_".
string profile_name = 5;
// ISO-4217 base currency used by every MONEY column in this table.
string base_currency = 6;
// Columns whose values identify a row to users in pickers, in the order
// they are shown. Each must name one of the user-defined columns above.
// Empty means the row is identified by its id alone.
@@ -94,7 +91,7 @@ message PostTableDefinitionRequest {
// ISO-4217 currency the profile keeps its accounting in. A profile is one
// accounting entity and keeps one set of books, so this is required only when
// the request creates the profile, and is ignored afterwards. It is unrelated
// to base_currency: tables may hold money in any currency, and amounts convert
// to individual MONEY-column currencies: tables may hold money in any currency, and amounts convert
// to this one when they reach the ledger.
string accounting_currency = 8;
}
@@ -116,7 +113,6 @@ message CreateInvoiceTemplateTableRequest {
string profile_name = 1;
string table_name = 2;
string typst_source = 3;
string base_currency = 4;
repeated string row_display_columns = 5;
}
@@ -150,9 +146,6 @@ message AddTableColumnsRequest {
// Optional indexes for the new columns only.
repeated string indexes = 4;
// Required when adding the first MONEY column to a table.
string base_currency = 5;
}
enum MoneyRounding {
@@ -176,7 +169,7 @@ message ColumnDefinition {
// RAW_DATETIME (timezone-free civil datetime)
// PHONE (international or national phone number; generates extension/type/country/calling-code companions)
// TIME (timezone-free time of day)
// MONEY (= unconstrained NUMERIC; currency comes from the table)
// MONEY (= unconstrained NUMERIC; currency is declared below)
// ACCOUNTING (creates schema-managed name, account, debit, and credit fields;
// account always selects a row from the profile's managed accounts table;
// name is limited to 10 characters and one stored row contributes
@@ -197,6 +190,10 @@ message ColumnDefinition {
// When true, this numeric column is server-owned and projected from the
// profile quantity ledger.
bool quantity_ledger = 4;
// Canonical uppercase ISO-4217 currency code. Required for MONEY and forbidden
// for every other field type.
string currency = 5;
}
// Response after table creation (success + DDL preview).
@@ -299,7 +296,6 @@ message TableDetail {
int64 id = 2;
repeated ColumnDefinition columns = 3;
repeated ScriptInfo scripts = 4;
string base_currency = 5;
repeated string row_display_columns = 6;
map<string, ColumnBehavior> column_behaviors = 7;
string table_kind = 8;

View File

@@ -210,8 +210,8 @@ message HydratedColumnValue {
string value = 4;
// Logical database type used to create a typed client ScriptValue.
string field_type = 5;
// Related table's base currency for MONEY values; otherwise empty.
string base_currency = 6;
// Related MONEY column's currency; otherwise empty.
string currency = 6;
}
// One declared related-collection aggregate input for the client Steel context.
@@ -229,8 +229,8 @@ message HydratedAggregateValue {
string value = 5;
// Logical source-column type; empty for row-only aggregates.
string field_type = 6;
// Aggregate table's base currency for MONEY values; otherwise empty.
string base_currency = 7;
// Aggregated MONEY column's currency; otherwise empty.
string currency = 7;
}
// Complete external dependency snapshot for client-side Steel execution.

Binary file not shown.

View File

@@ -22,8 +22,6 @@ pub struct AnalyticsTable {
pub columns: ::prost::alloc::vec::Vec<AnalyticsCatalogColumn>,
#[prost(message, repeated, tag = "4")]
pub links: ::prost::alloc::vec::Vec<AnalyticsTableLink>,
#[prost(string, tag = "5")]
pub base_currency: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AnalyticsCatalogColumn {
@@ -36,6 +34,9 @@ pub struct AnalyticsCatalogColumn {
pub is_system: bool,
#[prost(string, tag = "4")]
pub rounding: ::prost::alloc::string::String,
/// Canonical ISO-4217 code for MONEY; empty for every other type.
#[prost(string, tag = "5")]
pub currency: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AnalyticsTableLink {

View File

@@ -42,9 +42,6 @@ pub struct PostTableDefinitionRequest {
/// like "public", "information_schema", or ones starting with "pg\_".
#[prost(string, tag = "5")]
pub profile_name: ::prost::alloc::string::String,
/// ISO-4217 base currency used by every MONEY column in this table.
#[prost(string, tag = "6")]
pub base_currency: ::prost::alloc::string::String,
/// Columns whose values identify a row to users in pickers, in the order
/// they are shown. Each must name one of the user-defined columns above.
/// Empty means the row is identified by its id alone.
@@ -53,7 +50,7 @@ pub struct PostTableDefinitionRequest {
/// ISO-4217 currency the profile keeps its accounting in. A profile is one
/// accounting entity and keeps one set of books, so this is required only when
/// the request creates the profile, and is ignored afterwards. It is unrelated
/// to base_currency: tables may hold money in any currency, and amounts convert
/// to individual MONEY-column currencies: tables may hold money in any currency, and amounts convert
/// to this one when they reach the ledger.
#[prost(string, tag = "8")]
pub accounting_currency: ::prost::alloc::string::String,
@@ -80,8 +77,6 @@ pub struct CreateInvoiceTemplateTableRequest {
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, repeated, tag = "5")]
pub row_display_columns: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
@@ -125,9 +120,6 @@ pub struct AddTableColumnsRequest {
/// Optional indexes for the new columns only.
#[prost(string, repeated, tag = "4")]
pub indexes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Required when adding the first MONEY column to a table.
#[prost(string, tag = "5")]
pub base_currency: ::prost::alloc::string::String,
}
/// Describes one user-defined column for a table.
#[derive(serde::Serialize, serde::Deserialize)]
@@ -147,7 +139,7 @@ pub struct ColumnDefinition {
/// RAW_DATETIME (timezone-free civil datetime)
/// PHONE (international or national phone number; generates extension/type/country/calling-code companions)
/// TIME (timezone-free time of day)
/// MONEY (= unconstrained NUMERIC; currency comes from the table)
/// MONEY (= unconstrained NUMERIC; currency is declared below)
/// ACCOUNTING (creates schema-managed name, account, debit, and credit fields;
/// account always selects a row from the profile's managed accounts table;
/// name is limited to 10 characters and one stored row contributes
@@ -169,6 +161,10 @@ pub struct ColumnDefinition {
/// profile quantity ledger.
#[prost(bool, tag = "4")]
pub quantity_ledger: bool,
/// Canonical uppercase ISO-4217 currency code. Required for MONEY and forbidden
/// for every other field type.
#[prost(string, tag = "5")]
pub currency: ::prost::alloc::string::String,
}
/// Response after table creation (success + DDL preview).
#[derive(serde::Serialize, serde::Deserialize)]
@@ -310,8 +306,6 @@ pub struct TableDetail {
pub columns: ::prost::alloc::vec::Vec<ColumnDefinition>,
#[prost(message, repeated, tag = "4")]
pub scripts: ::prost::alloc::vec::Vec<ScriptInfo>,
#[prost(string, tag = "5")]
pub base_currency: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "6")]
pub row_display_columns: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(map = "string, message", tag = "7")]

View File

@@ -168,9 +168,9 @@ pub struct HydratedColumnValue {
/// Logical database type used to create a typed client ScriptValue.
#[prost(string, tag = "5")]
pub field_type: ::prost::alloc::string::String,
/// Related table's base currency for MONEY values; otherwise empty.
/// Related MONEY column's currency; otherwise empty.
#[prost(string, tag = "6")]
pub base_currency: ::prost::alloc::string::String,
pub currency: ::prost::alloc::string::String,
}
/// One declared related-collection aggregate input for the client Steel context.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -194,9 +194,9 @@ pub struct HydratedAggregateValue {
/// Logical source-column type; empty for row-only aggregates.
#[prost(string, tag = "6")]
pub field_type: ::prost::alloc::string::String,
/// Aggregate table's base currency for MONEY values; otherwise empty.
/// Aggregated MONEY column's currency; otherwise empty.
#[prost(string, tag = "7")]
pub base_currency: ::prost::alloc::string::String,
pub currency: ::prost::alloc::string::String,
}
/// Complete external dependency snapshot for client-side Steel execution.
#[derive(Clone, PartialEq, ::prost::Message)]