1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.timesummary;
17
18 import java.io.Serializable;
19 import java.math.BigDecimal;
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.LinkedHashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.kuali.kpme.core.util.HrConstants;
27 import org.kuali.kpme.tklm.api.time.timesummary.EarnGroupSectionContract;
28
29 public class EarnGroupSection implements Serializable, EarnGroupSectionContract {
30
31 private static final long serialVersionUID = 2655916770367036144L;
32 private String earnGroup;
33 private Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap = new HashMap<String, EarnCodeSection>();
34 private List<EarnCodeSection> earnCodeSections = new ArrayList<EarnCodeSection>();
35 private Map<Integer, BigDecimal> totals = new LinkedHashMap<Integer, BigDecimal>();
36 private BigDecimal earnGroupTotal = BigDecimal.ZERO;
37
38 public String getEarnGroup() {
39 return earnGroup;
40 }
41 public void setEarnGroup(String earnGroup) {
42 this.earnGroup = earnGroup;
43 }
44
45 public Map<Integer, BigDecimal> getTotals() {
46 return totals;
47 }
48
49 public void addEarnCodeSection(EarnCodeSection earnCodeSection, List<Boolean> dayArrangements){
50 for(AssignmentRow assignRow : earnCodeSection.getAssignmentsRows()) {
51 for(Integer i : assignRow.getAssignmentColumns().keySet()) {
52 AssignmentColumn assignmentColumn = assignRow.getAssignmentColumns().get(i);
53 BigDecimal value = totals.get(i).add(assignmentColumn.getTotal(), HrConstants.MATH_CONTEXT);
54 totals.put(i, value.setScale(HrConstants.BIG_DECIMAL_SCALE, HrConstants.BIG_DECIMAL_SCALE_ROUNDING));
55 earnGroupTotal = earnGroupTotal.add(assignmentColumn.getTotal());
56 earnGroupTotal.setScale(HrConstants.BIG_DECIMAL_SCALE, HrConstants.BIG_DECIMAL_SCALE_ROUNDING);
57 }
58
59
60
61
62
63
64
65
66
67 }
68 earnCodeToEarnCodeSectionMap.put(earnCodeSection.getEarnCode(), earnCodeSection);
69 earnCodeSections.add(earnCodeSection);
70
71
72 }
73 public Map<String, EarnCodeSection> getEarnCodeToEarnCodeSectionMap() {
74 return earnCodeToEarnCodeSectionMap;
75 }
76 public void setEarnCodeToEarnCodeSectionMap(
77 Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap) {
78 this.earnCodeToEarnCodeSectionMap = earnCodeToEarnCodeSectionMap;
79 }
80
81 public void addToTotal(int index, BigDecimal hrs){
82 BigDecimal total = getTotals().get(index);
83 total = total.add(hrs, HrConstants.MATH_CONTEXT);
84 getTotals().put(index, total);
85 }
86
87 public List<EarnCodeSection> getEarnCodeSections() {
88 return earnCodeSections;
89 }
90
91 public void setEarnCodeSections(List<EarnCodeSection> earnCodeSections) {
92 this.earnCodeSections = earnCodeSections;
93 }
94
95 public BigDecimal getEarnGroupTotal() {
96 return earnGroupTotal;
97 }
98
99 public void setEarnGroupTotal(BigDecimal earnGroupTotal) {
100 this.earnGroupTotal = earnGroupTotal;
101 }
102
103
104 }