Skip to content

Commit 2160f31

Browse files
jhfclaude
andcommitted
fix: Flip control/ownership primary_influencer_only semantics
The dbseed had control and ownership backwards: - Control (singular, hierarchy-forming) should be primary_influencer_only=TRUE - Ownership (shared, informational) should be primary_influencer_only=FALSE Swap type codes in demo CSVs to match: hierarchy-forming relationships are now 'control', shared stakes are now 'ownership'. Fix stale "50% or more" text in frontend import page — power groups form based on relationship type, not percentage thresholds. Fix nondeterministic ORDER BY in test 120 by adding lr.percentage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ec8126e commit 2160f31

File tree

7 files changed

+36
-34
lines changed

7 files changed

+36
-34
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
influencing_tax_ident,influenced_tax_ident,rel_type_code,percentage
2-
2407020166,2812760140,ownership,60
3-
2407020166,2602025168,control,100
4-
397611,397622,ownership,51
5-
2612760138,2507020167,ownership,75
6-
2200019,3300598,control,80
2+
2407020166,2812760140,control,60
3+
2407020166,2602025168,ownership,100
4+
397611,397622,control,51
5+
2612760138,2507020167,control,75
6+
2200019,3300598,ownership,80
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
influencing_tax_ident,influenced_tax_ident,rel_type_code,percentage,valid_from,valid_to
2-
2407020166,2812760140,ownership,40,2023-01-01,2023-12-31
3-
2407020166,2812760140,ownership,60,2024-01-01,2024-12-31
4-
2407020166,2812760140,ownership,60,2025-01-01,infinity
5-
2407020166,2602025168,control,100,2023-01-01,2023-12-31
6-
2407020166,2602025168,control,100,2024-01-01,2024-12-31
7-
2407020166,2602025168,control,100,2025-01-01,infinity
8-
397611,397622,ownership,34,2023-01-01,2023-12-31
9-
397611,397622,ownership,51,2024-01-01,2024-12-31
10-
397611,397622,ownership,51,2025-01-01,infinity
11-
2612760138,2507020167,ownership,75,2024-01-01,2024-12-31
12-
2612760138,2507020167,ownership,75,2025-01-01,infinity
13-
2200019,3300598,control,80,2023-01-01,2023-12-31
14-
2200019,3300598,control,80,2024-01-01,2024-12-31
15-
2200019,3300598,control,50,2025-01-01,infinity
2+
2407020166,2812760140,control,40,2023-01-01,2023-12-31
3+
2407020166,2812760140,control,60,2024-01-01,2024-12-31
4+
2407020166,2812760140,control,60,2025-01-01,infinity
5+
2407020166,2602025168,ownership,100,2023-01-01,2023-12-31
6+
2407020166,2602025168,ownership,100,2024-01-01,2024-12-31
7+
2407020166,2602025168,ownership,100,2025-01-01,infinity
8+
397611,397622,control,34,2023-01-01,2023-12-31
9+
397611,397622,control,51,2024-01-01,2024-12-31
10+
397611,397622,control,51,2025-01-01,infinity
11+
2612760138,2507020167,control,75,2024-01-01,2024-12-31
12+
2612760138,2507020167,control,75,2025-01-01,infinity
13+
2200019,3300598,ownership,80,2023-01-01,2023-12-31
14+
2200019,3300598,ownership,80,2024-01-01,2024-12-31
15+
2200019,3300598,ownership,50,2025-01-01,infinity

