Skip to content

Commit d2620ba

Browse files
authored
Merge pull request #107 from flock-community/fix/small_bugs
Fix/small bugs
2 parents d08be01 + 4b41a2e commit d2620ba

File tree

14 files changed

+18
-310
lines changed

14 files changed

+18
-310
lines changed

src/main/kotlin/controllers/AggregationController.kt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,7 @@ import org.springframework.web.bind.annotation.RestController
1515
class AggregationController(
1616
val aggregationService: AggregationService
1717
) {
18-
19-
@GetMapping("/revenue-per-month", params = ["year"])
20-
@PreAuthorize("hasAuthority('AggregationAuthority.READ')")
21-
fun revenuePerMonthByYear(@RequestParam year: Int): Map<YearMonth, BigDecimal> {
22-
val from = LocalDate.of(year, 1, 1)
23-
val to = LocalDate.of(year, 12, 31)
24-
return aggregationService.revenuePerMonth(from, to)
25-
}
26-
27-
@GetMapping("/cost-per-month", params = ["year"])
28-
@PreAuthorize("hasAuthority('AggregationAuthority.READ')")
29-
fun costPerMonthByYear(@RequestParam year: Int): Map<YearMonth, BigDecimal> {
30-
val from = LocalDate.of(year, 1, 1)
31-
val to = LocalDate.of(year, 12, 31)
32-
return aggregationService.costPerMonth(from, to)
33-
}
34-
18+
3519
@GetMapping("/total-per-client", params = ["year"])
3620
@PreAuthorize("hasAuthority('AggregationAuthority.READ')")
3721
fun revenuePerClientByYear(@RequestParam year: Int): List<Map<String, Any>> {

src/main/kotlin/services/AggregationService.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ class AggregationService(
3939
private val applicationConstants: ApplicationConstants
4040
) {
4141

42-
fun revenuePerMonth(from: LocalDate, to: LocalDate): Map<YearMonth, BigDecimal> {
43-
return assignmentService.findAllActive(from, to)
44-
.toMapWorkingDay(from, to)
45-
.entries
46-
.groupingBy { YearMonth.of(it.key.year, it.key.month) }
47-
.fold(BigDecimal.ZERO) { acc, cur -> acc + cur.value.fold(BigDecimal.ZERO) { a, c -> a + c.revenuePerDay() } }
48-
}
49-
50-
fun costPerMonth(from: LocalDate, to: LocalDate): Map<YearMonth, BigDecimal> {
51-
return contractService.findAllActive(from, to)
52-
.toMapWorkingDay(from, to)
53-
.entries
54-
.groupingBy { YearMonth.of(it.key.year, it.key.month) }
55-
.fold(BigDecimal.ZERO) { acc, cur -> acc + (cur.value.sumAmount(YearMonth.of(cur.key.year, cur.key.month))) }
56-
}
57-
5842
fun totalPerClient(from: LocalDate, to: LocalDate): List<Map<String, Any>> {
5943
val allAssignments = assignmentService.findAllActive(from, to)
6044
return clientService.findAll()

src/main/react/clients/AggregationClient.js

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,5 @@
11
const path = "/api/aggregations"
22

3-
export const revenuePerMonthByYear = year => {
4-
const opts = {
5-
method: "GET",
6-
}
7-
return fetch(`${path}/revenue-per-month?year=${year}`, opts).then(res => {
8-
if (res.status === 200) {
9-
return res.json()
10-
}
11-
throw res.json()
12-
})
13-
}
14-
15-
export const costPerMonthByYear = year => {
16-
const opts = {
17-
method: "GET",
18-
}
19-
return fetch(`${path}/cost-per-month?year=${year}`, opts).then(res => {
20-
if (res.status === 200) {
21-
return res.json()
22-
}
23-
throw res.json()
24-
})
25-
}
26-
27-
export const holidayPerPersonByYear = year => {
28-
const opts = {
29-
method: "GET",
30-
}
31-
return fetch(`${path}/holiday-per-person?year=${year}`, opts).then(res => {
32-
if (res.status === 200) {
33-
return res.json()
34-
}
35-
throw res.json()
36-
})
37-
}
38-
39-
export const sickdayPerPersonByYear = year => {
40-
const opts = {
41-
method: "GET",
42-
}
43-
return fetch(`${path}/sickday-per-person?year=${year}`, opts).then(res => {
44-
if (res.status === 200) {
45-
return res.json()
46-
}
47-
throw res.json()
48-
})
49-
}
50-
513
export const totalPerClientByYear = year => {
524
const opts = {
535
method: "GET",
@@ -97,8 +49,6 @@ export const totalPerMonthByYear = year => {
9749
}
9850

9951
export const AggregationClient = {
100-
revenuePerMonthByYear,
101-
costPerMonthByYear,
10252
totalPerClientByYear,
10353
totalPerPersonByYear,
10454
totalPerPersonByYearMonth,

src/main/react/clients/WorkDayClient.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const internalize = it => ({
55
...it,
66
from: moment(it.from),
77
to: moment(it.to),
8+
days: it.days && it.days.length === 0 ? null : it.days,
89
})
910

1011
const path = "/api/workdays"

src/main/react/components/charts/CostPerMonthChart.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/main/react/components/charts/HolidaysPerPersonChart.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Tooltip from "recharts/es6/component/Tooltip"
88
import Bar from "recharts/es6/cartesian/Bar"
99
import ResponsiveContainer from "recharts/es6/component/ResponsiveContainer"
1010
import PropTypes from "prop-types"
11+
import {AlignedLoader} from "@flock-community/flock-eco-core/src/main/react/components/AlignedLoader"
1112
import {AggregationClient} from "../../clients/AggregationClient"
1213

1314
export function HolidaysPerPersonChart({year}) {
@@ -34,7 +35,7 @@ export function HolidaysPerPersonChart({year}) {
3435
)
3536
}, [])
3637

37-
if (!state) return null
38+
if (!state) return <AlignedLoader />
3839

3940
const height = 50 + state.length * 50
4041

src/main/react/components/charts/RevenueCostPerMonthChart.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/main/react/components/charts/RevenuePerClientChart.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useEffect, useState} from "react"
22
import {Pie, PieChart, ResponsiveContainer, Tooltip} from "recharts"
33
import PropTypes from "prop-types"
4+
import {AlignedLoader} from "@flock-community/flock-eco-core/src/main/react/components/AlignedLoader"
45
import {AggregationClient} from "../../clients/AggregationClient"
56

67
export function RevenuePerClientChart({year}) {
@@ -13,6 +14,8 @@ export function RevenuePerClientChart({year}) {
1314
)
1415
}, [])
1516

17+
if (!state) return <AlignedLoader />
18+
1619
return (
1720
<ResponsiveContainer>
1821
<PieChart width={400} height={400}>

src/main/react/components/charts/RevenuePerMonthChart.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/main/react/components/charts/SickdayPerPersonChart.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Tooltip from "recharts/es6/component/Tooltip"
88
import Bar from "recharts/es6/cartesian/Bar"
99
import ResponsiveContainer from "recharts/es6/component/ResponsiveContainer"
1010
import PropTypes from "prop-types"
11+
import {AlignedLoader} from "@flock-community/flock-eco-core/src/main/react/components/AlignedLoader"
1112
import {AggregationClient} from "../../clients/AggregationClient"
1213

1314
export function SickdayPerPersonChart({year}) {
@@ -20,7 +21,7 @@ export function SickdayPerPersonChart({year}) {
2021
)
2122
}, [])
2223

23-
if (!state) return null
24+
if (!state) return <AlignedLoader />
2425

2526
const height = 50 + state.length * 50
2627

0 commit comments

Comments
 (0)