ecb conversions with corrections2

This commit is contained in:
Priec
2026-08-13 11:41:28 +02:00
parent 8f8b5b4601
commit 774c9a3ce0
9 changed files with 569 additions and 112 deletions

View File

@@ -2,6 +2,39 @@ syntax = "proto3";
package komp_ac.ecb;
// How the publication date is selected from the accounting basis date.
enum ExchangeRateDateRule {
EXCHANGE_RATE_DATE_RULE_UNSPECIFIED = 0;
// Latest TARGET publication strictly before the basis date.
EXCHANGE_RATE_DATE_RULE_PREVIOUS_PUBLICATION = 1;
// Latest TARGET publication on or before the basis date.
EXCHANGE_RATE_DATE_RULE_ON_OR_BEFORE_DATE = 2;
// The exact publication date supplied in specific_rate_date.
EXCHANGE_RATE_DATE_RULE_SPECIFIC_PUBLICATION_DATE = 3;
}
enum ExchangeRateSource {
EXCHANGE_RATE_SOURCE_UNSPECIFIED = 0;
EXCHANGE_RATE_SOURCE_ECB = 1;
// A reusable rate from the profile's custom_exchange_rates table.
EXCHANGE_RATE_SOURCE_SAVED_CUSTOM = 2;
// A one-off rate recorded only in this posting's immutable evidence.
EXCHANGE_RATE_SOURCE_MANUAL = 3;
}
// Accountant-controlled conversion treatment. Exceptional choices remain
// explicit and auditable rather than being inferred from a legal label.
message ExchangeRateSelection {
ExchangeRateDateRule date_rule = 1;
ExchangeRateSource source = 2;
// Required for SPECIFIC_PUBLICATION_DATE and MANUAL; YYYY-MM-DD.
optional string specific_rate_date = 3;
// Required only for MANUAL. Exact foreign-currency units per EUR.
optional string manual_units_per_eur = 4;
// Required for SPECIFIC_PUBLICATION_DATE and MANUAL.
string reason = 5;
}
// Read-only access to ECB conversion previews and audit evidence.
//
// This service exists for manual visual verification before and after posting.
@@ -93,34 +126,21 @@ message GetEcbPipelineStatusResponse {
optional string statements_postable_through = 10;
}
// Conversion basis rule used to select an ECB publication.
enum EcbConversionContext {
ECB_CONVERSION_CONTEXT_UNSPECIFIED = 0;
ECB_CONVERSION_CONTEXT_ORDINARY_TRANSACTION = 1;
ECB_CONVERSION_CONTEXT_FINANCIAL_STATEMENT = 2;
ECB_CONVERSION_CONTEXT_DECISIVE_DATE = 3;
}
// Exact inputs for a conversion preview. Decimal values are strings so the
// client never loses precision through binary floating point.
message PreviewEcbConversionRequest {
string original_amount = 1;
string original_currency = 2;
EcbConversionContext conversion_context = 3;
// ISO calendar date (YYYY-MM-DD) from which the applicable publication date
// is derived. Its meaning is selected by conversion_context: transaction,
// statement, or decisive date.
string conversion_basis_date = 4;
// ISO calendar date (YYYY-MM-DD) of the accounting case.
string conversion_basis_date = 3;
// Required. Profile whose rates apply. Only consulted when use_custom_rate is
// set, but always required so a preview names the books it describes.
string profile_name = 5;
// Required. Profile whose rates apply. Consulted when the selection requests
// a saved custom rate, and always required so the preview names its books.
string profile_name = 4;
// Preview the profile's own rate for the publication date rather than the ECB
// reference rate. Must match what the posting will ask for, or the preview
// describes a conversion that will not happen.
bool use_custom_rate = 6;
// Empty uses previous publication and ECB.
optional ExchangeRateSelection exchange_rate_selection = 5;
}
// The conversion and immutable local ECB observation that would be used now.
@@ -129,26 +149,31 @@ message PreviewEcbConversionResponse {
string original_amount = 1;
string original_currency = 2;
string eur_amount = 3;
EcbConversionContext conversion_context = 4;
string conversion_basis_date = 5;
string determination_method = 6;
string rounding_method = 7;
optional string rate_date = 8;
optional string units_per_eur = 9;
optional int64 rate_observation_id = 10;
optional string observation_hash = 11;
optional string source_payload_hash = 12;
optional string rate_fetched_at = 13;
optional int64 import_batch_id = 14;
optional string source_endpoint = 15;
string conversion_basis_date = 4;
string determination_method = 5;
string rounding_method = 6;
optional string rate_date = 7;
optional string units_per_eur = 8;
optional int64 rate_observation_id = 9;
optional string observation_hash = 10;
optional string source_payload_hash = 11;
optional string rate_fetched_at = 12;
optional int64 import_batch_id = 13;
optional string source_endpoint = 14;
// Present only when determination_method is custom_rate. rate_date and
// units_per_eur then describe the hand-entered row identified here, and the
// ECB observation fields above are empty.
optional int64 custom_rate_table_definition_id = 16;
optional int64 custom_rate_record_id = 17;
optional int64 custom_rate_row_revision = 18;
optional string custom_rate_note = 19;
optional int64 custom_rate_table_definition_id = 15;
optional int64 custom_rate_record_id = 16;
optional int64 custom_rate_row_revision = 17;
optional string custom_rate_note = 18;
// Accountant-supplied justification for an exceptional publication date or
// one-off manual rate. Empty for the normal/default rule.
ExchangeRateDateRule applied_date_rule = 19;
ExchangeRateSource applied_source = 20;
string selection_reason = 21;
}
// Identify one logical money cell whose conversion history should be inspected.
@@ -203,11 +228,15 @@ message EcbConversionEvidence {
optional int64 custom_rate_record_id = 20;
optional int64 custom_rate_row_revision = 21;
optional string custom_rate_note = 22;
// Immutable audit data for an accountant-controlled exception.
string selection_reason = 23;
optional string selected_by_user_id = 24;
}
message ListEcbConversionEvidenceResponse {
// True when at least one evidence row for this cell used a rate, whether it
// came from ECB or from a hand-entered custom row.
// True when at least one evidence row for this cell used an ECB, saved
// custom, or one-off manual rate.
bool has_exchange = 1;
// Newest-first immutable history for this page.