-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
79 lines (71 loc) · 1.91 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Define server logic
function(input, output, session) {
observe({
iv <- InputValidator$new()
iv$add_rule("income", sv_between(0, Inf))
iv$add_rule("cit", sv_between(0, max_cit(input$income)))
iv$add_rule("ssf", sv_between(0, max_ssf(input$cit)))
iv$add_rule("life", sv_between(0, max_life(input$year)))
iv$add_rule("medical", sv_between(0, 20000))
iv$add_rule("mexpense", sv_between(0, 5000))
iv$enable()
})
observeEvent(input$submit, {
data_in <- reactive({
req(input$income != 0)
income_tax(
input$disab,
input$sex,
input$mstatus,
input$flancer,
input$income,
input$year,
input$cit,
input$ssf,
input$life,
input$medical,
input$mexpense
)
})
data_in2 <- reactive({
req(input$income != 0)
total_taxable(
input$disab,
input$income,
input$year,
input$cit,
input$ssf,
input$life,
input$medical
)
})
output$table2 <- renderDataTable({
req(c(nrow(data_in2()) != 0, input$submit))
datatable(data_in2() ,
colnames = "Calculation Details",
# filter = "top",
extensions = c("Scroller", "Responsive"),
options = list(
dom = "t",
deferRender = TRUE,
scrollY = 150,
scroller = TRUE
), rownames = FALSE
) |> formatRound("val", digits=0)
})
output$table <- renderDataTable({
req(c(nrow(data_in()) != 0, input$submit))
datatable(data_in() ,
colnames = c("Taxable Income", "Rates (%)", "Tax Liability"),
# filter = "top",
extensions = c("Scroller", "Responsive"),
options = list(
dom = "t",
deferRender = TRUE,
scrollY = 300,
scroller = TRUE
), rownames = FALSE
) |> formatRound("tax_liability", digits=0)
})
})
}