diff --git a/.env.example b/.env.example index 7504d41..76a4063 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,7 @@ APP_NAME=swis-api APP_ROOT=/opt/${APP_NAME} -APP_VERSION=5.11.6 +APP_VERSION=5.11.7 # diff --git a/main.go b/main.go index 11c0718..4b668a8 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ // @title swis-api (swapi) v5 -// @version 5.11.6 +// @version 5.11.7 // @description sakalWeb Information System v5 RESTful API documentation // @termsOfService http://swagger.io/terms/ diff --git a/pkg/finance/controllers.go b/pkg/finance/controllers.go index b4c783c..1983ed5 100644 --- a/pkg/finance/controllers.go +++ b/pkg/finance/controllers.go @@ -342,8 +342,17 @@ func DoTaxesByOwner(ctx *gin.Context) { } } } - - tax.Base += tax.IncomeTotal - tax.ExpenseTotal + + // define the tax constants + const incTaxRate = 0.15 + const expRate60 = 0.60 + + // calculate the base for the income tax + tax.Base = tax.IncomeTotal - tax.ExpenseTotal + + // calculate two estimations of the income tax + tax.IncomeTaxEstAbs = tax.Base * (1 - incTaxRate) + tax.IncomeTaxEst60 = (tax.IncomeTotal * (1 - expRate60) * (1 - incTaxRate)) ctx.IndentedJSON(http.StatusOK, gin.H{ "code": http.StatusOK, diff --git a/pkg/finance/models.go b/pkg/finance/models.go index d87c376..b854f3c 100644 --- a/pkg/finance/models.go +++ b/pkg/finance/models.go @@ -73,4 +73,10 @@ type Tax struct { // Difference between incomes and expenses. Base for income tax. Base float64 `json:"base_sum"` + + // Absolute estimation of the income tax per year, from given totals. + IncomeTaxEstAbs float64 `json:"income_tax_estimation_abs"` + + // Weighted estimation of the income tax, where 60% of income are meant as expenses. + IncomeTaxEst60 float64 `json:"income_tax_estimation_60"` }