ecb conversions with corrections2
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
syntax = "proto3";
|
||||
package komp_ac.accounting;
|
||||
|
||||
import "ecb.proto";
|
||||
|
||||
// Mutable informational journals. A journal may contain only debits, only
|
||||
// credits, or any non-zero balance. Balance is reported but never enforced.
|
||||
// Accounting periods close date ranges inside a profile and freeze account sums
|
||||
@@ -36,6 +38,10 @@ service Accounting {
|
||||
// Soft-delete one line while retaining it for audit display.
|
||||
rpc SoftDeleteJournalLine(SoftDeleteJournalLineRequest) returns (Journal);
|
||||
|
||||
// Atomically supersede active lines and append corrected replacements. The
|
||||
// originals and their conversion evidence remain immutable audit history.
|
||||
rpc CorrectJournal(CorrectJournalRequest) returns (Journal);
|
||||
|
||||
// Create an open accounting period for a profile. Periods may be any length
|
||||
// (month, half-year, year). Overlapping ranges for the same profile are rejected.
|
||||
rpc ConfigureAccountingPeriod(ConfigureAccountingPeriodRequest)
|
||||
@@ -151,12 +157,6 @@ message PostJournalRequest {
|
||||
// the latest closed or approved accounting boundary for the profile.
|
||||
string accounting_date = 7;
|
||||
|
||||
// Convert this posting with the profile's own rate for the publication date
|
||||
// instead of the ECB reference rate. False, the default, always uses ECB, even
|
||||
// where a custom rate for that date exists. True requires one to have been
|
||||
// entered: a missing rate is refused rather than silently converted at the
|
||||
// official rate. Ignored when nothing needs converting.
|
||||
bool use_custom_rate = 8;
|
||||
}
|
||||
|
||||
message JournalLineInput {
|
||||
@@ -165,6 +165,9 @@ message JournalLineInput {
|
||||
string account = 2;
|
||||
string amount = 3;
|
||||
string description = 4;
|
||||
// Empty uses previous publication and ECB. Set this per line when the
|
||||
// accountant needs a different rule, a saved custom rate, or a one-off rate.
|
||||
optional komp_ac.ecb.ExchangeRateSelection exchange_rate_selection = 5;
|
||||
}
|
||||
|
||||
message CloseJournalRequest {
|
||||
@@ -181,8 +184,8 @@ message GetJournalRequest {
|
||||
string profile_name = 1;
|
||||
int64 journal_id = 2;
|
||||
|
||||
// False by default. True is reserved for a future Casbin permission granted
|
||||
// only to superadmin and is rejected until that permission is implemented.
|
||||
// False returns the live journal. True also returns superseded/deleted lines
|
||||
// so an authorized journal reader can inspect the correction trail.
|
||||
bool include_deleted = 3;
|
||||
}
|
||||
|
||||
@@ -276,6 +279,24 @@ message SoftDeleteJournalLineRequest {
|
||||
int64 journal_line_id = 3;
|
||||
}
|
||||
|
||||
message CorrectJournalRequest {
|
||||
string profile_name = 1;
|
||||
int64 journal_id = 2;
|
||||
// One or more line replacements committed as a single correction. Batching
|
||||
// lets both sides of a closed balanced journal be corrected together.
|
||||
repeated JournalLineCorrection corrections = 3;
|
||||
}
|
||||
|
||||
message JournalLineCorrection {
|
||||
int64 journal_line_id = 1;
|
||||
// Full replacement line. Its amount is expressed in currency.
|
||||
JournalLineInput replacement = 2;
|
||||
string currency = 3;
|
||||
// Required independently of any exceptional exchange-rate reason and stored
|
||||
// permanently beside this original/replacement pair.
|
||||
string correction_reason = 4;
|
||||
}
|
||||
|
||||
message JournalLine {
|
||||
int64 id = 1;
|
||||
int32 line_number = 2;
|
||||
@@ -290,6 +311,15 @@ message JournalLine {
|
||||
string source_table_name = 10;
|
||||
int64 source_record_id = 11;
|
||||
int64 source_row_revision = 12;
|
||||
// Populated on a replacement created by CorrectJournal.
|
||||
int64 supersedes_line_id = 13;
|
||||
string correction_reason = 14;
|
||||
string corrected_by_user_id = 15;
|
||||
// Original foreign-currency input and immutable conversion evidence. Empty/
|
||||
// zero when the line did not require conversion.
|
||||
string original_amount = 16;
|
||||
string original_currency = 17;
|
||||
int64 conversion_evidence_id = 18;
|
||||
}
|
||||
|
||||
message Journal {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -3,6 +3,7 @@ syntax = "proto3";
|
||||
package komp_ac.tables_data;
|
||||
|
||||
import "common.proto";
|
||||
import "ecb.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
// Read and write row data for user-defined tables inside profiles (schemas).
|
||||
@@ -23,6 +24,11 @@ service TablesData {
|
||||
// - If the physical table is missing but the definition exists, returns INTERNAL
|
||||
rpc PostTableData(PostTableDataRequest) returns (PostTableDataResponse);
|
||||
|
||||
// Insert an ACCOUNTING-enabled source row with an explicit exchange-rate
|
||||
// treatment for the journal line created from it.
|
||||
rpc PostAccountingTableData(PostAccountingTableDataRequest)
|
||||
returns (PostTableDataResponse);
|
||||
|
||||
// Insert multiple rows by applying PostTableData behavior to each row.
|
||||
//
|
||||
// Behavior:
|
||||
@@ -46,6 +52,8 @@ service TablesData {
|
||||
// - Binds values with correct SQL types; rejects invalid formats/ranges
|
||||
// - Updates the row and returns the id; queues search indexing (best effort)
|
||||
rpc PutTableData(PutTableDataRequest) returns (PutTableDataResponse);
|
||||
rpc PutAccountingTableData(PutAccountingTableDataRequest)
|
||||
returns (PutTableDataResponse);
|
||||
|
||||
// Performs a PUT after the user explicitly accepted changing a referenced version.
|
||||
rpc PutTableDataConfirmed(PutTableDataConfirmedRequest) returns (PutTableDataResponse);
|
||||
@@ -139,6 +147,11 @@ message PostTableDataRequest {
|
||||
map<string, google.protobuf.Value> data = 3;
|
||||
}
|
||||
|
||||
message PostAccountingTableDataRequest {
|
||||
PostTableDataRequest row = 1;
|
||||
komp_ac.ecb.ExchangeRateSelection exchange_rate_selection = 2;
|
||||
}
|
||||
|
||||
// Insert response.
|
||||
message PostTableDataResponse {
|
||||
// True if the insert succeeded.
|
||||
@@ -210,6 +223,14 @@ message PutTableDataRequest {
|
||||
|
||||
// Required. Revision returned when this row was loaded or last saved.
|
||||
int64 expected_revision = 5;
|
||||
|
||||
}
|
||||
|
||||
message PutAccountingTableDataRequest {
|
||||
PutTableDataRequest update = 1;
|
||||
komp_ac.ecb.ExchangeRateSelection exchange_rate_selection = 2;
|
||||
bool confirmed = 3;
|
||||
repeated string expected_affected_profiles = 4;
|
||||
}
|
||||
|
||||
message PutTableDataConfirmedRequest {
|
||||
|
||||
Reference in New Issue
Block a user