summarizing
This commit is contained in:
@ -25,7 +25,7 @@ apply plugin: 'war'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
group = 'jottyfan'
|
||||
version = '1.1.8'
|
||||
version = '1.1.9'
|
||||
|
||||
description = """timetrack"""
|
||||
|
||||
|
@ -11,7 +11,10 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
@ -121,6 +124,49 @@ public class DoneModel implements Model, Serializable {
|
||||
times.add(new TimeBean(defineNewTime(currentHour, currentMinute + 30), "link"));
|
||||
times.add(new TimeBean(defineNewTime(currentHour, currentMinute + 45), "link"));
|
||||
}
|
||||
|
||||
/**
|
||||
* summarizes the billings in horizon2020 notation
|
||||
*
|
||||
* @return the billings summary
|
||||
*/
|
||||
public String getSummaryBilling() {
|
||||
Map<String, Double> map = new HashMap<>();
|
||||
for (DailySummaryBean bean : getAllJobs()) {
|
||||
String shortcut = bean.getBillingShortcut();
|
||||
Double time = bean.getDurationHours();
|
||||
Double sumTime = map.get(shortcut);
|
||||
sumTime = sumTime == null ? time : (sumTime + time);
|
||||
map.put(shortcut, sumTime);
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (Entry<String, Double> entry : map.entrySet()) {
|
||||
buf.append(first ? "" : ", ");
|
||||
String key = entry.getKey();
|
||||
if (key == null || key.equals("null")) {
|
||||
buf.append("$ ");
|
||||
} else {
|
||||
buf.append(entry.getKey()).append(" ");
|
||||
}
|
||||
buf.append("(").append(entry.getValue()).append(")");
|
||||
first = false;
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* summarizes the time of a days work in commaseparated values
|
||||
*
|
||||
* @return the summarized times
|
||||
*/
|
||||
public String getSummaryTime() {
|
||||
Double sum = 0d;
|
||||
for (DailySummaryBean bean : getAllJobs()) {
|
||||
sum += bean.getDurationHours();
|
||||
}
|
||||
return sum.toString();
|
||||
}
|
||||
|
||||
private Calendar getCurrentTime() {
|
||||
return new GregorianCalendar(TimeZone.getTimeZone("Europe/Berlin"));
|
||||
|
@ -84,6 +84,11 @@
|
||||
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{col.durationHours} h" contentStyle="font-size: 120%" orderable="false" />
|
||||
</b:dataTable>
|
||||
<h:panelGrid columns="3" style="width: 100%">
|
||||
<h:outputText value="Zusammenfassung" style="font-size: 120%; font-weight: bold" />
|
||||
<h:outputText value="#{doneModel.summaryBilling}" style="font-size: 120%; font-weight: bold" />
|
||||
<h:outputText value="#{doneModel.summaryTime} h" style="font-size: 120%; font-weight: bold" />
|
||||
</h:panelGrid>
|
||||
</b:tab>
|
||||
<b:tab title="Anhang">
|
||||
<p>
|
||||
|
Reference in New Issue
Block a user