better end points and better tests

This commit is contained in:
samantha42
2026-03-21 15:47:40 +01:00
parent 3f203178b2
commit 3490dd13d4
10 changed files with 482 additions and 34 deletions

View File

@@ -276,3 +276,57 @@ type BudgetRow struct {
Amount float64
Currency string
}
// GLAmountRow is a single GL line returned by the ReportRepo amount queries.
// Used as the building block for PnLSection lines.
type GLAmountRow struct {
GLCode string `json:"gl_code"`
Description string `json:"description"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
}
// RevenueAmounts holds the per-GL amounts for revenue accounts in a single period.
// Used as input for P&L rollup and reforecast calculations.
type RevenueAmounts struct {
GLCode string
Description string
Amount float64
Currency string
}
// PnLSection is one block in the P&L (Revenue, COGS, Opex, etc.)
// Lines are the individual GL rows; Total is their sum.
type PnLSection struct {
Lines []GLAmountRow `json:"lines"`
Total float64 `json:"total"`
}
// PnLReport is the full P&L for a single period/dept/version.
// GrossProfit = Revenue - COGS
// EBIT = GrossProfit - Opex - Headcount
// NetIncome = EBIT - Capex
type PnLReport struct {
Department string `json:"department"`
FiscalYear int `json:"fiscal_year"`
FiscalPeriod int `json:"fiscal_period"`
Version BudgetVersion `json:"version"`
Currency string `json:"currency"`
Revenue PnLSection `json:"revenue"`
COGS PnLSection `json:"cogs"`
Opex PnLSection `json:"opex"`
Headcount PnLSection `json:"headcount"`
Capex PnLSection `json:"capex"`
GrossProfit float64 `json:"gross_profit"` // Revenue - COGS
EBIT float64 `json:"ebit"` // GrossProfit - Opex - Headcount
NetIncome float64 `json:"net_income"` // EBIT - Capex
}
type PnLRequest struct {
FiscalYears []int
FiscalPeriods []int
DeptCodes []string
Version BudgetVersion
}