excel preview & file handling
This commit is contained in:
@@ -132,6 +132,32 @@ export const getMonthlyTimeEntries = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate timesheet file for a month
|
||||
* POST /api/time-tracking/month/:year/:month/generate
|
||||
*/
|
||||
export const generateMonthlyTimesheet = async (req, res) => {
|
||||
try {
|
||||
const userId = req.userId;
|
||||
const { year, month } = req.params;
|
||||
|
||||
const result = await timeTrackingService.generateMonthlyTimesheet(
|
||||
userId,
|
||||
parseInt(year),
|
||||
parseInt(month)
|
||||
);
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
data: result,
|
||||
message: 'Timesheet bol vygenerovaný',
|
||||
});
|
||||
} catch (error) {
|
||||
const errorResponse = formatErrorResponse(error, process.env.NODE_ENV === 'development');
|
||||
res.status(error.statusCode || 500).json(errorResponse);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get time entry by ID
|
||||
* GET /api/time-tracking/:entryId
|
||||
|
||||
@@ -63,6 +63,7 @@ export const uploadTimesheet = async (req, res) => {
|
||||
fileSize: file.size,
|
||||
year: parseInt(year),
|
||||
month: parseInt(month),
|
||||
isGenerated: false,
|
||||
})
|
||||
.returning();
|
||||
|
||||
@@ -76,6 +77,7 @@ export const uploadTimesheet = async (req, res) => {
|
||||
fileSize: newTimesheet.fileSize,
|
||||
year: newTimesheet.year,
|
||||
month: newTimesheet.month,
|
||||
isGenerated: newTimesheet.isGenerated,
|
||||
uploadedAt: newTimesheet.uploadedAt,
|
||||
},
|
||||
},
|
||||
@@ -122,6 +124,7 @@ export const getMyTimesheets = async (req, res) => {
|
||||
fileSize: timesheets.fileSize,
|
||||
year: timesheets.year,
|
||||
month: timesheets.month,
|
||||
isGenerated: timesheets.isGenerated,
|
||||
uploadedAt: timesheets.uploadedAt,
|
||||
})
|
||||
.from(timesheets)
|
||||
@@ -171,6 +174,7 @@ export const getAllTimesheets = async (req, res) => {
|
||||
fileSize: timesheets.fileSize,
|
||||
year: timesheets.year,
|
||||
month: timesheets.month,
|
||||
isGenerated: timesheets.isGenerated,
|
||||
uploadedAt: timesheets.uploadedAt,
|
||||
userId: timesheets.userId,
|
||||
username: users.username,
|
||||
|
||||
Reference in New Issue
Block a user