Files
2026-04-28 10:23:20 +02:00

29 lines
1.0 KiB
R
Executable File

# R/read_functions.R — Hilfsfunktion
# R/read_functions.R — read_hibiscus bereinigen
read_hibiscus <- function(conn) {
tbl(conn, "hibiscus_transactions") %>%
select(id, konto_id, empfaenger_name, empfaenger_konto,
betrag, zweck, datum, valuta, saldo) %>%
left_join(
tbl(conn, "postings") %>%
select(id, bank_transaction_id, entry_id) %>%
rename(posting_id = id),
by = c("id" = "bank_transaction_id")
) %>%
collect() %>%
mutate(
datum = as.Date(datum), # einfach as.Date reicht da Text "2023-12-25"
valuta = as.Date(valuta),
gebucht = !is.na(posting_id)
) %>%
filter(datum >= "2026-01-01")
}
# R/read_functions.R — Kontakt aus bank_connections auflösen
resolve_contact <- function(conn, empfaenger_name, empfaenger_konto) {
bc <- tbl(conn, "bank_connections") %>%
filter(iban == empfaenger_konto | remote_name == empfaenger_name) %>%
select(contact_id) %>%
collect()
if (nrow(bc) > 0) bc$contact_id[1] else NA_integer_
}