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.List;
21
22 import org.kuali.hr.time.util.TkConstants;
23
24 public class AssignmentRow {
25 private String descr;
26 private List<BigDecimal> total = new ArrayList<BigDecimal>();
27 private String cssClass;
28 private String assignmentKey;
29
30 private List<BigDecimal> amount = new ArrayList<BigDecimal>();
31
32 private BigDecimal periodTotal = BigDecimal.ZERO;
33
34 private EarnCodeSection earnCodeSection;
35
36 public String getDescr() {
37 return descr;
38 }
39 public void setDescr(String descr) {
40 this.descr = descr;
41 }
42 public List<BigDecimal> getTotal() {
43 return total;
44 }
45 public void setTotal(List<BigDecimal> total) {
46 this.total = total;
47 }
48 public String getCssClass() {
49 return cssClass;
50 }
51 public void setCssClass(String cssClass) {
52 this.cssClass = cssClass;
53 }
54 public String getAssignmentKey() {
55 return assignmentKey;
56 }
57 public void setAssignmentKey(String assignmentKey) {
58 this.assignmentKey = assignmentKey;
59 }
60
61 public void addToTotal(int index, BigDecimal hrs){
62 BigDecimal total = getTotal().get(index);
63 total = total.add(hrs, TkConstants.MATH_CONTEXT);
64 getTotal().set(index, total);
65 getEarnCodeSection().addToTotal(index, hrs);
66 }
67
68 public void addWeeklyTotal(int index, int weekSize){
69 BigDecimal weeklyTotal = BigDecimal.ZERO;
70 BigDecimal weeklyAmt = BigDecimal.ZERO;
71 for(int i = index; i >= (index-weekSize) && i >=0;i--){
72 weeklyTotal = weeklyTotal.add(getTotal().get(i), TkConstants.MATH_CONTEXT);
73 weeklyAmt = weeklyAmt.add(getAmount().get(i), TkConstants.MATH_CONTEXT);
74 }
75 getTotal().set(index,weeklyTotal);
76 getAmount().set(index, weeklyAmt);
77
78 BigDecimal periodTotal = getTotal().get(getTotal().size()-1);
79 periodTotal = periodTotal.add(weeklyTotal, TkConstants.MATH_CONTEXT);
80 getTotal().set(getTotal().size()-1,periodTotal);
81
82
83 BigDecimal amountTotal = getAmount().get(getTotal().size()-1);
84 amountTotal = amountTotal.add(weeklyAmt, TkConstants.MATH_CONTEXT);
85 getAmount().set(getAmount().size()-1, amountTotal);
86 }
87 public EarnCodeSection getEarnCodeSection() {
88 return earnCodeSection;
89 }
90 public void setEarnCodeSection(EarnCodeSection earnCodeSection) {
91 this.earnCodeSection = earnCodeSection;
92 }
93 public BigDecimal getPeriodTotal() {
94 return periodTotal;
95 }
96 public void setPeriodTotal(BigDecimal periodTotal) {
97 this.periodTotal = periodTotal;
98 }
99 public List<BigDecimal> getAmount() {
100 return amount;
101 }
102 public void setAmount(List<BigDecimal> amount) {
103 this.amount = amount;
104 }
105
106 public void addToAmount(int index, BigDecimal amount){
107 if(amount == null){
108 return;
109 }
110 BigDecimal amtTotal = getAmount().get(index);
111 amtTotal = amtTotal.add(amount, TkConstants.MATH_CONTEXT);
112 getAmount().set(index, amtTotal);
113 }
114 }