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;
}