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 EarnCodeSection implements Serializable {
28 private String earnCode;
29 private String description;
30 private Map<String, AssignmentRow> assignKeyToAssignmentRowMap = new HashMap<String, AssignmentRow>();
31 private List<AssignmentRow> assignmentsRows = new ArrayList<AssignmentRow>();
32 private List<BigDecimal> totals = new ArrayList<BigDecimal>();
33 private Boolean isAmountEarnCode = Boolean.FALSE;;
34
35 private EarnGroupSection earnGroupSection;
36
37 public String getEarnCode() {
38 return earnCode;
39 }
40 public void setEarnCode(String earnCode) {
41 this.earnCode = earnCode;
42 }
43 public String getDescription() {
44 return description;
45 }
46 public void setDescription(String description) {
47 this.description = description;
48 }
49
50 public void addAssignmentRow(AssignmentRow assignRow) {
51 int i = 0;
52 for (AssignmentColumn assignmentColumn : assignRow.getAssignmentColumns()) {
53 BigDecimal value = totals.get(i).add(assignmentColumn.getTotal(), TkConstants.MATH_CONTEXT);
54 totals.set(i, value.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING));
55 i++;
56 }
57 assignKeyToAssignmentRowMap.put(assignRow.getAssignmentKey(), assignRow);
58 assignmentsRows.add(assignRow);
59 }
60
61 public void addWeeklyTotal(int index, int weekSize){
62
63 BigDecimal weeklyTotal = BigDecimal.ZERO;
64 for(int i = index; i >= (index-weekSize) && i >=0;i--){
65 weeklyTotal = weeklyTotal.add(getTotals().get(i), TkConstants.MATH_CONTEXT);
66 }
67 getTotals().set(index,weeklyTotal);
68 BigDecimal periodTotal = getTotals().get(getTotals().size()-1);
69 periodTotal = periodTotal.add(weeklyTotal, TkConstants.MATH_CONTEXT);
70 getTotals().set(getTotals().size()-1,periodTotal);
71
72 for(AssignmentRow ar : assignmentsRows){
73 ar.addWeeklyTotal(index, weekSize);
74 }
75 }
76
77 public List<AssignmentRow> getAssignmentsRows() {
78 return assignmentsRows;
79 }
80 public void setAssignmentsRows(List<AssignmentRow> assignmentsRows) {
81 this.assignmentsRows = assignmentsRows;
82 }
83 public List<BigDecimal> getTotals() {
84 return totals;
85 }
86 public void setTotals(List<BigDecimal> totals) {
87 this.totals = totals;
88 }
89 public Map<String, AssignmentRow> getAssignKeyToAssignmentRowMap() {
90 return assignKeyToAssignmentRowMap;
91 }
92 public void setAssignKeyToAssignmentRowMap(
93 Map<String, AssignmentRow> assignKeyToAssignmentRowMap) {
94 this.assignKeyToAssignmentRowMap = assignKeyToAssignmentRowMap;
95 }
96
97 public void addToTotal(int index, BigDecimal hrs){
98 BigDecimal total = getTotals().get(index);
99 total = total.add(hrs, TkConstants.MATH_CONTEXT);
100 getTotals().set(index, total);
101 }
102
103 public void addToAmount(int index, BigDecimal amount){
104 BigDecimal amtTotal = getTotals().get(index);
105 amtTotal = amtTotal.add(amount, TkConstants.MATH_CONTEXT);
106 getTotals().set(index, amtTotal);
107 }
108 public EarnGroupSection getEarnGroupSection() {
109 return earnGroupSection;
110 }
111 public void setEarnGroupSection(EarnGroupSection earnGroupSection) {
112 this.earnGroupSection = earnGroupSection;
113 }
114 public Boolean getIsAmountEarnCode() {
115 return isAmountEarnCode;
116 }
117 public void setIsAmountEarnCode(Boolean isAmountEarnCode) {
118 this.isAmountEarnCode = isAmountEarnCode;
119 }
120
121
122 }