checkStatus function
Implementation
bool checkStatus(List<TaskModel>? tasks, ProjectCycle? currentCycle) {
if (currentCycle == null) {
return false;
}
if (tasks == null || tasks.isEmpty) {
return true;
}
final lastTask = tasks.last;
final lastTaskCreatedTime = lastTask.clientAuditDetails?.createdTime;
if (lastTaskCreatedTime == null) {
return false;
}
final date = DateTime.fromMillisecondsSinceEpoch(lastTaskCreatedTime);
final diff = DateTime.now().difference(date);
final isLastCycleRunning = lastTaskCreatedTime >= currentCycle.startDate &&
lastTaskCreatedTime <= currentCycle.endDate;
if (isLastCycleRunning) {
if (lastTask.status == Status.delivered.name) {
return true;
}
return diff.inHours >= 24; // [TODO: Move gap between doses to config]
}
return true;
}