@ossy/consultancy 3.25.0 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +7 -7
  2. package/package.json +7 -5
  3. package/src/ConsultancyNav.jsx +6 -6
  4. package/src/CreateConsultancyButton.jsx +21 -7
  5. package/src/Forecast.jsx +38 -37
  6. package/src/RequestMatches.jsx +29 -19
  7. package/src/RequestStatsPanel.jsx +1 -1
  8. package/src/ResumeMatches.jsx +51 -0
  9. package/src/calendar-quarter-months.js +36 -0
  10. package/src/calendar-quarter-months.spec.js +22 -0
  11. package/src/create-company.flow.js +9 -9
  12. package/src/current-month.component.jsx +14 -25
  13. package/src/delete-company.flow.js +5 -5
  14. package/src/en.translations.json +17 -32
  15. package/src/extract-request.task.js +20 -13
  16. package/src/extract-request.task.spec.js +7 -3
  17. package/src/file-inbound-request.task.js +93 -0
  18. package/src/file-inbound-request.task.spec.js +118 -0
  19. package/src/forecast-figures.jsx +42 -0
  20. package/src/forecast-panels.jsx +29 -42
  21. package/src/index.js +0 -1
  22. package/src/intake-categories.js +6 -22
  23. package/src/kpi-trend.component.jsx +1 -1
  24. package/src/match-reasons.js +85 -0
  25. package/src/match-reasons.spec.js +73 -0
  26. package/src/match-resumes.js +12 -7
  27. package/src/match-resumes.spec.js +13 -8
  28. package/src/match-resumes.task.js +1 -22
  29. package/src/match-resumes.task.spec.js +19 -14
  30. package/src/{consultancy.page.jsx → overview.page.jsx} +7 -7
  31. package/src/refresh-matches.js +38 -0
  32. package/src/refresh-matches.spec.js +31 -1
  33. package/src/refresh-matches.task.js +322 -72
  34. package/src/refresh-matches.task.spec.js +229 -27
  35. package/src/request.schema.js +0 -1
  36. package/src/{resume-inbound-screening.task.js → resume-inbound-requests.task.js} +12 -14
  37. package/src/{resume-inbound-screening.task.spec.js → resume-inbound-requests.task.spec.js} +32 -18
  38. package/src/resumes.page.jsx +43 -12
  39. package/src/schema-ids.js +0 -1
  40. package/src/spend-for-month.js +67 -0
  41. package/src/spend-for-month.spec.js +41 -0
  42. package/src/spend-year.jsx +91 -0
  43. package/src/{org.page.jsx → spend.page.jsx} +14 -13
  44. package/src/sv.translations.json +17 -32
  45. package/src/use-chart-months.js +5 -2
  46. package/src/use-spend-by-month.js +52 -0
  47. package/src/utilization.component.jsx +1 -1
  48. package/src/view-forecasts.flow.js +3 -3
  49. package/src/year-totals.component.jsx +1 -1
  50. package/src/Overview.jsx +0 -91
  51. package/src/company-basic-info.schema.js +0 -25
  52. package/src/screen-inbound.task.js +0 -133
  53. package/src/screen-inbound.task.spec.js +0 -154
package/README.md CHANGED
@@ -8,13 +8,13 @@ Consultancy **feature package** for the Ossy platform — schemas and UI for emp
8
8
 
9
9
  | File | Page id | Default paths |
10
10
  |---|---|---|
11
- | `consultancy.page.jsx` | `consultancy/home` | `/consultancy` (en), `/konsultverksamhet` (sv) |
12
- | `org.page.jsx` | `consultancy/org` | `/consultancy/org`, `/konsultverksamhet/orgdetaljer` |
11
+ | `overview.page.jsx` | `consultancy/overview` | `/consultancy` (en), `/konsultverksamhet` (sv) |
12
+ | `spend.page.jsx` | `consultancy/spend` | `/consultancy/spend`, `/konsultverksamhet/utgifter` |
13
13
  | `margins.page.jsx` | `consultancy/margins` | `/consultancy/margins`, `/konsultverksamhet/marginaler` |
14
14
 
15
- One sidebar item (**Consultancy**). Overview (home), Margins, and Org Details are in-product tabs under that surface.
15
+ One sidebar item (**Consultancy**), opened on the overview. Margins and the sales records are in-product tabs under that surface. Company identity is the home page of `@ossy/organisation`.
16
16
 
