1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.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.List;
23 import java.util.Map;
24
25 import org.kuali.hr.time.util.TkConstants;
26
27 public class EarnGroupSection implements Serializable {
28 private String earnGroup;
29 private Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap = new HashMap<String, EarnCodeSection>();
30 private List<EarnCodeSection> earnCodeSections = new ArrayList<EarnCodeSection>();
31 private List<BigDecimal> totals = new ArrayList<BigDecimal>();
32 public String getEarnGroup() {
33 return earnGroup;
34 }
35 public void setEarnGroup(String earnGroup) {
36 this.earnGroup = earnGroup;
37 }
38
39 public List<BigDecimal> getTotals() {
40 return totals;
41 }
42
43 public void addEarnCodeSection(EarnCodeSection earnCodeSection, List<Boolean> dayArrangements){
44 for(AssignmentRow assignRow : earnCodeSection.getAssignmentsRows()) {
45 int i = 0;
46 for (AssignmentColumn assignmentColumn : assignRow.getAssignmentColumns()) {
47 BigDecimal value = totals.get(i).add(assignmentColumn.getTotal(), TkConstants.MATH_CONTEXT);
48 totals.set(i, value.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING));
49 i++;
50 }
51 }
52 earnCodeToEarnCodeSectionMap.put(earnCodeSection.getEarnCode(), earnCodeSection);
53 earnCodeSections.add(earnCodeSection);
54
55 BigDecimal periodTotal = BigDecimal.ZERO;
56 for(int i =0;i<totals.size()-2;i++){
57 if(dayArrangements.get(i)){
58 periodTotal = periodTotal.add(totals.get(i), TkConstants.MATH_CONTEXT);
59 }
60 }
61 totals.set(totals.size()-1, periodTotal);
62 }
63 public Map<String, EarnCodeSection> getEarnCodeToEarnCodeSectionMap() {
64 return earnCodeToEarnCodeSectionMap;
65 }
66 public void setEarnCodeToEarnCodeSectionMap(
67 Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap) {
68 this.earnCodeToEarnCodeSectionMap = earnCodeToEarnCodeSectionMap;
69 }
70
71
72 public void addToTotal(int index, BigDecimal hrs){
73 BigDecimal total = getTotals().get(index);
74 total = total.add(hrs, TkConstants.MATH_CONTEXT);
75 getTotals().set(index, total);
76 }
77 public List<EarnCodeSection> getEarnCodeSections() {
78 return earnCodeSections;
79 }
80 public void setEarnCodeSections(List<EarnCodeSection> earnCodeSections) {
81 this.earnCodeSections = earnCodeSections;
82 }
83 }