-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTaxModelLauncher.R
More file actions
205 lines (187 loc) · 8.05 KB
/
TaxModelLauncher.R
File metadata and controls
205 lines (187 loc) · 8.05 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
library(shiny)
library(shinydashboard)
library(shinyjs)
library(shinyWidgets)
library(DT)
library(fontawesome)
library(flexdashboard)
ui <- dashboardPage(
dashboardHeader(
titleWidth = "100%", # Make the header span the entire width
title = tags$div(
style = "width: 100%; display: flex; align-items: center; justify-content: space-between;",
# Left side: your image
uiOutput("headerImage"),
# Right side: your text
tags$span(
"Tax-Policy-Simulator",
style = "white-space: nowrap; font-size: 18px; margin-right: 20px;"
)
)
),
dashboardSidebar(
sidebarMenu(
menuItem("About Model", tabName = "aboutModel", icon = icon("info")),
menuItem("Direct Taxes", icon = icon("file-invoice"),
menuSubItem("PIT Module", tabName = "pitModule", icon = icon("chart-pie")),
menuSubItem("CIT Module", tabName = "citModule", icon = icon("industry"))
),
menuItem("Indirect Taxes", icon = icon("shopping-cart"),
menuSubItem("Import Taxes Module", tabName = "customsModule", icon = icon("truck")),
menuSubItem("VAT Module", tabName = "vatModule", icon = icon("cash-register"))
)
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "aboutModel",
h3("About the Model"),
#p("This is a centralized interface for managing and activating different tax modeling modules."),
p("This model was developed by",
a("Rajiv Kumar Senior Economist, EFMTX", href = "https://people.worldbank.org/people/profile/000395723", target = "_blank"),
" and ",
a("Jordan Simonov Consultant, EFMTX", href = "https://www.linkedin.com/in/jordan-s-b274a96/", target = "_blank"),
"in the R programming environment."),
br()
),
tabItem(
tabName = "pitModule",
h3("PIT Module"),
p("The PIT Module enables the simulation, analysis of personal income tax policies and estimation of tax expenditures"),
br(),
actionButton("activatePIT", "Activate PIT Module", icon = icon("play"), class = "btn-primary", style = "float: right;")
),
tabItem(
tabName = "citModule",
h3("CIT Module"),
p("The CIT Module enables the simulation,analysis of corporate income tax policies and estimation of tax expenditures"),
br(),
actionButton("activateCIT", "Activate CIT Module", icon = icon("play"), class = "btn-primary", style = "float: right;")
),
tabItem(
tabName = "vatModule",
h3("VAT Module"),
p("The VAT Module provides simulations, analysis for value-added tax policies and estimation of tax expenditures"),
br(),
actionButton("activateVAT", "Activate VAT Module", icon = icon("play"), class = "btn-primary", style = "float: right;")
),
tabItem(
tabName = "customsModule",
h3("Import Tax Module"),
p("The Import Tax Module provides simulations,analysis for customs policies and estimation of tax expenditures."),
br(),
actionButton("activateCustoms", "Activate Customs Module", icon = icon("play"), class = "btn-primary", style = "float: right;")
),
tabItem(
tabName = "exciseModule",
h3("Excise Module"),
p("The Excise Module provides simulations and analysis for excise tax policies."),
br(),
actionButton("activateExcise", "Activate Excise Module", icon = icon("play"), class = "btn-primary", style = "float: right;")
),
tabItem(
tabName = "shortTerm",
h3("Short-Term Forecasting"),
p("This module uses different statistical models which can be used for modeling time series. Exponential smoothing (ETS) and autoregressive integrated moving average (ARIMA) (Hyndman & Athanasopoulos, 2016) are considered two of the most frequently used models in time series forecasting that allow for a complementary approach to the problem.
The ETS forecasting model starts from the assumption that a certain regularity in the change of observations and their random fluctuations is present in the series, whereby the alignment method gives rise to the so-called 'smoothed series', showing the basic tendency of the time series that is further used for modeling.
The predictions of ARIMA forecasting models assume that future circumstances in the time series will be similar to past circumstances. Due to this feature, these models are widely used when modeling a great number of economic series that entail periodic variations.
"),
br(),
actionButton("activateShortTerm", "Activate Short-Term Forecast Module", icon = icon("play"), class = "btn-primary", style = "float: right;")
),
tabItem(
tabName = "mediumTerm",
h3("Medium-Term Forecast"),
p("This section provides tools and analysis for medium-term economic forecasting.")
),
tabItem(
tabName = "revMon",
h3("Revenue Monitoring"),
p("This section provides tools and analysis for monitoring revenue performance."),
br(),
actionButton("activateRevenueMonitoring", "Activate Revenue Monitoring", icon = icon("play"), class = "btn-primary", style = "float: right;")
)
)
)
)
server <- function(input, output, session) {
output$headerImage <- renderUI({
img_data <- base64enc::dataURI(file = "Modules/img/WB_pic.png", mime = "image/png")
tags$img(src = img_data, height = "40px", style = "float:left; margin-right:20px;")
})
run_shiny_app <- function(script_name, port = NULL) {
if (file.exists(script_name)) {
print(paste("Launching Shiny app:", script_name))
port <- if (is.null(port)) sample(8000:9000, 1) else port
command <- sprintf(
"R -e \"shiny::runApp('%s', port = %d, launch.browser = TRUE)\"",
script_name, port
)
system(command, wait = FALSE, intern = FALSE)
} else {
showModal(modalDialog(
title = "Error",
paste("Script not found:", script_name),
easyClose = TRUE
))
}
}
observeEvent(input$activatePIT, {
showModal(modalDialog(
title = "Activating PIT Module",
"The PIT Module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/PIT-Module.R")
})
observeEvent(input$activateCIT, {
showModal(modalDialog(
title = "Activating CIT Module",
"The CIT Module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/CIT-Module.R")
})
observeEvent(input$activateVAT, {
showModal(modalDialog(
title = "Activating VAT Module",
"The VAT Module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/VAT-Module.R")
})
observeEvent(input$activateCustoms, {
showModal(modalDialog(
title = "Activating Customs Module",
"The Customs Module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/Customs-Module.R")
})
observeEvent(input$activateExcise, {
showModal(modalDialog(
title = "Activating Excise Module",
"The Excise Module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/Excise-Module.R")
})
observeEvent(input$activateShortTerm, {
showModal(modalDialog(
title = "Activate Short-Term Forecast Module",
"The Short-Term Forecast Module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/ShortTermForecast-Module.R")
})
observeEvent(input$activateRevenueMonitoring, {
showModal(modalDialog(
title = "Activating Revenue Monitoring",
"The Revenue Monitoring module is now being activated in a new browser tab. Please wait...",
easyClose = TRUE
))
run_shiny_app("Modules/Revenue-Monitoring.R")
})
}
shinyApp(ui = ui, server = server)