17
- The home Overview tab shows fiscal-year KPIs via `@ossy/calendar`'s `useForecast` / `ForecastClient` (engine stays in calendar). Org Details shows company data (fiscal years, registration, VAT) via `@ossy/calendar`'s `useCompany` hook. Margins is a standalone calculator (not yet wired to live resources).
17
+ The overview shows fiscal-year KPIs via `@ossy/calendar`'s `useForecast` / `ForecastClient` (engine stays in calendar). Each overview card includes the SEK spend total, and result is income minus salary minus that total. The spending page lists the suppliers and invoices behind those totals. Margins is a standalone calculator (not yet wired to live resources).
18
18
 
19
19
  ### Schemas (ADR 0006)
20
20
 
@@ -24,13 +24,12 @@ Document types are defined in `*.schema.js`. Import canonical ids from `Consulta
24
24
  |--------|-----|---------|
25
25
  | Employee | `@ossy/consultancy/schema/employee` | Consultant employment records |
26
26
  | Contract | `@ossy/consultancy/schema/contract` | Client contracts linked to employees |
27
- | Company Basic Info | `@ossy/consultancy/schema/company-basic-info` | Company registration and VAT details |
28
27
  | Vacation | `@ossy/consultancy/schema/vacation` | Employee vacation periods |
29
28
  | Opportunity | `@ossy/consultancy/schema/opportunity` | Sales pipeline leads and qualification |
30
29
  | Proposal | `@ossy/consultancy/schema/proposal` | Draft and sent proposals linked to opportunities |
31
30
  | Calculator | `@ossy/consultancy/schema/calculator` | Assignment margin form fields (Platform category — not in create picker) |
32
31
 
33
- Document instances are stored under `/@ossy/consultancy/` (see the `location` export in `locations.js`).
32
+ Document instances are stored under `/@ossy/consultancy/` (see the `location` export in `locations.js`). Company identity lives in `@ossy/organisation` (`/@ossy/organisation/`).
34
33
 
35
34
  ### Opportunity → proposal pipeline
36
35
 
@@ -74,7 +73,7 @@ This package migrated from `*.resource.js` to ADR 0006 schemas. Stored `resource
74
73
  |--------|-------|
75
74
  | `@ossy/consultancy/employee` | `@ossy/consultancy/schema/employee` |
76
75
  | `@ossy/consultancy/contract` | `@ossy/consultancy/schema/contract` |
77
- | `@ossy/consultancy/companyBasicInfo` | `@ossy/consultancy/schema/company-basic-info` |
76
+ | `@ossy/consultancy/companyBasicInfo` | `@ossy/organisation/schema/organisation` |
78
77
  | `@ossy/consultancy/vacation` | `@ossy/consultancy/schema/vacation` |
79
78
 
80
79
  ## Dependencies
