moving balances of accounts between profiles - also other things in proto files

This commit is contained in:
Priec
2026-08-04 09:31:25 +02:00
parent f248a60b07
commit 0635e3bf10
6 changed files with 587 additions and 23 deletions

View File

@@ -7,6 +7,9 @@ package komp_ac.accounting;
// without replacing the live accounts projection. Closed periods can be reopened;
// approved periods are final.
service Accounting {
// Resolve or atomically create every node in a parsed account path.
rpc EnsureAccount(EnsureAccountRequest) returns (Account);
// Create a journal with its first lines when journal_id is absent, or append
// all supplied lines atomically when journal_id identifies an existing one.
rpc PostJournal(PostJournalRequest) returns (Journal);
@@ -53,6 +56,34 @@ service Accounting {
rpc ListAccountingPeriods(ListAccountingPeriodsRequest)
returns (ListAccountingPeriodsResponse);
rpc ListPeriodBalances(ListPeriodBalancesRequest) returns (ListPeriodBalancesResponse);
// Administratively map one account in a predecessor profile to one account
// in the current profile. Existing activity on the target account is allowed.
rpc MapOpeningBalanceAccount(MapOpeningBalanceAccountRequest)
returns (OpeningBalanceAccountMapping);
rpc UnmapOpeningBalanceAccount(UnmapOpeningBalanceAccountRequest)
returns (UnmapOpeningBalanceAccountResponse);
rpc ListOpeningBalanceAccounts(ListOpeningBalanceAccountsRequest)
returns (ListOpeningBalanceAccountsResponse);
}
message EnsureAccountRequest {
string profile_name = 1;
repeated string segments = 2;
// Currency accepted by source postings to the leaf account. Empty uses the
// profile accounting currency. Missing ancestors are created in the profile
// accounting currency.
string denomination_currency = 3;
}
message Account {
int64 id = 1;
optional int64 parent_account_id = 2;
string segment = 3;
// Root-to-leaf path of this account. Same shape as the request that created
// it; the server never joins segments into a delimited code.
repeated string segments = 4;
string denomination_currency = 5;
}
enum JournalSide {
@@ -91,8 +122,9 @@ message PostJournalRequest {
// an unknown id is never treated as a request to create one.
optional int64 journal_id = 2;
// Required when creating. When appending, empty uses the journal currency;
// a supplied value must match it exactly.
// Currency of the amounts supplied by this request. Required when creating;
// empty uses the profile accounting currency when appending. Journal amounts
// are stored and returned in the profile accounting currency.
string currency = 3;
// Applied when creating and required to be empty when appending.
@@ -242,7 +274,8 @@ message JournalLine {
int64 id = 1;
int32 line_number = 2;
JournalSide side = 3;
string account_code = 4;
// Root-to-leaf path of the posted account, as sent on JournalLineInput.
repeated string account_segments = 4;
string amount = 5;
string description = 6;
bool deleted = 7;
@@ -339,7 +372,8 @@ message ListPeriodBalancesRequest {
message PeriodBalance {
int64 period_id = 1;
string account_code = 2;
// Root-to-leaf path of the account this frozen balance belongs to.
repeated string account_segments = 2;
string currency = 3;
// Signed nets use debit-positive convention.
string opening_balance = 4;
@@ -351,3 +385,54 @@ message PeriodBalance {
message ListPeriodBalancesResponse {
repeated PeriodBalance balances = 1;
}
message MapOpeningBalanceAccountRequest {
// Open period whose profile receives the opening balance. Its configured
// previous_period_id identifies the source profile and period.
int64 target_period_id = 1;
repeated string source_account_segments = 2;
repeated string target_account_segments = 3;
}
message UnmapOpeningBalanceAccountRequest {
int64 target_period_id = 1;
repeated string target_account_segments = 2;
}
message UnmapOpeningBalanceAccountResponse {
bool removed = 1;
}
message ListOpeningBalanceAccountsRequest {
int64 target_period_id = 1;
}
enum OpeningBalanceStatus {
OPENING_BALANCE_STATUS_UNSPECIFIED = 0;
// The predecessor is still open, so its closed journal activity can change.
OPENING_BALANCE_STATUS_PROVISIONAL = 1;
// The value comes from the predecessor's frozen period snapshot.
OPENING_BALANCE_STATUS_FINAL = 2;
}
message OpeningBalanceAccountMapping {
int64 target_period_id = 1;
int64 source_period_id = 2;
string source_profile_name = 3;
repeated string source_account_segments = 4;
string target_profile_name = 5;
repeated string target_account_segments = 6;
string currency = 7;
// Signed balances use the debit-positive convention.
string opening_balance = 8;
string period_debit = 9;
string period_credit = 10;
string current_balance = 11;
OpeningBalanceStatus status = 12;
string created_at = 13;
string created_by_user_id = 14;
}
message ListOpeningBalanceAccountsResponse {
repeated OpeningBalanceAccountMapping mappings = 1;
}

View File

@@ -18,7 +18,7 @@ service EcbService {
returns (ListEcbConversionEvidenceResponse);
}
// Accounting date rule used to select an ECB publication.
// Conversion basis rule used to select an ECB publication.
enum EcbConversionContext {
ECB_CONVERSION_CONTEXT_UNSPECIFIED = 0;
ECB_CONVERSION_CONTEXT_ORDINARY_TRANSACTION = 1;
@@ -33,9 +33,10 @@ message PreviewEcbConversionRequest {
string original_currency = 2;
EcbConversionContext conversion_context = 3;
// ISO calendar date (YYYY-MM-DD). Its meaning is selected by
// conversion_context: transaction, statement, or decisive date.
string anchor_date = 4;
// 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;
// Required. Profile whose rates apply. Only consulted when use_custom_rate is
// set, but always required so a preview names the books it describes.
@@ -54,7 +55,7 @@ message PreviewEcbConversionResponse {
string original_currency = 2;
string eur_amount = 3;
EcbConversionContext conversion_context = 4;
string anchor_date = 5;
string conversion_basis_date = 5;
string determination_method = 6;
string rounding_method = 7;
optional string rate_date = 8;
@@ -107,7 +108,7 @@ message EcbConversionEvidence {
string original_currency = 4;
string eur_amount = 5;
string conversion_context = 6;
string anchor_date = 7;
string conversion_basis_date = 7;
string determination_method = 8;
string rounding_method = 9;
optional string rate_date = 10;