Subversion Repositories SmartDukaan

Rev

Rev 28805 | Rev 28812 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28805 Rev 28806
Line 1127... Line 1127...
1127
			User user = userMap.get(authUser.getEmailId());
1127
			User user = userMap.get(authUser.getEmailId());
1128
			Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
1128
			Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
1129
			if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null
1129
			if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null
1130
					|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
1130
					|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
1131
				String body = String.format(
1131
				String body = String.format(
1132
						"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team",
1132
						"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team",
1133
						authUser.getFullName(), (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? "" 
1133
						authUser.getFullName(), (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? "" 
1134
								: "(Punched at " + FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp()) +")" );
1134
								: "(Punched at " + FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp()) +")" );
1135
				Utils.sendMailWithAttachments(googleMailSender, new String[] {
1135
				Utils.sendMailWithAttachments(googleMailSender, new String[] {
1136
				authUser.getEmailId() }, new String[] { "jyoti.rawat@smartdukaan.com" },
1136
				authUser.getEmailId() }, new String[] { "jyoti.rawat@smartdukaan.com" },
1137
				"Attendance Alert", body);
1137
				"Attendance Alert", body);
Line 1156... Line 1156...
1156
			User user = userMap.get(authUser.getEmailId());
1156
			User user = userMap.get(authUser.getEmailId());
1157
			String body = null;
1157
			String body = null;
1158
			List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
1158
			List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
1159
			if (employeeAttendances == null) {
1159
			if (employeeAttendances == null) {
1160
				body = String.format(
1160
				body = String.format(
1161
						"Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team",
1161
						"Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day.\n\nRegards\nHR Team",
1162
						authUser.getFullName());
1162
						authUser.getFullName());
1163
			} else {
1163
			} else {
1164
				List<LocalDateTime> punchTimes = employeeAttendances.stream()
1164
				List<LocalDateTime> punchTimes = employeeAttendances.stream()
1165
						.sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))
1165
						.sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))
1166
						.map(x -> x.getCreateTimestamp()).collect(Collectors.toList());
1166
						.map(x -> x.getCreateTimestamp()).collect(Collectors.toList());
Line 1173... Line 1173...
1173
					LocalDateTime lastPunch = punchTimes.get(punchTimes.size() - 1);
1173
					LocalDateTime lastPunch = punchTimes.get(punchTimes.size() - 1);
1174
					Duration duration = Duration.between(firstPunch, lastPunch);
1174
					Duration duration = Duration.between(firstPunch, lastPunch);
1175
					boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
1175
					boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
1176
					if (!hoursCompleted) {
1176
					if (!hoursCompleted) {
1177
						body = String.format(
1177
						body = String.format(
1178
								"Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team",
1178
								"Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day.\n\nRegards\nHR Team",
1179
								authUser.getFullName(), duration.toHours(), duration.toMinutes() - duration.toHours()*60);
1179
								authUser.getFullName(), duration.toHours(), duration.toMinutes() - duration.toHours()*60);
1180
					}
1180
					}
1181
				}
1181
				}
1182
 
1182
 
1183
			}
1183
			}