Filter hinzugefügt

This commit is contained in:
2026-03-19 17:06:40 +01:00
parent daba64c83a
commit 70a2fe2526
7 changed files with 140 additions and 19 deletions
+12 -2
View File
@@ -1,4 +1,5 @@
f_reactable <- function(daten, coldefs = NULL, selection = "single", defaultSelected = NULL, hoehe = NULL) { f_reactable <- function(daten, coldefs = NULL, selection = "single",
defaultSelected = NULL, hoehe = NULL, highlight_valuta = NULL) {
reactable( reactable(
daten, daten,
selection = selection, selection = selection,
@@ -18,7 +19,16 @@ f_reactable <- function(daten, coldefs = NULL, selection = "single", defaultSele
# borderColor = "#dfe2e5", # borderColor = "#dfe2e5",
rowSelectedStyle = list(backgroundColor = "#98F5FF")# rowSelectedStyle = list(backgroundColor = "#98F5FF")#
), ),
rowStyle = list(cursor = "pointer"), rowStyle = function(index) {
style <- list(cursor = "pointer") # immer aktiv
if (!is.null(highlight_valuta) &&
daten$valuta[index] == highlight_valuta) {
style$background <- "#fff3cd"
}
style
},
onClick = "select", onClick = "select",
columns = coldefs columns = coldefs
) )
+27 -5
View File
@@ -19,7 +19,7 @@ buchungenUI <- function(id) {
) )
} }
buchungenServer <- function(id, conn) { buchungenServer <- function(id, conn, aktiver_filter = reactive("alle")) {
moduleServer(id, function(input, output, session) { moduleServer(id, function(input, output, session) {
ns <- session$ns ns <- session$ns
@@ -30,18 +30,39 @@ buchungenServer <- function(id, conn) {
current_main_idx <- reactiveVal(NULL) current_main_idx <- reactiveVal(NULL)
reset_trigger <- reactiveVal(0) # ← neu: erzwingt Re-render mit Filter-Reset reset_trigger <- reactiveVal(0) # ← neu: erzwingt Re-render mit Filter-Reset
modal_trigger <- reactiveVal(list(post_id = NULL, counter = 0)) 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) update_db_trigger <- postingModuleServer("posting_modal", conn, selected_trans_id, modal_trigger)
gefilterte_daten <- reactive({
d <- postings_data()
switch(aktiver_filter(),
"giro" = d |> filter(grepl("0130", account_name)),
"monat" = d |> filter(
floor_date(as.Date(valuta), "month") == floor_date(Sys.Date(), "month")
),
d
)
})
observeEvent(aktiver_filter(), {
current_main_idx(NULL)
selected_trans_id(NULL)
details_data(NULL)
})
# * Haupttabelle rendern ---- # * Haupttabelle rendern ----
output$buchungen_table <- renderReactable({ output$buchungen_table <- renderReactable({
reset_trigger() # Abhängigkeit bei Increment wird neu gerendert reset_trigger()
f_reactable( f_reactable(
daten = postings_data(), daten = gefilterte_daten(), # ← geändert
coldefs = coldef_entries_tabelle, coldefs = coldef_entries_tabelle,
selection = "single", selection = "single",
hoehe = "60vh", hoehe = "60vh",
defaultSelected = current_main_idx() defaultSelected = current_main_idx(),
highlight_valuta = highlighted_valuta()
) )
}) })
@@ -49,8 +70,9 @@ buchungenServer <- function(id, conn) {
sel_details <- reactive(getReactableState("buchungen_table", "selected")) sel_details <- reactive(getReactableState("buchungen_table", "selected"))
observeEvent(sel_details(), ignoreInit = TRUE, { observeEvent(sel_details(), ignoreInit = TRUE, {
req(sel_details()) req(sel_details())
highlighted_valuta(gefilterte_daten()[sel_details(), "valuta"])
current_main_idx(sel_details()) current_main_idx(sel_details())
t_id <- postings_data()[sel_details(), "entry_id"] |> pull() t_id <- gefilterte_daten()[sel_details(), "entry_id"] |> pull() # ← geändert
selected_trans_id(t_id) selected_trans_id(t_id)
details_data(read_buch_tabelle(conn, trans_id = t_id)) details_data(read_buch_tabelle(conn, trans_id = t_id))
}) })
+2 -1
View File
@@ -16,7 +16,8 @@ read_buch_tabelle <- function(conn, trans_id = NULL){
left_join(projects, by = c("project_id" = "id")) |> left_join(projects, by = c("project_id" = "id")) |>
select(id, valuta, account_name, projektname, display_name, amount, entry_id) |> select(id, valuta, account_name, projektname, display_name, amount, entry_id) |>
collect() %>% collect() %>%
mutate(saldo = 0) mutate(saldo = 0) %>%
arrange(valuta, entry_id)
} }
read_posting <- function(conn, id){ read_posting <- function(conn, id){
+45
View File
@@ -218,6 +218,22 @@ if (ok) {
creditorid TEXT creditorid TEXT
);") );")
# Attachments ----
exec_sql("CREATE TABLE attachments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
entry_id INTEGER,
quittung_id INTEGER,
adress_id INTEGER,
wiso_id INTEGER,
btisch_id TEXT,
original_name TEXT,
kategorie TEXT,
path TEXT NOT NULL,
note TEXT,
created_at TEXT DEFAULT (datetime('now')),
updated_at TEXT DEFAULT (datetime('now'))
);")
error_f <- fehler_add("Schema created", TRUE, error_f) error_f <- fehler_add("Schema created", TRUE, error_f)
} }
@@ -412,6 +428,35 @@ if (ok) {
dbWriteTable(con_s, "hibiscus_transactions", hib, append = TRUE) dbWriteTable(con_s, "hibiscus_transactions", hib, append = TRUE)
} }
# Transfer Attachments
## * Daten aus Attachments Tabelle übertragen ----
if(ok){
att <- dbxSelect(con_f, "SELECT id, trans_id, quittung_id, wiso_id, btisch_id,
adress_id, ft_dateiname, beschreibung, created_at, updated_at, ft_extension FROM Attachments") %>%
mutate(
id = as.integer(id),
trans_id = as.integer(trans_id),
quittung_id = as.integer(quittung_id),
wiso_id = as.integer(wiso_id),
btisch_id = as.integer(btisch_id),
adress_id = as.integer(adress_id),
created_at = as.character(created_at),
updated_at = as.character(updated_at),
path = paste0(id,".", ft_extension)
) %>%
rename(
entry_id = trans_id,
note = beschreibung,
original_name = ft_dateiname
) %>%
select(-ft_extension)
dbWriteTable(con_s, "Attachments", att, append = T)
} ## ------------------------------------------------------- 2026-03-19 16:38
# Close ---- # Close ----
dbDisconnect(con_s) dbDisconnect(con_s)
+11 -2
View File
@@ -1,5 +1,14 @@
server <- function(input, output) { server <- function(input, output) {
aktiver_filter <- reactive({
buchungenServer("buchungen_tab", conn) if (input$filter_giro > 0 &&
input$filter_giro == max(input$filter_giro, input$filter_monat, input$filter_alle))
"giro"
else if (input$filter_monat > 0 &&
input$filter_monat == max(input$filter_giro, input$filter_monat, input$filter_alle))
"monat"
else
"alle"
})
buchungenServer("buchungen_tab", conn, aktiver_filter = aktiver_filter)
} }
+27 -4
View File
@@ -3,9 +3,32 @@ dashboardPage(
dashboardHeader( ), dashboardHeader( ),
## Sidebar content ## Sidebar content
dashboardSidebar( dashboardSidebar(
sidebarMenu( sidebarMenu(id = "tabs",
menuItem("buchungen", tabName = "buchungen", icon = icon("dashboard")), menuItem("buchungen", tabName = "buchungen", icon = icon("list")),
menuItem("konten", tabName = "Konten", icon = icon("th")) menuItem("konten", tabName = "konten", icon = icon("building-columns"))
),
conditionalPanel(
condition = "input.tabs == 'buchungen'",
tags$ul(
class = "sidebar-menu",
tags$li(
class = "treeview",
tags$a(href = "#",
tags$i(class = "fa fa-filter"),
tags$span("Filter"),
tags$span(class = "pull-right-container",
tags$i(class = "fa fa-angle-left pull-right")
)
),
tags$ul(
class = "treeview-menu",
style = "padding: 5px 0;",
tags$li(actionBttn("filter_alle", "Alle", size = "xs", style = "minimal")),
tags$li(actionBttn("filter_giro", "Girokonto", size = "xs", style = "minimal")),
tags$li(actionBttn("filter_monat", "Dieser Monat", size = "xs", style = "minimal"))
)
)
)
) )
), ),
dashboardBody( dashboardBody(
@@ -14,7 +37,6 @@ dashboardPage(
tabItem(tabName = "buchungen", tabItem(tabName = "buchungen",
buchungenUI("buchungen_tab") buchungenUI("buchungen_tab")
), ),
# Second tab content # Second tab content
tabItem(tabName = "widgets", tabItem(tabName = "widgets",
h2("Widgets tab content") h2("Widgets tab content")
@@ -22,3 +44,4 @@ dashboardPage(
) )
) )
) )
+11
View File
@@ -0,0 +1,11 @@
/* Verringert den Abstand in der Filter-Zelle */
.rt-filter-group {
padding: 2px 4px !important;
}
/* Macht die Eingabefelder selbst flacher */
.rt-filter-input {
height: 28px !important;
font-size: 14px !important;
}