Skip to content

Commit 2b6742d

Browse files
authored
Merge pull request #2290: fix(portfolio): contracts count toward a usage again; contract page shows its supplier (REQ-CLR-014, REQ-CLR-016)
Merged by the stackiq merge lane after local green against development. cloud-merge-stackiq Assisted-by: ClaudeCode:claude-opus-5-5
2 parents 521ee1f + 50acbc8 commit 2b6742d

12 files changed

Lines changed: 563 additions & 21 deletions

File tree

‎l10n/en.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,11 @@
25112511
"No connections to draw": "No connections to draw",
25122512
"Diagram": "Diagram",
25132513
"Anyone can read this pentest report, also without an account. Publish it publicly?": "Anyone can read this pentest report, also without an account. Publish it publicly?",
2514-
"Publish publicly": "Publish publicly"
2514+
"Publish publicly": "Publish publicly",
2515+
"Loading the supplier": "Loading the supplier",
2516+
"The supplier could not be loaded.": "The supplier could not be loaded.",
2517+
"Through the service": "Through the service",
2518+
"The service of this contract names no supplier.": "The service of this contract names no supplier.",
2519+
"This contract names no service, so its supplier is not known.": "This contract names no service, so its supplier is not known."
25152520
}
25162521
}

‎l10n/nl.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2536,7 +2536,12 @@ OC.L10N.register(
25362536
"Failed to add contact person: {error}": "Contactpersoon toevoegen mislukt: {error}",
25372537
"Invalid contact person data structure": "Ongeldige gegevensstructuur van de contactpersoon",
25382538
"Anyone can read this pentest report, also without an account. Publish it publicly?": "Iedereen kan dit pentestrapport lezen, ook zonder account. Openbaar publiceren?",
2539-
"Publish publicly": "Openbaar publiceren"
2539+
"Publish publicly": "Openbaar publiceren",
2540+
"Loading the supplier": "Leverancier laden",
2541+
"The supplier could not be loaded.": "De leverancier kon niet worden geladen.",
2542+
"Through the service": "Via de dienst",
2543+
"The service of this contract names no supplier.": "De dienst van dit contract noemt geen leverancier.",
2544+
"This contract names no service, so its supplier is not known.": "Dit contract noemt geen dienst, dus de leverancier is niet bekend."
25402545
},
25412546
"nplurals=2; plural=(n != 1);"
25422547
)

‎l10n/nl.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,11 @@
25772577
"Failed to add contact person: {error}": "Contactpersoon toevoegen mislukt: {error}",
25782578
"Invalid contact person data structure": "Ongeldige gegevensstructuur van de contactpersoon",
25792579
"Anyone can read this pentest report, also without an account. Publish it publicly?": "Iedereen kan dit pentestrapport lezen, ook zonder account. Openbaar publiceren?",
2580-
"Publish publicly": "Openbaar publiceren"
2580+
"Publish publicly": "Openbaar publiceren",
2581+
"Loading the supplier": "Leverancier laden",
2582+
"The supplier could not be loaded.": "De leverancier kon niet worden geladen.",
2583+
"Through the service": "Via de dienst",
2584+
"The service of this contract names no supplier.": "De dienst van dit contract noemt geen leverancier.",
2585+
"This contract names no service, so its supplier is not known.": "Dit contract noemt geen dienst, dus de leverancier is niet bekend."
25812586
}
25822587
}

