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