diff --git a/lib/model/dailyTaskPlaning/report_task_bottom_sheet.dart b/lib/model/dailyTaskPlaning/report_task_bottom_sheet.dart index d4635ff..99441ff 100644 --- a/lib/model/dailyTaskPlaning/report_task_bottom_sheet.dart +++ b/lib/model/dailyTaskPlaning/report_task_bottom_sheet.dart @@ -124,10 +124,8 @@ class _ReportTaskBottomSheetState extends State .trim()), buildRow( "Assigned", - controller.basicValidator - .getController('assigned') - ?.text - .trim()), + "${controller.basicValidator.getController('assigned')?.text.trim()} " + "of ${widget.taskData['pendingWork'] ?? '-'} Pending"), Row( children: [ Icon(Icons.work_outline, @@ -141,8 +139,23 @@ class _ReportTaskBottomSheetState extends State ), MySpacing.height(8), TextFormField( - validator: controller.basicValidator - .getValidation('completed_work'), + validator: (value) { + if (value == null || value.trim().isEmpty) { + return 'Please enter completed work'; + } + final completed = int.tryParse(value.trim()); + final pending = widget.taskData['pendingWork'] ?? 0; + + if (completed == null) { + return 'Enter a valid number'; + } + + if (completed > pending) { + return 'Completed work cannot exceed pending work $pending'; + } + + return null; + }, controller: controller.basicValidator .getController('completed_work'), keyboardType: TextInputType.number, diff --git a/lib/view/taskPlaning/daily_progress.dart b/lib/view/taskPlaning/daily_progress.dart index 0c394d4..0447d97 100644 --- a/lib/view/taskPlaning/daily_progress.dart +++ b/lib/view/taskPlaning/daily_progress.dart @@ -440,6 +440,11 @@ class _DailyProgressReportScreenState extends State final teamMembers = task.teamMembers .map((e) => e.firstName) .toList(); + final pendingWork = (task.workItem + ?.plannedWork ?? + 0) - + (task.workItem?.completedWork ?? + 0); final taskData = { 'activity': activityName, @@ -452,6 +457,7 @@ class _DailyProgressReportScreenState extends State 'teamSize': task.teamMembers.length, 'teamMembers': teamMembers, + 'pendingWork': pendingWork, }; showModalBottomSheet(