feat: update totals for wages and expenses on reset
This commit is contained in:
@@ -1532,6 +1532,9 @@ document.getElementById("reportForm").addEventListener("submit", async (e) => {
|
||||
document.getElementById("expensesContainer").innerHTML = "";
|
||||
addExpenseRow();
|
||||
|
||||
document.getElementById("totalWages").textContent = "0.00";
|
||||
document.getElementById("totalExpensesInternal").textContent = "0.00";
|
||||
|
||||
showNotification(
|
||||
wasEdit ? "Отчет успешно отредактирован!" : "Отчет успешно создан!"
|
||||
);
|
||||
@@ -1546,11 +1549,18 @@ document.getElementById("reportForm").addEventListener("submit", async (e) => {
|
||||
});
|
||||
|
||||
//helper for USER UI
|
||||
// function refreshTodaysReports() {
|
||||
// const today = new Date().toISOString().split("T")[0];
|
||||
// appState.todaysReports = (appState.reportsList || []).filter(
|
||||
// (r) => (r.reportDate || r.date) === today
|
||||
// );
|
||||
// }
|
||||
|
||||
function refreshTodaysReports() {
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
appState.todaysReports = (appState.reportsList || []).filter(
|
||||
(r) => (r.reportDate || r.date) === today
|
||||
);
|
||||
appState.todaysReports = (appState.reportsList || [])
|
||||
.filter((r) => (r.reportDate || r.date) === today)
|
||||
.map((r) => ({ ...r, storeId: String(r.storeId) }));
|
||||
}
|
||||
|
||||
// Отчет за сегодня для пользователя
|
||||
@@ -1560,7 +1570,16 @@ document.getElementById("todayReportBtn").addEventListener("click", () => {
|
||||
showNotification("Пожалуйста, выберите магазин!", "error");
|
||||
return;
|
||||
}
|
||||
const report = (appState.todaysReports || []).find(
|
||||
|
||||
// Debug logs
|
||||
console.log("storeId:", storeId, typeof storeId);
|
||||
console.log("todaysReports:", appState.todaysReports);
|
||||
appState.reportsList.forEach((r) =>
|
||||
console.log("r.storeId", r.storeId, typeof r.storeId)
|
||||
);
|
||||
// The find
|
||||
|
||||
const report = (appState.reportsList || []).find(
|
||||
(r) => String(r.storeId) === String(storeId)
|
||||
);
|
||||
if (report) {
|
||||
|
||||
Reference in New Issue
Block a user