@ossy/consultancy 3.14.0 → 3.15.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 +10 -4
- package/package.json +10 -4
- package/src/AssignmentMarginCalculator.jsx +202 -0
- package/src/ConsultancyNav.jsx +38 -0
- package/src/Definition.js +2 -2
- package/src/Forecast.jsx +136 -0
- package/src/assignment-margin.flow.js +63 -0
- package/src/assignment-margin.js +106 -0
- package/src/assignment-margin.spec.js +85 -0
- package/src/calculator.form.js +5 -0
- package/src/calculator.schema.js +18 -0
- package/src/consultancy.page.jsx +2 -0
- package/src/en.translations.json +41 -1
- package/src/forecasts.page.jsx +39 -0
- package/src/index.js +9 -0
- package/src/margins.page.jsx +37 -0
- package/src/sv.translations.json +41 -1
- package/src/view-forecasts.flow.js +23 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ossy/consultancy
|
|
2
2
|
|
|
3
|
-
Consultancy **feature package** for the Ossy platform — schemas and UI for employees, contracts, company information, vacations,
|
|
3
|
+
Consultancy **feature package** for the Ossy platform — schemas and UI for employees, contracts, company information, vacations, the **opportunity → proposal** sales pipeline, **forecasts**, and an **assignment margin** calculator.
|
|
4
4
|
|
|
5
5
|
## What's included
|
|
6
6
|
|
|
@@ -9,8 +9,12 @@ Consultancy **feature package** for the Ossy platform — schemas and UI for emp
|
|
|
9
9
|
| File | Page id | Default paths |
|
|
10
10
|
|---|---|---|
|
|
11
11
|
| `consultancy.page.jsx` | `consultancy/home` | `/consultancy` (en), `/konsultverksamhet` (sv) |
|
|
12
|
+
| `forecasts.page.jsx` | `consultancy/forecasts` | `/consultancy/forecasts`, `/konsultverksamhet/prognoser` |
|
|
13
|
+
| `margins.page.jsx` | `consultancy/margins` | `/consultancy/margins`, `/konsultverksamhet/marginaler` |
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
One sidebar item (**Consultancy**). Overview, Forecasts, and Margins are in-product tabs under that surface.
|
|
16
|
+
|
|
17
|
+
The overview page shows company data (fiscal years, registration, VAT) via `@ossy/calendar`'s `useCompany` hook. Forecasts use `@ossy/calendar`'s `useForecast` / `ForecastClient` (engine stays in calendar). Margins is a standalone calculator (not yet wired to live resources).
|
|
14
18
|
|
|
15
19
|
### Schemas (ADR 0006)
|
|
16
20
|
|
|
@@ -24,6 +28,7 @@ Document types are defined in `*.schema.js`. Import canonical ids from `Consulta
|
|
|
24
28
|
| Vacation | `@ossy/consultancy/schema/vacation` | Employee vacation periods |
|
|
25
29
|
| Opportunity | `@ossy/consultancy/schema/opportunity` | Sales pipeline leads and qualification |
|
|
26
30
|
| Proposal | `@ossy/consultancy/schema/proposal` | Draft and sent proposals linked to opportunities |
|
|
31
|
+
| Calculator | `@ossy/consultancy/schema/calculator` | Assignment margin form fields (Platform category — not in create picker) |
|
|
27
32
|
|
|
28
33
|
Document instances are stored under `/@ossy/consultancy/` (see the `location` export in `locations.js`).
|
|
29
34
|
|
|
@@ -41,6 +46,7 @@ These schemas support platform automation workflows:
|
|
|
41
46
|
| `CreateConsultancyButton` | Add CTA that opens create-document for consultancy schemas |
|
|
42
47
|
| `ConsultancySchema` | Canonical schema id constants |
|
|
43
48
|
| `employeeSchema`, `contractSchema`, … | Schema definitions for manifest build |
|
|
49
|
+
| `calculateAssignmentMargin`, … | Pure margin / employer-cost helpers |
|
|
44
50
|
| `location` | Workspace storage path (`/@ossy/consultancy/`) |
|
|
45
51
|
| `Definition` | Feature metadata for store/sidebar (`status: ['beta']`) |
|
|
46
52
|
|
|
@@ -54,7 +60,7 @@ npm run build
|
|
|
54
60
|
`@ossy/app` discovers pages automatically via `"ossy": { "src": "./src" }` in `package.json`. Schemas are picked up from `*.schema.js` files at build time.
|
|
55
61
|
|
|
56
62
|
```js
|
|
57
|
-
import { ConsultancySchema,
|
|
63
|
+
import { ConsultancySchema, calculateAssignmentMargin } from '@ossy/consultancy'
|
|
58
64
|
|
|
59
65
|
ConsultancySchema.employee
|
|
60
66
|
// => '@ossy/consultancy/schema/employee'
|
|
@@ -76,7 +82,7 @@ This package migrated from `*.resource.js` to ADR 0006 schemas. Stored `resource
|
|
|
76
82
|
| Package | Role |
|
|
77
83
|
|---|---|
|
|
78
84
|
| `@ossy/schema` | Canonical id grammar and schema validation |
|
|
79
|
-
| `@ossy/calendar` | `DataLoader`, `useCompany`
|
|
85
|
+
| `@ossy/calendar` | `DataLoader`, `useCompany`, `useForecast` |
|
|
80
86
|
| `@ossy/design-system` | Layout primitives and `Page` component |
|
|
81
87
|
| `@ossy/router-react` | Page routing |
|
|
82
88
|
| `react` | UI |
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/consultancy",
|
|
3
|
-
"description": "Consultancy feature package — schemas
|
|
4
|
-
"version": "3.
|
|
3
|
+
"description": "Consultancy feature package — schemas, forecasts UI, and assignment margins",
|
|
4
|
+
"version": "3.15.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./src/index.js"
|
|
10
10
|
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose"
|
|
13
|
+
},
|
|
11
14
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
12
15
|
"license": "MIT",
|
|
13
16
|
"ossy": {
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
"README.md"
|
|
23
26
|
],
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"@ossy/schema": "^3.
|
|
28
|
+
"@ossy/schema": "^3.15.0"
|
|
26
29
|
},
|
|
27
30
|
"peerDependencies": {
|
|
28
31
|
"@ossy/calendar": "*",
|
|
@@ -30,5 +33,8 @@
|
|
|
30
33
|
"@ossy/router-react": "*",
|
|
31
34
|
"react": "*"
|
|
32
35
|
},
|
|
33
|
-
"
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"jest": "^30.2.0"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "23517232ddc4f2c64ca0062faa3cad84ceaa34a7"
|
|
34
40
|
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
Alert,
|
|
6
|
+
Separator,
|
|
7
|
+
Form,
|
|
8
|
+
FieldFactory,
|
|
9
|
+
useLocale,
|
|
10
|
+
} from '@ossy/design-system'
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_AVAILABLE_HOURS_PER_MONTH,
|
|
13
|
+
DEFAULT_WEEKS_PER_YEAR,
|
|
14
|
+
calculateAssignmentMargin,
|
|
15
|
+
estimateAdminLeakage,
|
|
16
|
+
} from './assignment-margin.js'
|
|
17
|
+
import { metadata as CalculatorForm } from './calculator.form.js'
|
|
18
|
+
import calculatorSchema from './calculator.schema.js'
|
|
19
|
+
|
|
20
|
+
const DEFAULT_DATA = {
|
|
21
|
+
hourlyRate: '900',
|
|
22
|
+
billableHours: '120',
|
|
23
|
+
monthlySalary: '47000',
|
|
24
|
+
availableHours: String(DEFAULT_AVAILABLE_HOURS_PER_MONTH),
|
|
25
|
+
teamSize: '10',
|
|
26
|
+
adminHoursPerWeek: '5',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function readFormData (form) {
|
|
30
|
+
if (!form) return null
|
|
31
|
+
const next = { ...DEFAULT_DATA }
|
|
32
|
+
for (const field of calculatorSchema.fields) {
|
|
33
|
+
const el = form.elements?.namedItem?.(field.name)
|
|
34
|
+
if (el && 'value' in el) next[field.name] = el.value
|
|
35
|
+
}
|
|
36
|
+
return next
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function parseNumber (value, fallback = 0) {
|
|
40
|
+
const trimmed = String(value ?? '').replace(/\s/g, '').replace(',', '.')
|
|
41
|
+
if (trimmed === '') return fallback
|
|
42
|
+
const parsed = Number(trimmed)
|
|
43
|
+
return Number.isFinite(parsed) ? parsed : fallback
|
|
44
|
+
}
|
|
45
|
+
|
|
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
|
+
function MetricRow ({ label, value }) {
|
|
73
|
+
return (
|
|
74
|
+
<View layout="row" justifyContent="space-between" gap="s">
|
|
75
|
+
<Text variant="small" text={label} />
|
|
76
|
+
<Text variant="small">{value}</Text>
|
|
77
|
+
</View>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const AssignmentMarginCalculator = () => {
|
|
82
|
+
const { language } = useLocale()
|
|
83
|
+
const locale = language === 'sv' ? 'sv-SE' : 'en-SE'
|
|
84
|
+
const [data, setData] = useState(DEFAULT_DATA)
|
|
85
|
+
|
|
86
|
+
// Keep live results aligned with the DOM. Playwright `form` fills update input
|
|
87
|
+
// values without always delivering React onChange; polling the form fields is
|
|
88
|
+
// reliable for this client-only calculator.
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
const sync = () => {
|
|
91
|
+
const form = document.getElementById(CalculatorForm.id)
|
|
92
|
+
?? document.querySelector(`form[id="${CalculatorForm.id}"]`)
|
|
93
|
+
const next = readFormData(form)
|
|
94
|
+
if (!next) return
|
|
95
|
+
setData((prev) => {
|
|
96
|
+
const same = calculatorSchema.fields.every((field) => (
|
|
97
|
+
String(prev[field.name] ?? '') === String(next[field.name] ?? '')
|
|
98
|
+
))
|
|
99
|
+
return same ? prev : next
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
sync()
|
|
103
|
+
const timer = window.setInterval(sync, 100)
|
|
104
|
+
return () => window.clearInterval(timer)
|
|
105
|
+
}, [])
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const rate = parseNumber(data.hourlyRate, 900)
|
|
109
|
+
const hours = parseNumber(data.billableHours, 120)
|
|
110
|
+
const salary = parseNumber(data.monthlySalary, 47000)
|
|
111
|
+
const available = parseNumber(data.availableHours, DEFAULT_AVAILABLE_HOURS_PER_MONTH)
|
|
112
|
+
const people = parseNumber(data.teamSize, 10)
|
|
113
|
+
const adminHours = parseNumber(data.adminHoursPerWeek, 5)
|
|
114
|
+
|
|
115
|
+
const margin = calculateAssignmentMargin({
|
|
116
|
+
hourlyRate: rate,
|
|
117
|
+
billableHours: hours,
|
|
118
|
+
monthlySalary: salary,
|
|
119
|
+
availableHoursPerMonth: available,
|
|
120
|
+
})
|
|
121
|
+
const leakage = estimateAdminLeakage({
|
|
122
|
+
teamSize: people,
|
|
123
|
+
adminHoursPerPersonPerWeek: adminHours,
|
|
124
|
+
hourlyRate: rate,
|
|
125
|
+
weeksPerYear: DEFAULT_WEEKS_PER_YEAR,
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const money = (value) => new Intl.NumberFormat(locale, {
|
|
129
|
+
style: 'currency',
|
|
130
|
+
currency: 'SEK',
|
|
131
|
+
maximumFractionDigits: 0,
|
|
132
|
+
}).format(Number.isFinite(value) ? value : 0)
|
|
133
|
+
|
|
134
|
+
const percent = (value) => new Intl.NumberFormat(locale, {
|
|
135
|
+
style: 'percent',
|
|
136
|
+
maximumFractionDigits: 1,
|
|
137
|
+
}).format(Number.isFinite(value) ? value : 0)
|
|
138
|
+
|
|
139
|
+
const hoursFormat = (value) => `${new Intl.NumberFormat(locale, {
|
|
140
|
+
maximumFractionDigits: 1,
|
|
141
|
+
}).format(Number.isFinite(value) ? value : 0)} h`
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<Form
|
|
145
|
+
id={CalculatorForm.id}
|
|
146
|
+
schemaId={CalculatorForm.schemaId}
|
|
147
|
+
fields={calculatorSchema.fields}
|
|
148
|
+
defaultData={DEFAULT_DATA}
|
|
149
|
+
onChange={({ data: next }) => setData(next)}
|
|
150
|
+
gap="m"
|
|
151
|
+
data-margins="calculator"
|
|
152
|
+
>
|
|
153
|
+
<Alert variant="info">
|
|
154
|
+
<Text as="span" variant="s" text="consultancy.margins.notes.purpose" style={{ display: 'block', marginBottom: 8 }} />
|
|
155
|
+
<Text as="span" variant="s" text="consultancy.margins.notes.swedishCost" style={{ display: 'block' }} />
|
|
156
|
+
</Alert>
|
|
157
|
+
|
|
158
|
+
<View layout="row-wrap" gap="m" style={{ alignItems: 'stretch' }}>
|
|
159
|
+
<View style={{ flex: '1 1 320px', minWidth: 0 }}>
|
|
160
|
+
<SectionPanel title="consultancy.margins.inputs.title">
|
|
161
|
+
<View inset="m" gap="m">
|
|
162
|
+
<FieldFactory />
|
|
163
|
+
</View>
|
|
164
|
+
</SectionPanel>
|
|
165
|
+
</View>
|
|
166
|
+
|
|
167
|
+
<View style={{ flex: '1 1 320px', minWidth: 0 }}>
|
|
168
|
+
<SectionPanel
|
|
169
|
+
title="consultancy.margins.results.title"
|
|
170
|
+
data-margins-status={margin.isProfitable ? 'profitable' : 'unprofitable'}
|
|
171
|
+
>
|
|
172
|
+
<View gap="s" inset="m">
|
|
173
|
+
<MetricRow label="consultancy.margins.results.revenue" value={money(margin.revenue)} />
|
|
174
|
+
<MetricRow label="consultancy.margins.results.deliveryCost" value={money(margin.deliveryCost)} />
|
|
175
|
+
<MetricRow label="consultancy.margins.results.grossMargin" value={money(margin.grossMargin)} />
|
|
176
|
+
<MetricRow label="consultancy.margins.results.marginPercent" value={percent(margin.marginPercent)} />
|
|
177
|
+
<Separator />
|
|
178
|
+
<MetricRow label="consultancy.margins.results.employerCost" value={money(margin.employerCost)} />
|
|
179
|
+
<MetricRow label="consultancy.margins.results.monthPnl" value={money(margin.monthPnl)} />
|
|
180
|
+
<MetricRow label="consultancy.margins.results.breakEvenHours" value={hoursFormat(margin.breakEvenHours)} />
|
|
181
|
+
<MetricRow label="consultancy.margins.results.utilization" value={percent(margin.utilization)} />
|
|
182
|
+
<MetricRow label="consultancy.margins.results.forgoneRevenue" value={money(margin.forgoneRevenue)} />
|
|
183
|
+
<Text
|
|
184
|
+
variant="small"
|
|
185
|
+
color="secondary"
|
|
186
|
+
text={margin.coversEmployerCost ? 'consultancy.margins.results.coversCost' : 'consultancy.margins.results.missesCost'}
|
|
187
|
+
/>
|
|
188
|
+
</View>
|
|
189
|
+
</SectionPanel>
|
|
190
|
+
</View>
|
|
191
|
+
</View>
|
|
192
|
+
|
|
193
|
+
<SectionPanel title="consultancy.margins.leakage.title" data-margins-leakage="on">
|
|
194
|
+
<View gap="m" inset="m">
|
|
195
|
+
<Text variant="small" color="secondary" text="consultancy.margins.leakage.description" />
|
|
196
|
+
<MetricRow label="consultancy.margins.leakage.hours" value={hoursFormat(leakage.leakedHours)} />
|
|
197
|
+
<MetricRow label="consultancy.margins.leakage.revenue" value={money(leakage.leakedRevenue)} />
|
|
198
|
+
</View>
|
|
199
|
+
</SectionPanel>
|
|
200
|
+
</Form>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Tabs } from '@ossy/design-system'
|
|
3
|
+
import { useRouter } from '@ossy/router-react'
|
|
4
|
+
|
|
5
|
+
const TABS = [
|
|
6
|
+
{
|
|
7
|
+
id: 'consultancy/home',
|
|
8
|
+
label: 'consultancy.nav.overview',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 'consultancy/forecasts',
|
|
12
|
+
label: 'consultancy.nav.forecasts',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'consultancy/margins',
|
|
16
|
+
label: 'consultancy.nav.margins',
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* In-product section nav for consultancy (one sidebar item, nested routes).
|
|
22
|
+
*/
|
|
23
|
+
export function ConsultancyNav ({ active }) {
|
|
24
|
+
const router = useRouter()
|
|
25
|
+
const tabs = TABS.map((tab) => ({
|
|
26
|
+
...tab,
|
|
27
|
+
href: router.getHref(`@${tab.id}`),
|
|
28
|
+
}))
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Tabs
|
|
32
|
+
tabs={tabs}
|
|
33
|
+
activeTabId={active}
|
|
34
|
+
onTabClick={() => {}}
|
|
35
|
+
data-consultancy-nav
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
package/src/Definition.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const Definition = {
|
|
2
2
|
id: 'consultancy',
|
|
3
3
|
title: 'Consultancy',
|
|
4
|
-
description: 'Consultancy
|
|
5
|
-
icon: '
|
|
4
|
+
description: 'Consultancy ops — overview, forecasts, and assignment margins.',
|
|
5
|
+
icon: 'briefcase',
|
|
6
6
|
status: ['beta'],
|
|
7
7
|
}
|
package/src/Forecast.jsx
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, Separator, useLocale } from '@ossy/design-system';
|
|
3
|
+
import { CalendarDaySurfaceStyles, useForecast } from '@ossy/calendar';
|
|
4
|
+
|
|
5
|
+
const grid = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
flexWrap: 'wrap',
|
|
11
|
+
gap: '1px',
|
|
12
|
+
overflowX: 'auto',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const calendarGrid = {
|
|
16
|
+
display: 'grid',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
gridTemplateColumns: 'repeat(7, 40px)',
|
|
20
|
+
gridAutoRows: 'repeat(6, 40px)',
|
|
21
|
+
gap: 'var(--space-m)',
|
|
22
|
+
justifyItems: 'center',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const calendarDayLayout = {
|
|
26
|
+
boxSizing: 'border-box',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
borderRadius: '50%',
|
|
31
|
+
padding: '8px',
|
|
32
|
+
fontSize: '.6rem',
|
|
33
|
+
margin: 0,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Forecast = () => {
|
|
37
|
+
const months = useForecast()
|
|
38
|
+
const { language } = useLocale()
|
|
39
|
+
const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', { style: "currency", currency: "SEK" }).format(value)
|
|
40
|
+
const hours = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-GB', { style: "unit", unit: "hour" }).format(value)
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<CalendarDaySurfaceStyles />
|
|
45
|
+
<style href="@ossy/website-ossy/forecast-separator" precedence="medium">
|
|
46
|
+
{`
|
|
47
|
+
[data-separator][data-forecast-current-month="true"] {
|
|
48
|
+
box-shadow: 0 0 0 1px var(--color-accent, hsl(167, 89%, 43%));
|
|
49
|
+
}
|
|
50
|
+
`}
|
|
51
|
+
</style>
|
|
52
|
+
<div style={grid}>
|
|
53
|
+
|
|
54
|
+
{months.map(month => {
|
|
55
|
+
const startPad = month.days[0].isoWeekday - 1
|
|
56
|
+
const totalCells = startPad + month.days.length
|
|
57
|
+
const endPad = (7 - (totalCells % 7)) % 7
|
|
58
|
+
const monthKey = `${month.year}-${month.month}`
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View
|
|
62
|
+
key={monthKey}
|
|
63
|
+
inset="l"
|
|
64
|
+
gap="m"
|
|
65
|
+
surface="primary"
|
|
66
|
+
roundness="m"
|
|
67
|
+
>
|
|
68
|
+
<Text variant="heading-tertiary" as="h3">{month.year} {month.month}</Text>
|
|
69
|
+
<Separator
|
|
70
|
+
data-forecast-current-month={month.isCurrentMonth}
|
|
71
|
+
variant={month.isCurrentMonth ? 'accent' : 'primary'}
|
|
72
|
+
/>
|
|
73
|
+
<View gap="s" style={{ flexGrow: '1' }}>
|
|
74
|
+
|
|
75
|
+
<View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
|
|
76
|
+
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
|
|
77
|
+
<Text variant="m" style={{ marginBottom: 0 }} >
|
|
78
|
+
{money(month.projectedIncome)}
|
|
79
|
+
</Text>
|
|
80
|
+
</View>
|
|
81
|
+
|
|
82
|
+
<View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
|
|
83
|
+
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.salaryCost" />
|
|
84
|
+
<Text variant="m" style={{ marginBottom: 0 }} >
|
|
85
|
+
{money(month.monthlyCostOfEmployees)}
|
|
86
|
+
</Text>
|
|
87
|
+
</View>
|
|
88
|
+
|
|
89
|
+
<View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
|
|
90
|
+
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.revenue" />
|
|
91
|
+
<Text variant="m" style={{ marginBottom: 0 }} >
|
|
92
|
+
{money(month.revenue)}
|
|
93
|
+
</Text>
|
|
94
|
+
</View>
|
|
95
|
+
|
|
96
|
+
<View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
|
|
97
|
+
<Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.hoursWorked" />
|
|
98
|
+
<Text variant="m" style={{ marginBottom: 0 }} >
|
|
99
|
+
{hours(month.hoursWorked)}
|
|
100
|
+
</Text>
|
|
101
|
+
</View>
|
|
102
|
+
|
|
103
|
+
</View>
|
|
104
|
+
|
|
105
|
+
<View style={{ height: 'var(--space-m)' }} />
|
|
106
|
+
|
|
107
|
+
<div style={calendarGrid}>
|
|
108
|
+
|
|
109
|
+
{Array.from({ length: startPad }, (_, i) => (
|
|
110
|
+
<div key={`${monthKey}-pad-s-${i}`} />
|
|
111
|
+
))}
|
|
112
|
+
|
|
113
|
+
{month.days.map(day => (
|
|
114
|
+
<Text
|
|
115
|
+
key={`${monthKey}-${day.monthDay}`}
|
|
116
|
+
variant="small"
|
|
117
|
+
data-ossy-calendar-day
|
|
118
|
+
data-day-off={!day.isWorkday}
|
|
119
|
+
style={calendarDayLayout}
|
|
120
|
+
>
|
|
121
|
+
{day.monthDay}
|
|
122
|
+
</Text>
|
|
123
|
+
))}
|
|
124
|
+
|
|
125
|
+
{Array.from({ length: endPad }, (_, i) => (
|
|
126
|
+
<div key={`${monthKey}-pad-e-${i}`} />
|
|
127
|
+
))}
|
|
128
|
+
|
|
129
|
+
</div>
|
|
130
|
+
</View>
|
|
131
|
+
)
|
|
132
|
+
})}
|
|
133
|
+
</div>
|
|
134
|
+
</>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import enableConsultancyFlow from './enable-consultancy.flow.js'
|
|
2
|
+
import { metadata as CalculatorForm } from './calculator.form.js'
|
|
3
|
+
|
|
4
|
+
export const metadata = {
|
|
5
|
+
id: '@ossy/consultancy/flows/assignment-margin',
|
|
6
|
+
feature: 'consultancy',
|
|
7
|
+
requires: ['server', 'database'],
|
|
8
|
+
timeout: 120_000,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const profitableFields = {
|
|
12
|
+
hourlyRate: 900,
|
|
13
|
+
billableHours: 120,
|
|
14
|
+
monthlySalary: 47000,
|
|
15
|
+
availableHours: 160,
|
|
16
|
+
teamSize: 10,
|
|
17
|
+
adminHoursPerWeek: 5,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const unprofitableFields = {
|
|
21
|
+
hourlyRate: 300,
|
|
22
|
+
billableHours: 160,
|
|
23
|
+
monthlySalary: 47000,
|
|
24
|
+
availableHours: 160,
|
|
25
|
+
teamSize: 10,
|
|
26
|
+
adminHoursPerWeek: 5,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Open the margins calculator under consultancy and toggle
|
|
31
|
+
* profitable vs unprofitable assignment inputs via the form schema.
|
|
32
|
+
*/
|
|
33
|
+
export default {
|
|
34
|
+
title: 'Assignment margin calculator',
|
|
35
|
+
description:
|
|
36
|
+
'Signed-in user enables consultancy, opens margins, sees a profitable default assignment, then fills unprofitable and profitable inputs',
|
|
37
|
+
steps: [
|
|
38
|
+
...enableConsultancyFlow.steps,
|
|
39
|
+
{ page: '@consultancy/margins' },
|
|
40
|
+
{ result: { selector: '[data-margins="calculator"]', timeout: 15000 } },
|
|
41
|
+
{
|
|
42
|
+
result: {
|
|
43
|
+
selector: '[data-margins-status="profitable"]',
|
|
44
|
+
timeout: 10000,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{ result: { selector: '[data-margins-leakage="on"]', timeout: 5000 } },
|
|
48
|
+
{ form: CalculatorForm, fields: unprofitableFields },
|
|
49
|
+
{
|
|
50
|
+
result: {
|
|
51
|
+
selector: '[data-margins-status="unprofitable"]',
|
|
52
|
+
timeout: 10000,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{ form: CalculatorForm, fields: profitableFields },
|
|
56
|
+
{
|
|
57
|
+
result: {
|
|
58
|
+
selector: '[data-margins-status="profitable"]',
|
|
59
|
+
timeout: 10000,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Full Swedish arbetsgivaravgift (employer social contributions). */
|
|
2
|
+
export const SOCIAL_TAX = 0.3142
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Annual semestertillägg as a fraction of one month's salary
|
|
6
|
+
* (typical tjänsteman: 0.8 % × 25 vacation days = 20 %).
|
|
7
|
+
*/
|
|
8
|
+
export const SEMESTER_TILLAGG_ANNUAL_RATE = 0.2
|
|
9
|
+
|
|
10
|
+
/** Default available hours in a consulting month (capacity, not billable target). */
|
|
11
|
+
export const DEFAULT_AVAILABLE_HOURS_PER_MONTH = 160
|
|
12
|
+
|
|
13
|
+
/** Working weeks used for annual leakage estimates (excludes typical leave). */
|
|
14
|
+
export const DEFAULT_WEEKS_PER_YEAR = 46
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Monthly employer cost for one consultant (salary + semestertillägg accrual + social tax).
|
|
18
|
+
* Tooling / onboarding catalogs live in `@ossy/ekonomi`; this stays assignment-focused.
|
|
19
|
+
*/
|
|
20
|
+
export function calculateMonthlyEmployerCost ({
|
|
21
|
+
monthlySalary,
|
|
22
|
+
socialTaxRate = SOCIAL_TAX,
|
|
23
|
+
} = {}) {
|
|
24
|
+
const salary = Math.max(0, Number(monthlySalary) || 0)
|
|
25
|
+
const holidayPay = (salary * SEMESTER_TILLAGG_ANNUAL_RATE) / 12
|
|
26
|
+
const socialTax = (salary + holidayPay) * socialTaxRate
|
|
27
|
+
return {
|
|
28
|
+
monthlySalary: salary,
|
|
29
|
+
holidayPay,
|
|
30
|
+
socialTax,
|
|
31
|
+
socialTaxRate,
|
|
32
|
+
total: salary + holidayPay + socialTax,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Live assignment / period margin from client rate, billable hours, and Swedish employer cost.
|
|
38
|
+
*/
|
|
39
|
+
export function calculateAssignmentMargin ({
|
|
40
|
+
hourlyRate,
|
|
41
|
+
billableHours,
|
|
42
|
+
monthlySalary,
|
|
43
|
+
availableHoursPerMonth = DEFAULT_AVAILABLE_HOURS_PER_MONTH,
|
|
44
|
+
socialTaxRate = SOCIAL_TAX,
|
|
45
|
+
} = {}) {
|
|
46
|
+
const rate = Math.max(0, Number(hourlyRate) || 0)
|
|
47
|
+
const hours = Math.max(0, Number(billableHours) || 0)
|
|
48
|
+
const available = Math.max(0, Number(availableHoursPerMonth) || 0)
|
|
49
|
+
const employer = calculateMonthlyEmployerCost({ monthlySalary, socialTaxRate })
|
|
50
|
+
|
|
51
|
+
const costPerAvailableHour = available > 0 ? employer.total / available : 0
|
|
52
|
+
const deliveryCost = hours * costPerAvailableHour
|
|
53
|
+
const revenue = hours * rate
|
|
54
|
+
const grossMargin = revenue - deliveryCost
|
|
55
|
+
const marginPercent = revenue > 0 ? grossMargin / revenue : 0
|
|
56
|
+
const nonBillableHours = Math.max(0, available - hours)
|
|
57
|
+
const forgoneRevenue = nonBillableHours * rate
|
|
58
|
+
const utilization = available > 0 ? hours / available : 0
|
|
59
|
+
const monthPnl = revenue - employer.total
|
|
60
|
+
const breakEvenHours = rate > 0 ? employer.total / rate : Number.POSITIVE_INFINITY
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
hourlyRate: rate,
|
|
64
|
+
billableHours: hours,
|
|
65
|
+
availableHoursPerMonth: available,
|
|
66
|
+
employerCost: employer.total,
|
|
67
|
+
employer,
|
|
68
|
+
costPerAvailableHour,
|
|
69
|
+
deliveryCost,
|
|
70
|
+
revenue,
|
|
71
|
+
grossMargin,
|
|
72
|
+
marginPercent,
|
|
73
|
+
nonBillableHours,
|
|
74
|
+
forgoneRevenue,
|
|
75
|
+
utilization,
|
|
76
|
+
monthPnl,
|
|
77
|
+
breakEvenHours,
|
|
78
|
+
isProfitable: grossMargin > 0,
|
|
79
|
+
coversEmployerCost: monthPnl >= -1e-9,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Team-scale annual revenue lost to recurring non-billable admin hours.
|
|
85
|
+
* Mirrors the “admin leakage” complaint shape from Nordic consulting ops notes.
|
|
86
|
+
*/
|
|
87
|
+
export function estimateAdminLeakage ({
|
|
88
|
+
teamSize = 1,
|
|
89
|
+
adminHoursPerPersonPerWeek = 5,
|
|
90
|
+
hourlyRate,
|
|
91
|
+
weeksPerYear = DEFAULT_WEEKS_PER_YEAR,
|
|
92
|
+
} = {}) {
|
|
93
|
+
const people = Math.max(0, Number(teamSize) || 0)
|
|
94
|
+
const adminHours = Math.max(0, Number(adminHoursPerPersonPerWeek) || 0)
|
|
95
|
+
const weeks = Math.max(0, Number(weeksPerYear) || 0)
|
|
96
|
+
const rate = Math.max(0, Number(hourlyRate) || 0)
|
|
97
|
+
const leakedHours = people * adminHours * weeks
|
|
98
|
+
return {
|
|
99
|
+
teamSize: people,
|
|
100
|
+
adminHoursPerPersonPerWeek: adminHours,
|
|
101
|
+
weeksPerYear: weeks,
|
|
102
|
+
hourlyRate: rate,
|
|
103
|
+
leakedHours,
|
|
104
|
+
leakedRevenue: leakedHours * rate,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SOCIAL_TAX,
|
|
3
|
+
SEMESTER_TILLAGG_ANNUAL_RATE,
|
|
4
|
+
DEFAULT_AVAILABLE_HOURS_PER_MONTH,
|
|
5
|
+
calculateMonthlyEmployerCost,
|
|
6
|
+
calculateAssignmentMargin,
|
|
7
|
+
estimateAdminLeakage,
|
|
8
|
+
} from './assignment-margin.js'
|
|
9
|
+
|
|
10
|
+
describe('calculateMonthlyEmployerCost', () => {
|
|
11
|
+
it('applies semestertillägg accrual and arbetsgivaravgift on salary + holiday pay', () => {
|
|
12
|
+
const cost = calculateMonthlyEmployerCost({ monthlySalary: 47000 })
|
|
13
|
+
const holidayPay = (47000 * SEMESTER_TILLAGG_ANNUAL_RATE) / 12
|
|
14
|
+
expect(cost.holidayPay).toBeCloseTo(holidayPay)
|
|
15
|
+
expect(cost.socialTax).toBeCloseTo((47000 + holidayPay) * SOCIAL_TAX)
|
|
16
|
+
expect(cost.total).toBeCloseTo(47000 + holidayPay + cost.socialTax)
|
|
17
|
+
expect(Math.round(cost.total)).toBe(62797)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('accepts a reduced social tax rate', () => {
|
|
21
|
+
const full = calculateMonthlyEmployerCost({ monthlySalary: 47000 })
|
|
22
|
+
const reduced = calculateMonthlyEmployerCost({ monthlySalary: 47000, socialTaxRate: 0.1021 })
|
|
23
|
+
expect(reduced.total).toBeLessThan(full.total)
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
describe('calculateAssignmentMargin', () => {
|
|
28
|
+
it('computes delivery cost from employer cost share of available hours', () => {
|
|
29
|
+
const result = calculateAssignmentMargin({
|
|
30
|
+
hourlyRate: 900,
|
|
31
|
+
billableHours: 120,
|
|
32
|
+
monthlySalary: 47000,
|
|
33
|
+
availableHoursPerMonth: DEFAULT_AVAILABLE_HOURS_PER_MONTH,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
expect(result.revenue).toBe(108000)
|
|
37
|
+
expect(result.costPerAvailableHour).toBeCloseTo(result.employerCost / 160)
|
|
38
|
+
expect(result.deliveryCost).toBeCloseTo(result.costPerAvailableHour * 120)
|
|
39
|
+
expect(result.grossMargin).toBeCloseTo(result.revenue - result.deliveryCost)
|
|
40
|
+
expect(result.nonBillableHours).toBe(40)
|
|
41
|
+
expect(result.forgoneRevenue).toBe(36000)
|
|
42
|
+
expect(result.utilization).toBeCloseTo(0.75)
|
|
43
|
+
expect(result.breakEvenHours).toBeCloseTo(result.employerCost / 900)
|
|
44
|
+
expect(result.isProfitable).toBe(true)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('flags unprofitable assignments when rate is below cost per hour', () => {
|
|
48
|
+
const result = calculateAssignmentMargin({
|
|
49
|
+
hourlyRate: 300,
|
|
50
|
+
billableHours: 160,
|
|
51
|
+
monthlySalary: 47000,
|
|
52
|
+
})
|
|
53
|
+
expect(result.isProfitable).toBe(false)
|
|
54
|
+
expect(result.coversEmployerCost).toBe(false)
|
|
55
|
+
expect(result.monthPnl).toBeLessThan(0)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('covers employer cost when billable hours meet break-even', () => {
|
|
59
|
+
const probe = calculateAssignmentMargin({
|
|
60
|
+
hourlyRate: 900,
|
|
61
|
+
billableHours: 0,
|
|
62
|
+
monthlySalary: 47000,
|
|
63
|
+
})
|
|
64
|
+
const atBreakEven = calculateAssignmentMargin({
|
|
65
|
+
hourlyRate: 900,
|
|
66
|
+
billableHours: probe.breakEvenHours,
|
|
67
|
+
monthlySalary: 47000,
|
|
68
|
+
})
|
|
69
|
+
expect(atBreakEven.monthPnl).toBeCloseTo(0, 5)
|
|
70
|
+
expect(atBreakEven.coversEmployerCost).toBe(true)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('estimateAdminLeakage', () => {
|
|
75
|
+
it('scales Blikk-style weekly admin hours across a team year', () => {
|
|
76
|
+
const leakage = estimateAdminLeakage({
|
|
77
|
+
teamSize: 10,
|
|
78
|
+
adminHoursPerPersonPerWeek: 5,
|
|
79
|
+
hourlyRate: 900,
|
|
80
|
+
weeksPerYear: 46,
|
|
81
|
+
})
|
|
82
|
+
expect(leakage.leakedHours).toBe(2300)
|
|
83
|
+
expect(leakage.leakedRevenue).toBe(2070000)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Assignment margin calculator — UI fields and flow faker schema. */
|
|
2
|
+
export default {
|
|
3
|
+
id: '@ossy/consultancy/schema/calculator',
|
|
4
|
+
name: 'Assignment margin calculator',
|
|
5
|
+
icon: 'chart',
|
|
6
|
+
// Platform category keeps this form schema out of the generic create picker.
|
|
7
|
+
categoryName: 'Platform',
|
|
8
|
+
// text fields: live calculator parses with parseNumber; schema labels resolve
|
|
9
|
+
// via `{schemaId}.{field}.label` catalog keys.
|
|
10
|
+
fields: [
|
|
11
|
+
{ name: 'hourlyRate', type: 'text', required: true },
|
|
12
|
+
{ name: 'billableHours', type: 'text', required: true },
|
|
13
|
+
{ name: 'monthlySalary', type: 'text', required: true },
|
|
14
|
+
{ name: 'availableHours', type: 'text', required: true },
|
|
15
|
+
{ name: 'teamSize', type: 'text', required: true },
|
|
16
|
+
{ name: 'adminHoursPerWeek', type: 'text', required: true },
|
|
17
|
+
],
|
|
18
|
+
}
|
package/src/consultancy.page.jsx
CHANGED
|
@@ -4,6 +4,7 @@ import { Overview } from './Overview.jsx'
|
|
|
4
4
|
import { DataLoader } from '@ossy/calendar'
|
|
5
5
|
import { Definition } from './Definition.js'
|
|
6
6
|
import { CreateConsultancyButton } from './CreateConsultancyButton.jsx'
|
|
7
|
+
import { ConsultancyNav } from './ConsultancyNav.jsx'
|
|
7
8
|
|
|
8
9
|
export const metadata = {
|
|
9
10
|
id: 'consultancy/home',
|
|
@@ -26,6 +27,7 @@ export const ConsultancyPage = () => {
|
|
|
26
27
|
far={<CreateConsultancyButton />}
|
|
27
28
|
>
|
|
28
29
|
<View gap="m">
|
|
30
|
+
<ConsultancyNav active="consultancy/home" />
|
|
29
31
|
<Text variant="heading-secondary" as="h2" text="design-system.overview" />
|
|
30
32
|
<DataLoader content={<Overview />} />
|
|
31
33
|
</View>
|
package/src/en.translations.json
CHANGED
|
@@ -1,13 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"consultancy/home.documentTitle": "Consultancy",
|
|
3
|
+
"consultancy/forecasts.documentTitle": "Forecasts",
|
|
4
|
+
"consultancy/margins.documentTitle": "Margins",
|
|
3
5
|
"consultancy.home.title": "Consultancy",
|
|
4
|
-
"consultancy.home.description": "Consultancy overview",
|
|
6
|
+
"consultancy.home.description": "Consultancy overview, forecasts, and assignment margins",
|
|
7
|
+
"consultancy.nav.overview": "Overview",
|
|
8
|
+
"consultancy.nav.forecasts": "Forecasts",
|
|
9
|
+
"consultancy.nav.margins": "Margins",
|
|
10
|
+
"consultancy.forecasts.title": "Forecasts",
|
|
11
|
+
"consultancy.forecasts.description": "Revenue and capacity forecasts from contracts, employees, and vacations",
|
|
12
|
+
"consultancy.forecasts.income": "Income",
|
|
13
|
+
"consultancy.forecasts.salaryCost": "Salary cost",
|
|
14
|
+
"consultancy.forecasts.revenue": "Revenue",
|
|
15
|
+
"consultancy.forecasts.hoursWorked": "Hours worked",
|
|
16
|
+
"consultancy.margins.title": "Margins",
|
|
17
|
+
"consultancy.margins.description": "See assignment margin and admin leakage before you invoice",
|
|
18
|
+
"consultancy.margins.notes.purpose": "Built for Nordic IT consultancies that outgrew timers + spreadsheets but do not need an enterprise PSA.",
|
|
19
|
+
"consultancy.margins.notes.swedishCost": "Employer cost includes salary, semestertillägg accrual, and arbetsgivaravgift. Tooling catalogs stay in Ekonomi.",
|
|
20
|
+
"consultancy.margins.inputs.title": "Assignment inputs",
|
|
21
|
+
"consultancy.margins.results.title": "Assignment margin",
|
|
22
|
+
"consultancy.margins.results.revenue": "Billable revenue",
|
|
23
|
+
"consultancy.margins.results.deliveryCost": "Delivery cost (hours × employer cost/h)",
|
|
24
|
+
"consultancy.margins.results.grossMargin": "Gross margin",
|
|
25
|
+
"consultancy.margins.results.marginPercent": "Margin %",
|
|
26
|
+
"consultancy.margins.results.employerCost": "Monthly employer cost",
|
|
27
|
+
"consultancy.margins.results.monthPnl": "Month P&L (revenue − employer cost)",
|
|
28
|
+
"consultancy.margins.results.breakEvenHours": "Break-even billable hours",
|
|
29
|
+
"consultancy.margins.results.utilization": "Utilization",
|
|
30
|
+
"consultancy.margins.results.forgoneRevenue": "Forgone revenue (non-billable hours)",
|
|
31
|
+
"consultancy.margins.results.coversCost": "Billable revenue covers the monthly employer cost.",
|
|
32
|
+
"consultancy.margins.results.missesCost": "Billable revenue does not cover the monthly employer cost yet.",
|
|
33
|
+
"consultancy.margins.leakage.title": "Admin leakage",
|
|
34
|
+
"consultancy.margins.leakage.description": "Estimate annual revenue lost when the team spends recurring hours on non-billable admin.",
|
|
35
|
+
"consultancy.margins.leakage.hours": "Leaked hours / year",
|
|
36
|
+
"consultancy.margins.leakage.revenue": "Leaked revenue / year",
|
|
5
37
|
"consultancy.overview.fiscalYears": "Fiscal years",
|
|
6
38
|
"consultancy.overview.company": "Company",
|
|
7
39
|
"consultancy.overview.noFiscalYears": "No fiscal years yet.",
|
|
8
40
|
"consultancy.empty.title": "Looks empty",
|
|
9
41
|
"consultancy.empty.text": "Add company info, employees, contracts, and vacations to get started.",
|
|
10
42
|
|
|
43
|
+
"@ossy/consultancy/form/calculator.label": "Assignment margin calculator",
|
|
44
|
+
"@ossy/consultancy/schema/calculator.hourlyRate.label": "Client hourly rate (SEK)",
|
|
45
|
+
"@ossy/consultancy/schema/calculator.billableHours.label": "Billable hours this period",
|
|
46
|
+
"@ossy/consultancy/schema/calculator.monthlySalary.label": "Monthly salary (SEK)",
|
|
47
|
+
"@ossy/consultancy/schema/calculator.availableHours.label": "Available hours this month",
|
|
48
|
+
"@ossy/consultancy/schema/calculator.teamSize.label": "Team size",
|
|
49
|
+
"@ossy/consultancy/schema/calculator.adminHoursPerWeek.label": "Admin hours per person / week",
|
|
50
|
+
|
|
11
51
|
"@ossy/consultancy/schema/company-basic-info.name.label": "Company name",
|
|
12
52
|
"@ossy/consultancy/schema/company-basic-info.name.description": "The registered legal name of the company.",
|
|
13
53
|
"@ossy/consultancy/schema/company-basic-info.registrationDate.label": "Registration date",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text, View, Page, Tags } from '@ossy/design-system'
|
|
3
|
+
import { Forecast } from './Forecast.jsx'
|
|
4
|
+
import { DataLoader } from '@ossy/calendar'
|
|
5
|
+
import { Definition } from './Definition.js'
|
|
6
|
+
import { CreateConsultancyButton } from './CreateConsultancyButton.jsx'
|
|
7
|
+
import { ConsultancyNav } from './ConsultancyNav.jsx'
|
|
8
|
+
|
|
9
|
+
export const metadata = {
|
|
10
|
+
id: 'consultancy/forecasts',
|
|
11
|
+
path: {
|
|
12
|
+
sv: '/konsultverksamhet/prognoser',
|
|
13
|
+
en: '/consultancy/forecasts',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ForecastsPage = () => {
|
|
18
|
+
const statusTags = (Definition.status ?? [])
|
|
19
|
+
.map((s) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[s]))
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Page
|
|
24
|
+
data-forecasts-status="on"
|
|
25
|
+
title="consultancy.forecasts.title"
|
|
26
|
+
near={statusTags.length > 0 ? <Tags tags={statusTags} size="s" /> : undefined}
|
|
27
|
+
description="consultancy.forecasts.description"
|
|
28
|
+
far={<CreateConsultancyButton />}
|
|
29
|
+
>
|
|
30
|
+
<View gap="m">
|
|
31
|
+
<ConsultancyNav active="consultancy/forecasts" />
|
|
32
|
+
<Text variant="heading-secondary" as="h2" text="design-system.overview" />
|
|
33
|
+
<DataLoader content={<Forecast />} />
|
|
34
|
+
</View>
|
|
35
|
+
</Page>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default ForecastsPage
|
package/src/index.js
CHANGED
|
@@ -8,3 +8,12 @@ export { default as opportunitySchema } from './opportunity.schema.js'
|
|
|
8
8
|
export { default as proposalSchema } from './proposal.schema.js'
|
|
9
9
|
export { Definition } from './Definition.js'
|
|
10
10
|
export { CreateConsultancyButton } from './CreateConsultancyButton.jsx'
|
|
11
|
+
export {
|
|
12
|
+
SOCIAL_TAX,
|
|
13
|
+
SEMESTER_TILLAGG_ANNUAL_RATE,
|
|
14
|
+
DEFAULT_AVAILABLE_HOURS_PER_MONTH,
|
|
15
|
+
DEFAULT_WEEKS_PER_YEAR,
|
|
16
|
+
calculateMonthlyEmployerCost,
|
|
17
|
+
calculateAssignmentMargin,
|
|
18
|
+
estimateAdminLeakage,
|
|
19
|
+
} from './assignment-margin.js'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Page, Tags } from '@ossy/design-system'
|
|
3
|
+
import { AssignmentMarginCalculator } from './AssignmentMarginCalculator.jsx'
|
|
4
|
+
import { Definition } from './Definition.js'
|
|
5
|
+
import { CreateConsultancyButton } from './CreateConsultancyButton.jsx'
|
|
6
|
+
import { ConsultancyNav } from './ConsultancyNav.jsx'
|
|
7
|
+
|
|
8
|
+
export const metadata = {
|
|
9
|
+
id: 'consultancy/margins',
|
|
10
|
+
path: {
|
|
11
|
+
sv: '/konsultverksamhet/marginaler',
|
|
12
|
+
en: '/consultancy/margins',
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const MarginsPage = () => {
|
|
17
|
+
const statusTags = (Definition.status ?? [])
|
|
18
|
+
.map((s) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[s]))
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Page
|
|
23
|
+
scroll
|
|
24
|
+
title="consultancy.margins.title"
|
|
25
|
+
near={statusTags.length > 0 ? <Tags tags={statusTags} size="s" /> : undefined}
|
|
26
|
+
description="consultancy.margins.description"
|
|
27
|
+
far={<CreateConsultancyButton />}
|
|
28
|
+
>
|
|
29
|
+
<View gap="m">
|
|
30
|
+
<ConsultancyNav active="consultancy/margins" />
|
|
31
|
+
<AssignmentMarginCalculator />
|
|
32
|
+
</View>
|
|
33
|
+
</Page>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default MarginsPage
|
package/src/sv.translations.json
CHANGED
|
@@ -1,13 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"consultancy/home.documentTitle": "Konsultverksamhet",
|
|
3
|
+
"consultancy/forecasts.documentTitle": "Prognoser",
|
|
4
|
+
"consultancy/margins.documentTitle": "Marginaler",
|
|
3
5
|
"consultancy.home.title": "Konsultverksamhet",
|
|
4
|
-
"consultancy.home.description": "Översikt
|
|
6
|
+
"consultancy.home.description": "Översikt, prognoser och uppdragsmarginaler",
|
|
7
|
+
"consultancy.nav.overview": "Översikt",
|
|
8
|
+
"consultancy.nav.forecasts": "Prognoser",
|
|
9
|
+
"consultancy.nav.margins": "Marginaler",
|
|
10
|
+
"consultancy.forecasts.title": "Prognoser",
|
|
11
|
+
"consultancy.forecasts.description": "Intäkts- och kapacitetsprognoser från avtal, anställda och semester",
|
|
12
|
+
"consultancy.forecasts.income": "Intäkt",
|
|
13
|
+
"consultancy.forecasts.salaryCost": "Lönekostnad",
|
|
14
|
+
"consultancy.forecasts.revenue": "Resultat",
|
|
15
|
+
"consultancy.forecasts.hoursWorked": "Arbetade timmar",
|
|
16
|
+
"consultancy.margins.title": "Marginaler",
|
|
17
|
+
"consultancy.margins.description": "Se uppdragets marginal och adminläckage innan du fakturerar",
|
|
18
|
+
"consultancy.margins.notes.purpose": "Byggt för nordiska IT-konsultbolag som vuxit ur timer + kalkylark men inte behöver ett tungt PSA.",
|
|
19
|
+
"consultancy.margins.notes.swedishCost": "Arbetsgivarkostnad inkluderar lön, semestertillägg och arbetsgivaravgift. Verktygskataloger finns i Ekonomi.",
|
|
20
|
+
"consultancy.margins.inputs.title": "Uppdrag",
|
|
21
|
+
"consultancy.margins.results.title": "Uppdragsmarginal",
|
|
22
|
+
"consultancy.margins.results.revenue": "Debiterbar intäkt",
|
|
23
|
+
"consultancy.margins.results.deliveryCost": "Leveranskostnad (timmar × arbetsgivarkostnad/h)",
|
|
24
|
+
"consultancy.margins.results.grossMargin": "Bruttomarginal",
|
|
25
|
+
"consultancy.margins.results.marginPercent": "Marginal %",
|
|
26
|
+
"consultancy.margins.results.employerCost": "Månatlig arbetsgivarkostnad",
|
|
27
|
+
"consultancy.margins.results.monthPnl": "Månadens resultat (intäkt − arbetsgivarkostnad)",
|
|
28
|
+
"consultancy.margins.results.breakEvenHours": "Nollpunkts debiterbara timmar",
|
|
29
|
+
"consultancy.margins.results.utilization": "Beläggning",
|
|
30
|
+
"consultancy.margins.results.forgoneRevenue": "Förlorad intäkt (icke-debiterbara timmar)",
|
|
31
|
+
"consultancy.margins.results.coversCost": "Debiterbar intäkt täcker den månatliga arbetsgivarkostnaden.",
|
|
32
|
+
"consultancy.margins.results.missesCost": "Debiterbar intäkt täcker ännu inte den månatliga arbetsgivarkostnaden.",
|
|
33
|
+
"consultancy.margins.leakage.title": "Adminläckage",
|
|
34
|
+
"consultancy.margins.leakage.description": "Uppskatta årlig intäktsförlust när teamet lägger återkommande tid på icke-debiterbar admin.",
|
|
35
|
+
"consultancy.margins.leakage.hours": "Läckta timmar / år",
|
|
36
|
+
"consultancy.margins.leakage.revenue": "Läckt intäkt / år",
|
|
5
37
|
"consultancy.overview.fiscalYears": "Räkenskapsår",
|
|
6
38
|
"consultancy.overview.company": "Företag",
|
|
7
39
|
"consultancy.overview.noFiscalYears": "Inga räkenskapsår ännu.",
|
|
8
40
|
"consultancy.empty.title": "Här är tomt",
|
|
9
41
|
"consultancy.empty.text": "Lägg till företagsinfo, anställda, avtal och semester för att komma igång.",
|
|
10
42
|
|
|
43
|
+
"@ossy/consultancy/form/calculator.label": "Uppdragsmarginalkalkylator",
|
|
44
|
+
"@ossy/consultancy/schema/calculator.hourlyRate.label": "Kundens timpris (SEK)",
|
|
45
|
+
"@ossy/consultancy/schema/calculator.billableHours.label": "Fakturerbara timmar denna period",
|
|
46
|
+
"@ossy/consultancy/schema/calculator.monthlySalary.label": "Månadslön (SEK)",
|
|
47
|
+
"@ossy/consultancy/schema/calculator.availableHours.label": "Tillgängliga timmar denna månad",
|
|
48
|
+
"@ossy/consultancy/schema/calculator.teamSize.label": "Teamstorlek",
|
|
49
|
+
"@ossy/consultancy/schema/calculator.adminHoursPerWeek.label": "Admintimmar per person / vecka",
|
|
50
|
+
|
|
11
51
|
"@ossy/consultancy/schema/company-basic-info.name.label": "Företagsnamn",
|
|
12
52
|
"@ossy/consultancy/schema/company-basic-info.name.description": "Bolagets registrerade namn.",
|
|
13
53
|
"@ossy/consultancy/schema/company-basic-info.registrationDate.label": "Registreringsdatum",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import enableConsultancyFlow from './enable-consultancy.flow.js'
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
id: '@ossy/consultancy/flows/view-forecasts',
|
|
5
|
+
feature: 'consultancy',
|
|
6
|
+
requires: ['server', 'database'],
|
|
7
|
+
timeout: 120_000,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* After enabling consultancy from the catalog, open forecasts and assert
|
|
12
|
+
* the workspace forecasts surface is mounted.
|
|
13
|
+
*/
|
|
14
|
+
export default {
|
|
15
|
+
title: 'View forecasts',
|
|
16
|
+
description:
|
|
17
|
+
'Signed-in user enables consultancy and opens the forecasts section',
|
|
18
|
+
steps: [
|
|
19
|
+
...enableConsultancyFlow.steps,
|
|
20
|
+
{ page: '@consultancy/forecasts' },
|
|
21
|
+
{ result: { selector: '[data-forecasts-status="on"]', timeout: 20000 } },
|
|
22
|
+
],
|
|
23
|
+
}
|