summarizing

This commit is contained in:
Jörg Henke
2022-01-12 10:47:26 +01:00
parent e10fe2976b
commit 6630a0e6c7
3 changed files with 52 additions and 1 deletions

View File

@ -25,7 +25,7 @@ apply plugin: 'war'
apply plugin: 'eclipse'
group = 'jottyfan'
version = '1.1.8'
version = '1.1.9'
description = """timetrack"""

View File

@ -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"));

View File

@ -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>