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