app/src/app/import/legal-relationships/page.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,22 @@ export default function LegalRelationshipsPage() {
117117
<AccordionTrigger>What is a Legal Relationship?</AccordionTrigger>
118118
<AccordionContent>
119119
<p className="mb-3">
120-
A <strong>Legal Relationship</strong> represents an ownership or
121-
control link between two Legal Units. When one Legal Unit owns 50%
122-
or more of another, they form part of a <strong>Power Group</strong>{" "}
123-
(a cluster of entities under common control).
120+
A <strong>Legal Relationship</strong> represents a control or
121+
ownership link between two Legal Units. Relationship types marked
122+
as hierarchy-forming (e.g. control) define{" "}
123+
<strong>Power Groups</strong> — clusters of entities under common
124+
control. Other types (e.g. ownership) record shared stakes without
125+
affecting the hierarchy.
124126
</p>
125127
</AccordionContent>
126128
</AccordionItem>
127129
<AccordionItem value="Legal Relationships File">
128130
<AccordionTrigger>What is a Legal Relationships file?</AccordionTrigger>
129131
<AccordionContent>
130132
<p className="mb-3">
131-
A Legal Relationships file is a CSV file containing ownership links.
132-
Each row specifies an influencing Legal Unit (owner), an influenced
133-
Legal Unit (owned), and an ownership percentage.
133+
A Legal Relationships file is a CSV file containing relationship
134+
links. Each row specifies an influencing Legal Unit, an influenced
135+
Legal Unit, a relationship type code, and an optional percentage.
134136
</p>
135137
<div className="flex flex-col space-y-2 pl-4">
136138
<a

migrations/20240428000000_generate_table_views_for_batch_api.up.psql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SET LOCAL client_min_messages TO INFO;
1414
\copy public.legal_rel_type_system(code, name, description) FROM 'dbseed/legal_rel_type.csv' WITH (FORMAT csv, DELIMITER ',', QUOTE '"', HEADER true);
1515

1616
-- Set primary_influencer_only (not supported by auto-generated _system view)
17-
UPDATE public.legal_rel_type SET primary_influencer_only = TRUE WHERE code = 'ownership';
18-
UPDATE public.legal_rel_type SET primary_influencer_only = FALSE WHERE code = 'control';
17+
UPDATE public.legal_rel_type SET primary_influencer_only = FALSE WHERE code = 'ownership';
18+
UPDATE public.legal_rel_type SET primary_influencer_only = TRUE WHERE code = 'control';
1919

2020
END;

test/expected/117_power_group_fundamentals.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ WHERE NOT EXISTS (SELECT 1 FROM public.legal_rel_type WHERE code = 'co_ownership
5353
SELECT code, name, description, primary_influencer_only FROM public.legal_rel_type ORDER BY code;
5454
code | name | description | primary_influencer_only
5555
----------------+----------------+----------------------------------------------------------------------------------+-------------------------
56-
control | Control | Controlling interest (may differ from ownership via voting rights or agreements) | f
56+
control | Control | Controlling interest (may differ from ownership via voting rights or agreements) | t
5757
co_ownership | Co-ownership | Shared ownership (multiple co-owners per entity) | f
58-
ownership | Ownership | Direct share ownership percentage | t
58+
ownership | Ownership | Direct share ownership percentage | f
5959
parent_company | Parent Company | Parent-subsidiary relationship (structurally 1:1 per subsidiary) | t
6060
(4 rows)
6161

test/expected/120_power_group_lifecycle.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ JOIN public.external_ident AS ei_ed ON ei_ed.legal_unit_id = lu_ed.id
668668
JOIN public.external_ident_type AS eit_ed ON eit_ed.id = ei_ed.type_id AND eit_ed.code = 'tax_ident'
669669
LEFT JOIN public.power_group AS pg ON pg.id = lr.power_group_id
670670
WHERE ei_ing.ident LIKE '30000000%'
671-
ORDER BY ei_ing.ident, ei_ed.ident;
671+
ORDER BY ei_ing.ident, ei_ed.ident, lr.percentage;
672672
influencing | influenced | percentage | power_group_ident
673673
-------------+------------+------------+-------------------
674674
300000001 | 300000002 | 80.00 | PG0004
@@ -822,7 +822,7 @@ JOIN public.external_ident_type AS eit_ed ON eit_ed.id = ei_ed.type_id AND eit_e
822822
LEFT JOIN public.power_group AS pg ON pg.id = lr.power_group_id
823823
WHERE ei_ing.ident LIKE '30000000%'
824824
AND lr.valid_range @> CURRENT_DATE
825-
ORDER BY ei_ing.ident, ei_ed.ident;
825+
ORDER BY ei_ing.ident, ei_ed.ident, lr.percentage;
826826
influencing | influenced | percentage | power_group_ident | valid_from
827827
-------------+------------+------------+-------------------+------------
828828
300000001 | 300000002 | 80.00 | PG0004 | 2023-01-01

test/sql/120_power_group_lifecycle.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ JOIN public.external_ident AS ei_ed ON ei_ed.legal_unit_id = lu_ed.id
496496
JOIN public.external_ident_type AS eit_ed ON eit_ed.id = ei_ed.type_id AND eit_ed.code = 'tax_ident'
497497
LEFT JOIN public.power_group AS pg ON pg.id = lr.power_group_id
498498
WHERE ei_ing.ident LIKE '30000000%'
499-
ORDER BY ei_ing.ident, ei_ed.ident;
499+
ORDER BY ei_ing.ident, ei_ed.ident, lr.percentage;
500500

501501
-- Save Round 1 PG idents for reuse verification in Phase 4
502502
CREATE TEMP TABLE _round1_pgs AS
@@ -596,7 +596,7 @@ JOIN public.external_ident_type AS eit_ed ON eit_ed.id = ei_ed.type_id AND eit_e
596596
LEFT JOIN public.power_group AS pg ON pg.id = lr.power_group_id
597597
WHERE ei_ing.ident LIKE '30000000%'
598598
AND lr.valid_range @> CURRENT_DATE
599-
ORDER BY ei_ing.ident, ei_ed.ident;
599+
ORDER BY ei_ing.ident, ei_ed.ident, lr.percentage;
600600

601601
-- ============================================================================
602602
-- PHASE 5: Pipeline Integration

0 commit comments

Comments
 (0)