turash/models/cost/cost.go
Damir Mukimov 4a2fda96cd
Initial commit: Repository setup with .gitignore, golangci-lint v2.6.0, and code quality checks
- Initialize git repository
- Add comprehensive .gitignore for Go projects
- Install golangci-lint v2.6.0 (latest v2) globally
- Configure .golangci.yml with appropriate linters and formatters
- Fix all formatting issues (gofmt)
- Fix all errcheck issues (unchecked errors)
- Adjust complexity threshold for validation functions
- All checks passing: build, test, vet, lint
2025-11-01 07:36:22 +01:00

43 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cost
import (
"github.com/damirmukimov/city_resource_graph/models/params"
)
// CostBreakdown represents all cost components for a given year.
type CostBreakdown struct {
Engineering float64 `json:"engineering"` // Engineering costs (EUR/year)
Infrastructure float64 `json:"infrastructure"` // Infrastructure costs (EUR/year)
MarketingSales float64 `json:"marketing_sales"` // Marketing & sales costs (EUR/year)
Operations float64 `json:"operations"` // Operations costs (EUR/year)
Total float64 `json:"total"` // Total costs (EUR/year)
}
// CalculateCosts computes all cost components for a given year.
func CalculateCosts(year int, p *params.Params) CostBreakdown {
cp := p.Costs
// Engineering costs = engineers × salary
engineers := cp.Engineers.GetYear(year)
engineering := float64(engineers) * cp.EngineerSalary
// Infrastructure costs (from params)
infrastructure := cp.Infrastructure.GetYear(year)
// Marketing & sales costs (from params)
marketingSales := cp.MarketingSales.GetYear(year)
// Operations costs (from params)
operations := cp.Operations.GetYear(year)
total := engineering + infrastructure + marketingSales + operations
return CostBreakdown{
Engineering: engineering,
Infrastructure: infrastructure,
MarketingSales: marketingSales,
Operations: operations,
Total: total,
}
}