ores.refdata.party
Table of Contents
Internal legal entities (the organisation and its subsidiaries) that
participate in financial transactions. Parties form a hierarchy through
parent_party_id, with exactly one root party per tenant representing the
organisation itself.
Flags
Cross-cutting properties. Consumed by both C++ and SQL codegen.
Primary key
UUID uniquely identifying this party.
Surrogate key for the party record.
Natural keys
Logical, human-meaningful identifiers. Inserted into the C++ struct alongside the primary key, and exposed in SQL as additional unique-indexed columns.
full_name
Full legal name of the party.
The official registered name of the entity.
std::string(faker::company::companyName())
short_code
Short code for quick reference.
A brief mnemonic code used in trading systems.
std::string(faker::string::alpha(6))
Columns
Regular columns. Inserted as struct fields in C++ and as table columns in SQL.
codename
Globally unique human-readable codename (adjective_noun).
Used as the per-party pgmq queue prefix, pg_cron job names, and operator tooling. Immutable once assigned; auto-generated by the SQL trigger if not supplied on insert.
std::string(faker::word::adjective()) + "_" + std::string(faker::word::noun())
transliterated_name
ASCII transliteration of the entity name.
Populated from GLEIF data for entities with non-Latin names (CJK, Cyrillic, Arabic, etc.). Null for entities already in Latin script.
std::nullopt
party_category
Structural classification of this party.
References the party_category lookup table. Values: 'System' (one per tenant, auto-created during provisioning) or 'Operational' (business entities created during normal system operation).
std::string("Operational")
party_type
Classification of this party.
References the party_type lookup table.
std::string("Corporate")
parent_party_id
Parent party for hierarchy.
References the parent party record for group structures. Null for root parties.
std::nullopt
business_center_code
Business center location code.
FpML business center code indicating primary location.
std::string("GBLO")
status
Current lifecycle status.
References the party_status lookup table.
std::string("Active")
SQL
Everything below is consumed by the SQL codegen pipeline only.
Flags
C++
Everything below is consumed by the C++ codegen pipeline only.
Flags
Repository
Domain includes
#include <chrono> #include <string> #include <optional> #include <boost/uuid/uuid.hpp>
Entity includes
#include <string> #include <optional> #include "sqlgen/Timestamp.hpp" #include "sqlgen/PrimaryKey.hpp"
Conventions
Table display
| column | header |
|---|---|
| short_code | Code |
| full_name | Name |
| party_type | Type |
| status | Status |
| business_center_code | Business Center |
| modified_by | Modified By |
| version | Version |
Qt
Detail fields
| field | label | widget | type | is_key | is_required | placeholder |
|---|---|---|---|---|---|---|
| short_code | Short Code | codeEdit | line_edit | true | true | Enter short code |
| full_name | Full Name | nameEdit | line_edit | false | true | Enter full name |
| party_type | Party Type | partyTypeEdit | line_edit | false | false | Enter party type |
| status | Status | statusEdit | line_edit | false | false | Enter status |
| business_center_code | Business Center | businessCenterEdit | line_edit | false | false | Enter business center code |
Columns (Qt model)
| enum_name | field | header | type | width |
|---|---|---|---|---|
| ShortCode | short_code | Code | string | 120 |
| FullName | full_name | Name | string | 250 |
| PartyType | party_type | Type | string | 120 |
| Status | status | Status | string | 100 |
| BusinessCenterCode | business_center_code | Business Center | string | 130 |
| Version | version | Version | int | 80 |
| ModifiedBy | modified_by | Modified By | string | 120 |
| RecordedAt | recorded_at | Recorded At | timestamp | 150 |
Custom repository methods
The four methods below are beyond the standard repository template because
they require: raw SQL access (read_system_party, read_descendants),
pagination with offset/limit (read_latest), or a count aggregate
(get_total_party_count). The codegen mechanism injects them at
template-rendered markers.
read_system_party
Calls ores_refdata_read_system_party_fn stored procedure. Every tenant has
exactly one system party (party_category'System'=) which serves as the
root of the party hierarchy.
std::vector<domain::party> read_system_party(context ctx, const std::string& tenant_id);
#include <boost/uuid/uuid_io.hpp> #include <boost/lexical_cast.hpp> #include "ores.utility/uuid/tenant_id.hpp"
std::vector<domain::party> party_repository::read_system_party(context ctx, const std::string& tenant_id) { BOOST_LOG_SEV(lg(), debug) << "Reading system party for tenant: " << tenant_id; const std::string sql = "SELECT * FROM ores_refdata_read_system_party_fn('" + tenant_id + "'::uuid)"; const auto rows = execute_raw_multi_column_query(ctx, sql, lg(), "Reading system party by tenant"); std::vector<domain::party> result; result.reserve(rows.size()); static constexpr std::array required_columns = {0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14}; for (const auto& row : rows) { if (row.size() >= 16 && std::ranges::all_of(required_columns, [&row](int i) { return static_cast<bool>(row[i]); })) { domain::party p; p.id = boost::lexical_cast<boost::uuids::uuid>(*row[0]); p.tenant_id = utility::uuid::tenant_id::from_string(*row[1]).value(); p.version = std::stoi(*row[2]); p.full_name = *row[3]; p.short_code = *row[4]; p.party_category = *row[5]; p.party_type = *row[6]; if (row[7]) p.parent_party_id = boost::lexical_cast<boost::uuids::uuid>(*row[7]); if (row[8]) p.business_center_code = *row[8]; p.status = *row[9]; p.modified_by = *row[10]; result.push_back(p); } } return result; }
read_latest_paginated
Paginated variant of read_latest. Returns at most limit rows starting
from offset, ordered by full_name. The template does not generate
pagination overloads.
std::vector<domain::party> read_latest(context ctx, std::uint32_t offset, std::uint32_t limit);
#include <cstdint>
std::vector<domain::party> party_repository::read_latest(context ctx, std::uint32_t offset, std::uint32_t limit) { BOOST_LOG_SEV(lg(), debug) << "Reading latest parties. Offset: " << offset << " limit: " << limit; static auto max(make_timestamp(MAX_TIMESTAMP, lg())); const auto query = sqlgen::read<std::vector<party_entity>> | where("valid_to"_c == max.value()) | order_by("full_name"_c) | sqlgen::offset(offset) | sqlgen::limit(limit); return execute_read_query<party_entity, domain::party>( ctx, query, [](const auto& entities) { return party_mapper::map(entities); }, lg(), "Reading latest parties with pagination."); }
get_total_party_count
Aggregate count of active parties (valid_to == infinity). Exposed for pagination total-available reporting.
std::uint32_t get_total_party_count(context ctx);
std::uint32_t party_repository::get_total_party_count(context ctx) { BOOST_LOG_SEV(lg(), debug) << "Getting total active party count"; static auto max(make_timestamp(MAX_TIMESTAMP, lg())); struct count_result { long long count; }; const auto query = sqlgen::select_from<party_entity>( sqlgen::count().as<"count">()) | where("valid_to"_c == max.value()) | sqlgen::to<count_result>; const auto r = sqlgen::session(ctx.connection_pool()).and_then(query); ensure_success(r, lg()); return static_cast<std::uint32_t>(r->count); }
read_descendants
Traverses the party hierarchy via a recursive CTE starting from root_id.
Returns the root plus every descendant (active records only).
std::vector<boost::uuids::uuid> read_descendants(context ctx, const boost::uuids::uuid& root_id);
#include <boost/uuid/uuid_io.hpp> #include <boost/lexical_cast.hpp>
std::vector<boost::uuids::uuid> party_repository::read_descendants(context ctx, const boost::uuids::uuid& root_id) { BOOST_LOG_SEV(lg(), debug) << "Reading party descendants. Root: " << root_id; const auto id_str = boost::uuids::to_string(root_id); const std::string sql = "WITH RECURSIVE party_tree AS (" " SELECT id FROM ores_refdata_parties_tbl" " WHERE id = '" + id_str + "' AND valid_to = '" + MAX_TIMESTAMP + "'" " UNION ALL" " SELECT p.id FROM ores_refdata_parties_tbl p" " JOIN party_tree pt ON p.parent_party_id = pt.id" " WHERE p.valid_to = '" + MAX_TIMESTAMP + "'" ") SELECT id FROM party_tree"; const auto rows = execute_raw_multi_column_query(ctx, sql, lg(), "Reading party descendants"); std::vector<boost::uuids::uuid> result; result.reserve(rows.size()); for (const auto& row : rows) if (!row.empty() && row[0]) result.push_back(boost::lexical_cast<boost::uuids::uuid>(*row[0])); return result; }
See also
- ores.refdata — component group overview.