feat: updated generatio of test data, always starting from yesterday, to leave today free to create a report and update report endpoint to send username of the worker who created report

This commit is contained in:
Angie
2025-07-26 20:51:17 +02:00
parent bd2d19a543
commit 92dcdb05d2
2 changed files with 8 additions and 6 deletions

View File

@@ -159,7 +159,7 @@ async function createTestData() {
// Создаем тестовые отчеты за последние 30 дней
const today = new Date();
for (let i = 0; i < 30; i++) {
for (let i = 1; i < 30; i++) {
const date = new Date(today);
date.setDate(date.getDate() - i);
const dateString = date.toISOString().split("T")[0];

View File

@@ -66,6 +66,7 @@ router.post(
finalCash,
],
function (err) {
console.error("DB error:", err);
if (err) return res.status(500).json({ error: "Database error" });
res.status(201).json({ id: this.lastID });
}
@@ -84,11 +85,12 @@ router.get(
],
(req, res) => {
let sql = `
SELECT reports.*, stores.name AS storeName
FROM reports
JOIN stores ON reports.storeId = stores.id
WHERE 1=1
`;
SELECT reports.*, stores.name AS storeName, users.username AS username, users.fullName AS fullName
FROM reports
JOIN stores ON reports.storeId = stores.id
JOIN users ON reports.userId = users.id
WHERE 1=1
`;
const params = [];
if (req.user.role !== "admin") {