Skip to content

Commit 76da953

Browse files
authored
Merge pull request #2735 from objectcomputing/feature-2732/total-compensation-merit-report
Feature 2732/total compensation merit report
2 parents 91108f5 + 839a94a commit 76da953

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public class CompensationHistory extends CSVProcessor {
2323
public record Compensation(
2424
UUID memberId,
2525
LocalDate startDate,
26-
float amount
26+
String amount,
27+
String totalComp
2728
) {
2829
}
2930

@@ -45,11 +46,13 @@ protected void loadImpl(MemberProfileRepository memberProfileRepository,
4546
if (date == null) {
4647
LOG.error("Unable to parse date: {}", startDate);
4748
} else {
49+
String value = csvRecord.get("compensation");
4850
Compensation comp = new Compensation(
4951
memberProfile.get().getId(),
5052
date,
51-
Float.parseFloat(csvRecord.get("compensation")
52-
.replaceAll("[^\\d\\.,]", "")));
53+
value == null ? null : value.replaceAll("[^\\d\\.,]", ""),
54+
csvRecord.get("totalComp")
55+
);
5356
history.add(comp);
5457
}
5558
} else {

server/src/test/java/com/objectcomputing/checkins/services/reports/ReportDataControllerTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ void validateReportData(JsonNode node, MemberProfile user) {
185185

186186
// Compensation History
187187
ArrayNode comp = (ArrayNode)node.get("compensationHistory");
188-
assertEquals(5, comp.size());
188+
assertEquals(10, comp.size());
189189
assertEquals(memberId, comp.get(0).get("memberId").asText());
190190
assertTrue(comp.get(0).get("amount").asDouble() > 0);
191+
assertFalse(comp.get(9).get("totalComp").asText().isEmpty());
191192

192193
// Current Information
193194
JsonNode curr = node.get("currentInformation");
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
"emailAddress","startDate","compensation"
2-
"[email protected]","1/1/2024","100000.00"
3-
"[email protected]","1/1/2023","95000.00"
4-
"[email protected]","1/1/2022","90000.00"
5-
"[email protected]","1/1/2021","85000.00"
6-
"[email protected]","1/1/2020","80000.00"
7-
"[email protected]","2/1/2024","100000.00"
8-
"[email protected]","2/1/2023","95000.00"
9-
"[email protected]","2/1/2022","90000.00"
10-
"[email protected]","2/1/2021","85000.00"
11-
"[email protected]","2/1/2020","80000.00"
1+
"emailAddress","startDate","compensation","totalComp"
2+
"[email protected]","1/1/2024","100000.00",
3+
"[email protected]","1/1/2023","95000.00",
4+
"[email protected]","1/1/2022","90000.00",
5+
"[email protected]","1/1/2021","85000.00",
6+
"[email protected]","1/1/2020","80000.00",
7+
"[email protected]","2/1/2024","100000.00",
8+
"[email protected]","2/1/2023","95000.00",
9+
"[email protected]","2/1/2022","90000.00",
10+
"[email protected]","2/1/2021","85000.00",
11+
"[email protected]","2/1/2020","80000.00",
12+
"[email protected]","2024",,"103000.00"
13+
"[email protected]","2023",,"98000.00"
14+
"[email protected]","2022",,"93000.00"
15+
"[email protected]","2021",,"88000.00"
16+
"[email protected]","2020",,"83000.00"
17+
"[email protected]","2024",,"103000.00"
18+
"[email protected]","2023",,"98000.00"
19+
"[email protected]","2022",,"93000.00"
20+
"[email protected]","2021",,"88000.00"
21+
"[email protected]","2020",,"83000.00"

web-ui/src/pages/MeritReportPage.jsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,8 @@ const MeritReportPage = () => {
432432
return text;
433433
};
434434

435-
const markdownCompensationHistory = (data) => {
436-
// Sort them latest to oldest and truncate to the first 3.
437-
const compHistory = data.compensationHistory.sort((a, b) => {
435+
const prepareCompensationHistory = (data, fn) => {
436+
return data.compensationHistory.filter(fn).sort((a, b) => {
438437
for(let i = 0; i < a.length; i++) {
439438
if (a.startDate[i] != b.startDate[i]) {
440439
return b.startDate[i] - a.startDate[i];
@@ -443,10 +442,20 @@ const MeritReportPage = () => {
443442
return 0;
444443
}).slice(0, 3);
445444

445+
};
446+
447+
const markdownCompensationHistory = (data) => {
448+
// Sort them latest to oldest and truncate to the first 3.
449+
const compBase = prepareCompensationHistory(data, (comp) => !!comp.amount);
450+
const compTotal = prepareCompensationHistory(data, (comp) => !!comp.totalComp);
451+
446452
let text = markdown.headers.h2("Compensation History");
447-
text += markdown.lists.ul(compHistory,
453+
text += markdown.lists.ul(compBase,
448454
(comp) => formatDate(dateFromArray(comp.startDate)) + " - " +
449-
"$" + comp.amount.toFixed(2) + " (base)");
455+
"$" + parseFloat(comp.amount).toFixed(2) + " (base)");
456+
text += markdown.lists.ul(compTotal,
457+
(comp) => dateFromArray(comp.startDate).getFullYear() + " - " +
458+
comp.totalComp);
450459
return text;
451460
};
452461

0 commit comments

Comments
 (0)