You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.2 KiB
87 lines
2.2 KiB
|
|
|
|
|
|
# Database details
|
|
|
|
|
|
dsn_database <- "postgres"
|
|
|
|
dsn_hostname <- "localhost"
|
|
|
|
dsn_port <- "5432"
|
|
|
|
dsn_uid <- "postgres"
|
|
|
|
dsn_pwd <- "julley09"
|
|
|
|
|
|
|
|
|
|
# Read Cost Center etc. list from data (Changes, modification needs creating the file again and redeploying the app)
|
|
|
|
cost.centers <- readRDS("./data/costcenters.RDS")
|
|
glaccounts <- readRDS("./data/glaccounts.RDS")
|
|
mont <- readRDS("./data/months.RDS")
|
|
|
|
# Email settings
|
|
|
|
# smtp <- server(
|
|
# host = "smtp.sendgrid.net",
|
|
# port = 465,
|
|
# username = "apikey",
|
|
# password = "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"
|
|
# )
|
|
|
|
|
|
# Function to get data from DB
|
|
|
|
get.db.data <- function(qry = 'SELECT * FROM calculated') {
|
|
dbGetQuery(connec,
|
|
qry)
|
|
}
|
|
|
|
# Function to aggregate monthly deviation
|
|
|
|
mon.dev <- function(dat) {
|
|
dat |>
|
|
mutate(month = ym(month)) |>
|
|
group_by(month) |>
|
|
summarise(Plan = sum(Plan), Actual = sum(Actual)) |>
|
|
mutate(devia = Actual - Plan) |>
|
|
mutate(deviation.percent = round(devia * 100 / Plan, 2))
|
|
}
|
|
|
|
# Function to aggregate last month by gl and cost
|
|
|
|
last.mon <- function(dat) {
|
|
dat |>
|
|
filter(month == max(month)) |>
|
|
mutate(cost_gl = paste0(Cost.center, "_", GL.account)) |>
|
|
group_by(cost_gl) |>
|
|
summarise(Plan = sum(Plan), Actual = sum(Actual)) |>
|
|
mutate(devia = Actual - Plan) |>
|
|
mutate(deviation.percent = round(devia * 100 / Plan, 2)) |>
|
|
arrange(desc(deviation.percent))
|
|
}
|
|
|
|
|
|
admin.menu <- sidebarMenu(
|
|
id = "m",
|
|
menuItem("Dashboard", tabName = "dashboard", icon = icon("chart-line")),
|
|
menuItem("Upload", icon = icon("upload"), tabName = "upload"),
|
|
menuItem("Approvals", icon = icon("check"), tabName = "approvals"),
|
|
menuItem("Explanations", icon = icon("file"), tabName = "explanations"),
|
|
menuItem("Admin", icon = icon("toolbox"), tabName = "admin"),
|
|
menuItem("Contact us", icon = icon("at"), href = "https://lanubia.com/contact/")
|
|
)
|
|
|
|
other.menu <- sidebarMenu(
|
|
id = "m",
|
|
menuItem(
|
|
"Dashboard",
|
|
tabName = "dashboard",
|
|
icon = icon("dashboard")
|
|
),
|
|
menuItem("Explanations", icon = icon("th"), tabName = "explanations"),
|
|
menuItem("Contact us", icon = icon("id-card"), href = "https://lanubia.com/contact/")
|
|
)
|