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

@@ -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 {