Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeNextDue(last *time.Time, intervalMonths int) *time.Time
- func DefaultDBPath() (string, error)
- func FormatCents(cents int64) string
- func FormatDate(value *time.Time) string
- func FormatOptionalCents(cents *int64) string
- func ParseOptionalCents(input string) (*int64, error)
- func ParseOptionalDate(input string) (*time.Time, error)
- func ParseOptionalFloat(input string) (float64, error)
- func ParseOptionalInt(input string) (int, error)
- func ParseRequiredCents(input string) (int64, error)
- func ParseRequiredDate(input string) (time.Time, error)
- func ParseRequiredFloat(input string) (float64, error)
- func ParseRequiredInt(input string) (int, error)
- func ProjectStatuses() []string
- type Appliance
- type DeletionRecord
- type HouseProfile
- type MaintenanceCategory
- type MaintenanceItem
- type Project
- type ProjectType
- type Quote
- type ServiceLogEntry
- type Store
- func (s *Store) AutoMigrate() error
- func (s *Store) Close() error
- func (s *Store) CountMaintenanceByAppliance(applianceIDs []uint) (map[uint]int, error)
- func (s *Store) CountQuotesByVendor(vendorIDs []uint) (map[uint]int, error)
- func (s *Store) CountServiceLogs(itemIDs []uint) (map[uint]int, error)
- func (s *Store) CountServiceLogsByVendor(vendorIDs []uint) (map[uint]int, error)
- func (s *Store) CreateAppliance(item Appliance) error
- func (s *Store) CreateHouseProfile(profile HouseProfile) error
- func (s *Store) CreateMaintenance(item MaintenanceItem) error
- func (s *Store) CreateProject(project Project) error
- func (s *Store) CreateQuote(quote Quote, vendor Vendor) error
- func (s *Store) CreateServiceLog(entry ServiceLogEntry, vendor Vendor) error
- func (s *Store) CreateVendor(vendor Vendor) error
- func (s *Store) DeleteAppliance(id uint) error
- func (s *Store) DeleteMaintenance(id uint) error
- func (s *Store) DeleteProject(id uint) error
- func (s *Store) DeleteQuote(id uint) error
- func (s *Store) DeleteServiceLog(id uint) error
- func (s *Store) GetAppliance(id uint) (Appliance, error)
- func (s *Store) GetMaintenance(id uint) (MaintenanceItem, error)
- func (s *Store) GetProject(id uint) (Project, error)
- func (s *Store) GetQuote(id uint) (Quote, error)
- func (s *Store) GetServiceLog(id uint) (ServiceLogEntry, error)
- func (s *Store) GetVendor(id uint) (Vendor, error)
- func (s *Store) HouseProfile() (HouseProfile, error)
- func (s *Store) LastDeletion(entity string) (DeletionRecord, error)
- func (s *Store) ListActiveProjects() ([]Project, error)
- func (s *Store) ListAppliances(includeDeleted bool) ([]Appliance, error)
- func (s *Store) ListExpiringWarranties(now time.Time, lookBack, horizon time.Duration) ([]Appliance, error)
- func (s *Store) ListMaintenance(includeDeleted bool) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceByAppliance(applianceID uint, includeDeleted bool) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceWithSchedule() ([]MaintenanceItem, error)
- func (s *Store) ListProjects(includeDeleted bool) ([]Project, error)
- func (s *Store) ListQuotes(includeDeleted bool) ([]Quote, error)
- func (s *Store) ListRecentServiceLogs(limit int) ([]ServiceLogEntry, error)
- func (s *Store) ListServiceLog(maintenanceItemID uint, includeDeleted bool) ([]ServiceLogEntry, error)
- func (s *Store) ListVendors() ([]Vendor, error)
- func (s *Store) MaintenanceCategories() ([]MaintenanceCategory, error)
- func (s *Store) ProjectTypes() ([]ProjectType, error)
- func (s *Store) RestoreAppliance(id uint) error
- func (s *Store) RestoreMaintenance(id uint) error
- func (s *Store) RestoreProject(id uint) error
- func (s *Store) RestoreQuote(id uint) error
- func (s *Store) RestoreServiceLog(id uint) error
- func (s *Store) SeedDefaults() error
- func (s *Store) SeedDemoData() error
- func (s *Store) UpdateAppliance(item Appliance) error
- func (s *Store) UpdateHouseProfile(profile HouseProfile) error
- func (s *Store) UpdateMaintenance(item MaintenanceItem) error
- func (s *Store) UpdateProject(project Project) error
- func (s *Store) UpdateQuote(quote Quote, vendor Vendor) error
- func (s *Store) UpdateServiceLog(entry ServiceLogEntry, vendor Vendor) error
- func (s *Store) UpdateVendor(vendor Vendor) error
- func (s *Store) YTDProjectSpendCents() (int64, error)
- func (s *Store) YTDServiceSpendCents(yearStart time.Time) (int64, error)
- type Vendor
Constants ¶
const ( ProjectStatusIdeating = "ideating" ProjectStatusPlanned = "planned" ProjectStatusQuoted = "quoted" ProjectStatusInProgress = "underway" ProjectStatusDelayed = "delayed" ProjectStatusCompleted = "completed" ProjectStatusAbandoned = "abandoned" )
const ( DeletionEntityProject = "project" DeletionEntityQuote = "quote" DeletionEntityMaintenance = "maintenance" DeletionEntityAppliance = "appliance" DeletionEntityServiceLog = "service_log" )
const AppName = "micasa"
const DateLayout = "2006-01-02"
Variables ¶
Functions ¶
func DefaultDBPath ¶
func FormatCents ¶
func FormatDate ¶
func FormatOptionalCents ¶
func ParseOptionalCents ¶
func ParseOptionalFloat ¶
func ParseOptionalInt ¶
func ParseRequiredCents ¶
func ParseRequiredFloat ¶
func ParseRequiredInt ¶
func ProjectStatuses ¶
func ProjectStatuses() []string
Types ¶
type Appliance ¶
type Appliance struct {
ID uint `gorm:"primaryKey"`
Name string
Brand string
ModelNumber string `gorm:"column:model_no"`
SerialNumber string `gorm:"column:serial_no"`
PurchaseDate *time.Time `gorm:"column:purch_dt"`
WarrantyExpiry *time.Time `gorm:"column:warr_exp"`
Location string
CostCents *int64 `gorm:"column:cost_ct"`
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type DeletionRecord ¶
type HouseProfile ¶
type HouseProfile struct {
ID uint `gorm:"primaryKey"`
Nickname string
AddressLine1 string
AddressLine2 string
City string
State string
PostalCode string
YearBuilt int `gorm:"column:yr_blt"`
SquareFeet int `gorm:"column:sq_ft"`
LotSquareFeet int `gorm:"column:lot_sq_ft"`
Bedrooms int `gorm:"column:br"`
Bathrooms float64 `gorm:"column:ba"`
FoundationType string `gorm:"column:fnd_t"`
WiringType string `gorm:"column:wir_t"`
RoofType string `gorm:"column:roof_t"`
ExteriorType string `gorm:"column:ext_t"`
HeatingType string `gorm:"column:heat_t"`
CoolingType string `gorm:"column:cool_t"`
WaterSource string `gorm:"column:wtr_src"`
SewerType string `gorm:"column:sewer_t"`
ParkingType string `gorm:"column:park_t"`
BasementType string `gorm:"column:base_t"`
InsuranceCarrier string `gorm:"column:ins_co"`
InsurancePolicy string `gorm:"column:ins_pol"`
InsuranceRenewal *time.Time
PropertyTaxCents *int64 `gorm:"column:tax_ct"`
HOAName string `gorm:"column:hoa_nm"`
HOAFeeCents *int64 `gorm:"column:hoa_ct"`
CreatedAt time.Time
UpdatedAt time.Time
}
type MaintenanceCategory ¶
type MaintenanceItem ¶
type MaintenanceItem struct {
ID uint `gorm:"primaryKey"`
Name string
CategoryID uint
Category MaintenanceCategory `gorm:"constraint:OnDelete:RESTRICT;"`
ApplianceID *uint
Appliance Appliance `gorm:"constraint:OnDelete:SET NULL;"`
LastServicedAt *time.Time `gorm:"column:last_srv"`
IntervalMonths int `gorm:"column:int_mo"`
ManualURL string `gorm:"column:man_url"`
ManualText string `gorm:"column:man_txt"`
Notes string
CostCents *int64 `gorm:"column:cost_ct"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type Project ¶
type Project struct {
ID uint `gorm:"primaryKey"`
Title string
ProjectTypeID uint
ProjectType ProjectType `gorm:"constraint:OnDelete:RESTRICT;"`
Status string
Description string
StartDate *time.Time
EndDate *time.Time
BudgetCents *int64 `gorm:"column:bud_ct"`
ActualCents *int64 `gorm:"column:act_ct"`
PreferredVendorID *uint
PreferredVendor Vendor `gorm:"constraint:OnDelete:SET NULL;"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type ProjectType ¶
type Quote ¶
type Quote struct {
ID uint `gorm:"primaryKey"`
ProjectID uint
Project Project `gorm:"constraint:OnDelete:RESTRICT;"`
VendorID uint
Vendor Vendor `gorm:"constraint:OnDelete:RESTRICT;"`
TotalCents int64 `gorm:"column:tot_ct"`
LaborCents *int64 `gorm:"column:lbr_ct"`
MaterialsCents *int64 `gorm:"column:mat_ct"`
OtherCents *int64 `gorm:"column:oth_ct"`
ReceivedDate *time.Time
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type ServiceLogEntry ¶
type ServiceLogEntry struct {
ID uint `gorm:"primaryKey"`
MaintenanceItemID uint `gorm:"index"`
MaintenanceItem MaintenanceItem `gorm:"constraint:OnDelete:CASCADE;"`
ServicedAt time.Time
VendorID *uint
Vendor Vendor `gorm:"constraint:OnDelete:SET NULL;"`
CostCents *int64 `gorm:"column:cost_ct"`
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AutoMigrate ¶
func (*Store) CountMaintenanceByAppliance ¶
CountMaintenanceByAppliance returns the count of non-deleted maintenance items for each appliance ID.
func (*Store) CountQuotesByVendor ¶ added in v1.6.0
CountQuotesByVendor returns the number of non-deleted quotes per vendor ID.
func (*Store) CountServiceLogs ¶
CountServiceLogs returns the number of non-deleted service log entries per maintenance item ID for the given set of IDs.
func (*Store) CountServiceLogsByVendor ¶ added in v1.6.0
CountServiceLogsByVendor returns the number of non-deleted service log entries per vendor ID.
func (*Store) CreateAppliance ¶
func (*Store) CreateHouseProfile ¶
func (s *Store) CreateHouseProfile(profile HouseProfile) error
func (*Store) CreateMaintenance ¶
func (s *Store) CreateMaintenance(item MaintenanceItem) error
func (*Store) CreateProject ¶
func (*Store) CreateServiceLog ¶
func (s *Store) CreateServiceLog(entry ServiceLogEntry, vendor Vendor) error
func (*Store) CreateVendor ¶ added in v1.6.0
func (*Store) DeleteAppliance ¶
func (*Store) DeleteMaintenance ¶
func (*Store) DeleteProject ¶
func (*Store) DeleteQuote ¶
func (*Store) DeleteServiceLog ¶
func (*Store) GetMaintenance ¶
func (s *Store) GetMaintenance(id uint) (MaintenanceItem, error)
func (*Store) GetServiceLog ¶
func (s *Store) GetServiceLog(id uint) (ServiceLogEntry, error)
func (*Store) HouseProfile ¶
func (s *Store) HouseProfile() (HouseProfile, error)
func (*Store) LastDeletion ¶
func (s *Store) LastDeletion(entity string) (DeletionRecord, error)
func (*Store) ListActiveProjects ¶
ListActiveProjects returns non-deleted projects with status "underway" or "delayed", preloading ProjectType.
func (*Store) ListAppliances ¶
func (*Store) ListExpiringWarranties ¶
func (s *Store) ListExpiringWarranties( now time.Time, lookBack, horizon time.Duration, ) ([]Appliance, error)
ListExpiringWarranties returns non-deleted appliances whose warranty expires between (now - lookBack) and (now + horizon).
func (*Store) ListMaintenance ¶
func (s *Store) ListMaintenance(includeDeleted bool) ([]MaintenanceItem, error)
func (*Store) ListMaintenanceByAppliance ¶
func (s *Store) ListMaintenanceByAppliance( applianceID uint, includeDeleted bool, ) ([]MaintenanceItem, error)
func (*Store) ListMaintenanceWithSchedule ¶
func (s *Store) ListMaintenanceWithSchedule() ([]MaintenanceItem, error)
ListMaintenanceWithSchedule returns all non-deleted maintenance items that have a positive interval, preloading Category and Appliance. These are the items eligible for overdue/upcoming computation.
func (*Store) ListRecentServiceLogs ¶
func (s *Store) ListRecentServiceLogs(limit int) ([]ServiceLogEntry, error)
ListRecentServiceLogs returns the most recent service log entries across all maintenance items, preloading MaintenanceItem and Vendor.
func (*Store) ListServiceLog ¶
func (s *Store) ListServiceLog( maintenanceItemID uint, includeDeleted bool, ) ([]ServiceLogEntry, error)
func (*Store) ListVendors ¶
func (*Store) MaintenanceCategories ¶
func (s *Store) MaintenanceCategories() ([]MaintenanceCategory, error)
func (*Store) ProjectTypes ¶
func (s *Store) ProjectTypes() ([]ProjectType, error)
func (*Store) RestoreAppliance ¶
func (*Store) RestoreMaintenance ¶
func (*Store) RestoreProject ¶
func (*Store) RestoreQuote ¶
func (*Store) RestoreServiceLog ¶
func (*Store) SeedDefaults ¶
func (*Store) SeedDemoData ¶
SeedDemoData populates the database with plausible sample data for testing. It is idempotent: if a house profile already exists, it returns immediately.
func (*Store) UpdateAppliance ¶
func (*Store) UpdateHouseProfile ¶
func (s *Store) UpdateHouseProfile(profile HouseProfile) error
func (*Store) UpdateMaintenance ¶
func (s *Store) UpdateMaintenance(item MaintenanceItem) error
func (*Store) UpdateProject ¶
func (*Store) UpdateServiceLog ¶
func (s *Store) UpdateServiceLog(entry ServiceLogEntry, vendor Vendor) error
func (*Store) UpdateVendor ¶ added in v1.6.0
func (*Store) YTDProjectSpendCents ¶
YTDProjectSpendCents returns the total actual spend across all non-deleted projects.