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 for(int i = 0;i<assignRow.getTotal().size()-1;i++){
52
53 BigDecimal value = totals.get(i).add(assignRow.getTotal().get(i), TkConstants.MATH_CONTEXT);
54 totals.set(i, value.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING));
55 }
56 assignKeyToAssignmentRowMap.put(assignRow.getAssignmentKey(), assignRow);
57 assignmentsRows.add(assignRow);
58 }
59
60 public void addWeeklyTotal(int index, int weekSize){
61
62 BigDecimal weeklyTotal = BigDecimal.ZERO;
63 for(int i = index; i >= (index-weekSize) && i >=0;i--){
64 weeklyTotal = weeklyTotal.add(getTotals().get(i), TkConstants.MATH_CONTEXT);
65 }
66 getTotals().set(index,weeklyTotal);
67 BigDecimal periodTotal = getTotals().get(getTotals().size()-1);
68 periodTotal = periodTotal.add(weeklyTotal, TkConstants.MATH_CONTEXT);
69 getTotals().set(getTotals().size()-1,periodTotal);
70
71 for(AssignmentRow ar : assignmentsRows){
72 ar.addWeeklyTotal(index, weekSize);
73 }
74 }
75
76 public List<AssignmentRow> getAssignmentsRows() {
77 return assignmentsRows;
78 }
79 public void setAssignmentsRows(List<AssignmentRow> assignmentsRows) {
80 this.assignmentsRows = assignmentsRows;
81 }
82 public List<BigDecimal> getTotals() {
83 return totals;
84 }
85 public void setTotals(List<BigDecimal> totals) {
86 this.totals = totals;
87 }
88 public Map<String, AssignmentRow> getAssignKeyToAssignmentRowMap() {
89 return assignKeyToAssignmentRowMap;
90 }
91 public void setAssignKeyToAssignmentRowMap(
92 Map<String, AssignmentRow> assignKeyToAssignmentRowMap) {
93 this.assignKeyToAssignmentRowMap = assignKeyToAssignmentRowMap;
94 }
95
96 public void addToTotal(int index, BigDecimal hrs){
97 BigDecimal total = getTotals().get(index);
98 total = total.add(hrs, TkConstants.MATH_CONTEXT);
99 getTotals().set(index, total);
100 }
101
102 public void addToAmount(int index, BigDecimal amount){
103 BigDecimal amtTotal = getTotals().get(index);
104 amtTotal = amtTotal.add(amount, TkConstants.MATH_CONTEXT);
105 getTotals().set(index, amtTotal);
106 }
107 public EarnGroupSection getEarnGroupSection() {
108 return earnGroupSection;
109 }
110 public void setEarnGroupSection(EarnGroupSection earnGroupSection) {
111 this.earnGroupSection = earnGroupSection;
112 }
113 public Boolean getIsAmountEarnCode() {
114 return isAmountEarnCode;
115 }
116 public void setIsAmountEarnCode(Boolean isAmountEarnCode) {
117 this.isAmountEarnCode = isAmountEarnCode;
118 }
119
120
121 }