@ossy/consultancy 3.25.0 → 3.27.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.
- package/README.md +7 -7
- package/package.json +7 -5
- package/src/ConsultancyNav.jsx +6 -6
- package/src/CreateConsultancyButton.jsx +21 -7
- package/src/Forecast.jsx +38 -37
- package/src/RequestMatches.jsx +29 -19
- package/src/RequestStatsPanel.jsx +1 -1
- package/src/ResumeMatches.jsx +51 -0
- package/src/calendar-quarter-months.js +36 -0
- package/src/calendar-quarter-months.spec.js +22 -0
- package/src/create-company.flow.js +9 -9
- package/src/current-month.component.jsx +14 -25
- package/src/delete-company.flow.js +5 -5
- package/src/en.translations.json +17 -32
- package/src/extract-request.task.js +20 -13
- package/src/extract-request.task.spec.js +7 -3
- package/src/file-inbound-request.task.js +93 -0
- package/src/file-inbound-request.task.spec.js +118 -0
- package/src/forecast-figures.jsx +42 -0
- package/src/forecast-panels.jsx +31 -42
- package/src/index.js +0 -1
- package/src/intake-categories.js +6 -22
- package/src/kpi-trend.component.jsx +1 -1
- package/src/match-reasons.js +85 -0
- package/src/match-reasons.spec.js +73 -0
- package/src/match-resumes.js +12 -7
- package/src/match-resumes.spec.js +13 -8
- package/src/match-resumes.task.js +1 -22
- package/src/match-resumes.task.spec.js +19 -14
- package/src/{consultancy.page.jsx → overview.page.jsx} +7 -7
- package/src/refresh-matches.js +38 -0
- package/src/refresh-matches.spec.js +31 -1
- package/src/refresh-matches.task.js +322 -72
- package/src/refresh-matches.task.spec.js +229 -27
- package/src/request.schema.js +0 -1
- package/src/{resume-inbound-screening.task.js → resume-inbound-requests.task.js} +12 -14
- package/src/{resume-inbound-screening.task.spec.js → resume-inbound-requests.task.spec.js} +32 -18
- package/src/resumes.page.jsx +43 -12
- package/src/schema-ids.js +0 -1
- package/src/spend-for-month.js +72 -0
- package/src/spend-for-month.spec.js +49 -0
- package/src/spend-year.jsx +91 -0
- package/src/{org.page.jsx → spend.page.jsx} +14 -13
- package/src/sv.translations.json +17 -32
- package/src/use-chart-months.js +5 -2
- package/src/use-spend-by-month.js +52 -0
- package/src/utilization.component.jsx +1 -1
- package/src/view-forecasts.flow.js +3 -3
- package/src/year-totals.component.jsx +1 -1
- package/src/Overview.jsx +0 -91
- package/src/company-basic-info.schema.js +0 -25
- package/src/screen-inbound.task.js +0 -133
- 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
|
-
| `
|
|
12
|
-
| `
|
|
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**)
|
|
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
|
|
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/
|
|
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.
|
|
4
|
+
"version": "3.27.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.
|
|
29
|
-
"@ossy/event-store": "^3.
|
|
30
|
-
"@ossy/
|
|
28
|
+
"@ossy/email": "^3.27.0",
|
|
29
|
+
"@ossy/event-store": "^3.26.0",
|
|
30
|
+
"@ossy/organisation": "^3.26.0",
|
|
31
|
+
"@ossy/schema": "^3.27.0",
|
|
32
|
+
"@ossy/spend": "^3.27.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": "
|
|
47
|
+
"gitHead": "f72042c42723468c010d0d9744ad69257143d0b9"
|
|
46
48
|
}
|
package/src/ConsultancyNav.jsx
CHANGED
|
@@ -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
|
|
5
|
+
/** Overview, then the sales records, then the people. */
|
|
6
6
|
const TABS = [
|
|
7
7
|
{
|
|
8
|
-
id: 'consultancy/
|
|
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
|
-
{
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
23
|
+
const fiscalMonths = useForecast()
|
|
24
|
+
const company = useCompany()
|
|
10
25
|
const { language } = useLocale()
|
|
11
|
-
const
|
|
12
|
-
const
|
|
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={
|
|
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"
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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} />
|
package/src/RequestMatches.jsx
CHANGED
|
@@ -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 {
|
|
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(
|
|
19
|
-
|
|
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 =
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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>
|
|
@@ -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 {
|
|
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
|
|
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
|
|
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/
|
|
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: '
|
|
28
|
-
schemaId:
|
|
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="${
|
|
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/
|
|
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 {
|
|
26
|
-
const
|
|
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"
|
|
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
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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/
|
|
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
|
|
14
|
-
* Consultancy
|
|
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/
|
|
34
|
+
{ page: '@consultancy/overview' },
|
|
35
35
|
{ result: { selector: '[data-consultancy-status="empty"]', timeout: 15000 } },
|
|
36
36
|
],
|
|
37
37
|
}
|