Umsatz-modul eingebaut, buchen noch nicht getestet

This commit is contained in:
2026-03-24 17:28:21 +01:00
parent 126c2fc7d7
commit 2d2eb2fa1c
10 changed files with 428 additions and 70 deletions
+25 -17
View File
@@ -1,13 +1,13 @@
# server.R
server <- function(input, output, session) {
# ── Globaler Navigations-Bus ───────────────────────────────────────────────
r_global <- reactiveValues(
# Navigation
active_tab = NULL,
nav_history = list(), # ← Stack der letzten Positionen
# Filter + Sprungziele
nav_history = list(),
buchungen_filter = "alle",
umsatz_zeige_alle = FALSE,
umsatz_refresh = 0,
jump_to_entry_id = NULL,
jump_to_account_id = NULL,
jump_to_contact_id = NULL,
@@ -17,33 +17,41 @@ server <- function(input, output, session) {
# ── Tab-Wechsel ────────────────────────────────────────────────────────────
observeEvent(r_global$active_tab, ignoreInit = TRUE, {
req(r_global$active_tab)
cat("Tab-Wechsel zu:", r_global$active_tab, "\n")
updateTabItems(session, "tabs", selected = r_global$active_tab)
r_global$active_tab <- NULL
})
# ── Back-Button ────────────────────────────────────────────────────────────
observeEvent(input$back_btn, {
req(length(r_global$nav_history) > 0)
# Letzten Zustand holen und Stack kürzen
last <- tail(r_global$nav_history, 1)[[1]]
last <- tail(r_global$nav_history, 1)[[1]]
r_global$nav_history <- head(r_global$nav_history, -1)
# Zurückspringen
updateTabItems(session, "tabs", selected = last$tab)
# Zustand wiederherstellen — je nach Tab
if (last$tab == "konten") {
r_global$jump_to_account_name <- last$account_name
}
})
# ── Filter-Buttons (falls in der Navbar oder UI definiert) ─────────────────
# ── Filter Buchungen ───────────────────────────────────────────────────────
observeEvent(input$filter_alle, { r_global$buchungen_filter <- "alle" })
observeEvent(input$filter_giro, { r_global$buchungen_filter <- "giro" })
observeEvent(input$filter_monat, { r_global$buchungen_filter <- "monat" })
# ── Filter Umsätze ─────────────────────────────────────────────────────────
observeEvent(input$umsatz_filter_ungebucht, { r_global$umsatz_zeige_alle <- FALSE })
observeEvent(input$umsatz_filter_alle, { r_global$umsatz_zeige_alle <- TRUE })
# ── Sync Hibiscus ──────────────────────────────────────────────────────────
observeEvent(input$umsatz_sync, {
showNotification("Sync läuft...", type = "message", duration = 3)
tryCatch({
source("sync_hibiscus.R", local = TRUE)
r_global$umsatz_refresh <- isolate(r_global$umsatz_refresh) + 1
showNotification("✓ Sync abgeschlossen", type = "message")
}, error = function(e) {
showNotification(paste("Fehler:", e$message), type = "error")
})
})
# ── Module ─────────────────────────────────────────────────────────────────
accountsServer("accounts_tab", conn, r_global)
accountsServer("accounts_tab", conn, r_global)
buchungenServer("buchungen_tab", conn, r_global)
umsatzServer("umsatz_tab", conn, r_global)
}