footer
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
class MonthStart {
|
||||
final DateTime month; // YYYY-MM-01
|
||||
final int startMinutes; // starthours (in Minuten)
|
||||
final int startVacationUnits; // startvacation (z.B. Tage)
|
||||
final int overtimeMinutes; // overtime (Minuten)
|
||||
final int correctionMinutes; // correction (Minuten)
|
||||
|
||||
const MonthStart({
|
||||
required this.month,
|
||||
required this.startMinutes,
|
||||
required this.startVacationUnits,
|
||||
required this.overtimeMinutes,
|
||||
required this.correctionMinutes,
|
||||
});
|
||||
|
||||
/// Basis für kumulierte Differenz
|
||||
int get carryBaseMinutes => startMinutes + overtimeMinutes + correctionMinutes;
|
||||
|
||||
static MonthStart fromJson(Map<String, dynamic> json) {
|
||||
final bookings = (json['bookings'] as List?) ?? const [];
|
||||
final row = bookings.isNotEmpty ? (bookings.first as Map<String, dynamic>) : const <String, dynamic>{};
|
||||
final dateStr = (json['date'] as String?) ?? '1970-01-01';
|
||||
final dt = DateTime.tryParse(dateStr) ?? DateTime(1970, 1, 1);
|
||||
|
||||
int _toInt(dynamic v) => v is num ? v.toInt() : int.tryParse('$v') ?? 0;
|
||||
|
||||
return MonthStart(
|
||||
month: DateTime(dt.year, dt.month, 1),
|
||||
startMinutes: _toInt(row['starthours']),
|
||||
startVacationUnits: _toInt(row['startvacation']),
|
||||
overtimeMinutes: _toInt(row['overtime']),
|
||||
correctionMinutes: _toInt(row['correction']),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/work_time.dart';
|
||||
import 'work_interval.dart';
|
||||
|
||||
class WorkDay {
|
||||
final DateTime date;
|
||||
final List<WorkInterval> intervals; // bis zu 5
|
||||
final String? code; // GZ, K, U, SU, T oder null
|
||||
final int targetMinutes; // Soll
|
||||
final List<WorkInterval> intervals;
|
||||
final int targetMinutes;
|
||||
final String? code; // 'G','U','SU','K','T' oder null
|
||||
|
||||
const WorkDay({
|
||||
required this.date,
|
||||
@@ -14,6 +15,6 @@ class WorkDay {
|
||||
this.code,
|
||||
});
|
||||
|
||||
int get workedMinutes => intervals.fold(0, (sum, i) => sum + i.minutes);
|
||||
int get diffMinutes => workedMinutes - targetMinutes;
|
||||
/// Effektive Ist-Zeit mit 30-Minuten-Pausenregel (>6h) und Lückenanrechnung
|
||||
int get workedMinutes => effectiveWorkedMinutes(intervals);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,5 @@ import 'package:flutter/material.dart';
|
||||
class WorkInterval {
|
||||
final TimeOfDay start;
|
||||
final TimeOfDay end;
|
||||
|
||||
const WorkInterval(this.start, this.end);
|
||||
|
||||
int get minutes {
|
||||
final aMin = start.hour * 60 + start.minute;
|
||||
final bMin = end.hour * 60 + end.minute;
|
||||
final d = bMin - aMin;
|
||||
if (d <= 0) return 0;
|
||||
if (d >= 24 * 60) return 24 * 60;
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user