@@ -82,6 +81,7 @@ This package migrated from `*.resource.js` to ADR 0006 schemas. Stored `resource
82
81
  | Package | Role |
83
82
  |---|---|
84
83
  | `@ossy/schema` | Canonical id grammar and schema validation |
84
+ | `@ossy/organisation` | Company identity schema and storage location |
85
85
  | `@ossy/calendar` | `DataLoader`, `useCompany`, `useForecast` |
86
86
  | `@ossy/design-system` | Layout primitives and `Page` component |
87
87
  | `@ossy/router-react` | Page routing |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/consultancy",
3
3
  "description": "Consultancy feature package — schemas, forecasts UI, and assignment margins",
4
- "version": "3.25.0",
4
+ "version": "3.26.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
@@ -25,9 +25,11 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
- "@ossy/email": "^3.25.0",
29
- "@ossy/event-store": "^3.24.1",
30
- "@ossy/schema": "^3.24.0"
28
+ "@ossy/email": "^3.26.0",
29
+ "@ossy/event-store": "^3.26.0",
30
+ "@ossy/organisation": "^3.26.0",
31
+ "@ossy/schema": "^3.24.0",
32
+ "@ossy/spend": "^3.26.0"
31
33
  },
32
34
  "peerDependencies": {
33
35
  "@ossy/calendar": "*",
@@ -42,5 +44,5 @@
42
44
  "devDependencies": {
43
45
  "jest": "^30.2.0"
44
46
  },
45
- "gitHead": "00dd4b51a94de7e0399c9dfa59380a53e58c8523"
47
+ "gitHead": "0df308a330150a890b9dd4d6ffc2e9f28bd31966"
46
48
  }
@@ -2,12 +2,16 @@ import React from 'react'
2
2
  import { Tabs } from '@ossy/design-system'
3
3
  import { useRouter } from '@ossy/router-react'
4
4
 
5
- /** Overview, then the sales records, then the people and the company. */
5
+ /** Overview, then the sales records, then the people. */
6
6
  const TABS = [
7
7
  {
8
- id: 'consultancy/home',
8
+ id: 'consultancy/overview',
9
9
  label: 'consultancy.nav.overview',
10
10
  },
11
+ {
12
+ id: 'consultancy/spend',
13
+ label: 'consultancy.nav.spend',
14
+ },
11
15
  {
12
16
  id: 'consultancy/requests',
13
17
  label: 'consultancy.nav.requests',
@@ -44,10 +48,6 @@ const TABS = [
44
48
  id: 'consultancy/margins',
45
49
  label: 'consultancy.nav.margins',
46
50
  },
47
- {
48
- id: 'consultancy/org',
49
- label: 'consultancy.nav.orgDetails',
50
- },
51
51
  ]
52
52
 
53
53
  /**
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
2
  import { Button, ContextMenu, Dropdown, View, useLocale } from '@ossy/design-system'
3
3
  import { useRouter } from '@ossy/router-react'
4
+ import { organisationSchema, location as organisationLocation } from '@ossy/organisation'
4
5
  import { location } from './locations.js'
5
- import companyBasicInfoSchema from './company-basic-info.schema.js'
6
6
  import employeeSchema from './employee.schema.js'
7
7
  import contractSchema from './contract.schema.js'
8
8
  import vacationSchema from './vacation.schema.js'
@@ -10,7 +10,12 @@ import opportunitySchema from './opportunity.schema.js'
10
10
  import proposalSchema from './proposal.schema.js'
11
11
 
12
12
  const ADD_TYPES = [
13
- { schema: companyBasicInfoSchema, label: 'consultancy.add.company' },
13
+ {
14
+ schema: organisationSchema,
15
+ label: 'consultancy.add.company',
16
+ createLocation: organisationLocation,
17
+ category: 'Organisation',
18
+ },
14
19
  { schema: employeeSchema, label: 'consultancy.add.employee' },
15
20
  { schema: contractSchema, label: 'consultancy.add.contract' },
16
21
  { schema: opportunitySchema, label: 'consultancy.add.opportunity' },
@@ -36,8 +41,8 @@ function currentReturnTo (href) {
36
41
  }
37
42
  }
38
43
 
39
- function createHref (router, schemaId) {
40
- const params = new URLSearchParams({ location, category: 'Consultancy' })
44
+ function createHref (router, { schemaId, createLocation = location, category = 'Consultancy' }) {
45
+ const params = new URLSearchParams({ location: createLocation, category })
41
46
  if (schemaId) params.set('schemaId', schemaId)
42
47
  const returnTo = currentReturnTo(router.href)
43
48
  if (returnTo) params.set('returnTo', returnTo)
@@ -55,11 +60,16 @@ export function CreateConsultancyButton ({ schemaId, before, ...props }) {
55
60
  const router = useRouter()
56
61
 
57
62
  if (schemaId) {
63
+ const match = ADD_TYPES.find((entry) => entry.schema.id === schemaId)
58
64
  return (
59
65
  <Button
60
66
  variant="cta"
61
67
  prefix="add"
62
- href={createHref(router, schemaId)}
68
+ href={createHref(router, {
69
+ schemaId,
70
+ createLocation: match?.createLocation,
71
+ category: match?.category,
72
+ })}
63
73
  {...props}
64
74
  >
65
75
  {t('design-system.add')}
@@ -78,11 +88,15 @@ export function CreateConsultancyButton ({ schemaId, before, ...props }) {
78
88
  <View inset="xs" surface="primary" roundness="s">
79
89
  <ContextMenu roundness="s" surface="primary">
80
90
  {before}
81
- {ADD_TYPES.map(({ schema, label }) => (
91
+ {ADD_TYPES.map(({ schema, label, createLocation, category }) => (
82
92
  <ContextMenu.Item
83
93
  key={schema.id}
84
94
  prefix={schema.icon || 'add'}
85
- href={createHref(router, schema.id)}
95
+ href={createHref(router, {
96
+ schemaId: schema.id,
97
+ createLocation,
98
+ category,
99
+ })}
86
100
  data-schema-id={schema.id}
87
101
  >
88
102
  {t(label)}
package/src/Forecast.jsx CHANGED
@@ -1,15 +1,39 @@
1
- import React from 'react'
1
+ import React, { useMemo } from 'react'
2
2
  import { DashboardLayout, Panel, View, Text, useLocale } from '@ossy/design-system'
3
- import { useForecast } from '@ossy/calendar'
3
+ import { CalendarClient, DEFAULT_HOLIDAY_LOCALE, useCompany, useForecast } from '@ossy/calendar'
4
+ import { calendarQuarterMonths } from './calendar-quarter-months.js'
4
5
  import { CurrentMonthForecastPanel } from './current-month.component.jsx'
6
+ import { ForecastFigures } from './forecast-figures.jsx'
5
7
  import { KpiTrendPanel, UtilizationPanel, YearTotalsPanel } from './forecast-panels.jsx'
6
8
  import { MonthDayGrid } from './MonthDayGrid.jsx'
9
+ import { spendForMonth } from './spend-for-month.js'
10
+ import { useSpendByMonth } from './use-spend-by-month.js'
11
+
12
+ function daysForMonth (year, monthIndex, holidayLocale) {
13
+ const start = new Date(year, monthIndex, 1)
14
+ const end = new Date(year, monthIndex + 1, 0)
15
+ return CalendarClient.getAllDaysInDateSpan(start, end).map((day) => ({
16
+ monthDay: String(day.getDate()).padStart(2, '0'),
17
+ isoWeekday: day.getDay() === 0 ? 7 : day.getDay(),
18
+ isWorkday: CalendarClient.isWorkDay(day, holidayLocale),
19
+ }))
20
+ }
7
21
 
8
22
  export const Forecast = () => {
9
- const months = useForecast()
23
+ const fiscalMonths = useForecast()
24
+ const company = useCompany()
10
25
  const { language } = useLocale()
11
- const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', { style: "currency", currency: "SEK" }).format(value)
12
- const hours = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-GB', { style: "unit", unit: "hour" }).format(value)
26
+ const { totals: spendByMonth } = useSpendByMonth()
27
+ const holidayLocale = company?.holidayLocale || DEFAULT_HOLIDAY_LOCALE
28
+ const year = new Date().getFullYear()
29
+ const months = useMemo(
30
+ () => calendarQuarterMonths(fiscalMonths, {
31
+ year,
32
+ language,
33
+ daysForMonth: (monthYear, monthIndex) => daysForMonth(monthYear, monthIndex, holidayLocale),
34
+ }),
35
+ [fiscalMonths, year, language, holidayLocale],
36
+ )
13
37
 
14
38
  return (
15
39
  <>
@@ -30,46 +54,23 @@ export const Forecast = () => {
30
54
  const monthKey = `${month.year}-${month.month}`
31
55
 
32
56
  return (
33
- <DashboardLayout.Widget key={monthKey} span={3}>
57
+ <DashboardLayout.Widget key={monthKey} span={4}>
34
58
  <Panel
35
59
  status={month.isCurrentMonth ? 'success' : undefined}
36
60
  title={(
37
- <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>
61
+ <Text variant="small" as="h2" weight="bold">
38
62
  {month.year} {month.month}
39
63
  </Text>
40
64
  )}
41
65
  style={{ minWidth: 0, flex: '1 1 auto' }}
42
66
  >
43
- <View gap="s" inset="m" style={{ flexGrow: 1 }}>
44
-
45
- <View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
46
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
47
- <Text variant="m" style={{ marginBottom: 0 }} >
48
- {money(month.projectedIncome)}
49
- </Text>
50
- </View>
51
-
52
- <View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
53
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.salaryCost" />
54
- <Text variant="m" style={{ marginBottom: 0 }} >
55
- {money(month.monthlyCostOfEmployees)}
56
- </Text>
57
- </View>
58
-
59
- <View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
60
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.revenue" />
61
- <Text variant="m" style={{ marginBottom: 0 }} >
62
- {money(month.revenue)}
63
- </Text>
64
- </View>
65
-
66
- <View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
67
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.hoursWorked" />
68
- <Text variant="m" style={{ marginBottom: 0 }} >
69
- {hours(month.hoursWorked)}
70
- </Text>
71
- </View>
72
-
67
+ <View inset="m" style={{ flexGrow: 1 }}>
68
+ <ForecastFigures
69
+ income={month.projectedIncome}
70
+ salary={month.monthlyCostOfEmployees}
71
+ spend={spendForMonth(spendByMonth, month)}
72
+ hours={month.hoursWorked}
73
+ />
73
74
  </View>
74
75
 
75
76
  <MonthDayGrid month={month} />
@@ -1,11 +1,11 @@
1
- import React from 'react'
2
- import { List, Text, View } from '@ossy/design-system'
1
+ import React, { useMemo } from 'react'
2
+ import { List, Tags, Text, View } from '@ossy/design-system'
3
3
  import { useRouter } from '@ossy/router-react'
4
4
  import { AsyncStatus, useSdk } from '@ossy/sdk-react'
5
5
  import { ListResources } from '@ossy/resources'
6
6
  import { referenceId } from '@ossy/resumes/resume-links'
7
7
  import { ConsultancySchema } from './schema-ids.js'
8
- import { matchesLocation } from './locations.js'
8
+ import { hasMatchSignal, requestMatchesRead, sharedTagsOf } from './match-reasons.js'
9
9
 
10
10
  /**
11
11
  * Saved matches for one request. Embedding and ranking happen when the
@@ -15,13 +15,20 @@ export function RequestMatches ({ requestId, resourceId }) {
15
15
  const id = requestId || resourceId
16
16
  const sdk = useSdk()
17
17
  const router = useRouter()
18
- const { data: resources = [], status } = sdk.read(ListResources, { location: matchesLocation })
19
- const loading = status === AsyncStatus.Loading || status === AsyncStatus.NotInitialized
18
+ const { data: resources = [], status } = sdk.read(
19
+ ListResources,
20
+ requestMatchesRead(id),
21
+ { enabled: Boolean(id) },
22
+ )
23
+ const loading = Boolean(id) && (status === AsyncStatus.Loading || status === AsyncStatus.NotInitialized)
20
24
  const match = (Array.isArray(resources) ? resources : []).find((resource) => (
21
25
  resource?.type === ConsultancySchema.requestMatches
22
26
  && referenceId(resource?.content?.request) === id
23
27
  ))
24
- const matches = Array.isArray(match?.content?.matches) ? match.content.matches : []
28
+ const matches = useMemo(() => {
29
+ const items = Array.isArray(match?.content?.matches) ? match.content.matches : []
30
+ return items.filter(hasMatchSignal)
31
+ }, [match])
25
32
 
26
33
  return (
27
34
  <View gap="s" inset="m" data-request-matches={loading ? 'loading' : match ? 'ready' : 'pending'}>
@@ -32,19 +39,22 @@ export function RequestMatches ({ requestId, resourceId }) {
32
39
  ) : null}
33
40
  {!loading && matches.length > 0 ? (
34
41
  <List>
35
- {matches.map((item) => (
36
- <List.Item
37
- key={item.resourceId}
38
- href={router.getHref({
39
- id: '@resume',
40
- params: { resumeId: item.resourceId, workspaceId: router.params.workspaceId },
41
- })}
42
- data-resource-name={item.name || undefined}
43
- meta={item.shared?.length ? <Text variant="small">{item.shared.join(', ')}</Text> : null}
44
- >
45
- {item.name || item.resourceId}
46
- </List.Item>
47
- ))}
42
+ {matches.map((item) => {
43
+ const shared = sharedTagsOf(item)
44
+ return (
45
+ <List.Item
46
+ key={item.resourceId}
47
+ href={router.getHref({
48
+ id: '@resume',
49
+ params: { resumeId: item.resourceId, workspaceId: router.params.workspaceId },
50
+ })}
51
+ data-resource-name={item.name || undefined}
52
+ meta={shared.length ? <Tags tags={shared} size="s" gap="xs" /> : null}
53
+ >
54
+ {item.name || item.resourceId}
55
+ </List.Item>
56
+ )
57
+ })}
48
58
  </List>
49
59
  ) : null}
50
60
  </View>
@@ -10,7 +10,7 @@ const SERIES = [
10
10
  {
11
11
  key: 'count',
12
12
  label: 'consultancy.requests.statsSeries',
13
- color: 'var(--color-info, hsl(199, 89%, 43%))',
13
+ color: 'var(--surface-info, hsl(199, 89%, 43%))',
14
14
  },
15
15
  ]
16
16
 
@@ -0,0 +1,51 @@
1
+ import React, { useMemo } from 'react'
2
+ import { List, Tags, Text, View } from '@ossy/design-system'
3
+ import { useRouter } from '@ossy/router-react'
4
+ import { AsyncStatus, useSdk } from '@ossy/sdk-react'
5
+ import { ListResources } from '@ossy/resources'
6
+ import { matchesForResume, resumeMatchesRead } from './match-reasons.js'
7
+
8
+ /**
9
+ * Requests that matched this resume, inverted from saved request-matches docs.
10
+ * Same shared-tag reasons as {@link RequestMatches}.
11
+ */
12
+ export function ResumeMatches ({ resourceId }) {
13
+ const sdk = useSdk()
14
+ const router = useRouter()
15
+ const { data: resources = [], status } = sdk.read(
16
+ ListResources,
17
+ resumeMatchesRead(resourceId),
18
+ { enabled: Boolean(resourceId) },
19
+ )
20
+ const loading = Boolean(resourceId) && (status === AsyncStatus.Loading || status === AsyncStatus.NotInitialized)
21
+ const matches = useMemo(
22
+ () => matchesForResume(resources, resourceId),
23
+ [resources, resourceId],
24
+ )
25
+ const ready = !loading
26
+
27
+ return (
28
+ <View gap="s" inset="m" data-resume-matches={loading ? 'loading' : ready ? 'ready' : 'pending'}>
29
+ {loading ? <Text color="secondary" text="consultancy.matches.requestsLoading" /> : null}
30
+ {!loading && matches.length === 0 ? (
31
+ <Text color="secondary" text="consultancy.matches.requestsEmpty" />
32
+ ) : null}
33
+ {!loading && matches.length > 0 ? (
34
+ <List>
35
+ {matches.map((item) => (
36
+ <List.Item
37
+ key={item.requestId}
38
+ href={router.getHref(
39
+ `@consultancy/requests?r=${encodeURIComponent(item.requestId)}`,
40
+ )}
41
+ data-resource-name={item.name || undefined}
42
+ meta={item.shared.length ? <Tags tags={item.shared} size="s" gap="xs" /> : null}
43
+ >
44
+ {item.name || item.requestId}
45
+ </List.Item>
46
+ ))}
47
+ </List>
48
+ ) : null}
49
+ </View>
50
+ )
51
+ }
@@ -0,0 +1,36 @@
1
+ import { monthSpendKey } from './spend-for-month.js'
2
+
3
+ /**
4
+ * January–December of one calendar year, in quarter order.
5
+ * Forecast figures are kept when that month is inside the open fiscal year.
6
+ * Other months stay on the grid so each row is still a quarter.
7
+ *
8
+ * @param {Array<object>} fiscalMonths
9
+ * @param {{ year: number, language?: string, today?: Date, daysForMonth?: (year: number, monthIndex: number) => Array<object> }} options
10
+ */
11
+ export function calendarQuarterMonths (fiscalMonths, { year, language = 'en', today = new Date(), daysForMonth } = {}) {
12
+ const byKey = new Map()
13
+ for (const month of Array.isArray(fiscalMonths) ? fiscalMonths : []) {
14
+ const key = monthSpendKey(month)
15
+ if (key?.startsWith(`${year}-`)) byKey.set(key, month)
16
+ }
17
+
18
+ const locale = language === 'sv' ? 'sv-SE' : 'en'
19
+ return Array.from({ length: 12 }, (_, index) => {
20
+ const monthNumber = String(index + 1).padStart(2, '0')
21
+ const existing = byKey.get(`${year}-${monthNumber}`)
22
+ const isCurrentMonth = today.getFullYear() === year && today.getMonth() === index
23
+ if (existing) return { ...existing, isCurrentMonth }
24
+ return {
25
+ isCurrentMonth,
26
+ month: new Intl.DateTimeFormat(locale, { month: 'long' }).format(new Date(year, index, 1)),
27
+ year,
28
+ monthNumber,
29
+ days: typeof daysForMonth === 'function' ? daysForMonth(year, index) : [],
30
+ projectedIncome: 0,
31
+ monthlyCostOfEmployees: 0,
32
+ revenue: 0,
33
+ hoursWorked: 0,
34
+ }
35
+ })
36
+ }
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from '@jest/globals'
2
+ import { calendarQuarterMonths } from './calendar-quarter-months.js'
3
+
4
+ describe('calendar quarter months', () => {
5
+ it('starts in January even when the fiscal year starts in August', () => {
6
+ const months = calendarQuarterMonths([
7
+ { year: 2026, monthNumber: '08', month: 'augusti', projectedIncome: 10, days: [{ monthDay: '01' }] },
8
+ { year: 2027, monthNumber: '01', month: 'januari', projectedIncome: 99, days: [{ monthDay: '01' }] },
9
+ ], { year: 2026, language: 'sv', today: new Date(2026, 9, 31) })
10
+
11
+ expect(months).toHaveLength(12)
12
+ expect(months.map((month) => month.monthNumber)).toEqual([
13
+ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12',
14
+ ])
15
+ expect(months[0].month).toBe('januari')
16
+ expect(months[0].projectedIncome).toBe(0)
17
+ expect(months[7].projectedIncome).toBe(10)
18
+ expect(months[7].days).toEqual([{ monthDay: '01' }])
19
+ expect(months[9].isCurrentMonth).toBe(true)
20
+ expect(months[0].isCurrentMonth).toBe(false)
21
+ })
22
+ })
@@ -1,5 +1,5 @@
1
1
  import signUpFlow from '@ossy/authentication/sign-up.flow.js'
2
- import { ConsultancySchema, location } from '@ossy/consultancy'
2
+ import { OrganisationSchema, location as organisationLocation } from '@ossy/organisation'
3
3
  import { CreateResource, CreateDocumentForm } from '@ossy/resources'
4
4
 
5
5
  export const metadata = {
@@ -10,28 +10,28 @@ export const metadata = {
10
10
  }
11
11
 
12
12
  /**
13
- * Happy path for issue #5 — consultancy empty state to company-basic-info ready.
13
+ * Happy path for issue #5 / #1108 — consultancy empty state to organisation ready.
14
14
  */
15
15
  export default {
16
16
  title: 'Create company',
17
17
  description:
18
- 'Signed-in user sees consultancy empty, creates company-basic-info via create-document, then sees the ready home overview',
18
+ 'Signed-in user sees consultancy empty, creates organisation via create-document, then sees the ready overview',
19
19
  steps: [
20
20
  ...signUpFlow.steps,
21
- { page: '@consultancy/home' },
21
+ { page: '@consultancy/overview' },
22
22
  { result: { selector: '[data-consultancy-status="empty"]', timeout: 15000 } },
23
23
  {
24
24
  page: '@create-document',
25
25
  search: {
26
- location,
27
- category: 'Consultancy',
28
- schemaId: ConsultancySchema.companyBasicInfo,
26
+ location: organisationLocation,
27
+ category: 'Organisation',
28
+ schemaId: OrganisationSchema.organisation,
29
29
  },
30
30
  },
31
31
  { result: { selector: '[data-flow-stage="create-document"]', timeout: 15000 } },
32
32
  {
33
33
  result: {
34
- selector: `[data-schema-id="${ConsultancySchema.companyBasicInfo}"]`,
34
+ selector: `[data-schema-id="${OrganisationSchema.organisation}"]`,
35
35
  timeout: 10000,
36
36
  },
37
37
  },
@@ -39,7 +39,7 @@ export default {
39
39
  { form: CreateDocumentForm, fields: { name: 'e2e-company' } },
40
40
  { action: CreateResource },
41
41
  { result: { page: '@storage/home', timeout: 20000 } },
42
- { page: '@consultancy/home' },
42
+ { page: '@consultancy/overview' },
43
43
  { result: { selector: '[data-consultancy-status="ready"]', timeout: 15000 } },
44
44
  { result: { selector: '[data-forecasts-status="on"]', timeout: 10000 } },
45
45
  { result: { selector: '[data-consultancy-year-summary]', timeout: 10000 } },
@@ -1,36 +1,23 @@
1
1
  import React from 'react'
2
2
  import { Panel, Text, View, useLocale } from '@ossy/design-system'
3
3
  import { DataLoader, useForecast } from '@ossy/calendar'
4
+ import { ForecastFigures } from './forecast-figures.jsx'
4
5
  import { ForecastWidgetMenu } from './forecast-widget-menu.jsx'
5
6
  import { MonthDayGrid } from './MonthDayGrid.jsx'
7
+ import { spendForMonth } from './spend-for-month.js'
8
+ import { useSpendByMonth } from './use-spend-by-month.js'
6
9
 
7
10
  export const CURRENT_MONTH_WIDGET_ID = '@ossy/consultancy/view/current-month'
8
11
 
9
12
  const panelStyle = { height: '100%', flex: '1 1 auto', minWidth: 0 }
10
13
 
11
- function MetricRow ({ label, value }) {
12
- return (
13
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
14
- <Text variant="m" style={{ marginBottom: 0 }} text={label} />
15
- <Text variant="m" style={{ marginBottom: 0 }}>{value}</Text>
16
- </View>
17
- )
18
- }
19
-
20
14
  /**
21
15
  * Compact current-month forecast metrics, using the shared Panel header.
22
16
  */
23
17
  export function CurrentMonthForecastPanel ({ dashboardId, pinnedWidgetId }) {
24
18
  const months = useForecast()
25
- const { language, t } = useLocale()
26
- const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', {
27
- style: 'currency',
28
- currency: 'SEK',
29
- }).format(value)
30
- const hours = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-GB', {
31
- style: 'unit',
32
- unit: 'hour',
33
- }).format(value)
19
+ const { totals: spendByMonth } = useSpendByMonth()
20
+ const { t } = useLocale()
34
21
 
35
22
  const current = (Array.isArray(months) ? months : []).find((m) => m.isCurrentMonth)
36
23
  ?? (Array.isArray(months) ? months[0] : null)
@@ -46,7 +33,7 @@ export function CurrentMonthForecastPanel ({ dashboardId, pinnedWidgetId }) {
46
33
  return (
47
34
  <Panel
48
35
  title={current ? (
49
- <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>
36
+ <Text variant="small" as="h2" weight="bold">
50
37
  {t('consultancy.forecasts.monthForecast', { month: current.month })}
51
38
  </Text>
52
39
  ) : 'consultancy.widgets.forecastCurrentMonth.title'}
@@ -60,11 +47,13 @@ export function CurrentMonthForecastPanel ({ dashboardId, pinnedWidgetId }) {
60
47
  </View>
61
48
  ) : (
62
49
  <>
63
- <View gap="s" inset="m">
64
- <MetricRow label="consultancy.forecasts.income" value={money(current.projectedIncome)} />
65
- <MetricRow label="consultancy.forecasts.salaryCost" value={money(current.monthlyCostOfEmployees)} />
66
- <MetricRow label="consultancy.forecasts.revenue" value={money(current.revenue)} />
67
- <MetricRow label="consultancy.forecasts.hoursWorked" value={hours(current.hoursWorked)} />
50
+ <View inset="m">
51
+ <ForecastFigures
52
+ income={current.projectedIncome}
53
+ salary={current.monthlyCostOfEmployees}
54
+ spend={spendForMonth(spendByMonth, current)}
55
+ hours={current.hoursWorked}
56
+ />
68
57
  </View>
69
58
  <MonthDayGrid month={current} />
70
59
  </>
@@ -84,5 +73,5 @@ export const metadata = {
84
73
 
85
74
  /** Slot widget — current-month forecast panel for dashboards. */
86
75
  export default function CurrentMonthForecastWidget (props) {
87
- return <DataLoader content={<CurrentMonthForecastPanel {...props} />} />
76
+ return <DataLoader emptyGuide={false} content={<CurrentMonthForecastPanel {...props} />} />
88
77
  }
@@ -1,5 +1,5 @@
1
1
  import createCompanyFlow from './create-company.flow.js'
2
- import { location } from '@ossy/consultancy'
2
+ import { location as organisationLocation } from '@ossy/organisation'
3
3
  import { DeleteResource } from '@ossy/resources'
4
4
 
5
5
  export const metadata = {
@@ -10,8 +10,8 @@ export const metadata = {
10
10
  }
11
11
 
12
12
  /**
13
- * After creating company-basic-info, open it in storage and delete it.
14
- * Consultancy home should return to the empty state.
13
+ * After creating organisation, open it in storage and delete it.
14
+ * Consultancy overview should return to the empty state.
15
15
  */
16
16
  export default {
17
17
  title: 'Delete company',
@@ -19,7 +19,7 @@ export default {
19
19
  'Signed-in user creates a company, deletes it from storage, and sees consultancy empty again',
20
20
  steps: [
21
21
  ...createCompanyFlow.steps,
22
- { page: '@storage/home', search: { location } },
22
+ { page: '@storage/home', search: { location: organisationLocation } },
23
23
  { result: { selector: '[data-resource-name="e2e-company"]', timeout: 20000 } },
24
24
  { click: { selector: '[data-resource-name="e2e-company"]' } },
25
25
  { result: { action: DeleteResource, timeout: 15000 } },
@@ -31,7 +31,7 @@ export default {
31
31
  timeout: 20000,
32
32
  },
33
33
  },
34
- { page: '@consultancy/home' },
34
+ { page: '@consultancy/overview' },
35
35
  { result: { selector: '[data-consultancy-status="empty"]', timeout: 15000 } },
36
36
  ],
37
37
  }