updated absensi lunch_in in API history and admin

This commit is contained in:
2025-10-21 14:18:06 +07:00
parent 9d4a310738
commit 328b3653fe
2 changed files with 8 additions and 4 deletions

View File

@@ -266,7 +266,7 @@ const history = async (req, res) => {
const result = attendances.map(a => {
let duration = null;
if (a.clock_in && a.clock_out) {
if (a.clock_in && a.clock_out && a.lunch_in) {
const diffMs = new Date(a.clock_out) - new Date(a.clock_in);
const totalMinutes = Math.floor(diffMs / 60000);
const hours = Math.floor(totalMinutes / 60);
@@ -283,6 +283,9 @@ const history = async (req, res) => {
clock_out: a.clock_out
? moment(a.clock_out).tz('Asia/Jakarta').format('YYYY-MM-DD HH:mm:ss')
: '-',
lunch_in: a.lunch_in
? moment(a.lunch_in).tz('Asia/Jakarta').format('YYYY-MM-DD HH:mm:ss')
: '-',
duration: duration || '-',
type: a.type,
};
@@ -297,7 +300,7 @@ const history = async (req, res) => {
const getAll = async (req, res) => {
try {
const today = moment().tz('Asia/Jakarta').format('YYYY-MM-DD');
const attendances = await Attedances.findAll({
@@ -308,7 +311,7 @@ const getAll = async (req, res) => {
{
model: User,
as: 'user',
attributes: ['id', 'name', 'email']
attributes: ['id', 'name', 'email']
}
],
order: [['created_at', 'DESC']]