billing

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BudgetStatus added in v0.7.2

type BudgetStatus struct {
	BudgetHours int     `json:"budget_hours"`
	UsedHours   float64 `json:"used_hours"`
	Remaining   float64 `json:"remaining"`
	PercentUsed float64 `json:"percent_used"`
	OverBudget  bool    `json:"over_budget"`
}

BudgetStatus represents the current budget consumption state.

func NewBudgetStatus added in v0.7.2

func NewBudgetStatus(budgetHours, totalMinutes int) *BudgetStatus

NewBudgetStatus creates a BudgetStatus from budget hours and total consumed minutes.

type CostReport

type CostReport struct {
	GeneratedAt  time.Time         `json:"generated_at"`
	Currency     string            `json:"currency"`
	Period       string            `json:"period,omitempty"`
	TaxName      string            `json:"tax_name,omitempty"`
	TaxPercent   float64           `json:"tax_percent,omitempty"`
	Entries      []CostReportEntry `json:"entries"`
	TotalHours   float64           `json:"total_hours"`
	TotalCost    float64           `json:"total_cost"`
	TotalTax     float64           `json:"total_tax"`
	TotalWithTax float64           `json:"total_with_tax"`
}

func NewCostReport

func NewCostReport(currency string) *CostReport

func (*CostReport) AddEntry

func (cr *CostReport) AddEntry(entry CostReportEntry, tax *TaxConfig)

func (*CostReport) CSV

func (cr *CostReport) CSV() string

func (*CostReport) SetTax

func (cr *CostReport) SetTax(tax *TaxConfig)

type CostReportEntry

type CostReportEntry struct {
	TaskID       string  `json:"task_id"`
	Title        string  `json:"title"`
	RateID       string  `json:"rate_id"`
	RateName     string  `json:"rate_name"`
	Hours        float64 `json:"hours"`
	HourlyRate   float64 `json:"hourly_rate"`
	Cost         float64 `json:"cost"`
	Currency     string  `json:"currency"`
	Description  string  `json:"description,omitempty"`
	Tax          float64 `json:"tax,omitempty"`
	TotalWithTax float64 `json:"total_with_tax,omitempty"`
}

type Rate

type Rate struct {
	ID         string  `yaml:"id" json:"id"`
	Name       string  `yaml:"name" json:"name"`
	HourlyRate float64 `yaml:"hourly_rate" json:"hourly_rate"`
	IsDefault  bool    `yaml:"default" json:"default"`
}

func NewRate added in v0.7.2

func NewRate(id, name string, hourlyRate float64, isDefault bool) (Rate, error)

NewRate creates a validated Rate value object.

type RateConfig

type RateConfig struct {
	Currency string     `yaml:"currency" json:"currency"`
	Tax      *TaxConfig `yaml:"tax,omitempty" json:"tax,omitempty"`
	Rates    []Rate     `yaml:"rates" json:"rates"`
}

func (*RateConfig) AddRate added in v0.7.2

func (rc *RateConfig) AddRate(rate Rate) error

AddRate adds a rate to the config, enforcing uniqueness and single-default.

func (*RateConfig) GetByID

func (rc *RateConfig) GetByID(id string) *Rate

func (*RateConfig) GetDefault

func (rc *RateConfig) GetDefault() *Rate

func (*RateConfig) RemoveRate added in v0.7.2

func (rc *RateConfig) RemoveRate(rateID string) error

RemoveRate removes a rate by ID.

func (*RateConfig) SetDefault added in v0.7.2

func (rc *RateConfig) SetDefault(rateID string) error

SetDefault marks the given rate as default, clearing default from all others.

type Repository added in v0.7.2

type Repository interface {
	SaveRates(config *RateConfig) error
	LoadRates() (*RateConfig, error)
	SaveTimeEntries(entries []TimeEntry) error
	LoadTimeEntries() ([]TimeEntry, error)
}

Repository handles the persistence of billing artifacts. New code should depend on this interface rather than the composed WorkspaceRepository.

type TaxConfig

type TaxConfig struct {
	Name     string  `yaml:"name" json:"name"`         // e.g., "VAT", "Sales Tax"
	Percent  float64 `yaml:"percent" json:"percent"`   // e.g., 20.0 for 20%
	Included bool    `yaml:"included" json:"included"` // true if tax is included in rate
}

type TimeEntry

type TimeEntry struct {
	ID          string    `yaml:"id" json:"id"`
	TaskID      string    `yaml:"task_id" json:"task_id"`
	RateID      string    `yaml:"rate_id" json:"rate_id"`
	Minutes     int       `yaml:"minutes" json:"minutes"`
	Description string    `yaml:"description,omitempty" json:"description,omitempty"`
	CreatedAt   time.Time `yaml:"created_at" json:"created_at"`
}

func NewTimeEntry added in v0.7.2

func NewTimeEntry(id, taskID, rateID string, minutes int, description string, createdAt time.Time) (TimeEntry, error)

NewTimeEntry creates a validated TimeEntry.

func (*TimeEntry) Hours

func (te *TimeEntry) Hours() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL