@ossy/consultancy 3.21.0 → 3.22.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/package.json +3 -2
- package/src/AssignmentMarginCalculator.jsx +7 -32
- package/src/ConsultancyNav.jsx +17 -9
- package/src/Forecast.jsx +42 -343
- package/src/Overview.jsx +10 -31
- package/src/RequestStatsPanel.jsx +66 -0
- package/src/consultancy.page.jsx +3 -40
- package/src/current-month.component.jsx +43 -25
- package/src/en.translations.json +26 -2
- package/src/extract-request.action.js +5 -0
- package/src/extract-request.task.js +100 -0
- package/src/extract-request.task.spec.js +89 -0
- package/src/forecast-panels.jsx +125 -0
- package/src/forecast-widget-menu.jsx +89 -0
- package/src/get-request-stats.action.js +6 -0
- package/src/get-request-stats.task.js +26 -0
- package/src/index.js +1 -0
- package/src/intake-categories.js +39 -0
- package/src/kpi-trend.component.jsx +17 -0
- package/src/margin-panels.jsx +7 -32
- package/src/org.page.jsx +1 -2
- package/src/reports.page.jsx +103 -0
- package/src/request-buckets.js +76 -0
- package/src/request-buckets.spec.js +33 -0
- package/src/request-stats.aggregate.js +52 -0
- package/src/request-stats.aggregate.spec.js +34 -0
- package/src/request-stats.component.jsx +16 -0
- package/src/request.schema.js +29 -0
- package/src/requests.page.jsx +26 -0
- package/src/schema-ids.js +1 -0
- package/src/screen-inbound.task.js +84 -0
- package/src/screen-inbound.task.spec.js +97 -0
- package/src/sv.translations.json +26 -2
- package/src/use-chart-months.js +27 -0
- package/src/utilization.component.jsx +17 -0
- package/src/year-totals.component.jsx +17 -0
- package/src/forecast-kpi-chart.js +0 -184
- package/src/forecast-kpi-chart.spec.js +0 -159
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.22.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@ossy/event-store": "^3.20.1",
|
|
28
29
|
"@ossy/schema": "^3.20.1"
|
|
29
30
|
},
|
|
30
31
|
"peerDependencies": {
|
|
@@ -39,5 +40,5 @@
|
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"jest": "^30.2.0"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "29de300fd5e2c36f9d6d00f09eb9f1508997a904"
|
|
43
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import {
|
|
3
|
+
Panel,
|
|
3
4
|
View,
|
|
4
5
|
Text,
|
|
5
6
|
Alert,
|
|
@@ -43,32 +44,6 @@ function parseNumber (value, fallback = 0) {
|
|
|
43
44
|
return Number.isFinite(parsed) ? parsed : fallback
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
function SectionPanel ({ title, children, ...props }) {
|
|
47
|
-
return (
|
|
48
|
-
<View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden' }} {...props}>
|
|
49
|
-
<View stack bordered>
|
|
50
|
-
<View.Item
|
|
51
|
-
data-surface="primary"
|
|
52
|
-
layout="row"
|
|
53
|
-
style={{
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
justifyContent: 'space-between',
|
|
56
|
-
padding: 'var(--space-s) var(--space-m)',
|
|
57
|
-
gap: 'var(--space-m)',
|
|
58
|
-
height: '48px',
|
|
59
|
-
flexShrink: 0,
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<Text variant="small" as="h2" style={{ fontWeight: 'bold' }} text={title} />
|
|
63
|
-
</View.Item>
|
|
64
|
-
<View.Item>
|
|
65
|
-
{children}
|
|
66
|
-
</View.Item>
|
|
67
|
-
</View>
|
|
68
|
-
</View>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
47
|
function MetricRow ({ label, value }) {
|
|
73
48
|
return (
|
|
74
49
|
<View layout="row" justifyContent="space-between" gap="s">
|
|
@@ -157,15 +132,15 @@ export const AssignmentMarginCalculator = () => {
|
|
|
157
132
|
|
|
158
133
|
<View layout="row-wrap" gap="m" style={{ alignItems: 'stretch' }}>
|
|
159
134
|
<View style={{ flex: '1 1 320px', minWidth: 0 }}>
|
|
160
|
-
<
|
|
135
|
+
<Panel title="consultancy.margins.inputs.title">
|
|
161
136
|
<View inset="m" gap="m">
|
|
162
137
|
<FieldFactory />
|
|
163
138
|
</View>
|
|
164
|
-
</
|
|
139
|
+
</Panel>
|
|
165
140
|
</View>
|
|
166
141
|
|
|
167
142
|
<View style={{ flex: '1 1 320px', minWidth: 0 }}>
|
|
168
|
-
<
|
|
143
|
+
<Panel
|
|
169
144
|
title="consultancy.margins.results.title"
|
|
170
145
|
data-margins-status={margin.isProfitable ? 'profitable' : 'unprofitable'}
|
|
171
146
|
>
|
|
@@ -186,17 +161,17 @@ export const AssignmentMarginCalculator = () => {
|
|
|
186
161
|
text={margin.coversEmployerCost ? 'consultancy.margins.results.coversCost' : 'consultancy.margins.results.missesCost'}
|
|
187
162
|
/>
|
|
188
163
|
</View>
|
|
189
|
-
</
|
|
164
|
+
</Panel>
|
|
190
165
|
</View>
|
|
191
166
|
</View>
|
|
192
167
|
|
|
193
|
-
<
|
|
168
|
+
<Panel title="consultancy.margins.leakage.title" data-margins-leakage="on">
|
|
194
169
|
<View gap="m" inset="m">
|
|
195
170
|
<Text variant="small" color="secondary" text="consultancy.margins.leakage.description" />
|
|
196
171
|
<MetricRow label="consultancy.margins.leakage.hours" value={hoursFormat(leakage.leakedHours)} />
|
|
197
172
|
<MetricRow label="consultancy.margins.leakage.revenue" value={money(leakage.leakedRevenue)} />
|
|
198
173
|
</View>
|
|
199
|
-
</
|
|
174
|
+
</Panel>
|
|
200
175
|
</Form>
|
|
201
176
|
)
|
|
202
177
|
}
|
package/src/ConsultancyNav.jsx
CHANGED
|
@@ -2,12 +2,28 @@ import React from 'react'
|
|
|
2
2
|
import { Tabs } from '@ossy/design-system'
|
|
3
3
|
import { useRouter } from '@ossy/router-react'
|
|
4
4
|
|
|
5
|
-
/** Overview
|
|
5
|
+
/** Overview, then the sales records, then the people and the company. */
|
|
6
6
|
const TABS = [
|
|
7
7
|
{
|
|
8
8
|
id: 'consultancy/home',
|
|
9
9
|
label: 'consultancy.nav.overview',
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
id: 'consultancy/requests',
|
|
13
|
+
label: 'consultancy.nav.requests',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 'consultancy/opportunities',
|
|
17
|
+
label: 'consultancy.nav.opportunities',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'consultancy/proposals',
|
|
21
|
+
label: 'consultancy.nav.proposals',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'consultancy/reports',
|
|
25
|
+
label: 'consultancy.nav.reports',
|
|
26
|
+
},
|
|
11
27
|
{
|
|
12
28
|
id: 'consultancy/employees',
|
|
13
29
|
label: 'consultancy.nav.employees',
|
|
@@ -20,14 +36,6 @@ const TABS = [
|
|
|
20
36
|
id: 'consultancy/contracts',
|
|
21
37
|
label: 'consultancy.nav.contracts',
|
|
22
38
|
},
|
|
23
|
-
{
|
|
24
|
-
id: 'consultancy/opportunities',
|
|
25
|
-
label: 'consultancy.nav.opportunities',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'consultancy/proposals',
|
|
29
|
-
label: 'consultancy.nav.proposals',
|
|
30
|
-
},
|
|
31
39
|
{
|
|
32
40
|
id: 'consultancy/margins',
|
|
33
41
|
label: 'consultancy.nav.margins',
|
package/src/Forecast.jsx
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { View, Text,
|
|
3
|
-
import { CalendarDaySurfaceStyles,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { buildKpiChartLayout } from './forecast-kpi-chart.js'
|
|
7
|
-
import { TIMESHEET_LOCATION, TIMESHEET_TYPE, withUtilizationHours } from './utilization-hours.js'
|
|
8
|
-
|
|
9
|
-
const grid = {
|
|
10
|
-
width: '100%',
|
|
11
|
-
height: '100%',
|
|
12
|
-
display: 'flex',
|
|
13
|
-
flexDirection: 'row',
|
|
14
|
-
flexWrap: 'wrap',
|
|
15
|
-
gap: '1px',
|
|
16
|
-
overflowX: 'auto',
|
|
17
|
-
}
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { DashboardLayout, Panel, View, Text, useLocale } from '@ossy/design-system'
|
|
3
|
+
import { CalendarDaySurfaceStyles, useForecast } from '@ossy/calendar'
|
|
4
|
+
import { CurrentMonthForecastPanel } from './current-month.component.jsx'
|
|
5
|
+
import { KpiTrendPanel, UtilizationPanel, YearTotalsPanel } from './forecast-panels.jsx'
|
|
18
6
|
|
|
19
7
|
const calendarGrid = {
|
|
20
8
|
display: 'grid',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
gridTemplateColumns: 'repeat(7,
|
|
24
|
-
|
|
25
|
-
gap: 'var(--space-m)',
|
|
9
|
+
width: '100%',
|
|
10
|
+
minWidth: 0,
|
|
11
|
+
gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
|
|
12
|
+
gap: '4px',
|
|
26
13
|
justifyItems: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
27
15
|
}
|
|
28
16
|
|
|
29
17
|
const calendarDayLayout = {
|
|
@@ -31,304 +19,18 @@ const calendarDayLayout = {
|
|
|
31
19
|
display: 'flex',
|
|
32
20
|
justifyContent: 'center',
|
|
33
21
|
alignItems: 'center',
|
|
22
|
+
width: '100%',
|
|
23
|
+
maxWidth: 32,
|
|
24
|
+
aspectRatio: '1',
|
|
25
|
+
minWidth: 0,
|
|
34
26
|
borderRadius: '50%',
|
|
35
|
-
padding:
|
|
27
|
+
padding: 0,
|
|
36
28
|
fontSize: '.6rem',
|
|
37
29
|
margin: 0,
|
|
38
30
|
}
|
|
39
31
|
|
|
40
|
-
const KPI_SERIES = [
|
|
41
|
-
// Contract forecast is dashed. Timesheet actuals are solid. Same color pairs the two.
|
|
42
|
-
{ key: 'projectedIncome', label: 'consultancy.forecasts.forecastIncome', color: 'var(--color-info, hsl(199, 89%, 43%))', dashed: true },
|
|
43
|
-
{ key: 'actualIncome', label: 'consultancy.forecasts.actualIncome', color: 'var(--color-info, hsl(199, 89%, 43%))' },
|
|
44
|
-
{ key: 'monthlyCostOfEmployees', label: 'consultancy.forecasts.salaryCost', color: 'var(--color-warning, hsl(38, 92%, 50%))', dashed: true },
|
|
45
|
-
{ key: 'revenue', label: 'consultancy.forecasts.forecastRevenue', color: 'var(--color-accent, hsl(167, 89%, 43%))', dashed: true },
|
|
46
|
-
{ key: 'actualRevenue', label: 'consultancy.forecasts.actualRevenue', color: 'var(--color-accent, hsl(167, 89%, 43%))' },
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
const UTILIZATION_SERIES = [
|
|
50
|
-
{ key: 'forecastHours', label: 'consultancy.forecasts.forecastHours', color: 'var(--color-info, hsl(199, 89%, 43%))', scale: 'hours', dashed: true },
|
|
51
|
-
{ key: 'actualHours', label: 'consultancy.forecasts.actualHours', color: 'var(--color-accent, hsl(167, 89%, 43%))', scale: 'hours' },
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
function ChartAxisLabel ({ x, y, viewWidth, viewHeight, children }) {
|
|
55
|
-
return (
|
|
56
|
-
<Text
|
|
57
|
-
as="span"
|
|
58
|
-
variant="small"
|
|
59
|
-
data-chart-axis-label=""
|
|
60
|
-
style={{
|
|
61
|
-
position: 'absolute',
|
|
62
|
-
left: `${(x / viewWidth) * 100}%`,
|
|
63
|
-
top: `${(y / viewHeight) * 100}%`,
|
|
64
|
-
transform: 'translate(-50%, -100%)',
|
|
65
|
-
margin: 0,
|
|
66
|
-
opacity: 0.75,
|
|
67
|
-
lineHeight: 1,
|
|
68
|
-
whiteSpace: 'nowrap',
|
|
69
|
-
pointerEvents: 'none',
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
{children}
|
|
73
|
-
</Text>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function SectionPanel ({ title, children }) {
|
|
78
|
-
return (
|
|
79
|
-
<View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden', height: '100%' }}>
|
|
80
|
-
<View stack bordered>
|
|
81
|
-
<View.Item
|
|
82
|
-
data-surface="primary"
|
|
83
|
-
layout="row"
|
|
84
|
-
style={{
|
|
85
|
-
alignItems: 'center',
|
|
86
|
-
justifyContent: 'space-between',
|
|
87
|
-
padding: 'var(--space-s) var(--space-m)',
|
|
88
|
-
gap: 'var(--space-m)',
|
|
89
|
-
height: '48px',
|
|
90
|
-
flexShrink: 0,
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{title}</Text>
|
|
94
|
-
</View.Item>
|
|
95
|
-
<View.Item>
|
|
96
|
-
{children}
|
|
97
|
-
</View.Item>
|
|
98
|
-
</View>
|
|
99
|
-
</View>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Hand-rolled multi-series line chart.
|
|
105
|
-
* Matches the no-dependency SVG approach from analytics DailyBarChart (#917).
|
|
106
|
-
*/
|
|
107
|
-
function ForecastKpiChart ({ months, series, unit }) {
|
|
108
|
-
const { language, t } = useLocale()
|
|
109
|
-
const chart = useMemo(
|
|
110
|
-
() => buildKpiChartLayout({ months, series, language }),
|
|
111
|
-
[months, series, language],
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
if (!chart) {
|
|
115
|
-
return (
|
|
116
|
-
<View inset="m">
|
|
117
|
-
<Text variant="small" text="consultancy.forecasts.yearChartEmpty" />
|
|
118
|
-
</View>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<View gap="s" inset="m" style={{ width: '100%' }}>
|
|
124
|
-
<View layout="row-wrap" gap="m" style={{ alignItems: 'center', justifyContent: 'space-between' }}>
|
|
125
|
-
<View layout="row-wrap" gap="m" style={{ alignItems: 'center' }}>
|
|
126
|
-
{series.map((entry) => (
|
|
127
|
-
<View key={entry.key} layout="row" gap="s" style={{ alignItems: 'center' }}>
|
|
128
|
-
<span
|
|
129
|
-
aria-hidden
|
|
130
|
-
style={{
|
|
131
|
-
width: 10,
|
|
132
|
-
height: 10,
|
|
133
|
-
borderRadius: 2,
|
|
134
|
-
background: entry.color,
|
|
135
|
-
display: 'inline-block',
|
|
136
|
-
flexShrink: 0,
|
|
137
|
-
...(entry.dashed
|
|
138
|
-
? {
|
|
139
|
-
background: 'transparent',
|
|
140
|
-
borderTop: `2px dashed ${entry.color}`,
|
|
141
|
-
height: 0,
|
|
142
|
-
borderRadius: 0,
|
|
143
|
-
}
|
|
144
|
-
: null),
|
|
145
|
-
}}
|
|
146
|
-
/>
|
|
147
|
-
<Text variant="small" style={{ marginBottom: 0 }} text={entry.label} />
|
|
148
|
-
</View>
|
|
149
|
-
))}
|
|
150
|
-
</View>
|
|
151
|
-
{unit ? (
|
|
152
|
-
<Text
|
|
153
|
-
as="span"
|
|
154
|
-
variant="small"
|
|
155
|
-
data-consultancy-chart-unit=""
|
|
156
|
-
text={unit}
|
|
157
|
-
style={{ marginBottom: 0 }}
|
|
158
|
-
/>
|
|
159
|
-
) : null}
|
|
160
|
-
</View>
|
|
161
|
-
<div style={{ display: 'flex', alignItems: 'stretch', width: '100%', gap: 4 }}>
|
|
162
|
-
{chart.yTicks.length > 0 ? (
|
|
163
|
-
<div style={{ position: 'relative', flex: '0 0 auto' }}>
|
|
164
|
-
<div aria-hidden style={{ display: 'grid' }}>
|
|
165
|
-
{chart.yTicks.map((tick) => (
|
|
166
|
-
<Text
|
|
167
|
-
key={`tick-size-${tick.value}`}
|
|
168
|
-
as="span"
|
|
169
|
-
variant="small"
|
|
170
|
-
style={{
|
|
171
|
-
gridArea: '1 / 1',
|
|
172
|
-
visibility: 'hidden',
|
|
173
|
-
margin: 0,
|
|
174
|
-
lineHeight: 1,
|
|
175
|
-
whiteSpace: 'nowrap',
|
|
176
|
-
}}
|
|
177
|
-
>
|
|
178
|
-
{tick.label}
|
|
179
|
-
</Text>
|
|
180
|
-
))}
|
|
181
|
-
</div>
|
|
182
|
-
{chart.yTicks.map((tick) => (
|
|
183
|
-
<Text
|
|
184
|
-
key={`tick-label-${tick.value}`}
|
|
185
|
-
as="span"
|
|
186
|
-
variant="small"
|
|
187
|
-
data-consultancy-chart-tick={tick.label}
|
|
188
|
-
style={{
|
|
189
|
-
position: 'absolute',
|
|
190
|
-
right: 0,
|
|
191
|
-
top: `${(tick.y / chart.viewHeight) * 100}%`,
|
|
192
|
-
transform: 'translateY(-50%)',
|
|
193
|
-
margin: 0,
|
|
194
|
-
opacity: 0.75,
|
|
195
|
-
lineHeight: 1,
|
|
196
|
-
whiteSpace: 'nowrap',
|
|
197
|
-
pointerEvents: 'none',
|
|
198
|
-
}}
|
|
199
|
-
>
|
|
200
|
-
{tick.label}
|
|
201
|
-
</Text>
|
|
202
|
-
))}
|
|
203
|
-
</div>
|
|
204
|
-
) : null}
|
|
205
|
-
<div style={{ position: 'relative', flex: '1 1 auto', minWidth: 0 }}>
|
|
206
|
-
<svg
|
|
207
|
-
data-consultancy-kpi-chart
|
|
208
|
-
viewBox={`0 0 ${chart.viewWidth} ${chart.viewHeight}`}
|
|
209
|
-
width="100%"
|
|
210
|
-
role="img"
|
|
211
|
-
aria-label={unit ? t(unit) : undefined}
|
|
212
|
-
style={{
|
|
213
|
-
display: 'block',
|
|
214
|
-
width: '100%',
|
|
215
|
-
height: 'auto',
|
|
216
|
-
aspectRatio: `${chart.viewWidth} / ${chart.viewHeight}`,
|
|
217
|
-
}}
|
|
218
|
-
preserveAspectRatio="xMidYMid meet"
|
|
219
|
-
>
|
|
220
|
-
{chart.yTicks.map((tick) => (
|
|
221
|
-
<line
|
|
222
|
-
key={`tick-${tick.value}`}
|
|
223
|
-
x1={tick.x1}
|
|
224
|
-
x2={tick.x2}
|
|
225
|
-
y1={tick.y}
|
|
226
|
-
y2={tick.y}
|
|
227
|
-
stroke="currentColor"
|
|
228
|
-
strokeOpacity="0.15"
|
|
229
|
-
vectorEffect="non-scaling-stroke"
|
|
230
|
-
/>
|
|
231
|
-
))}
|
|
232
|
-
{chart.seriesPaths.map((series) => (
|
|
233
|
-
series.path ? (
|
|
234
|
-
<path
|
|
235
|
-
key={series.key}
|
|
236
|
-
d={series.path}
|
|
237
|
-
fill="none"
|
|
238
|
-
stroke={series.color}
|
|
239
|
-
strokeWidth={2}
|
|
240
|
-
strokeLinejoin="round"
|
|
241
|
-
strokeLinecap="round"
|
|
242
|
-
strokeDasharray={series.dashed ? '6 4' : undefined}
|
|
243
|
-
vectorEffect="non-scaling-stroke"
|
|
244
|
-
/>
|
|
245
|
-
) : null
|
|
246
|
-
))}
|
|
247
|
-
</svg>
|
|
248
|
-
{chart.monthLabels.map((label) => (
|
|
249
|
-
<ChartAxisLabel
|
|
250
|
-
key={`month-${label.index}`}
|
|
251
|
-
x={label.x}
|
|
252
|
-
y={label.y}
|
|
253
|
-
viewWidth={chart.viewWidth}
|
|
254
|
-
viewHeight={chart.viewHeight}
|
|
255
|
-
>
|
|
256
|
-
<span data-consultancy-kpi-month={label.label}>{label.label}</span>
|
|
257
|
-
</ChartAxisLabel>
|
|
258
|
-
))}
|
|
259
|
-
</div>
|
|
260
|
-
</div>
|
|
261
|
-
</View>
|
|
262
|
-
)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function UtilizationPanel ({ months }) {
|
|
266
|
-
const { t } = useLocale()
|
|
267
|
-
|
|
268
|
-
return (
|
|
269
|
-
<SectionPanel title={t('consultancy.forecasts.utilization')}>
|
|
270
|
-
<ForecastKpiChart months={months} series={UTILIZATION_SERIES} unit="consultancy.forecasts.unitHours" />
|
|
271
|
-
</SectionPanel>
|
|
272
|
-
)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function YearSummary ({ months, money, hours }) {
|
|
276
|
-
const { t } = useLocale()
|
|
277
|
-
const totals = useMemo(() => sumFiscalYearTotals(months), [months])
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<View
|
|
281
|
-
data-consultancy-year-summary
|
|
282
|
-
layout="row-wrap"
|
|
283
|
-
gap="m"
|
|
284
|
-
style={{ alignItems: 'stretch', width: '100%' }}
|
|
285
|
-
>
|
|
286
|
-
<View style={{ flex: '2 1 320px', minWidth: 0 }}>
|
|
287
|
-
<SectionPanel title={t('consultancy.forecasts.yearChart')}>
|
|
288
|
-
<ForecastKpiChart months={months} series={KPI_SERIES} unit="consultancy.forecasts.unitMoney" />
|
|
289
|
-
</SectionPanel>
|
|
290
|
-
</View>
|
|
291
|
-
<View style={{ flex: '1 1 240px', minWidth: 0 }}>
|
|
292
|
-
<SectionPanel title={t('consultancy.forecasts.yearSummary')}>
|
|
293
|
-
<View gap="s" inset="m">
|
|
294
|
-
<View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
|
|
295
|
-
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
|
|
296
|
-
<Text variant="m" style={{ marginBottom: 0 }}>{money(totals.projectedIncome)}</Text>
|
|
297
|
-
</View>
|
|
298
|
-
<View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
|
|
299
|
-
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.salaryCost" />
|
|
300
|
-
<Text variant="m" style={{ marginBottom: 0 }}>{money(totals.monthlyCostOfEmployees)}</Text>
|
|
301
|
-
</View>
|
|
302
|
-
<View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
|
|
303
|
-
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.revenue" />
|
|
304
|
-
<Text variant="m" style={{ marginBottom: 0 }}>{money(totals.revenue)}</Text>
|
|
305
|
-
</View>
|
|
306
|
-
<View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
|
|
307
|
-
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.hoursWorked" />
|
|
308
|
-
<Text variant="m" style={{ marginBottom: 0 }}>{hours(totals.hoursWorked)}</Text>
|
|
309
|
-
</View>
|
|
310
|
-
</View>
|
|
311
|
-
</SectionPanel>
|
|
312
|
-
</View>
|
|
313
|
-
</View>
|
|
314
|
-
)
|
|
315
|
-
}
|
|
316
|
-
|
|
317
32
|
export const Forecast = () => {
|
|
318
33
|
const months = useForecast()
|
|
319
|
-
const contracts = useContracts()
|
|
320
|
-
const employees = useEmployees()
|
|
321
|
-
const vacations = useVacations()
|
|
322
|
-
const sdk = useSdk()
|
|
323
|
-
const { data: timesheetResources = [] } = sdk.read(ListResources, { location: TIMESHEET_LOCATION })
|
|
324
|
-
const chartMonths = useMemo(() => withUtilizationHours({
|
|
325
|
-
months,
|
|
326
|
-
timesheets: (Array.isArray(timesheetResources) ? timesheetResources : [])
|
|
327
|
-
.filter((resource) => resource.type === TIMESHEET_TYPE),
|
|
328
|
-
vacations,
|
|
329
|
-
employees,
|
|
330
|
-
contracts,
|
|
331
|
-
}), [months, timesheetResources, vacations, employees, contracts])
|
|
332
34
|
const { language } = useLocale()
|
|
333
35
|
const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', { style: "currency", currency: "SEK" }).format(value)
|
|
334
36
|
const hours = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-GB', { style: "unit", unit: "hour" }).format(value)
|
|
@@ -336,18 +38,19 @@ export const Forecast = () => {
|
|
|
336
38
|
return (
|
|
337
39
|
<>
|
|
338
40
|
<CalendarDaySurfaceStyles />
|
|
339
|
-
<
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
<
|
|
350
|
-
|
|
41
|
+
<DashboardLayout gap="xs">
|
|
42
|
+
<DashboardLayout.Widget span={4}>
|
|
43
|
+
<CurrentMonthForecastPanel />
|
|
44
|
+
</DashboardLayout.Widget>
|
|
45
|
+
<DashboardLayout.Widget span={8}>
|
|
46
|
+
<UtilizationPanel />
|
|
47
|
+
</DashboardLayout.Widget>
|
|
48
|
+
<DashboardLayout.Widget span={4}>
|
|
49
|
+
<YearTotalsPanel />
|
|
50
|
+
</DashboardLayout.Widget>
|
|
51
|
+
<DashboardLayout.Widget span={8}>
|
|
52
|
+
<KpiTrendPanel />
|
|
53
|
+
</DashboardLayout.Widget>
|
|
351
54
|
{months.map(month => {
|
|
352
55
|
const startPad = month.days[0].isoWeekday - 1
|
|
353
56
|
const totalCells = startPad + month.days.length
|
|
@@ -355,19 +58,17 @@ export const Forecast = () => {
|
|
|
355
58
|
const monthKey = `${month.year}-${month.month}`
|
|
356
59
|
|
|
357
60
|
return (
|
|
358
|
-
<
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
61
|
+
<DashboardLayout.Widget key={monthKey} span={3}>
|
|
62
|
+
<Panel
|
|
63
|
+
status={month.isCurrentMonth ? 'success' : undefined}
|
|
64
|
+
title={(
|
|
65
|
+
<Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>
|
|
66
|
+
{month.year} {month.month}
|
|
67
|
+
</Text>
|
|
68
|
+
)}
|
|
69
|
+
style={{ minWidth: 0, flex: '1 1 auto' }}
|
|
364
70
|
>
|
|
365
|
-
<
|
|
366
|
-
<Separator
|
|
367
|
-
data-forecast-current-month={month.isCurrentMonth}
|
|
368
|
-
variant={month.isCurrentMonth ? 'accent' : 'primary'}
|
|
369
|
-
/>
|
|
370
|
-
<View gap="s" style={{ flexGrow: '1' }}>
|
|
71
|
+
<View gap="s" inset="m" style={{ flexGrow: 1 }}>
|
|
371
72
|
|
|
372
73
|
<View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
|
|
373
74
|
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
|
|
@@ -399,9 +100,7 @@ export const Forecast = () => {
|
|
|
399
100
|
|
|
400
101
|
</View>
|
|
401
102
|
|
|
402
|
-
<
|
|
403
|
-
|
|
404
|
-
<div style={calendarGrid}>
|
|
103
|
+
<div style={{ ...calendarGrid, padding: '0 var(--space-m) var(--space-m)' }}>
|
|
405
104
|
|
|
406
105
|
{Array.from({ length: startPad }, (_, i) => (
|
|
407
106
|
<div key={`${monthKey}-pad-s-${i}`} />
|
|
@@ -424,11 +123,11 @@ export const Forecast = () => {
|
|
|
424
123
|
))}
|
|
425
124
|
|
|
426
125
|
</div>
|
|
427
|
-
</
|
|
126
|
+
</Panel>
|
|
127
|
+
</DashboardLayout.Widget>
|
|
428
128
|
)
|
|
429
129
|
})}
|
|
430
|
-
|
|
431
|
-
</View>
|
|
130
|
+
</DashboardLayout>
|
|
432
131
|
</>
|
|
433
132
|
)
|
|
434
133
|
}
|
package/src/Overview.jsx
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { View, Text, useLocale } from '@ossy/design-system'
|
|
2
|
+
import { Panel, View, Text, useLocale } from '@ossy/design-system'
|
|
3
3
|
import { useCompany } from '@ossy/calendar'
|
|
4
4
|
|
|
5
|
-
function SectionPanel ({ title, children }) {
|
|
6
|
-
return (
|
|
7
|
-
<View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden', height: '100%' }}>
|
|
8
|
-
<View stack bordered>
|
|
9
|
-
<View.Item
|
|
10
|
-
data-surface="primary"
|
|
11
|
-
layout="row"
|
|
12
|
-
style={{
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
justifyContent: 'space-between',
|
|
15
|
-
padding: 'var(--space-s) var(--space-m)',
|
|
16
|
-
gap: 'var(--space-m)',
|
|
17
|
-
height: '48px',
|
|
18
|
-
flexShrink: 0,
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{title}</Text>
|
|
22
|
-
</View.Item>
|
|
23
|
-
<View.Item>
|
|
24
|
-
{children}
|
|
25
|
-
</View.Item>
|
|
26
|
-
</View>
|
|
27
|
-
</View>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
5
|
function InfoRow ({ label, value }) {
|
|
32
6
|
return (
|
|
33
7
|
<View layout="row" justifyContent="space-between" gap="s">
|
|
@@ -63,7 +37,7 @@ export const Overview = () => {
|
|
|
63
37
|
style={{ alignItems: 'stretch' }}
|
|
64
38
|
>
|
|
65
39
|
<View style={{ flex: '1 1 280px', minWidth: 0 }}>
|
|
66
|
-
<
|
|
40
|
+
<Panel title="consultancy.overview.fiscalYears" style={{ height: '100%' }}>
|
|
67
41
|
<View gap="s" inset="m">
|
|
68
42
|
{fiscalYears.length === 0 ? (
|
|
69
43
|
<Text variant="small" text="consultancy.overview.noFiscalYears" />
|
|
@@ -74,11 +48,16 @@ export const Overview = () => {
|
|
|
74
48
|
</View>
|
|
75
49
|
))}
|
|
76
50
|
</View>
|
|
77
|
-
</
|
|
51
|
+
</Panel>
|
|
78
52
|
</View>
|
|
79
53
|
|
|
80
54
|
<View style={{ flex: '1 1 280px', minWidth: 0 }}>
|
|
81
|
-
<
|
|
55
|
+
<Panel
|
|
56
|
+
style={{ height: '100%' }}
|
|
57
|
+
title={company?.name
|
|
58
|
+
? <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{company.name}</Text>
|
|
59
|
+
: 'consultancy.overview.company'}
|
|
60
|
+
>
|
|
82
61
|
<View gap="s" inset="m">
|
|
83
62
|
<InfoRow
|
|
84
63
|
label={t('@ossy/consultancy/schema/company-basic-info.registrationDate.label')}
|
|
@@ -105,7 +84,7 @@ export const Overview = () => {
|
|
|
105
84
|
value={vatPeriodLabel}
|
|
106
85
|
/>
|
|
107
86
|
</View>
|
|
108
|
-
</
|
|
87
|
+
</Panel>
|
|
109
88
|
</View>
|
|
110
89
|
</View>
|
|
111
90
|
)
|