summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2022-08-17 11:41:48 +0200
committerAldrik Ramaekers <aldrik@amftech.nl>2022-08-17 11:41:48 +0200
commit3d25fdc99fd37f3b5e37f25b7a38804a02130426 (patch)
tree8cd4eb086492dfacdcd288dba0f1f025f3f66daa /lib
parent9649d80a2b0a0c46a8ae68606d3e0cfe6f49faee (diff)
money calculation working
Diffstat (limited to 'lib')
-rw-r--r--lib/pages/logbook_page.dart5
-rw-r--r--lib/shift.dart14
-rw-r--r--lib/widgets/agenda_week_item.dart44
3 files changed, 52 insertions, 11 deletions
diff --git a/lib/pages/logbook_page.dart b/lib/pages/logbook_page.dart
index 0e81f49..0849cda 100644
--- a/lib/pages/logbook_page.dart
+++ b/lib/pages/logbook_page.dart
@@ -23,11 +23,10 @@ class MonthData {
void calculateData() {
totalWorkedTime = Duration();
+ expectedSalary = 0;
for (var shift in shifts) {
totalWorkedTime += shift.getElapsedSessionTime();
- }
- if (shifts.isNotEmpty) {
- expectedSalary = totalWorkedTime.inMinutes * shifts[0].getMinutePayRate();
+ expectedSalary += shift.getEarnedMoney();
}
}
diff --git a/lib/shift.dart b/lib/shift.dart
index fd32cf7..eecf4cc 100644
--- a/lib/shift.dart
+++ b/lib/shift.dart
@@ -45,7 +45,7 @@ class Shift {
case ShiftStatus.Active:
return Padding(
child: CircularProgressIndicator(
- strokeWidth: 1,
+ strokeWidth: 2,
color: Colors.white,
),
padding:
@@ -111,6 +111,18 @@ class Shift {
!DateUtilities.DateUtils.isSameDay(start, DateTime.now());
}
+ double getEarnedMoney() {
+ DateTime? endToCalculate = end;
+ endToCalculate ??= expectedEndTime();
+
+ if (start.weekday == 6) {
+ return endToCalculate.difference(start).inMinutes *
+ getMinutePayRate() *
+ 1.35;
+ }
+ return endToCalculate.difference(start).inMinutes * getMinutePayRate();
+ }
+
double getMoneyForActiveSession() {
if (getIsActive()) {
Duration elapsed = DateTime.now().difference(start);
diff --git a/lib/widgets/agenda_week_item.dart b/lib/widgets/agenda_week_item.dart
index 779b42d..b74cabd 100644
--- a/lib/widgets/agenda_week_item.dart
+++ b/lib/widgets/agenda_week_item.dart
@@ -200,6 +200,12 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
child: Text('Invullen'));
}
+ Widget createOldShiftInfoText() {
+ return Text(
+ '€' + widget.shift.getEarnedMoney().toStringAsFixed(2),
+ );
+ }
+
Widget createShiftModifyButton() {
if (!widget.shift.getIsActive() && widget.shift.canStart()) {
return createStartShiftButton();
@@ -207,6 +213,8 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
return createStopShiftButton();
} else if (widget.shift.shiftIsOpenButBeforeToday()) {
return createCompleteOldShiftButton();
+ } else if (widget.shift.isDone()) {
+ return createOldShiftInfoText();
}
return Padding(padding: const EdgeInsets.all(0));
@@ -258,6 +266,21 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
setStartAndEndTime();
+ double widthOfItem = MediaQuery.of(context).size.width - 20;
+ double heightOfItem = 48;
+ double widthOfIcon = 32;
+ double widthOfWeekday = 35;
+ double widthOfDates = 95;
+ double widthOfAction = 90;
+
+ double remaining = widthOfItem -
+ widthOfIcon -
+ widthOfWeekday -
+ widthOfDates -
+ widthOfAction -
+ 20; // padding
+ double widthOfShiftType = remaining;
+
return Padding(
padding: const EdgeInsets.only(bottom: 8, left: 10, right: 10),
child: Container(
@@ -270,7 +293,8 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
- width: double.infinity,
+ width: widthOfItem,
+ height: heightOfItem,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(4))),
padding: EdgeInsets.all(0),
@@ -288,8 +312,8 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8))),
- height: 48.0,
- width: 32.0,
+ height: heightOfItem,
+ width: widthOfIcon,
child: widget.shift.getStatusIcon(),
),
),
@@ -299,7 +323,7 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
DateHelper.getWeekdayName(widget.shift.start.weekday),
style: Style.listItemTitletextBold,
),
- width: 35,
+ width: widthOfWeekday,
),
Container(
child: RichText(
@@ -312,15 +336,21 @@ class _ExerciseEntryState extends State<AgendaWeekItem> {
],
),
),
- width: 95,
+ width: widthOfDates,
),
Container(
child: Text(
'| ' + shiftTypeName,
),
- width: 100,
+ width: widthOfShiftType,
+ ),
+ Container(
+ child: Align(
+ child: startShiftWidget,
+ alignment: Alignment.centerRight,
+ ),
+ width: widthOfAction,
),
- startShiftWidget,
],
),
),