当前位置:网站首页>Golang implements a five insurance and one gold calculator with web interface
Golang implements a five insurance and one gold calculator with web interface
2022-04-23 12:56:00 【Play ha ha 527】
Run code , Browser input link localhost:8090/page
package main
import (
"fmt"
"log"
"net/http"
"strconv"
)
// Write this data to the client , So that the client can fill in the text and submit
var indexHTML = `<html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title> test </title> </head> <body> <form action="/page" method="post"> Basic monthly wage :<br> <input name="monthpay" type="text"><br> Personal endowment insurance tax rate :<input name="EN" type="text"> Enterprise endowment insurance tax rate :<input name="EEN" type="text"><br> Personal medical insurance tax rate :<input name="ME" type="text"> Enterprise medical insurance tax rate :<input name="EME" type="text"><br> Personal injury insurance tax rate :<input name="EM" type="text"> Enterprise industrial injury insurance tax rate :<input name="EEM" type="text"><br> Personal maternity insurance tax rate :<input name="MA" type="text"> Enterprise maternity insurance tax rate :<input name="EMA" type="text"><br> Personal unemployment insurance tax rate :<input name="UN" type="text"> Enterprise unemployment insurance tax rate :<input name="EUN" type="text"><br> Personal provident fund tax rate : <input name="AF" type="text"> Enterprise provident fund tax rate : <input name="AF" type="text"><br> <input type="submit" value=" Submit "> </form> </body> </html>`
// Used to redirect the page to the home page
var redirectHTML = `<html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <meta http-equiv="Refresh" content="0; url={
{.}}"> </head> <body></body> </html>`
// Process home page requests
func index(w http.ResponseWriter, r *http.Request) {
// Write the prepared page to the client
fmt.Fprintf(w, indexHTML)
}
// Process the data submitted by the client
func page(w http.ResponseWriter, r *http.Request) {
// Basic monthly wage
var monthpay float64
// Monthly number
var monthnum float64 = 12
// endowment insurance
//var EN float64
var ratio_EN, Eratio_EN float64
// Medical insurance
//var ME float64
var ratio_ME, Eratio_ME float64
// unemployment insurance
//var UN float64
var ratio_UN, Eratio_UN float64
// employment injury insurance
//var EM float64
var ratio_EM, Eratio_EM float64
// maternity insurance
//var MA float64
var ratio_MA, Eratio_MA float64
// Accumulation fund
//var AF float64
var ratio_AF, Eratio_AF float64
//per Individual income tax pertax Personal income tax rate ,su Quick deduction calculation number
var per,pertax,su float64
// We stipulate that we must pass POST Submit data
if r.Method == "POST" {
// Parse the information requested by the client
if err := r.ParseForm(); err != nil {
log.Println(err)
}
// Get the content entered by the client
ENS := r.Form.Get("EN")
EMS := r.Form.Get("EM")
UNS := r.Form.Get("UN")
MAS := r.Form.Get("MA")
AFS := r.Form.Get("AF")
MES := r.Form.Get("ME")
monthpayS := r.Form.Get("monthpay")
EENS := r.Form.Get("EEN")
EEMS := r.Form.Get("EEM")
EUNS := r.Form.Get("EUN")
EMAS := r.Form.Get("EMA")
EAFS := r.Form.Get("EAF")
EMES := r.Form.Get("EME")
//userText := r.Form.Get("usertext")
ratio_EN, _ = strconv.ParseFloat(ENS, 64)
ratio_EM, _ = strconv.ParseFloat(EMS, 64)
ratio_UN, _ = strconv.ParseFloat(UNS, 64)
ratio_MA, _ = strconv.ParseFloat(MAS, 64)
ratio_AF, _ = strconv.ParseFloat(AFS, 64)
ratio_ME, _ = strconv.ParseFloat(MES, 64)
monthpay, _ = strconv.ParseFloat(monthpayS, 64)
Eratio_EN, _ = strconv.ParseFloat(EENS, 64)
Eratio_EM, _ = strconv.ParseFloat(EEMS, 64)
Eratio_UN, _ = strconv.ParseFloat(EUNS, 64)
Eratio_MA, _ = strconv.ParseFloat(EMAS, 64)
Eratio_AF, _ = strconv.ParseFloat(EAFS, 64)
Eratio_ME, _ = strconv.ParseFloat(EMES, 64)
switch{
case monthpay<=5000:pertax=0;su=0
case monthpay>5000&&monthpay<=8000:pertax=0.03;su=0
case monthpay>8000&&monthpay<=17000:pertax=0.1;su=210
case monthpay>17000&&monthpay<=30000:pertax=0.2;su=1410
case monthpay>30000&&monthpay<=40000:pertax=0.25;su=2660
case monthpay>40000&&monthpay<=60000:pertax=0.3;su=4410
case monthpay>60000&&monthpay<=85000:pertax=0.35;su=7160
case monthpay>85000:pertax=0.45;su=15160
}
per=(monthpay-5000)*pertax-su
// Annual basic wage
YearBasePay := yearbasepay(monthpay, monthnum)
fmt.Println(YearBasePay)
// After pension tax
After_tax_endowment := tax_endowment(monthpay, ratio_EN/100)
tax_Eendowment := tax_endowment(monthpay, Eratio_EN/100)
// Birth tax
After_tax_maternity := tax_maternity(monthpay, ratio_MA/100)
tax_Ematernity := tax_maternity(monthpay, Eratio_MA/100)
// After unemployment tax
After_tax_unemployment := tax_unemployment(monthpay, ratio_UN/100)
tax_Eunemployment := tax_unemployment(monthpay, Eratio_UN/100)
// After medical tax
After_tax_medical := tax_medical(monthpay, ratio_ME/100)
tax_Emedical := tax_medical(monthpay, Eratio_ME/100)
// After work-related injury tax
After_tax_employment_injury := tax_employment_injury(monthpay, ratio_EM/100)
tax_Eemployment_injury := tax_employment_injury(monthpay, Eratio_EM/100)
// Provident fund after tax
After_tax_accumulation_fund := tax_accumulation_fund(monthpay, ratio_AF/100)
tax_Eaccumulation_fund := tax_accumulation_fund(monthpay, Eratio_AF/100)
// After tax
After_taxmonth := After_tax_month(monthpay, After_tax_accumulation_fund, After_tax_endowment, After_tax_maternity, After_tax_unemployment, After_tax_medical, After_tax_employment_injury,per)
//After_tax_year:=YearBasePay-(After_tax_accumulation_fund+After_tax_endowment+After_tax_maternity+After_tax_unemployment+After_tax_medical+After_tax_employment_injury)
E_tax:=Etax(tax_Eaccumulation_fund, tax_Eendowment, tax_Ematernity, tax_Eunemployment, tax_Emedical, tax_Eemployment_injury)
fmt.Println(After_taxmonth)
// Feed back the content to the client
fmt.Fprintf(w, " Basic monthly wage %f, What you input is :%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f, Monthly after tax salary :%f, The amount paid by the enterprise :%f",
monthpay, ratio_EN, Eratio_EN, ratio_ME, Eratio_ME, ratio_EM, Eratio_EM, ratio_MA, Eratio_MA, ratio_UN, Eratio_UN, ratio_AF, Eratio_AF, After_taxmonth,E_tax)
} else {
// If not through POST Data submitted , Redirect the page to the home page
fmt.Fprintf(w, redirectHTML)
}
}
func main() {
//ROUND(MAX((Q5-5000)*{0.03;0.1;0.2;0.25;0.3;0.35;0.45}-{0;210;1410;2660;4410;7160;15160},0),2)
http.HandleFunc("/", index) // Set the route to access
http.HandleFunc("/page", page) // Set the route to access
err := http.ListenAndServe(":8090", nil) // Set the listening port
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
func yearbasepay(monthbasepay float64, monthnum float64) float64 {
YaerBasepay := monthbasepay * monthnum
return YaerBasepay
}
func tax_endowment(monthpay, ratio_endowment_insurance float64) float64 {
res := monthpay * ratio_endowment_insurance
return res
}
func tax_medical(monthpay, ratio_medical_insurance float64) float64 {
res := monthpay * ratio_medical_insurance
return res
}
func tax_unemployment(monthpay, ratio_unemployment_insurance float64) float64 {
res := monthpay * ratio_unemployment_insurance
return res
}
func tax_maternity(monthpay, ratio_maternity_insurance float64) float64 {
res := monthpay * ratio_maternity_insurance
return res
}
func tax_accumulation_fund(monthpay, ratio_accumulation_fund float64) float64 {
res := monthpay * ratio_accumulation_fund
return res
}
func tax_employment_injury(monthpay, ratio_employment_injury float64) float64 {
res := monthpay * ratio_employment_injury
return res
}
func After_tax_month(monthpay, tax_accumulation_fund, tax_endowment, tax_maternity, tax_unemployment, tax_medical, tax_employment_injury,per float64) float64 {
res := monthpay - (tax_accumulation_fund + tax_endowment + tax_maternity + tax_unemployment + tax_medical + tax_employment_injury)-per
return res
}
func Etax(tax_Eaccumulation_fund, tax_Eendowment, tax_Ematernity, tax_Eunemployment, tax_Emedical, tax_Eemployment_injury float64) float64 {
res := tax_Eaccumulation_fund + tax_Eendowment + tax_Ematernity + tax_Eunemployment + tax_Emedical + tax_Eemployment_injury
return res
}
版权声明
本文为[Play ha ha 527]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230615231181.html
边栏推荐
- Softbank vision fund entered the Web3 security industry and led a new round of investment of US $60 million in certik
- 软件测试周刊(第68期):解决棘手问题的最上乘方法是:静观其变,顺水推舟。
- SSL certificate refund instructions
- Zero trust in network information security
- RT-thread中关键词解释及部分API
- V-model binding value in El select, data echo only displays value, not label
- 21 days learning mongodb notes
- Huawei cloud MVP email
- Sort out several uses of network IP agent
- If you were a golang interviewer, what questions would you ask?
猜你喜欢
[csnote] ER diagram
leetcode:437. Path sum III [DFS selected or not selected?]
SSM framework series - data source configuration day2-1
Introduction to metalama 4 Use fabric to manipulate items or namespaces
解锁OpenHarmony技术日!年度盛会,即将揭幕!
Homomorphic encryption technology learning
实现一个盒子在父盒子中水平垂直居中的几种“姿势”
MySQL supports IP access
Remote access to raspberry pie at home (Part 1)
数据库中的日期时间类型
随机推荐
unity常见的问题(一)
MySQL supports IP access
风尚云网学习-h5的input:type属性的image属性
洛谷P3236 [HNOI2014]画框 题解
mysql中 innoDB执行过程分析
leetcode:437. Path sum III [DFS selected or not selected?]
4. DRF permission & access frequency & filtering & sorting
SSM framework series - annotation development day2-2
Buuctf Web [gxyctf2019] no dolls
航芯技术分享 | ACM32 MCU安全特性概述
CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer
SSM framework series - data source configuration day2-1
Stm32cubeprogrammer basic instructions
C#,二维贝塞尔拟合曲线(Bézier Curve)参数点的计算代码
拥抱机器视觉新蓝海,冀为好望开启数字经济发展新“冀”遇
Keyword interpretation and some APIs in RT thread
The continuous construction of the Internet industry platform is not only able to collect traffic
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
If you were a golang interviewer, what questions would you ask?
如何实现点击一下物体播放一次动画