Compare commits
5 Commits
089a930488
...
0bbb656d22
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bbb656d22 | |||
| 1f0b9eb214 | |||
| 23e3c3d4fb | |||
| a0e2fb986d | |||
| db63fecded |
@@ -1,5 +1,5 @@
|
|||||||
f_reactable <- function(daten, coldefs = NULL, selection = "single",
|
f_reactable <- function(daten, coldefs = NULL, selection = "single",
|
||||||
defaultSelected = NULL, hoehe = NULL, highlight_valuta = NULL) {
|
defaultSelected = NULL, hoehe = NULL, highlight_valuta = NULL, filterable = T) {
|
||||||
reactable(
|
reactable(
|
||||||
daten,
|
daten,
|
||||||
selection = selection,
|
selection = selection,
|
||||||
@@ -7,7 +7,8 @@ f_reactable <- function(daten, coldefs = NULL, selection = "single",
|
|||||||
pagination = F,
|
pagination = F,
|
||||||
defaultPageSize = 17,
|
defaultPageSize = 17,
|
||||||
showPageSizeOptions = TRUE,
|
showPageSizeOptions = TRUE,
|
||||||
filterable = TRUE,
|
defaultSorted = list(valuta = "desc"),
|
||||||
|
filterable = filterable,
|
||||||
highlight = TRUE,
|
highlight = TRUE,
|
||||||
height = hoehe, # <--- FIXIERT DEN HEADER und macht den Body scrollbar
|
height = hoehe, # <--- FIXIERT DEN HEADER und macht den Body scrollbar
|
||||||
bordered = TRUE,
|
bordered = TRUE,
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ accountsServer <- function(id, conn, r_global) {
|
|||||||
# ── Gewähltes Konto ────────────────────────────────────────────────────────
|
# ── Gewähltes Konto ────────────────────────────────────────────────────────
|
||||||
selected_name <- reactive({
|
selected_name <- reactive({
|
||||||
sel <- get_selected(input$account_tree, format = "names")
|
sel <- get_selected(input$account_tree, format = "names")
|
||||||
cat("raw selected:", paste(sel, collapse=", "), "\n")
|
|
||||||
if (length(sel) == 0) return(NULL)
|
if (length(sel) == 0) return(NULL)
|
||||||
name <- sub(" \\(\\d+\\)$", "", sel[[1]])
|
name <- sub(" \\(\\d+\\)$", "", sel[[1]])
|
||||||
cat("cleaned name:", name, "\n")
|
cat("cleaned name:", name, "\n")
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ contactsUI <- function(id) {
|
|||||||
),
|
),
|
||||||
fluidRow(
|
fluidRow(
|
||||||
column(4, actionBttn(ns("add"), "Neu", size = "sm", style = "material-flat", color = "warning", icon = icon("plus"), block = T)),
|
column(4, actionBttn(ns("add"), "Neu", size = "sm", style = "material-flat", color = "warning", icon = icon("plus"), block = T)),
|
||||||
column(4, actionBttn(ns("del"), "Löschen", size = "sm", style = "material-flat", color = "danger", icon = icon("thrash"), block = T)),
|
column(4, actionBttn(ns("del"), "Löschen", size = "sm", style = "material-flat", color = "danger", icon = icon("trash"), block = T)),
|
||||||
column(4, actionBttn(ns("save"), "Speichern", size = "sm", style = "material-flat", color = "success", icon = icon("floppy-disk"), block = T)),
|
column(4, actionBttn(ns("save"), "Speichern", size = "sm", style = "material-flat", color = "success", icon = icon("floppy-disk"), block = T)),
|
||||||
),
|
),
|
||||||
br(),
|
br(),
|
||||||
@@ -119,6 +119,7 @@ contactsServer <- function(id, conn, r_global) {
|
|||||||
valuta = colDef(name = "Wertstellung", minWidth = 80),
|
valuta = colDef(name = "Wertstellung", minWidth = 80),
|
||||||
account_name = colDef( name = "Konto", minWidth = 150 ),
|
account_name = colDef( name = "Konto", minWidth = 150 ),
|
||||||
projektname = colDef(name = "Projekt", minWidth = 150),
|
projektname = colDef(name = "Projekt", minWidth = 150),
|
||||||
|
|
||||||
amount = colDef(name = "Betrag", minWidth = 150)
|
amount = colDef(name = "Betrag", minWidth = 150)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ read_posting <- function(conn, id){
|
|||||||
dbxSelect(conn, paste0("SELECT * FROM postings WHERE id =", id))
|
dbxSelect(conn, paste0("SELECT * FROM postings WHERE id =", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_buch_entries <- function(conn, idwert){
|
||||||
|
dbxSelect(conn, paste0("SELECT id, entry_id, valuta, account_id, project_id, amount FROM postings WHERE entry_id=", idwert))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
coldef_entries_tabelle <-
|
coldef_entries_tabelle <-
|
||||||
list(
|
list(
|
||||||
|
|||||||
+109
-132
@@ -5,22 +5,46 @@ buchungenUI <- function(id) {
|
|||||||
tagList(
|
tagList(
|
||||||
useShinyjs(),
|
useShinyjs(),
|
||||||
h3("Hauptbuchungen"),
|
h3("Hauptbuchungen"),
|
||||||
reactableOutput(ns("buchungen_table")),
|
fluidRow(
|
||||||
hr(),
|
column(8, reactableOutput(ns("buchungen_table")),
|
||||||
h3("Details / Gegenbuchungen"),
|
hr(),
|
||||||
reactableOutput(ns("details_table")),
|
h3("Details / Gegenbuchungen"),
|
||||||
h3("Anhänge"),
|
uiOutput(ns("details_table")) ,
|
||||||
uiOutput(ns("attachments_ui")),
|
|
||||||
fileInput(ns("anhang"), NULL, multiple = TRUE,
|
|
||||||
accept = c(".pdf", ".jpg", ".png", ".xlsx", ".docx"),
|
),
|
||||||
width = "100%"),
|
|
||||||
br(),
|
column(4,
|
||||||
actionBttn(ns("add_trans"), "Transaktion hinzu", size = "sm", style = "material-flat", color = "warning"),
|
selectizeInput(ns("contact"), label = "Kontakt", choices = get_contact_choices(conn),
|
||||||
actionBttn(ns("del_trans"), "Transaktion Löschen", size = "sm", style = "material-flat", color = "danger"),
|
selected = NA, width = "100%"),
|
||||||
actionBttn(ns("add_detail"), "Detail hinzu", size = "sm", style = "material-flat", color = "success"),
|
textAreaInput(ns("note"), label = "Verwendungszweck", value = NA, width = "100%"),
|
||||||
|
h3("Dateien"),
|
||||||
|
uiOutput(ns("attachments_ui")),
|
||||||
|
fileInput(ns("anhang"), NULL, multiple = TRUE,
|
||||||
|
accept = c(".pdf", ".jpg", ".png", ".xlsx", ".docx"),
|
||||||
|
width = "100%"),
|
||||||
|
div(
|
||||||
|
style = "display: flex; flex-direction: column; gap: 10px; align-items: flex-start;",
|
||||||
|
|
||||||
|
actionBttn(ns("add_detail"), "Detail hinzu",
|
||||||
|
size = "sm", style = "material-flat", color = "default", block = TRUE),
|
||||||
|
actionBttn(ns("del_detail"), "Detail Löschen",
|
||||||
|
size = "sm", style = "material-flat", color = "danger", block = TRUE),
|
||||||
|
actionBttn(ns("add_trans"), "Transaktion hinzu",
|
||||||
|
size = "sm", style = "material-flat", color = "default", block = TRUE),
|
||||||
|
|
||||||
|
actionBttn(ns("del_trans"), "Transaktion Löschen",
|
||||||
|
size = "sm", style = "material-flat", color = "danger", block = TRUE),
|
||||||
|
actionBttn(ns("save_trans"), "Transaktion speichern",
|
||||||
|
size = "sm", style = "material-flat", color = "success", block = TRUE, icon = icon("floppy-disk")),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Das UI-Element des Moduls (auch wenn es leer ist)
|
|
||||||
postingModuleUI(ns("posting_modal"))
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,16 +54,13 @@ buchungenServer <- function(id, conn, r_global) {
|
|||||||
|
|
||||||
# ── Reactive Variablen ----
|
# ── Reactive Variablen ----
|
||||||
postings_data <- reactiveVal(read_buch_tabelle(conn))
|
postings_data <- reactiveVal(read_buch_tabelle(conn))
|
||||||
details_data <- reactiveVal(NULL)
|
sel_details <- reactiveVal(NULL)
|
||||||
selected_trans_id <- reactiveVal(NULL)
|
selected_trans_id <- reactiveVal(NULL)
|
||||||
current_main_idx <- reactiveVal(NULL)
|
reset_trigger <- reactiveVal(NULL)
|
||||||
reset_trigger <- reactiveVal(0)
|
current_main_idx <- reactiveVal(NULL)
|
||||||
modal_trigger <- reactiveVal(list(post_id = NULL, counter = 0))
|
|
||||||
highlighted_valuta <- reactiveVal(NULL)
|
|
||||||
|
|
||||||
update_db_trigger <- postingModuleServer(
|
|
||||||
"posting_modal", conn, selected_trans_id, modal_trigger
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── Filter ----
|
# ── Filter ----
|
||||||
aktiver_filter <- reactive(r_global$buchungen_filter)
|
aktiver_filter <- reactive(r_global$buchungen_filter)
|
||||||
@@ -58,35 +79,6 @@ buchungenServer <- function(id, conn, r_global) {
|
|||||||
else d
|
else d
|
||||||
})
|
})
|
||||||
|
|
||||||
observeEvent(aktiver_filter(), {
|
|
||||||
current_main_idx(NULL)
|
|
||||||
selected_trans_id(NULL)
|
|
||||||
details_data(NULL)
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── Sprung von anderem Modul ----
|
|
||||||
observeEvent(r_global$jump_to_entry_id, ignoreInit = TRUE, {
|
|
||||||
req(r_global$jump_to_entry_id)
|
|
||||||
t_id <- r_global$jump_to_entry_id
|
|
||||||
|
|
||||||
# Daten neu laden
|
|
||||||
postings_data(read_buch_tabelle(conn))
|
|
||||||
|
|
||||||
# Zeile suchen
|
|
||||||
idx <- which(gefilterte_daten()$entry_id == t_id)[1]
|
|
||||||
req(!is.na(idx))
|
|
||||||
|
|
||||||
current_main_idx(idx)
|
|
||||||
selected_trans_id(t_id)
|
|
||||||
details_data(read_buch_tabelle(conn, trans_id = t_id))
|
|
||||||
highlighted_valuta(gefilterte_daten()[idx, "valuta"])
|
|
||||||
|
|
||||||
reset_trigger(isolate(reset_trigger()) + 1)
|
|
||||||
scroll_to_row(ns("buchungen_table"), idx)
|
|
||||||
|
|
||||||
# Sprungziel zurücksetzen
|
|
||||||
r_global$jump_to_entry_id <- NULL
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── Haupttabelle rendern ----
|
# ── Haupttabelle rendern ----
|
||||||
output$buchungen_table <- renderReactable({
|
output$buchungen_table <- renderReactable({
|
||||||
@@ -96,99 +88,84 @@ buchungenServer <- function(id, conn, r_global) {
|
|||||||
coldefs = coldef_entries_tabelle,
|
coldefs = coldef_entries_tabelle,
|
||||||
selection = "single",
|
selection = "single",
|
||||||
hoehe = "60vh",
|
hoehe = "60vh",
|
||||||
defaultSelected = current_main_idx(),
|
filterable = TRUE,
|
||||||
highlight_valuta = highlighted_valuta()
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
# ── Details laden ──────────────────────────────────────────────────────────
|
sel <- reactive(getReactableState("buchungen_table", "selected"))
|
||||||
sel_details <- reactive(getReactableState("buchungen_table", "selected"))
|
observeEvent(sel(), ignoreInit = T, {
|
||||||
|
output$details_table <- renderUI({
|
||||||
|
req(sel())
|
||||||
|
# Daten laden
|
||||||
|
df <- read_buch_entries(conn, gefilterte_daten()$entry_id[sel()])
|
||||||
|
sel_details(df)
|
||||||
|
|
||||||
|
rows <- lapply(1:nrow(df), function(ind) {
|
||||||
|
fluidRow(class = "details-row",
|
||||||
|
# HIER: Index an die ID hängen!
|
||||||
|
column(1, numericInput(ns(paste0("id_", ind)), label = NULL, width = "100%", value = df$id[ind])),
|
||||||
|
column(2, dateInput(ns(paste0("valuta_", ind)), label = NULL, width = "100%", value = df$valuta[ind])),
|
||||||
|
column(3, selectizeInput(ns(paste0("account_", ind)), label = NULL,
|
||||||
|
choices = get_account_choices(conn),
|
||||||
|
selected = df$account_id[ind], width = "100%")),
|
||||||
|
column(3, selectizeInput(ns(paste0("projekt_", ind)), label = NULL,
|
||||||
|
choices = get_project_choices(conn),
|
||||||
|
selected = df$projekt_id[ind], width = "100%")),
|
||||||
|
column(2, numericInput(ns(paste0("betrag_", ind)), label = NULL, width = "100%", value = df$amount[ind]))
|
||||||
|
)
|
||||||
|
})
|
||||||
|
tagList(rows)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
observeEvent(sel_details(), ignoreInit = TRUE, {
|
observeEvent(input$save_trans, {
|
||||||
req(sel_details())
|
req(sel_details())
|
||||||
highlighted_valuta(gefilterte_daten()[sel_details(), "valuta"])
|
n_rows <- nrow(sel_details())
|
||||||
current_main_idx(sel_details())
|
|
||||||
t_id <- gefilterte_daten()[sel_details(), "entry_id"] |> pull()
|
|
||||||
selected_trans_id(t_id)
|
|
||||||
details_data(read_buch_tabelle(conn, trans_id = t_id))
|
|
||||||
})
|
|
||||||
|
|
||||||
output$details_table <- renderReactable({
|
|
||||||
req(details_data())
|
|
||||||
f_reactable(
|
|
||||||
details_data(),
|
|
||||||
coldefs = coldef_entries_tabelle,
|
|
||||||
selection = "single",
|
|
||||||
hoehe = NULL
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── Detail hinzufügen ----
|
|
||||||
observeEvent(input$add_detail, {
|
|
||||||
req(selected_trans_id())
|
|
||||||
modal_trigger(list(post_id = NULL, counter = modal_trigger()$counter + 1))
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── Detail editieren ----
|
|
||||||
sel_detail <- reactive(getReactableState("details_table", "selected"))
|
|
||||||
|
|
||||||
observeEvent(sel_detail(), ignoreInit = TRUE, {
|
|
||||||
p_id <- details_data()$id[sel_detail()]
|
|
||||||
modal_trigger(list(post_id = p_id, counter = modal_trigger()$counter + 1))
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── DB-Update durch Modal ----
|
|
||||||
observeEvent(update_db_trigger(), ignoreInit = TRUE, {
|
|
||||||
req(selected_trans_id())
|
|
||||||
details_data(read_buch_tabelle(conn, trans_id = selected_trans_id()))
|
|
||||||
postings_data(read_buch_tabelle(conn))
|
|
||||||
updateReactable("buchungen_table", data = gefilterte_daten())
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── Neue Transaktion ----
|
|
||||||
observeEvent(input$add_trans, {
|
|
||||||
new_t_id <- max_id(conn, "entries") + 1
|
|
||||||
dbxInsert(conn, "entries", data.frame(id = new_t_id))
|
|
||||||
p_id1 <- max_id(conn, "postings") + 1
|
|
||||||
p_id2 <- p_id1 + 1
|
|
||||||
dbxInsert(conn, "postings", data.frame(
|
|
||||||
id = c(p_id1, p_id2),
|
|
||||||
entry_id = c(new_t_id, new_t_id),
|
|
||||||
amount = c(0, 0),
|
|
||||||
account_id = c(0, 0),
|
|
||||||
valuta = c(Sys.Date(), Sys.Date())
|
|
||||||
))
|
|
||||||
|
|
||||||
# Filter zurücksetzen damit neue Transaktion sichtbar ist
|
# Alle Zeilen in einer Liste sammeln
|
||||||
r_global$buchungen_filter <- "alle"
|
all_records <- lapply(1:n_rows, function(ind) {
|
||||||
|
data.frame(
|
||||||
|
id = as.integer(input[[paste0("id_", ind)]]),
|
||||||
|
valuta = as.Date(input[[paste0("valuta_", ind)]]),
|
||||||
|
amount = as.numeric(input[[paste0("betrag_", ind)]]),
|
||||||
|
account_id = input[[paste0("account_", ind)]],
|
||||||
|
projekt_id = input[[paste0("projekt_", ind)]],
|
||||||
|
stringsAsFactors = FALSE
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
postings_data(read_buch_tabelle(conn))
|
# Zu einem großen Dataframe zusammenfügen
|
||||||
selected_trans_id(new_t_id)
|
final_df <- do.call(rbind, all_records)
|
||||||
details_data(read_buch_tabelle(conn, trans_id = new_t_id))
|
browser()
|
||||||
|
|
||||||
neue_zeile <- which(postings_data()$id == p_id1)
|
# Datenbank-Update-Logik
|
||||||
current_main_idx(neue_zeile)
|
tryCatch({
|
||||||
reset_trigger(isolate(reset_trigger()) + 1)
|
# Beispiel: Für jede Zeile ein Update ausführen
|
||||||
scroll_to_row(ns("buchungen_table"), neue_zeile)
|
for(i in 1:nrow(final_df)) {
|
||||||
|
update_buchung_detail(conn, final_df[i, ]) # Deine DB-Funktion
|
||||||
|
}
|
||||||
|
|
||||||
|
showNotification("Daten erfolgreich gespeichert", type = "message")
|
||||||
|
|
||||||
|
# Optional: Haupttabelle aktualisieren, falls sich Summen geändert haben
|
||||||
|
# trigger_refresh(trigger_refresh() + 1)
|
||||||
|
|
||||||
|
}, error = function(e) {
|
||||||
|
showNotification(paste("Fehler beim Speichern:", e$message), type = "error")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
# ── Transaktion löschen ----
|
|
||||||
observeEvent(input$del_trans, ignoreInit = TRUE, {
|
|
||||||
req(selected_trans_id())
|
|
||||||
dbxDelete(conn, "postings", where = data.frame(entry_id = selected_trans_id()))
|
|
||||||
dbxDelete(conn, "entries", where = data.frame(id = selected_trans_id()))
|
|
||||||
postings_data(read_buch_tabelle(conn))
|
|
||||||
current_main_idx(NULL)
|
|
||||||
selected_trans_id(NULL)
|
|
||||||
details_data(NULL)
|
|
||||||
updateReactable("buchungen_table", data = gefilterte_daten())
|
|
||||||
})
|
|
||||||
|
|
||||||
# ── Anhänge ----
|
# ── Anhänge ----
|
||||||
output$attachments_ui <- renderUI({
|
output$attachments_ui <- renderUI({
|
||||||
req(selected_trans_id())
|
req(sel_details())
|
||||||
|
entry_id <-
|
||||||
|
dbxSelect(conn, paste0("SELECT entry_id FROM postings WHERE id=",
|
||||||
|
sel_details()$id[1])) %>% pull
|
||||||
att <- dbxSelect(conn, paste0(
|
att <- dbxSelect(conn, paste0(
|
||||||
"SELECT * FROM attachments WHERE entry_id = ", selected_trans_id()
|
"SELECT * FROM attachments WHERE entry_id = ", entry_id
|
||||||
))
|
))
|
||||||
if (nrow(att) == 0) return(p("Keine Anhänge vorhanden."))
|
if (nrow(att) == 0) return(p("Keine Anhänge vorhanden."))
|
||||||
|
|
||||||
@@ -198,7 +175,7 @@ buchungenServer <- function(id, conn, r_global) {
|
|||||||
|
|
||||||
observeEvent(input[[paste0("open_att_", att$id[i])]], {
|
observeEvent(input[[paste0("open_att_", att$id[i])]], {
|
||||||
showModal(modalDialog(
|
showModal(modalDialog(
|
||||||
tags$iframe(src = filename, width = "100%", height = "600px",
|
tags$iframe(src = filename, width = "100%", height = "600px",
|
||||||
style = "border:none;"),
|
style = "border:none;"),
|
||||||
title = att$original_name[i],
|
title = att$original_name[i],
|
||||||
size = "l",
|
size = "l",
|
||||||
|
|||||||
+90
-35
@@ -4,11 +4,15 @@ umsatzUI <- function(id) {
|
|||||||
useShinyjs(),
|
useShinyjs(),
|
||||||
# Sync-Button oben
|
# Sync-Button oben
|
||||||
div(
|
div(
|
||||||
style = "display: flex; justify-content: flex-end; margin-bottom: 8px;",
|
style = "display: flex; justify-content: flex-end; margin-bottom: 8px; gap: 8px;",
|
||||||
|
actionBttn(ns("deselect_all"), "Auswahl aufheben",
|
||||||
|
size = "xs", style = "minimal",
|
||||||
|
icon = icon("xmark"), color = "default"),
|
||||||
actionBttn(ns("sync"), "Sync Hibiscus",
|
actionBttn(ns("sync"), "Sync Hibiscus",
|
||||||
size = "xs", style = "minimal",
|
size = "xs", style = "minimal",
|
||||||
icon = icon("rotate"), color = "primary")
|
icon = icon("rotate"), color = "primary")
|
||||||
),
|
),
|
||||||
|
|
||||||
# Buchungspanel immer sichtbar unten
|
# Buchungspanel immer sichtbar unten
|
||||||
uiOutput(ns("buchungs_panel")),
|
uiOutput(ns("buchungs_panel")),
|
||||||
# Tabelle mit begrenzter Höhe und Scroll
|
# Tabelle mit begrenzter Höhe und Scroll
|
||||||
@@ -78,7 +82,7 @@ umsatzServer <- function(id, conn, r_global) {
|
|||||||
}"),
|
}"),
|
||||||
filterable = F,
|
filterable = F,
|
||||||
pagination = F,
|
pagination = F,
|
||||||
selection = "single",
|
selection = "multiple",
|
||||||
onClick = "select",
|
onClick = "select",
|
||||||
defaultSorted = list(valuta = "desc"),
|
defaultSorted = list(valuta = "desc"),
|
||||||
columns = list(
|
columns = list(
|
||||||
@@ -128,18 +132,46 @@ umsatzServer <- function(id, conn, r_global) {
|
|||||||
# ── Buchungs-Panel ----
|
# ── Buchungs-Panel ----
|
||||||
output$buchungs_panel <- renderUI({
|
output$buchungs_panel <- renderUI({
|
||||||
req(selected_umsatz())
|
req(selected_umsatz())
|
||||||
u <- selected_umsatz()
|
rows <- selected_umsatz()
|
||||||
|
|
||||||
if (u$gebucht) {
|
alle_gebucht <- all(rows$gebucht)
|
||||||
|
manche_gebucht <- any(rows$gebucht) && !alle_gebucht
|
||||||
|
keine_gebucht <- !any(rows$gebucht)
|
||||||
|
|
||||||
|
if (alle_gebucht && nrow(rows) == 1) {
|
||||||
|
# Einzelauswahl, bereits gebucht → Sprung-Button
|
||||||
tagList(
|
tagList(
|
||||||
h4("Bereits gebucht"),
|
h4("Bereits gebucht"),
|
||||||
actionBttn(ns("goto_buchung"),
|
actionBttn(ns("goto_buchung"),
|
||||||
paste0("→ Zur Buchung (Entry #", u$entry_id, ")"),
|
paste0("→ Zur Buchung (Entry #", rows$entry_id, ")"),
|
||||||
size = "sm", style = "minimal", color = "primary")
|
size = "sm", style = "minimal", color = "primary")
|
||||||
)
|
)
|
||||||
|
} else if (manche_gebucht) {
|
||||||
|
div(style = "color: orange;",
|
||||||
|
icon("triangle-exclamation"),
|
||||||
|
strong(paste0(sum(rows$gebucht), " von ", nrow(rows),
|
||||||
|
" Umsätzen bereits gebucht – bitte nur ungebuchte auswählen."))
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
|
# Alle ungebucht → Buchungsformular
|
||||||
|
info_text <- if (nrow(rows) > 1) {
|
||||||
|
tags$p(style = "color: steelblue; font-size: 0.9em;",
|
||||||
|
icon("info-circle"),
|
||||||
|
paste0(nrow(rows), " Umsätze ausgewählt – ",
|
||||||
|
"Konto/Projekt/Kontakt werden für alle verwendet.")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Kontakt: bei Mehrfachauswahl keinen Auto-Resolve
|
||||||
|
kontakt_selected <- if (nrow(rows) == 1) {
|
||||||
|
resolve_contact(conn, rows$empfaenger_name, rows$empfaenger_konto)
|
||||||
|
} else {
|
||||||
|
NULL
|
||||||
|
}
|
||||||
|
|
||||||
tagList(
|
tagList(
|
||||||
h4("Buchen"),
|
h4(if (nrow(rows) == 1) "Buchen" else paste0(nrow(rows), " Umsätze buchen")),
|
||||||
|
info_text,
|
||||||
fluidRow(
|
fluidRow(
|
||||||
column(4,
|
column(4,
|
||||||
selectizeInput(ns("konto"), "Konto:",
|
selectizeInput(ns("konto"), "Konto:",
|
||||||
@@ -155,11 +187,11 @@ umsatzServer <- function(id, conn, r_global) {
|
|||||||
column(3,
|
column(3,
|
||||||
selectizeInput(ns("kontakt"), "Kontakt:",
|
selectizeInput(ns("kontakt"), "Kontakt:",
|
||||||
choices = get_contact_choices(conn),
|
choices = get_contact_choices(conn),
|
||||||
selected = resolve_contact(conn, u$empfaenger_name, u$empfaenger_konto),
|
selected = kontakt_selected,
|
||||||
width = "100%")
|
width = "100%")
|
||||||
),
|
),
|
||||||
column(1,
|
column(1,
|
||||||
div(style = "margin-top: 25px;", # Label-Höhe ausgleichen
|
div(style = "margin-top: 25px;",
|
||||||
actionBttn(ns("new_contact"), "Neuer Kontakt",
|
actionBttn(ns("new_contact"), "Neuer Kontakt",
|
||||||
size = "xs", style = "minimal", icon = icon("plus"), color = "warning")
|
size = "xs", style = "minimal", icon = icon("plus"), color = "warning")
|
||||||
)
|
)
|
||||||
@@ -171,7 +203,7 @@ umsatzServer <- function(id, conn, r_global) {
|
|||||||
icon = icon("check"))
|
icon = icon("check"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -186,36 +218,55 @@ umsatzServer <- function(id, conn, r_global) {
|
|||||||
|
|
||||||
# ── Buchen ----
|
# ── Buchen ----
|
||||||
observeEvent(input$buchen, {
|
observeEvent(input$buchen, {
|
||||||
req(selected_umsatz(), input$konto)
|
req(selected_umsatz(), input$konto, input$konto != 0)
|
||||||
u <- selected_umsatz()
|
rows <- selected_umsatz()
|
||||||
|
rows <- rows %>% filter(!gebucht)
|
||||||
|
req(nrow(rows) > 0)
|
||||||
|
|
||||||
gegenkonto_id <- dbReadTable(conn, "accounts") %>%
|
bank_connections <- dbReadTable(conn, "bank_connections")
|
||||||
filter(hibiscus_account_id == u$konto_id) %>%
|
|
||||||
pull(id)
|
|
||||||
|
|
||||||
req(length(gegenkonto_id) > 0, input$konto != 0)
|
for (i in seq_len(nrow(rows))) {
|
||||||
|
u <- rows[i, ]
|
||||||
new_t_id <- max_id(conn, "entries") + 1L
|
gegenkonto_id <- dbReadTable(conn, "accounts") %>%
|
||||||
dbxInsert(conn, "entries", data.frame(
|
filter(hibiscus_account_id == u$konto_id) %>%
|
||||||
id = new_t_id,
|
pull(id)
|
||||||
contact_id = as.integer(input$kontakt),
|
if (length(gegenkonto_id) == 0) next
|
||||||
note = u$zweck
|
|
||||||
))
|
# contact_id: manuell gewählt oder aus bank_connections
|
||||||
|
contact_id <- if (!is.null(input$kontakt) && as.integer(input$kontakt) != 0) {
|
||||||
p_id1 <- max_id(conn, "postings") + 1L
|
as.integer(input$kontakt)
|
||||||
dbxInsert(conn, "postings", data.frame(
|
} else {
|
||||||
id = c(p_id1, p_id1 + 1L),
|
match <- bank_connections %>%
|
||||||
entry_id = c(new_t_id, new_t_id),
|
filter(contact_text == u$empfaenger_name) %>%
|
||||||
account_id = c(as.integer(input$konto), gegenkonto_id),
|
pull(contact_id)
|
||||||
project_id = c(as.integer(input$projekt), NA_integer_),
|
if (length(match) > 0) as.integer(match[[1]]) else NA_integer_
|
||||||
amount = c(u$betrag, -u$betrag),
|
}
|
||||||
valuta = c(as.character(u$valuta), as.character(u$valuta)),
|
|
||||||
booking_date = c(as.character(u$datum), as.character(u$datum)),
|
new_t_id <- max_id(conn, "entries") + 1L
|
||||||
bank_transaction_id = c(u$id, NA_integer_)
|
dbxInsert(conn, "entries", data.frame(
|
||||||
))
|
id = new_t_id,
|
||||||
|
contact_id = contact_id,
|
||||||
|
note = u$zweck
|
||||||
|
))
|
||||||
|
|
||||||
|
p_id1 <- max_id(conn, "postings") + 1L
|
||||||
|
dbxInsert(conn, "postings", data.frame(
|
||||||
|
id = c(p_id1, p_id1 + 1L),
|
||||||
|
entry_id = c(new_t_id, new_t_id),
|
||||||
|
account_id = c(as.integer(input$konto), gegenkonto_id),
|
||||||
|
project_id = c(as.integer(input$projekt), NA_integer_),
|
||||||
|
amount = c(u$betrag, -u$betrag),
|
||||||
|
valuta = c(as.character(u$valuta), as.character(u$valuta)),
|
||||||
|
booking_date = c(as.character(u$datum), as.character(u$datum)),
|
||||||
|
bank_transaction_id = c(u$id, NA_integer_)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
refresh(refresh() + 1)
|
refresh(refresh() + 1)
|
||||||
showNotification("✓ Gebucht", type = "message")
|
showNotification(
|
||||||
|
paste0("✓ ", nrow(rows), " Umsatz/Umsätze gebucht"),
|
||||||
|
type = "message"
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
# ── Neuer Kontakt / Bankverbindung ----
|
# ── Neuer Kontakt / Bankverbindung ----
|
||||||
@@ -277,6 +328,10 @@ umsatzServer <- function(id, conn, r_global) {
|
|||||||
showNotification(msg, type = "message")
|
showNotification(msg, type = "message")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
## ** Auswahl aufheben ----
|
||||||
|
observeEvent(input$deselect_all, {
|
||||||
|
updateReactable("umsatz_table", selected = NA, session = session)
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -55,6 +55,9 @@ dashboardPage(
|
|||||||
),
|
),
|
||||||
|
|
||||||
dashboardBody(
|
dashboardBody(
|
||||||
|
tags$head(
|
||||||
|
tags$link(rel = "stylesheet", type = "text/css", href = "main.css")
|
||||||
|
),
|
||||||
tabItems(
|
tabItems(
|
||||||
tabItem(tabName = "buchungen",
|
tabItem(tabName = "buchungen",
|
||||||
buchungenUI("buchungen_tab")
|
buchungenUI("buchungen_tab")
|
||||||
|
|||||||
@@ -9,3 +9,34 @@
|
|||||||
height: 28px !important;
|
height: 28px !important;
|
||||||
font-size: 14px !important;
|
font-size: 14px !important;
|
||||||
}
|
}
|
||||||
|
/* 1. Den Abstand des Containers verringern */
|
||||||
|
.details-row .form-group {
|
||||||
|
margin-bottom: 2px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2. Die Geister-Labels (shiny-label-null) komplett ausblenden */
|
||||||
|
.details-row .shiny-label-null {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3. Den Abstand der Zeile selbst minimieren */
|
||||||
|
.details-row {
|
||||||
|
margin-top: 0px !important;
|
||||||
|
margin-bottom: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 4. Speziell für die Selectize-Felder (die sind oft höher) */
|
||||||
|
.details-row .selectize-control {
|
||||||
|
margin-bottom: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Positioniert das Dropdown-Menü über dem Eingabefeld statt darunter */
|
||||||
|
.details-row .selectize-dropdown {
|
||||||
|
top: auto !important;
|
||||||
|
bottom: 100% !important;
|
||||||
|
margin-bottom: 2px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user