‎lib/Service/PortfolioReportDerivation.php‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,16 @@ public function parseDate(mixed $value): ?DateTimeImmutable {
261261
* Normalize OpenRegister search results (ObjectEntity or plain array)
262262
* into plain data-bag arrays.
263263
*
264+
* An entity's getObject() holds its properties only, so the organisation
265+
* that owns the row is carried over as `_organisation`: the report costs
266+
* only the contracts the reporting organisation owns, and without it every
267+
* contract read from an entity was dropped.
268+
*
264269
* @param array<int,mixed> $results Raw search results.
265270
*
266271
* @return array<int,array<string,mixed>> Normalized data bags.
267272
*
268-
* @spec openspec/changes/portfolio-rationalization-time/specs/portfolio-rationalization-time/spec.md#requirement-report-aggregation-queries-are-bounded
273+
* @spec openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/application-value-assessment/spec.md#requirement-the-portfolio-report-shows-each-usage-s-yearly-cost-beside-its-value-and-risk-scores-req-clr-016
269274
*/
270275
public function normalizeResults(array $results): array {
271276
return array_map(
@@ -274,11 +279,19 @@ static function ($object) {
274279
return $object;
275280
}
276281

277-
if (is_object($object) === true && method_exists($object, 'getObject') === true) {
278-
return $object->getObject();
282+
if (is_object($object) === false || method_exists($object, 'getObject') === false) {
283+
return [];
284+
}
285+
286+
$data = $object->getObject();
287+
if (isset($data['_organisation']) === false
288+
&& isset($data['@self']['organisation']) === false
289+
&& method_exists($object, 'getOrganisation') === true
290+
) {
291+
$data['_organisation'] = $object->getOrganisation();
279292
}
280293

281-
return [];
294+
return $data;
282295
},
283296
$results
284297
);

‎openspec/changes/capability-rows-the-code-does-not-yet-meet/tasks.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@
6969
- **files**: `tests/e2e/workflows/catalog-ratings.spec.ts`, `tests/e2e/workflows/vulnerabilities.spec.ts`, `tests/e2e/workflows/bulk-actions.spec.ts`, `tests/e2e/workflows/connections.spec.ts`, `tests/e2e/workflows/contracts.spec.ts`, `tests/e2e/workflows/federation-settings.spec.ts`, `tests/e2e/workflows/portfolio-report.spec.ts`, `tests/Unit/Settings/FieldUpdateRulesTest.php`
7070
- **acceptance_criteria**:
7171
- REQ-CLR-005, 009, 011, 013, 014, 015, 016 and 017 each have a test that passes against the current code
72-
- [ ] Test
72+
- [x] Test
7373
- Progress 21 Nov: `tests/e2e/workflows/catalog-ratings.spec.ts` (REQ-CLR-009) is written; like the other specs this task lists, it has not run against a live instance yet.
7474
- Progress 23 Nov: `tests/Unit/Settings/FieldUpdateRulesTest.php` (REQ-CLR-017) is written and passes: the import key is updated by admins only and stays readable, the maintenance notification fields declare their update group, the application keeps its own rules, and every field-level update rule is well formed. The task stays open until the e2e specs run against a live instance.
7575
- Live 25 Nov 2026 (sandbox Nextcloud 34, PostgreSQL 16, OpenRegister main, stackiq development): passing REQ-CLR-009 `catalog-ratings.spec.ts` 1/1, REQ-CLR-005 `vulnerabilities.spec.ts` 1/1, REQ-CLR-011 `bulk-actions.spec.ts` 1/1, REQ-CLR-013 `connections.spec.ts` 4/4, REQ-CLR-015 `federation-settings.spec.ts` 2/2 (specs corrected to the page: required seed fields, the in-production start date, the record sidebar, the row link, below-the-fold widgets, the Actions menu, the switch role), REQ-CLR-017 `FieldUpdateRulesTest`. Still open: REQ-CLR-014 (`contracts.spec.ts` stays `test.fixme`: the contract page shows no supplier, a product gap) and REQ-CLR-016 (`portfolio-report.spec.ts`: the report costs only contracts owned by the selected organisation, and the seed's contract belongs to the admin's organisation; creating it inside the municipality's organisation is refused because the register's schemas do not resolve there).
7676

77+
- Built 26 Nov 2026 (REQ-CLR-014): the contract page shows its supplier. `ContractSupplierPanel` (a ContractDetail body widget, `ct-supplier`) reads the contract, then its service, then the service's provider, and links the supplier's name to OrganisatieDetail; it says so when the contract names no service or the service no supplier. vitest `tests/vitest/contractSupplierPanel.spec.js`; `contracts.spec.ts` is no longer fixme and passes live 1/1 (26 Nov 2026, sandbox Nextcloud 34.0.6, PostgreSQL 16, OpenRegister main 01e805cd + openregister#11305; seed corrected to the required catalogService.type and catalogContract.usage, status In negotiation because Active needs an approved decision). REQ-CLR-016 also passes live 1/1 the same day: `portfolio-report.spec.ts` seeds the municipality as an OpenRegister organisation (same uuid) and moves the contract into it, and `PortfolioReportDerivation::normalizeResults()` now keeps an entity's owning organisation (`_organisation`); before, `ownedContracts()` dropped every contract read as an entity, so no usage ever showed a cost. PHPUnit `PortfolioReportDerivationGoldenTest::testNormalizedEntityKeepsItsOwningOrganisation`. Every REQ this task names now has a passing test, so Test is ticked.
78+
7779
### Task 11: Open a vulnerability on its own page with the exposed organisations
7880
- **spec_ref**: openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/module-vulnerability-tracking/spec.md
7981
- **files**: `src/views/KwetsbaarhedenView.vue` (row opens KwetsbaarheidDetail, not the generic modal), `src/manifest.json` (VulnerabilityExposurePanel)
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
3+
- SPDX-License-Identifier: EUPL-1.2
4+
-->
5+
<template>
6+
<CnWidgetWrapper
7+
:title="t('stackiq', 'Supplier')"
8+
titleIconPosition="left"
9+
:showRefresh="false"
10+
:showRequestFeature="false">
11+
<template #title-icon>
12+
<CnIcon name="OfficeBuildingOutline" :size="20" />
13+
</template>
14+
<section class="contract-supplier-panel" data-testid="contract-supplier-panel">
15+
<NcLoadingIcon
16+
v-if="loading"
17+
:size="32"
18+
:name="t('stackiq', 'Loading the supplier')" />
19+
<NcNoteCard v-else-if="error" type="error">
20+
{{ t('stackiq', 'The supplier could not be loaded.') }}
21+
</NcNoteCard>
22+
<p
23+
v-else-if="!supplier"
24+
class="contract-supplier-panel__empty"
25+
data-testid="contract-supplier-empty">
26+
{{ emptyLabel }}
27+
</p>
28+
<dl v-else class="contract-supplier-panel__fields">
29+
<div>
30+
<dt>{{ t('stackiq', 'Supplier') }}</dt>
31+
<dd data-testid="contract-supplier-name">
32+
<router-link :to="supplierRoute">
33+
{{ supplier.name }}
34+
</router-link>
35+
</dd>
36+
</div>
37+
<div v-if="service && service.name">
38+
<dt>{{ t('stackiq', 'Through the service') }}</dt>
39+
<dd>{{ service.name }}</dd>
40+
</div>
41+
</dl>
42+
</section>
43+
</CnWidgetWrapper>
44+
</template>
45+
46+
<script>
47+
/**
48+
* The supplier of a contract (REQ-CLR-014): a contract names the service it
49+
* is for, and that service names its provider, so the panel reads the three
50+
* records in turn and links the provider to its organisation page.
51+
*/
52+
import { CnIcon, CnWidgetWrapper } from '@conduction/nextcloud-vue'
53+
import axios from '@nextcloud/axios'
54+
import { translate as t } from '@nextcloud/l10n'
55+
import { generateUrl } from '@nextcloud/router'
56+
import { NcLoadingIcon, NcNoteCard } from '@nextcloud/vue'
57+
58+
/**
59+
* The object in an OpenRegister object reply: the body itself when it
60+
* carries `@self`, else its `object`, else the body, else an empty object.
61+
*
62+
* @param {object|null} data The reply body.
63+
* @return {object} The object.
64+
*/
65+
function objectOf(data) {
66+
return data && data['@self'] !== undefined ? data : data?.object || data || {}
67+
}
68+
69+
/**
70+
* The id a reference property holds: a uuid string, or the `id` (or
71+
* `@self.id`) of an expanded object. Empty when the property is unset.
72+
*
73+
* @param {string|object|null|undefined} value The property value.
74+
* @return {string} The referenced id, or ''.
75+
* @spec openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/vendor-product-master-data/spec.md#requirement-a-contract-shows-its-supplier-through-the-service-it-is-for-req-clr-014
76+
*/
77+
export function referenceId(value) {
78+
if (typeof value === 'string') {
79+
return value.trim()
80+
}
81+
if (value && typeof value === 'object') {
82+
const id = value.id ?? value['@self']?.id ?? value.uuid
83+
return id === undefined || id === null ? '' : String(id).trim()
84+
}
85+
return ''
86+
}
87+
88+
export default {
89+
name: 'ContractSupplierPanel',
90+
components: {
91+
CnIcon,
92+
CnWidgetWrapper,
93+
NcLoadingIcon,
94+
NcNoteCard,
95+
},
96+
97+
props: {
98+
objectId: {
99+
type: [String, Number],
100+
default: '',
101+
},
102+
103+
register: {
104+
type: String,
105+
default: 'stackiq',
106+
},
107+
108+
schema: {
109+
type: String,
110+
default: 'catalogContract',
111+
},
112+
113+
serviceSchema: {
114+
type: String,
115+
default: 'catalogService',
116+
},
117+
118+
organisationSchema: {
119+
type: String,
120+
default: 'organization',
121+
},
122+
},
123+
124+
data() {
125+
return {
126+
loading: true,
127+
error: false,
128+
service: null,
129+
supplier: null,
130+
hasService: false,
131+
}
132+
},
133+
134+
computed: {
135+
/**
136+
* The supplier's organisation page.
137+
*
138+
* @return {object} The route.
139+
* @spec openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/vendor-product-master-data/spec.md#requirement-a-contract-shows-its-supplier-through-the-service-it-is-for-req-clr-014
140+
*/
141+
supplierRoute() {
142+
return { name: 'OrganisatieDetail', params: { id: String(this.supplier?.id ?? '') } }
143+
},
144+
145+
/**
146+
* Why no supplier shows: the contract names no service, or its service no provider.
147+
*
148+
* @return {string} The translated line.
149+
* @spec openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/vendor-product-master-data/spec.md#requirement-a-contract-shows-its-supplier-through-the-service-it-is-for-req-clr-014
150+
*/
151+
emptyLabel() {
152+
return this.hasService
153+
? t('stackiq', 'The service of this contract names no supplier.')
154+
: t('stackiq', 'This contract names no service, so its supplier is not known.')
155+
},
156+
},
157+
158+
async mounted() {
159+
await this.load()
160+
},
161+
162+
methods: {
163+
t,
164+
165+
/**
166+
* Read the contract, then its service, then the service's provider.
167+
*
168+
* @return {Promise<void>} Resolves once the supplier is read or known to be absent.
169+
* @spec openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/vendor-product-master-data/spec.md#requirement-a-contract-shows-its-supplier-through-the-service-it-is-for-req-clr-014
170+
*/
171+
async load() {
172+
this.loading = true
173+
this.error = false
174+
this.service = null
175+
this.supplier = null
176+
this.hasService = false
177+
try {
178+
if (!this.objectId) {
179+
return
180+
}
181+
const contract = await this.fetchObject(this.schema, String(this.objectId))
182+
const serviceId = referenceId(contract.service)
183+
if (serviceId === '') {
184+
return
185+
}
186+
this.hasService = true
187+
const service = await this.fetchObject(this.serviceSchema, serviceId)
188+
this.service = { id: serviceId, name: service.name || '' }
189+
const providerId = referenceId(service.provider)
190+
if (providerId === '') {
191+
return
192+
}
193+
const provider = await this.fetchObject(this.organisationSchema, providerId)
194+
this.supplier = { id: providerId, name: provider.name || provider.title || providerId }
195+
} catch {
196+
this.error = true
197+
} finally {
198+
this.loading = false
199+
}
200+
},
201+
202+
/**
203+
* Fetch one object of this register, unwrapped from its envelope.
204+
*
205+
* @param {string} schema The schema slug.
206+
* @param {string} id The object id.
207+
* @return {Promise<object>} The object.
208+
* @spec openspec/changes/capability-rows-the-code-does-not-yet-meet/specs/vendor-product-master-data/spec.md#requirement-a-contract-shows-its-supplier-through-the-service-it-is-for-req-clr-014
209+
*/
210+
async fetchObject(schema, id) {
211+
const url = generateUrl(
212+
'/apps/openregister/api/objects/{register}/{schema}/{id}',
213+
{ register: this.register, schema, id },
214+
)
215+
const { data } = await axios.get(url)
216+
return objectOf(data)
217+
},
218+
},
219+
}
220+
</script>
221+
222+
<style scoped>
223+
.contract-supplier-panel__fields {
224+
display: grid;
225+
grid-template-columns: repeat(2, minmax(0, 1fr));
226+
gap: 8px;
227+
margin: 0;
228+
}
229+
230+
.contract-supplier-panel__fields dt,
231+
.contract-supplier-panel__empty {
232+
color: var(--color-text-maxcontrast);
233+
}
234+
235+
.contract-supplier-panel__fields dd {
236+
margin: 0;
237+
}
238+
</style>

‎src/customComponents.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import ConnectionSuggestionsPanel from './components/connections/ConnectionSugge
3030
import ApplicationContractsPanel from './components/contracts/ApplicationContractsPanel.vue'
3131
import ContractApprovalPanel from './components/contracts/ContractApprovalPanel.vue'
3232
import ContractSeatsPanel from './components/contracts/ContractSeatsPanel.vue'
33+
import ContractSupplierPanel from './components/contracts/ContractSupplierPanel.vue'
3334
import ChangeEntryTypePanel from './components/entries/ChangeEntryTypePanel.vue'
3435
import ConnectionWizardAction from './components/entryWizard/ConnectionWizardAction.vue'
3536
import ProvenanceNotice from './components/federation/ProvenanceNotice.vue'
@@ -208,6 +209,9 @@ export default {
208209
// Licences in use against licences bought (contracts-licence-seats).
209210
ContractSeatsPanel,
210211

212+
// A contract's supplier, read through the service it is for (REQ-CLR-014).
213+
ContractSupplierPanel,
214+
211215
// The supplier's roadmap statement and the product's versions on a timeline,
212216
// a bodyWidgets section on ModuleDetail (lifecycle-maintenance-and-supplier-roadmap):
213217
// it reads the module and its versions, which no built-in widget combines.

‎src/manifest.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@
687687
{ "id": "5", "widgetId": "ct-decisions", "gridX": 0, "gridY": 10, "gridWidth": 12, "gridHeight": 4 }
688688
],
689689
"bodyWidgets": [
690+
{ "id": "ct-supplier", "component": "ContractSupplierPanel", "props": { "objectId": "@objectId" }, "placement": "end", "colSpan": 12, "_note": "REQ-CLR-014: the supplier is the provider of the contract's service, read through that service and linked to its organisation page." },
690691
{ "id": "ct-approval", "component": "ContractApprovalPanel", "props": { "objectId": "@objectId" }, "placement": "end", "colSpan": 12 },
691692
{ "id": "ct-seats", "component": "ContractSeatsPanel", "props": { "objectId": "@objectId" }, "placement": "end", "colSpan": 12 }
692693
],

0 commit comments

Comments
 (0)