package model

import (
	"fmt"
)

type RevenueCategory struct {
	ID        int
	CompanyID int
	ParentID  *int
	Name      string // e.g. "product", "location", "segment"
}

func (rc *RevenueCategory) Validate(checkID bool) error {
	if rc.ID == 0 && checkID {
		return fmt.Errorf("No ID Set")
	} else if rc.Name == "" {
		return fmt.Errorf("No Name found")
	} else if rc.CompanyID == 0 {
		return fmt.Errorf("No Company Set")
	}
	return nil
}

// Revenue is a single line in a financial report
type Revenue struct {
	ID       int
	Company  *Company
	Currency *Currency
	Category *RevenueCategory
	Period   *Period
	Value    float64
}

// made to be inserted to database
type RevenueInsert struct {
	CompanyID    int
	CurrencyID   int
	CategoryName string
	ParentID     int
	Period       Period
	Value        float64
}
