@ossy/consultancy 3.20.1 → 3.21.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/ConsultancyNav.jsx +22 -1
- package/src/ConsultancyRecordList.jsx +172 -0
- package/src/CreateConsultancyButton.jsx +61 -13
- package/src/Forecast.jsx +157 -34
- package/src/contracts.page.jsx +26 -0
- package/src/employees.page.jsx +26 -0
- package/src/en.translations.json +41 -0
- package/src/forecast-kpi-chart.js +57 -10
- package/src/forecast-kpi-chart.spec.js +40 -3
- package/src/opportunities.page.jsx +26 -0
- package/src/opportunity.schema.js +1 -1
- package/src/proposals.page.jsx +26 -0
- package/src/sv.translations.json +41 -0
- package/src/utilization-hours.js +196 -0
- package/src/utilization-hours.spec.js +134 -0
- package/src/vacations.page.jsx +26 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { actualHoursForMonth, actualIncomeForMonth, withUtilizationHours } from './utilization-hours.js'
|
|
2
|
+
|
|
3
|
+
const january = {
|
|
4
|
+
year: 2026,
|
|
5
|
+
monthNumber: '01',
|
|
6
|
+
hoursWorked: 120,
|
|
7
|
+
days: [
|
|
8
|
+
{ date: '2026-01-05', isWorkday: true },
|
|
9
|
+
{ date: '2026-01-06', isWorkday: true },
|
|
10
|
+
{ date: '2026-01-10', isWorkday: false },
|
|
11
|
+
],
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('actualHoursForMonth', () => {
|
|
15
|
+
it('sums timesheet hours that fall in the month', () => {
|
|
16
|
+
const hours = actualHoursForMonth({
|
|
17
|
+
month: january,
|
|
18
|
+
timesheets: [{
|
|
19
|
+
content: {
|
|
20
|
+
employeeId: 'emp-1',
|
|
21
|
+
lines: [
|
|
22
|
+
{ date: new Date(2026, 0, 5).getTime(), hours: 6 },
|
|
23
|
+
{ date: new Date(2026, 1, 2).getTime(), hours: 8 },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
}],
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
expect(hours).toBe(6)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('counts a vacation workday when that day has no timesheet line', () => {
|
|
33
|
+
const hours = actualHoursForMonth({
|
|
34
|
+
month: january,
|
|
35
|
+
employees: [{ id: 'emp-1', workHoursPerDay: 8 }],
|
|
36
|
+
vacations: [{ employeeId: 'emp-1', start: '2026-01-05', end: '2026-01-06' }],
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
expect(hours).toBe(16)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('does not add vacation hours on top of a timesheet line for the same day', () => {
|
|
43
|
+
const hours = actualHoursForMonth({
|
|
44
|
+
month: january,
|
|
45
|
+
employees: [{ id: 'emp-1', workHoursPerDay: 8 }],
|
|
46
|
+
vacations: [{ employeeId: 'emp-1', start: '2026-01-05', end: '2026-01-05' }],
|
|
47
|
+
timesheets: [{
|
|
48
|
+
content: {
|
|
49
|
+
employeeId: 'emp-1',
|
|
50
|
+
lines: [{ date: new Date(2026, 0, 5).getTime(), hours: 4 }],
|
|
51
|
+
},
|
|
52
|
+
}],
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
expect(hours).toBe(4)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('ignores vacation days that are not workdays', () => {
|
|
59
|
+
const hours = actualHoursForMonth({
|
|
60
|
+
month: january,
|
|
61
|
+
employees: [{ id: 'emp-1', workHoursPerDay: 8 }],
|
|
62
|
+
vacations: [{ employeeId: 'emp-1', start: '2026-01-10', end: '2026-01-10' }],
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
expect(hours).toBe(0)
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('actualIncomeForMonth', () => {
|
|
70
|
+
it('bills timesheet hours at the linked contract rate', () => {
|
|
71
|
+
const income = actualIncomeForMonth({
|
|
72
|
+
month: january,
|
|
73
|
+
contracts: [{ id: 'con-1', hourlyCompensation: 1000, employeeId: 'emp-1' }],
|
|
74
|
+
timesheets: [{
|
|
75
|
+
content: {
|
|
76
|
+
contractId: 'con-1',
|
|
77
|
+
lines: [
|
|
78
|
+
{ date: new Date(2026, 0, 5).getTime(), hours: 6 },
|
|
79
|
+
{ date: new Date(2026, 1, 2).getTime(), hours: 8 },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
}],
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
expect(income).toBe(6000)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('falls back to the employee contract when the sheet has no contract', () => {
|
|
89
|
+
const income = actualIncomeForMonth({
|
|
90
|
+
month: january,
|
|
91
|
+
contracts: [{ id: 'con-1', hourlyCompensation: 500, employeeId: { resourceId: 'emp-1' } }],
|
|
92
|
+
timesheets: [{
|
|
93
|
+
content: {
|
|
94
|
+
employeeId: 'emp-1',
|
|
95
|
+
lines: [{ date: new Date(2026, 0, 5).getTime(), hours: 4 }],
|
|
96
|
+
},
|
|
97
|
+
}],
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
expect(income).toBe(2000)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
describe('withUtilizationHours', () => {
|
|
105
|
+
it('uses contract hours as the forecast series', () => {
|
|
106
|
+
const [month] = withUtilizationHours({
|
|
107
|
+
months: [january],
|
|
108
|
+
timesheets: [{
|
|
109
|
+
content: {
|
|
110
|
+
lines: [{ date: new Date(2026, 0, 6).getTime(), hours: 7 }],
|
|
111
|
+
},
|
|
112
|
+
}],
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
expect(month.forecastHours).toBe(120)
|
|
116
|
+
expect(month.actualHours).toBe(7)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('sets actual result from timesheet income minus salary cost', () => {
|
|
120
|
+
const [month] = withUtilizationHours({
|
|
121
|
+
months: [{ ...january, monthlyCostOfEmployees: 4000 }],
|
|
122
|
+
contracts: [{ id: 'con-1', hourlyCompensation: 1000 }],
|
|
123
|
+
timesheets: [{
|
|
124
|
+
content: {
|
|
125
|
+
contractId: { resourceId: 'con-1' },
|
|
126
|
+
lines: [{ date: new Date(2026, 0, 5).getTime(), hours: 6 }],
|
|
127
|
+
},
|
|
128
|
+
}],
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
expect(month.actualIncome).toBe(6000)
|
|
132
|
+
expect(month.actualRevenue).toBe(2000)
|
|
133
|
+
})
|
|
134
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ConsultancyRecordPage } from './ConsultancyRecordList.jsx'
|
|
3
|
+
import { ConsultancySchema } from './schema-ids.js'
|
|
4
|
+
import vacationSchema from './vacation.schema.js'
|
|
5
|
+
|
|
6
|
+
export const metadata = {
|
|
7
|
+
id: 'consultancy/vacations',
|
|
8
|
+
path: {
|
|
9
|
+
sv: '/konsultverksamhet/semester',
|
|
10
|
+
en: '/consultancy/vacations',
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const VacationsPage = () => (
|
|
15
|
+
<ConsultancyRecordPage
|
|
16
|
+
active="consultancy/vacations"
|
|
17
|
+
title="consultancy.vacations.title"
|
|
18
|
+
description="consultancy.vacations.description"
|
|
19
|
+
schemaId={ConsultancySchema.vacation}
|
|
20
|
+
icon={vacationSchema.icon}
|
|
21
|
+
listHeader="consultancy.nav.vacations"
|
|
22
|
+
emptyText="consultancy.vacations.empty"
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export default VacationsPage
|