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 for(int i = 0;i<(assignRow.getTotal().size()-1);i++){
46 BigDecimal value = totals.get(i).add(assignRow.getTotal().get(i), TkConstants.MATH_CONTEXT);
47 totals.set(i, value.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING));
48 }
49 }
50 earnCodeToEarnCodeSectionMap.put(earnCodeSection.getEarnCode(), earnCodeSection);
51 earnCodeSections.add(earnCodeSection);
52
53 BigDecimal periodTotal = BigDecimal.ZERO;
54 for(int i =0;i<totals.size()-2;i++){
55 if(dayArrangements.get(i)){
56 periodTotal = periodTotal.add(totals.get(i), TkConstants.MATH_CONTEXT);
57 }
58 }
59 totals.set(totals.size()-1, periodTotal);
60 }
61 public Map<String, EarnCodeSection> getEarnCodeToEarnCodeSectionMap() {
62 return earnCodeToEarnCodeSectionMap;
63 }
64 public void setEarnCodeToEarnCodeSectionMap(
65 Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap) {
66 this.earnCodeToEarnCodeSectionMap = earnCodeToEarnCodeSectionMap;
67 }
68
69
70 public void addToTotal(int index, BigDecimal hrs){
71 BigDecimal total = getTotals().get(index);
72 total = total.add(hrs, TkConstants.MATH_CONTEXT);
73 getTotals().set(index, total);
74 }
75 public List<EarnCodeSection> getEarnCodeSections() {
76 return earnCodeSections;
77 }
78 public void setEarnCodeSections(List<EarnCodeSection> earnCodeSections) {
79 this.earnCodeSections = earnCodeSections;
80 }
81 }