basic online
This commit is contained in:
139
internal/model/model.go
Normal file
139
internal/model/model.go
Normal file
@@ -0,0 +1,139 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type GLAccountType string
|
||||
|
||||
const (
|
||||
GLRevenue GLAccountType = "revenue"
|
||||
GLCOGS GLAccountType = "cogs"
|
||||
GLOpex GLAccountType = "opex"
|
||||
GLCapex GLAccountType = "capex"
|
||||
GLHeadcount GLAccountType = "headcount"
|
||||
)
|
||||
|
||||
type BudgetVersion string
|
||||
|
||||
const (
|
||||
VersionOriginal BudgetVersion = "original"
|
||||
VersionForecast1 BudgetVersion = "forecast_1"
|
||||
VersionForecast2 BudgetVersion = "forecast_2"
|
||||
)
|
||||
|
||||
type Department struct {
|
||||
ID int `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
CostCenter string `json:"cost_center"`
|
||||
}
|
||||
|
||||
type GLAccount struct {
|
||||
ID int `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description"`
|
||||
Type GLAccountType `json:"type"`
|
||||
FavourHigh bool `json:"favour_high"`
|
||||
}
|
||||
|
||||
type Budget struct {
|
||||
ID int `json:"id"`
|
||||
FiscalYear int `json:"fiscal_year"`
|
||||
FiscalPeriod int `json:"fiscal_period"`
|
||||
Version BudgetVersion `json:"version"`
|
||||
DepartmentID int `json:"department_id"`
|
||||
GLAccountID int `json:"gl_account_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
Currency string `json:"currency"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateBudgetRequest struct {
|
||||
FiscalYear int `json:"fiscal_year"`
|
||||
FiscalPeriod int `json:"fiscal_period"`
|
||||
Version BudgetVersion `json:"version"`
|
||||
DepartmentID int `json:"department_id"`
|
||||
GLAccountID int `json:"gl_account_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
Currency string `json:"currency"`
|
||||
Notes string `json:"notes"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
}
|
||||
|
||||
type Actual struct {
|
||||
ID int `json:"id"`
|
||||
FiscalYear int `json:"fiscal_year"`
|
||||
FiscalPeriod int `json:"fiscal_period"`
|
||||
DepartmentID int `json:"department_id"`
|
||||
GLAccountID int `json:"gl_account_id"`
|
||||
GLCode string `json:"gl_code"`
|
||||
Amount float64 `json:"amount"`
|
||||
Currency string `json:"currency"`
|
||||
Source string `json:"source"`
|
||||
IngestedAt time.Time `json:"ingested_at"`
|
||||
}
|
||||
|
||||
type IngestActualsRequest struct {
|
||||
FiscalYear int `json:"fiscal_year"`
|
||||
FiscalPeriod int `json:"fiscal_period"`
|
||||
DeptCode string `json:"dept_code"`
|
||||
GLCode string `json:"gl_code"`
|
||||
Amount float64 `json:"amount"`
|
||||
Currency string `json:"currency"`
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
type VarianceStatus string
|
||||
|
||||
const (
|
||||
StatusFavourable VarianceStatus = "favourable"
|
||||
StatusUnfavourable VarianceStatus = "unfavourable"
|
||||
StatusOnBudget VarianceStatus = "on_budget"
|
||||
)
|
||||
|
||||
type VarianceLine struct {
|
||||
GLCode string `json:"gl_code"`
|
||||
GLDescription string `json:"gl_description"`
|
||||
GLType GLAccountType `json:"gl_type"`
|
||||
Budget float64 `json:"budget"`
|
||||
Actual float64 `json:"actual"`
|
||||
VarianceAbs float64 `json:"variance_abs"`
|
||||
VariancePct *float64 `json:"variance_pct"`
|
||||
Status VarianceStatus `json:"status"`
|
||||
Currency string `json:"currency"`
|
||||
}
|
||||
|
||||
type VarianceReport struct {
|
||||
Department string `json:"department"`
|
||||
FiscalYear int `json:"fiscal_year"`
|
||||
FiscalPeriod int `json:"fiscal_period"`
|
||||
Version BudgetVersion `json:"version"`
|
||||
Currency string `json:"currency"`
|
||||
Lines []VarianceLine `json:"lines"`
|
||||
TotalBudget float64 `json:"total_budget"`
|
||||
TotalActual float64 `json:"total_actual"`
|
||||
TotalVariance float64 `json:"total_variance"`
|
||||
VariancePct *float64 `json:"total_variance_pct"`
|
||||
}
|
||||
|
||||
type AlertThreshold struct {
|
||||
GLCode string `json:"gl_code"`
|
||||
Description string `json:"description"`
|
||||
Budget float64 `json:"budget"`
|
||||
Actual float64 `json:"actual"`
|
||||
VariancePct float64 `json:"variance_pct"`
|
||||
Status VarianceStatus `json:"status"`
|
||||
Department string `json:"department"`
|
||||
}
|
||||
|
||||
// BudgetRow is used internally by the variance service
|
||||
type BudgetRow struct {
|
||||
GLCode string
|
||||
GLDescription string
|
||||
GLType GLAccountType
|
||||
FavourHigh bool
|
||||
Amount float64
|
||||
Currency string
|
||||
}
|
||||
Reference in New Issue
Block a user