Skip to content

Commit

Permalink
added warning for using commute earn code on a non regular work day, …
Browse files Browse the repository at this point in the history
…fixed typo
  • Loading branch information
sibow committed Feb 27, 2024
1 parent 16c24ae commit 9cc8f1c
Show file tree
Hide file tree
Showing 10 changed files with 1,492 additions and 1,370 deletions.
87 changes: 75 additions & 12 deletions src/main/java/in/bloomington/timer/bean/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Map;
import java.util.Arrays;
import java.util.TreeMap;
import java.sql.*;
import javax.sql.*;
Expand Down Expand Up @@ -61,11 +62,12 @@ public class Document implements Serializable{
Map<String, Double> amountCodeWeek1 = null;
Map<String, Double> amountCodeWeek2 = null;

Map<String, Double> reasonTotals = null;
Map<String, Double> reasonWeek1 = null;
Map<String, Double> reasonWeek2 = null;
Map<String, List<Double>> reasonTotals = null;
Map<String, List<Double>> reasonWeek1 = null;
Map<String, List<Double>> reasonWeek2 = null;

Map<Integer, List<TimeBlock>> dailyBlocks = null;
Map<Integer, DayBlocks> dayBlocksMap = null;
List<EmployeeAccrual> employeeAccruals = null;
List<TimeNote> timeNotes = null;
List<TimeIssue> timeIssues = null;
Expand Down Expand Up @@ -514,6 +516,7 @@ public void prepareDaily(boolean includeEmptyBlocks){
daily = tl.getDaily();
dailyInt = tl.getDailyInt();
dailyBlocks = tl.getDailyBlocks();
dayBlocksMap = tl.getDayBlocksMap();
hourCodeTotals = tl.getHourCodeTotals();
hourCodeWeek1 = tl.getHourCodeWeek1();
hourCodeWeek2 = tl.getHourCodeWeek2();
Expand Down Expand Up @@ -775,6 +778,40 @@ public List<EmployeeAccrual> getEmpAccruals(){
}
return employeeAccruals;
}
private void checkWarningForCommute(){
if(dailyBlocks != null){
// all reg codes
// 18,19,20,21,22,23,93, 111,117,151,36,37,38,39,40,41
Set<String> comSet = new HashSet<>(Arrays.asList("157","158")); // regular codes
Set<String> regSet = new HashSet<>(Arrays.asList("1","18","19","20","21","22","23","36","37","38","39","40","41","93","111","117","151"));

Set<Integer> orderIdSet = dailyBlocks.keySet();
if(orderIdSet != null){
for(Integer order_id:orderIdSet){
boolean hasRegular = false;
boolean hasCommute = false;
String day = "";
List<TimeBlock> blocks = dailyBlocks.get(order_id);
for(TimeBlock block:blocks){
day = block.getDate();
String code_id = block.getHour_code_id();
if(!code_id.isEmpty()){
if(regSet.contains(code_id)){
hasRegular = true;
}
else if(comSet.contains(code_id)){
hasCommute = true;
}
}
}
if(hasCommute && !hasRegular){
String str = " The Sustainable Commute Benefit can only be claimed on days you work regular hours. Please add a Regular Hours block or remove the Sustainable Commute block on "+day;
warnings.add(str);
}
}
}
}
}
private void checkForExcessUse(double weekTotal,
int whichWeek){
if(job != null){
Expand Down Expand Up @@ -942,6 +979,10 @@ public boolean hasDailyBlocks(){
getDailyBlocks();
return dailyBlocks != null;
}
public boolean hasDayBlocksMap(){
getDayBlocksMap();
return dayBlocksMap != null;
}
public boolean hasTimeBlocks(){
return timeBlocks != null;
}
Expand Down Expand Up @@ -986,6 +1027,12 @@ public Map<Integer, List<TimeBlock>> getDailyBlocks(){
}
return dailyBlocks;
}
public Map<Integer, DayBlocks> getDayBlocksMap(){
if(dayBlocksMap == null){
prepareDaily();
}
return dayBlocksMap;
}
public Map<Integer, Double> getHourCodeTotals(){
return hourCodeTotals;
}
Expand All @@ -1001,23 +1048,23 @@ public Map<String, Double> getAmountCodeWeek1Dbl(){
public Map<String, Double> getAmountCodeWeek2Dbl(){
return amountCodeWeek2;
}
public Map<String, Double> getReasonTotalsDbl(){
public Map<String, List<Double>> getReasonTotalsDbl(){
return reasonTotals;
}
public Map<String, Double> getReasonWeek1Dbl(){
public Map<String, List<Double>> getReasonWeek1Dbl(){
return reasonWeek1;
}
public Map<String, Double> getReasonWeek2Dbl(){
public Map<String, List<Double>> getReasonWeek2Dbl(){
return reasonWeek2;
}
public Map<String, String> getReasonTotals(){
return mapDoubleToStr(reasonTotals);
public Map<String, List<String>> getReasonTotals(){
return mapDoubleArrToStr(reasonTotals);
}
public Map<String, String> getReasonWeek1(){
return mapDoubleToStr(reasonWeek1);
public Map<String, List<String>> getReasonWeek1(){
return mapDoubleArrToStr(reasonWeek1);
}
public Map<String, String> getReasonWeek2(){
return mapDoubleToStr(reasonWeek2);
public Map<String, List<String>> getReasonWeek2(){
return mapDoubleArrToStr(reasonWeek2);
}
/**
* we need to format double values to dd.dd format
Expand All @@ -1031,8 +1078,23 @@ public Map<String, String> mapDoubleToStr(Map<String, Double> map){
map2.put(key, dfn.format(val));
}
}

return map2;
}
public Map<String, List<String>> mapDoubleArrToStr(Map<String, List<Double>> map){
Map<String, List<String>> map2 = new TreeMap<>();
if(map != null && !map.isEmpty()){
Set<String> keys = map.keySet();
for(String key:keys){
List<Double> val = map.get(key);
List<String> val2 = new ArrayList<>();
val2.add(dfn.format(val.get(0))); //hours
val2.add(dfn.format(val.get(1))); //amount
map2.put(key, val2);
}
}
return map2;
}
public Map<String, String> getHourCodeWeek1(){
return mapDoubleToStr(hourCodeWeek1);
}
Expand Down Expand Up @@ -1226,6 +1288,7 @@ private void checkForWarnings(){
try{
checkForWarningsAfter();
checkForWarningsBefore();
checkWarningForCommute();
}catch(Exception ex){
System.err.println("check warn "+ex);
}
Expand Down
100 changes: 50 additions & 50 deletions src/main/java/in/bloomington/timer/bean/JobType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,70 @@
*/
public class JobType extends Type implements java.io.Serializable, Comparable<JobType> {

static final long serialVersionUID = 3700L;
static Logger logger = LogManager.getLogger(JobType.class);
//
public JobType(){
super();
}
public JobType(String val){
//
super(val);
static final long serialVersionUID = 3700L;
static Logger logger = LogManager.getLogger(JobType.class);
//
public JobType(){
super();
}
public JobType(String val){
//
super(val);
}
public JobType(String val, String val2){
//
// initialize
//
super(val, val2);
public JobType(String val, String val2){
//
// initialize
//
super(val, val2);
}
@Override
public boolean equals(Object obj){
if(obj instanceof JobType){
JobType one =(JobType)obj;
return id.equals(one.getId());
}
return false;
}
@Override
public int hashCode(){
int seed = 37;
if(!id.isEmpty()){
try{
seed += Integer.parseInt(id);
}catch(Exception ex){
}
}
return seed;
}
@Override
public boolean equals(Object obj){
if(obj instanceof JobType){
JobType one =(JobType)obj;
return id.equals(one.getId());
}
return false;
}
@Override
public int hashCode(){
int seed = 37;
if(!id.isEmpty()){
try{
seed += Integer.parseInt(id);
}catch(Exception ex){
}
}
return seed;
}
public int getId_int(){
int seed = 23;
try{
seed += Integer.parseInt(id);
}catch(Exception ex){
}
return seed;
}
@Override
public int getId_int(){
int seed = 23;
try{
seed += Integer.parseInt(id);
}catch(Exception ex){
}
return seed;
}
@Override
public int compareTo(JobType otherJob) {
return (this.getId_int() - otherJob.getId_int());
}
//
// getters
//
public String getJob_id(){
return id;
return id;
}
public String getJob_name(){
return name;
return name;
}
//
// setters
//
public void setJob_id(String val){
setId(val);
}
public void setJob_name(String val){
setName(val);
}
public void setJob_id(String val){
setId(val);
}
public void setJob_name(String val){
setName(val);
}

}
Loading

0 comments on commit 9cc8f1c

Please sign in to comment.