Documentation
¶
Index ¶
- Constants
- Variables
- func AddMonths(t time.Time, months int) time.Time
- func ApplyDefaults(v any)
- func AreaFormTitle(u UnitSystem) string
- func AreaPlaceholder(u UnitSystem) string
- func BuildEntityKindToTable(models []any) map[string]string
- func ComputeNextDue(last *time.Time, intervalMonths int, dueDate *time.Time) *time.Time
- func DefaultDBPath() (string, error)
- func DisplayIntToSqFt(display int, u UnitSystem) int
- func DocumentCacheDir() (string, error)
- func EvictStaleCache(dir string, ttl time.Duration) (int, error)
- func ExpandHome(path string) string
- func FieldError(label string, err error) error
- func FormatArea(sqft int, u UnitSystem) string
- func FormatDate(value *time.Time) string
- func FormatLotArea(sqft int, u UnitSystem) string
- func Hint(err error) string
- func IsSafeIdentifier(s string) bool
- func LotAreaFormTitle(u UnitSystem) string
- func LotAreaPlaceholder(u UnitSystem) string
- func Models() []any
- func ParseIntervalMonths(input string) (int, error)
- func ParseOptionalDate(input string) (*time.Time, error)
- func ParseOptionalDateAt(input string, ref time.Time) (*time.Time, error)
- func ParseOptionalFloat(input string) (float64, error)
- func ParseOptionalInt(input string) (int, error)
- func ParseRequiredDate(input string) (time.Time, error)
- func ParseRequiredDateAt(input string, ref time.Time) (time.Time, error)
- func ParseRequiredFloat(input string) (float64, error)
- func ParseRequiredInt(input string) (int, error)
- func SeasonForMonth(m time.Month) string
- func SqFtToDisplayInt(sqft int, u UnitSystem) int
- func SqFtToSqM(sqft float64) float64
- func SqMToSqFt(sqm float64) float64
- func StructDefault[T any](fieldName string) string
- func TitleFromFilename(name string) string
- func ValidateDBPath(path string) error
- func WithHint(err error, hint string) error
- type Appliance
- type ChatInput
- type DeletionRecord
- type Document
- type DocumentSearchResult
- type EntityRow
- type EntityRowContext
- type HouseProfile
- type Incident
- type MaintenanceCategory
- type MaintenanceItem
- type PragmaColumn
- type Project
- type ProjectType
- type Quote
- type SeedSummary
- type ServiceLogEntry
- type Setting
- type Store
- func (s *Store) AppendChatInput(input string) error
- func (s *Store) AutoMigrate() error
- func (s *Store) Backup(ctx context.Context, destPath string) error
- func (s *Store) Close() error
- func (s *Store) ColumnHints() string
- func (s *Store) CountDocumentsByEntity(entityKind string, entityIDs []uint) (map[uint]int, error)
- func (s *Store) CountIncidentsByAppliance(applianceIDs []uint) (map[uint]int, error)
- func (s *Store) CountIncidentsByVendor(vendorIDs []uint) (map[uint]int, error)
- func (s *Store) CountMaintenanceByAppliance(applianceIDs []uint) (map[uint]int, error)
- func (s *Store) CountQuotesByProject(projectIDs []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) CreateDocument(doc *Document) error
- func (s *Store) CreateHouseProfile(profile HouseProfile) error
- func (s *Store) CreateIncident(item *Incident) 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) Currency() locale.Currency
- func (s *Store) DataDump() string
- func (s *Store) DeleteAppliance(id uint) error
- func (s *Store) DeleteDocument(id uint) error
- func (s *Store) DeleteIncident(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) DeleteVendor(id uint) error
- func (s *Store) EntityNames() (vendors, projects, appliances []string, err error)
- func (s *Store) EntityRows() (EntityRowContext, error)
- func (s *Store) ExtractDocument(id uint) (string, error)
- func (s *Store) FindOrCreateAppliance(item Appliance) (Appliance, error)
- func (s *Store) FindOrCreateMaintenance(item MaintenanceItem) (MaintenanceItem, error)
- func (s *Store) FindOrCreateVendor(vendor Vendor) (Vendor, error)
- func (s *Store) GetAppliance(id uint) (Appliance, error)
- func (s *Store) GetCurrency() (string, error)
- func (s *Store) GetDocument(id uint) (Document, error)
- func (s *Store) GetDocumentMetadata(id uint) (Document, error)
- func (s *Store) GetIncident(id uint) (Incident, error)
- func (s *Store) GetLastModel() (string, 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) GetSetting(key string) (string, error)
- func (s *Store) GetShowDashboard() (bool, error)
- func (s *Store) GetUnitSystem() (UnitSystem, error)
- func (s *Store) GetVendor(id uint) (Vendor, error)
- func (s *Store) HardDeleteIncident(id uint) error
- func (s *Store) HouseProfile() (HouseProfile, error)
- func (s *Store) IsMicasaDB() (bool, 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) ListDocuments(includeDeleted bool) ([]Document, error)
- func (s *Store) ListDocumentsByEntity(entityKind string, entityID uint, includeDeleted bool) ([]Document, error)
- func (s *Store) ListExpiringWarranties(now time.Time, lookBack, horizon time.Duration) ([]Appliance, error)
- func (s *Store) ListIncidents(includeDeleted bool) ([]Incident, error)
- func (s *Store) ListMaintenance(includeDeleted bool) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceByAppliance(applianceID uint, includeDeleted bool) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceBySeason(season string) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceWithSchedule() ([]MaintenanceItem, error)
- func (s *Store) ListOpenIncidents() ([]Incident, error)
- func (s *Store) ListProjects(includeDeleted bool) ([]Project, error)
- func (s *Store) ListQuotes(includeDeleted bool) ([]Quote, error)
- func (s *Store) ListQuotesByProject(projectID uint, includeDeleted bool) ([]Quote, error)
- func (s *Store) ListQuotesByVendor(vendorID uint, 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) ListServiceLogsByVendor(vendorID uint, includeDeleted bool) ([]ServiceLogEntry, error)
- func (s *Store) ListVendors(includeDeleted bool) ([]Vendor, error)
- func (s *Store) LoadChatHistory() ([]string, error)
- func (s *Store) MaintenanceCategories() ([]MaintenanceCategory, error)
- func (s *Store) MarkTesseractHintSeen() error
- func (s *Store) MaxDocumentSize() uint64
- func (s *Store) MaxIDs(tables ...string) (map[string]uint, error)
- func (s *Store) ProjectTypes() ([]ProjectType, error)
- func (s *Store) PutCurrency(code string) error
- func (s *Store) PutLastModel(model string) error
- func (s *Store) PutSetting(key, value string) error
- func (s *Store) PutShowDashboard(show bool) error
- func (s *Store) PutUnitSystem(u UnitSystem) error
- func (s *Store) ReadOnlyQuery(query string) (columns []string, rows [][]string, err error)
- func (s *Store) RebuildFTSIndex() error
- func (s *Store) ResolveCurrency(configured string) error
- func (s *Store) RestoreAppliance(id uint) error
- func (s *Store) RestoreDocument(id uint) error
- func (s *Store) RestoreIncident(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) RestoreVendor(id uint) error
- func (s *Store) SearchDocuments(query string) ([]DocumentSearchResult, error)
- func (s *Store) SeedDefaults() error
- func (s *Store) SeedDemoData() error
- func (s *Store) SeedDemoDataFrom(h *fake.HomeFaker) error
- func (s *Store) SeedScaledData(years int) (SeedSummary, error)
- func (s *Store) SeedScaledDataFrom(h *fake.HomeFaker, years int) (SeedSummary, error)
- func (s *Store) SetCurrency(cur locale.Currency)
- func (s *Store) SetMaxDocumentSize(n uint64) error
- func (s *Store) TableColumns(table string) ([]PragmaColumn, error)
- func (s *Store) TableDDL(tables ...string) (map[string]string, error)
- func (s *Store) TableNames() ([]string, error)
- func (s *Store) TesseractHintSeen() bool
- func (s *Store) TotalProjectSpendCents() (int64, error)
- func (s *Store) Transaction(fn func(tx *Store) error) error
- func (s *Store) UpdateAppliance(item Appliance) error
- func (s *Store) UpdateDocument(doc Document) error
- func (s *Store) UpdateDocumentExtraction(id uint, text string, data []byte) error
- func (s *Store) UpdateHouseProfile(profile HouseProfile) error
- func (s *Store) UpdateIncident(item Incident) 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) WalCheckpoint() error
- func (s *Store) YTDServiceSpendCents(yearStart time.Time) (int64, error)
- type UnitSystem
- type Vendor
Constants ¶
const ( TableAppliances = "appliances" TableChatInputs = "chat_inputs" TableDeletionRecords = "deletion_records" TableDocuments = "documents" TableHouseProfiles = "house_profiles" TableIncidents = "incidents" TableMaintenanceCategories = "maintenance_categories" TableMaintenanceItems = "maintenance_items" TableProjectTypes = "project_types" TableProjects = "projects" TableQuotes = "quotes" TableServiceLogEntries = "service_log_entries" TableSettings = "settings" TableVendors = "vendors" )
Table name constants derived from GORM model structs.
const ( ColActualCents = "actual_cents" ColAddressLine1 = "address_line1" ColAddressLine2 = "address_line2" ColApplianceID = "appliance_id" ColBasementType = "basement_type" ColBathrooms = "bathrooms" ColBedrooms = "bedrooms" ColBrand = "brand" ColBudgetCents = "budget_cents" ColCategoryID = "category_id" ColChecksumSHA256 = "sha256" ColCity = "city" ColContactName = "contact_name" ColCoolingType = "cooling_type" ColCostCents = "cost_cents" ColCreatedAt = "created_at" ColData = "data" ColDateNoticed = "date_noticed" ColDateResolved = "date_resolved" ColDeletedAt = "deleted_at" ColDescription = "description" ColDueDate = "due_date" ColEmail = "email" ColEndDate = "end_date" ColEntity = "entity" ColEntityID = "entity_id" ColEntityKind = "entity_kind" ColExteriorType = "exterior_type" ColExtractData = "ocr_data" ColExtractedText = "extracted_text" ColFileName = "file_name" ColFoundationType = "foundation_type" ColHOAFeeCents = "hoa_fee_cents" ColHOAName = "hoa_name" ColHeatingType = "heating_type" ColID = "id" ColInput = "input" ColInsuranceCarrier = "insurance_carrier" ColInsurancePolicy = "insurance_policy" ColInsuranceRenewal = "insurance_renewal" ColIntervalMonths = "interval_months" ColKey = "key" ColLaborCents = "labor_cents" ColLastServicedAt = "last_serviced_at" ColLocation = "location" ColLotSquareFeet = "lot_square_feet" ColMIMEType = "mime_type" ColMaintenanceItemID = "maintenance_item_id" ColManualText = "manual_text" ColManualURL = "manual_url" ColMaterialsCents = "materials_cents" ColModelNumber = "model_number" ColName = "name" ColNickname = "nickname" ColNotes = "notes" ColOtherCents = "other_cents" ColParkingType = "parking_type" ColPhone = "phone" ColPostalCode = "postal_code" ColPreviousStatus = "previous_status" ColProjectID = "project_id" ColProjectTypeID = "project_type_id" ColPropertyTaxCents = "property_tax_cents" ColPurchaseDate = "purchase_date" ColReceivedDate = "received_date" ColRestoredAt = "restored_at" ColRoofType = "roof_type" ColSeason = "season" ColSerialNumber = "serial_number" ColServicedAt = "serviced_at" ColSeverity = "severity" ColSewerType = "sewer_type" ColSizeBytes = "size_bytes" ColSquareFeet = "square_feet" ColStartDate = "start_date" ColState = "state" ColStatus = "status" ColTargetID = "target_id" ColTitle = "title" ColTotalCents = "total_cents" ColUpdatedAt = "updated_at" ColValue = "value" ColVendorID = "vendor_id" ColWarrantyExpiry = "warranty_expiry" ColWaterSource = "water_source" ColWebsite = "website" ColWiringType = "wiring_type" ColYearBuilt = "year_built" )
Column name constants derived from GORM model structs.
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" DeletionEntityVendor = "vendor" DeletionEntityDocument = "document" DeletionEntityIncident = "incident" )
const ( IncidentStatusOpen = "open" IncidentStatusInProgress = "in_progress" IncidentStatusResolved = "resolved" )
const ( IncidentSeverityUrgent = "urgent" IncidentSeveritySoon = "soon" IncidentSeverityWhenever = "whenever" )
const ( SeasonSpring = "spring" SeasonSummer = "summer" SeasonFall = "fall" SeasonWinter = "winter" )
const ( DocumentEntityNone = "" DocumentEntityProject = "project" DocumentEntityQuote = "quote" DocumentEntityMaintenance = "maintenance" DocumentEntityAppliance = "appliance" DocumentEntityServiceLog = "service_log" DocumentEntityVendor = "vendor" DocumentEntityIncident = "incident" )
Document entity kind values for polymorphic linking.
const AppName = "micasa"
const DateLayout = "2006-01-02"
Variables ¶
var ( // ErrParentDeleted indicates the parent record exists but is soft-deleted. ErrParentDeleted = errors.New("parent record is deleted") // ErrParentNotFound indicates the parent record doesn't exist at all. ErrParentNotFound = errors.New("parent record not found") )
var ( ErrInvalidDate = errors.New("invalid date value") ErrInvalidInt = errors.New("invalid integer value") ErrInvalidFloat = errors.New("invalid decimal value") ErrInvalidInterval = errors.New("invalid interval value") ErrIntervalAndDueDate = errors.New("set interval or due date, not both") )
var EntityKindToTable = BuildEntityKindToTable(Models())
EntityKindToTable maps document entity_kind values (polymorphicValue) to their corresponding table names. Derived from GORM polymorphic tags via schema introspection at init time.
var TableExtractColumns = map[string][]metaColumn{ TableAppliances: { {Name: "name", JSONType: "string"}, {Name: "brand", JSONType: "string"}, {Name: "model_number", JSONType: "string"}, {Name: "serial_number", JSONType: "string"}, {Name: "location", JSONType: "string"}, {Name: "cost_cents", JSONType: "integer"}, {Name: "notes", JSONType: "string"}, }, TableChatInputs: { {Name: "input", JSONType: "string"}, }, TableDeletionRecords: { {Name: "entity", JSONType: "string"}, {Name: "target_id", JSONType: "integer"}, {Name: "restored_at", JSONType: "string"}, }, TableDocuments: { {Name: "title", JSONType: "string"}, {Name: "file_name", JSONType: "string"}, {Name: "entity_kind", JSONType: "string"}, {Name: "entity_id", JSONType: "integer"}, {Name: "notes", JSONType: "string"}, }, TableHouseProfiles: { {Name: "nickname", JSONType: "string"}, {Name: "address_line1", JSONType: "string"}, {Name: "address_line2", JSONType: "string"}, {Name: "city", JSONType: "string"}, {Name: "state", JSONType: "string"}, {Name: "postal_code", JSONType: "string"}, {Name: "year_built", JSONType: "integer"}, {Name: "square_feet", JSONType: "integer"}, {Name: "lot_square_feet", JSONType: "integer"}, {Name: "bedrooms", JSONType: "integer"}, {Name: "bathrooms", JSONType: "integer"}, {Name: "foundation_type", JSONType: "string"}, {Name: "wiring_type", JSONType: "string"}, {Name: "roof_type", JSONType: "string"}, {Name: "exterior_type", JSONType: "string"}, {Name: "heating_type", JSONType: "string"}, {Name: "cooling_type", JSONType: "string"}, {Name: "water_source", JSONType: "string"}, {Name: "sewer_type", JSONType: "string"}, {Name: "parking_type", JSONType: "string"}, {Name: "basement_type", JSONType: "string"}, {Name: "insurance_carrier", JSONType: "string"}, {Name: "insurance_policy", JSONType: "string"}, {Name: "insurance_renewal", JSONType: "string"}, {Name: "property_tax_cents", JSONType: "integer"}, {Name: "hoa_name", JSONType: "string"}, {Name: "hoa_fee_cents", JSONType: "integer"}, }, TableIncidents: { {Name: "title", JSONType: "string"}, {Name: "description", JSONType: "string"}, {Name: "status", JSONType: "string"}, {Name: "severity", JSONType: "string"}, {Name: "date_noticed", JSONType: "string"}, {Name: "location", JSONType: "string"}, {Name: "cost_cents", JSONType: "integer"}, {Name: "appliance_id", JSONType: "integer"}, {Name: "vendor_id", JSONType: "integer"}, {Name: "notes", JSONType: "string"}, }, TableMaintenanceCategories: { {Name: "name", JSONType: "string"}, }, TableMaintenanceItems: { {Name: "name", JSONType: "string"}, {Name: "category_id", JSONType: "integer"}, {Name: "appliance_id", JSONType: "integer"}, {Name: "season", JSONType: "string"}, {Name: "interval_months", JSONType: "integer"}, {Name: "notes", JSONType: "string"}, {Name: "cost_cents", JSONType: "integer"}, }, TableProjectTypes: { {Name: "name", JSONType: "string"}, }, TableProjects: { {Name: "title", JSONType: "string"}, {Name: "project_type_id", JSONType: "integer"}, {Name: "status", JSONType: "string"}, {Name: "description", JSONType: "string"}, {Name: "budget_cents", JSONType: "integer"}, }, TableQuotes: { {Name: "project_id", JSONType: "integer"}, {Name: "vendor_id", JSONType: "integer"}, {Name: "total_cents", JSONType: "integer"}, {Name: "labor_cents", JSONType: "integer"}, {Name: "materials_cents", JSONType: "integer"}, {Name: "notes", JSONType: "string"}, }, TableServiceLogEntries: { {Name: "maintenance_item_id", JSONType: "integer"}, {Name: "serviced_at", JSONType: "string"}, {Name: "vendor_id", JSONType: "integer"}, {Name: "cost_cents", JSONType: "integer"}, {Name: "notes", JSONType: "string"}, }, TableSettings: { {Name: "key", JSONType: "string"}, {Name: "value", JSONType: "string"}, }, TableVendors: { {Name: "name", JSONType: "string"}, {Name: "contact_name", JSONType: "string"}, {Name: "email", JSONType: "string"}, {Name: "phone", JSONType: "string"}, {Name: "website", JSONType: "string"}, {Name: "notes", JSONType: "string"}, }, }
TableExtractColumns maps each table to its extractable columns. Excludes primary keys, auto-managed timestamps, soft-delete markers, GORM association fields, and binary data columns.
Functions ¶
func AddMonths ¶ added in v1.29.0
AddMonths adds the given number of months to t, clamping the day to the last day of the target month. This avoids the time.AddDate gotcha where Jan 31 + 1 month = March 3 instead of Feb 28.
func ApplyDefaults ¶ added in v1.77.1
func ApplyDefaults(v any)
ApplyDefaults sets zero-valued fields on the struct pointed to by v to the values specified in their `default` struct tags. Fields that are already non-zero are left untouched. Nested structs without a default tag are recursed into automatically.
Supported field types and tag values:
- string: literal value; "today" is replaced with time.Now() formatted as DateLayout
- int, int64, uint, uint64, float64: parsed via strconv
- time.Time: "now" is replaced with time.Now()
- Named types with int/uint underlying kind: parsed as the underlying integer
- Nested structs: recursed into (no tag needed on the struct field itself)
func AreaFormTitle ¶ added in v1.55.0
func AreaFormTitle(u UnitSystem) string
AreaFormTitle returns the form field title for the building area.
func AreaPlaceholder ¶ added in v1.55.0
func AreaPlaceholder(u UnitSystem) string
AreaPlaceholder returns a placeholder value for the building area field.
func BuildEntityKindToTable ¶ added in v1.71.1
BuildEntityKindToTable derives the entity_kind-to-table mapping from GORM polymorphic tags on the given models. Each model with a polymorphic HasMany to the documents table contributes one entry: polymorphicValue -> owner table name.
func ComputeNextDue ¶
func DefaultDBPath ¶
func DisplayIntToSqFt ¶ added in v1.55.0
func DisplayIntToSqFt(display int, u UnitSystem) int
DisplayIntToSqFt converts a user-entered display value back to sq ft for storage.
func DocumentCacheDir ¶ added in v1.27.0
DocumentCacheDir returns the directory used for extracted document BLOBs. On Linux: $XDG_CACHE_HOME/micasa/documents (default ~/.cache/micasa/documents)
func EvictStaleCache ¶ added in v1.29.0
EvictStaleCache removes cached document files from dir that haven't been modified within the given TTL. A ttl of 0 disables eviction. Returns the number of files removed and any error encountered while listing the directory (individual file removal errors are skipped).
func ExpandHome ¶ added in v1.41.0
ExpandHome replaces a leading "~" or "~/" with the current user's home directory. Other forms like "~user/" are left as-is because os/user.Lookup requires cgo on macOS.
func FieldError ¶ added in v1.54.2
FieldError wraps a validation sentinel error with a field-specific, user-friendly message. The sentinel is preserved in the error chain.
func FormatArea ¶ added in v1.55.0
func FormatArea(sqft int, u UnitSystem) string
FormatArea formats a stored sq ft value for display in the user's unit system. Returns "" for zero values.
func FormatDate ¶
func FormatLotArea ¶ added in v1.55.0
func FormatLotArea(sqft int, u UnitSystem) string
FormatLotArea formats a stored lot sq ft value with a "lot" suffix. Returns "" for zero values.
func Hint ¶ added in v1.54.2
Hint extracts the user-facing hint from an error chain. Returns "" if no hint is found.
func IsSafeIdentifier ¶ added in v1.74.1
IsSafeIdentifier returns true if s contains only alphanumerics and underscores -- safe for interpolation into SQL statements.
func LotAreaFormTitle ¶ added in v1.55.0
func LotAreaFormTitle(u UnitSystem) string
LotAreaFormTitle returns the form field title for the lot area.
func LotAreaPlaceholder ¶ added in v1.55.0
func LotAreaPlaceholder(u UnitSystem) string
LotAreaPlaceholder returns a placeholder value for the lot area field.
func Models ¶ added in v1.69.2
func Models() []any
Models returns a pointer to every GORM model struct in source order. Used by AutoMigrate and FK introspection.
func ParseIntervalMonths ¶ added in v1.30.0
ParseIntervalMonths parses a human-friendly interval into months. Accepts bare integers ("12"), month suffix ("6m"), year suffix ("1y"), or combined ("2y 6m", "1y6m"). Case-insensitive, whitespace-flexible. Returns (0, nil) for empty/blank input (non-recurring).
func ParseOptionalDateAt ¶ added in v1.52.0
func ParseOptionalFloat ¶
func ParseOptionalInt ¶
func ParseRequiredDateAt ¶ added in v1.52.0
func ParseRequiredFloat ¶
func ParseRequiredInt ¶
func SeasonForMonth ¶ added in v1.80.0
SeasonForMonth returns the season constant for a given calendar month. Northern hemisphere: Mar-May spring, Jun-Aug summer, Sep-Nov fall, Dec-Feb winter.
func SqFtToDisplayInt ¶ added in v1.55.0
func SqFtToDisplayInt(sqft int, u UnitSystem) int
SqFtToDisplayInt converts a stored sq ft value to the user's display unit.
func StructDefault ¶ added in v1.77.1
StructDefault returns the default tag value for the named field on the given struct (or pointer-to-struct). Returns "" if the field does not exist or has no default tag.
func TitleFromFilename ¶ added in v1.27.0
TitleFromFilename derives a human-friendly title from a filename by stripping extensions (including compound ones like .tar.gz), splitting on word boundaries via strcase, and title-casing each word.
func ValidateDBPath ¶ added in v1.10.1
ValidateDBPath rejects paths that could be interpreted as URIs by the SQLite driver. The underlying go-sqlite driver passes query strings through net/url.ParseQuery (subject to CVE GO-2026-4341) and enables SQLITE_OPEN_URI, so both file:// URIs and scheme://... URLs must be blocked. Only plain filesystem paths and the special ":memory:" value are accepted.
Types ¶
type Appliance ¶
type Appliance struct {
ID uint `gorm:"primaryKey"`
Name string
Brand string
ModelNumber string
SerialNumber string
PurchaseDate *time.Time ` extract:"-"`
WarrantyExpiry *time.Time `gorm:"index" extract:"-"`
Location string
CostCents *int64
Notes string
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:appliance"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type ChatInput ¶ added in v1.22.0
type ChatInput struct {
ID uint `gorm:"primaryKey"`
Input string `gorm:"not null"`
CreatedAt time.Time
}
ChatInput stores a single chat prompt for cross-session history. Ordered by creation time, newest last.
type DeletionRecord ¶
type Document ¶ added in v1.27.0
type Document struct {
ID uint `gorm:"primaryKey"`
Title string
FileName string `gorm:"column:file_name"`
EntityKind string `gorm:"index:idx_doc_entity"`
EntityID uint `gorm:"index:idx_doc_entity"`
MIMEType string ` extract:"-"`
SizeBytes int64 ` extract:"-"`
ChecksumSHA256 string `gorm:"column:sha256" extract:"-"`
Data []byte
ExtractedText string ` extract:"-"`
ExtractData []byte `gorm:"column:ocr_data"`
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type DocumentSearchResult ¶ added in v1.75.0
type DocumentSearchResult struct {
ID uint
Title string
FileName string
EntityKind string
EntityID uint
Snippet string
UpdatedAt time.Time
}
DocumentSearchResult holds a single FTS5 match with metadata for display.
type EntityRow ¶ added in v1.49.0
EntityRow is a lightweight (id, name) pair for FK context in LLM prompts.
type EntityRowContext ¶ added in v1.49.0
type EntityRowContext struct {
Vendors []EntityRow
Projects []EntityRow
Appliances []EntityRow
MaintenanceItems []EntityRow
MaintenanceCategories []EntityRow
ProjectTypes []EntityRow
}
EntityRowContext provides (id, name) tuples for all FK-referenceable tables so the LLM can generate correct foreign key values in SQL output.
type HouseProfile ¶
type HouseProfile struct {
ID uint `gorm:"primaryKey"`
Nickname string
AddressLine1 string
AddressLine2 string
City string
State string
PostalCode string
YearBuilt int
SquareFeet int
LotSquareFeet int
Bedrooms int
Bathrooms float64
FoundationType string
WiringType string
RoofType string
ExteriorType string
HeatingType string
CoolingType string
WaterSource string
SewerType string
ParkingType string
BasementType string
InsuranceCarrier string
InsurancePolicy string
InsuranceRenewal *time.Time
PropertyTaxCents *int64
HOAName string
HOAFeeCents *int64
CreatedAt time.Time
UpdatedAt time.Time
}
type Incident ¶ added in v1.36.0
type Incident struct {
ID uint `gorm:"primaryKey"`
Title string
Description string
Status string ` default:"open"`
PreviousStatus string ` extract:"-"`
Severity string ` default:"soon"`
DateNoticed time.Time ` default:"now"`
DateResolved *time.Time ` extract:"-"`
Location string
CostCents *int64
ApplianceID *uint `gorm:"index"`
Appliance Appliance `gorm:"constraint:OnDelete:SET NULL;"`
VendorID *uint `gorm:"index"`
Vendor Vendor `gorm:"constraint:OnDelete:SET NULL;"`
Notes string
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:incident"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type MaintenanceCategory ¶
type MaintenanceItem ¶
type MaintenanceItem struct {
ID uint `gorm:"primaryKey"`
Name string
CategoryID uint `gorm:"index"`
Category MaintenanceCategory `gorm:"constraint:OnDelete:RESTRICT;"`
ApplianceID *uint `gorm:"index"`
Appliance Appliance `gorm:"constraint:OnDelete:SET NULL;"`
Season string
LastServicedAt *time.Time ` extract:"-"`
IntervalMonths int
DueDate *time.Time ` extract:"-"`
ManualURL string ` extract:"-"`
ManualText string ` extract:"-"`
Notes string
CostCents *int64
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:maintenance"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type PragmaColumn ¶ added in v1.22.0
type PragmaColumn struct {
CID int `gorm:"column:cid"`
Name string `gorm:"column:name"`
Type string `gorm:"column:type"`
NotNull bool `gorm:"column:notnull"`
DfltValue *string `gorm:"column:dflt_value"`
PK int `gorm:"column:pk"`
}
PragmaColumn mirrors the output of PRAGMA table_info.
type Project ¶
type Project struct {
ID uint `gorm:"primaryKey"`
Title string
ProjectTypeID uint
ProjectType ProjectType `gorm:"constraint:OnDelete:RESTRICT;"`
Status string ` default:"planned"`
Description string
StartDate *time.Time ` extract:"-"`
EndDate *time.Time ` extract:"-"`
BudgetCents *int64
ActualCents *int64 ` extract:"-"`
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:project"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type ProjectType ¶
type Quote ¶
type Quote struct {
ID uint `gorm:"primaryKey"`
ProjectID uint `gorm:"index"`
Project Project `gorm:"constraint:OnDelete:RESTRICT;"`
VendorID uint `gorm:"index"`
Vendor Vendor `gorm:"constraint:OnDelete:RESTRICT;"`
TotalCents int64
LaborCents *int64
MaterialsCents *int64
OtherCents *int64 ` extract:"-"`
ReceivedDate *time.Time ` extract:"-"`
Notes string
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:quote"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type SeedSummary ¶ added in v1.33.0
type SeedSummary struct {
Vendors int
Projects int
Quotes int
Appliances int
Maintenance int
Incidents int
ServiceLogs int
Documents int
}
SeedSummary holds counts of generated entities for display after seeding.
type ServiceLogEntry ¶
type ServiceLogEntry struct {
ID uint `gorm:"primaryKey"`
MaintenanceItemID uint `gorm:"index"`
MaintenanceItem MaintenanceItem `gorm:"constraint:OnDelete:CASCADE;"`
ServicedAt time.Time
VendorID *uint `gorm:"index"`
Vendor Vendor `gorm:"constraint:OnDelete:SET NULL;"`
CostCents *int64
Notes string
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:service_log"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type Setting ¶ added in v1.22.0
Setting is a simple key-value store for app preferences that persist across sessions (e.g. last-used LLM model). Stored in SQLite so a single "micasa backup backup.db" captures everything.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AppendChatInput ¶ added in v1.22.0
AppendChatInput adds a prompt to the persistent history, deduplicating consecutive repeats. Trims old entries beyond chatHistoryMax.
func (*Store) AutoMigrate ¶
func (*Store) Backup ¶ added in v1.38.0
Backup creates a consistent snapshot of the database at destPath using SQLite's Online Backup API. The destination must not already exist. After copying, it runs PRAGMA integrity_check on the backup to verify internal consistency.
func (*Store) ColumnHints ¶ added in v1.22.0
ColumnHints queries the database for distinct values in key columns and returns them as a formatted string suitable for inclusion in an LLM prompt. Returns empty string if no hints are available.
func (*Store) CountDocumentsByEntity ¶ added in v1.27.0
func (s *Store) CountDocumentsByEntity( entityKind string, entityIDs []uint, ) (map[uint]int, error)
CountDocumentsByEntity counts non-deleted documents grouped by entity_id where entity_kind matches. Uses a custom query because documents use two-column polymorphic keys that countByFK can't handle.
func (*Store) CountIncidentsByAppliance ¶ added in v1.36.0
func (*Store) CountIncidentsByVendor ¶ added in v1.36.0
func (*Store) CountMaintenanceByAppliance ¶
CountMaintenanceByAppliance returns the count of non-deleted maintenance items for each appliance ID.
func (*Store) CountQuotesByProject ¶ added in v1.18.0
CountQuotesByProject returns the number of non-deleted quotes per project 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) CreateDocument ¶ added in v1.27.0
func (*Store) CreateHouseProfile ¶
func (s *Store) CreateHouseProfile(profile HouseProfile) error
func (*Store) CreateIncident ¶ added in v1.36.0
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) DataDump ¶ added in v1.22.0
DataDump exports every row of every user table as readable text, suitable for stuffing into an LLM context window. For a home-scale database this is small enough to fit comfortably.
Unlike ReadOnlyQuery this bypasses the row cap and keyword filter -- table names come from sqlite_master so the queries are fully trusted.
The output is optimized for small LLMs: null/empty values are omitted, money columns (ending in "_ct") are formatted as dollars, and internal columns (id, created_at, updated_at, deleted_at) are excluded to reduce noise.
func (*Store) DeleteAppliance ¶
func (*Store) DeleteDocument ¶ added in v1.27.0
func (*Store) DeleteIncident ¶ added in v1.36.0
func (*Store) DeleteMaintenance ¶
func (*Store) DeleteProject ¶
func (*Store) DeleteQuote ¶
func (*Store) DeleteServiceLog ¶
func (*Store) DeleteVendor ¶ added in v1.11.0
func (*Store) EntityNames ¶ added in v1.45.0
EntityNames returns the names of all active (non-deleted) vendors, projects, and appliances. Used to provide context for LLM extraction so it can match extracted references against known entities.
func (*Store) EntityRows ¶ added in v1.49.0
func (s *Store) EntityRows() (EntityRowContext, error)
EntityRows returns (id, name) pairs for all active entities that an extraction prompt might reference as foreign keys.
func (*Store) ExtractDocument ¶ added in v1.27.0
ExtractDocument writes the document's BLOB content to the XDG cache directory and returns the resulting filesystem path. If the cached file already exists and has the expected size, the extraction is skipped.
func (*Store) FindOrCreateAppliance ¶ added in v1.61.0
FindOrCreateAppliance looks up an appliance by name. If found, returns it. If not found, creates a new one. Soft-deleted appliances with the same name are restored.
func (*Store) FindOrCreateMaintenance ¶ added in v1.61.0
func (s *Store) FindOrCreateMaintenance(item MaintenanceItem) (MaintenanceItem, error)
FindOrCreateMaintenance looks up a maintenance item by name and category. If found, returns it. If not found, creates a new one. Soft-deleted items with the same name+category are restored.
func (*Store) FindOrCreateVendor ¶ added in v1.61.0
FindOrCreateVendor looks up a vendor by name. If found, updates its contact fields and returns it. If not found, creates a new one. Soft-deleted vendors with the same name are restored.
func (*Store) GetCurrency ¶ added in v1.56.0
GetCurrency returns the persisted currency code (e.g. "USD", "EUR"), or "" if none has been set.
func (*Store) GetDocumentMetadata ¶ added in v1.69.1
GetDocumentMetadata loads a document by ID without the Data BLOB, ExtractData, or other heavy columns. Use GetDocument when you need the file bytes.
func (*Store) GetLastModel ¶ added in v1.22.0
GetLastModel returns the persisted LLM model name, or "" if none.
func (*Store) GetMaintenance ¶
func (s *Store) GetMaintenance(id uint) (MaintenanceItem, error)
func (*Store) GetServiceLog ¶
func (s *Store) GetServiceLog(id uint) (ServiceLogEntry, error)
func (*Store) GetSetting ¶ added in v1.22.0
GetSetting retrieves a setting by key. Returns ("", nil) if not found.
func (*Store) GetShowDashboard ¶ added in v1.24.0
GetShowDashboard returns whether the dashboard should be shown on startup. Defaults to true when no preference has been saved.
func (*Store) GetUnitSystem ¶ added in v1.55.0
func (s *Store) GetUnitSystem() (UnitSystem, error)
GetUnitSystem returns the persisted unit system preference, falling back to locale-based detection if no preference has been saved.
func (*Store) HardDeleteIncident ¶ added in v1.60.0
func (*Store) HouseProfile ¶
func (s *Store) HouseProfile() (HouseProfile, error)
func (*Store) IsMicasaDB ¶ added in v1.38.0
IsMicasaDB returns true if the database contains the core micasa tables.
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) ListDocuments ¶ added in v1.27.0
func (*Store) ListDocumentsByEntity ¶ added in v1.27.0
func (s *Store) ListDocumentsByEntity( entityKind string, entityID uint, includeDeleted bool, ) ([]Document, error)
ListDocumentsByEntity returns documents scoped to a specific entity, excluding the BLOB data.
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) ListIncidents ¶ added in v1.36.0
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) ListMaintenanceBySeason ¶ added in v1.80.0
func (s *Store) ListMaintenanceBySeason(season string) ([]MaintenanceItem, error)
ListMaintenanceBySeason returns non-deleted maintenance items tagged with the given season, preloading Category and Appliance.
func (*Store) ListMaintenanceWithSchedule ¶
func (s *Store) ListMaintenanceWithSchedule() ([]MaintenanceItem, error)
ListMaintenanceWithSchedule returns all non-deleted maintenance items that have a positive interval or an explicit due date, preloading Category and Appliance. These are the items eligible for overdue/upcoming computation.
func (*Store) ListOpenIncidents ¶ added in v1.36.0
ListOpenIncidents returns non-deleted incidents (open or in-progress), preloading Appliance and Vendor. Ordered by severity (urgent first) then most recently updated.
func (*Store) ListQuotesByProject ¶ added in v1.18.0
ListQuotesByProject returns all quotes for a specific project.
func (*Store) ListQuotesByVendor ¶ added in v1.18.0
ListQuotesByVendor returns all quotes for a specific vendor.
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) ListServiceLogsByVendor ¶ added in v1.18.0
func (s *Store) ListServiceLogsByVendor( vendorID uint, includeDeleted bool, ) ([]ServiceLogEntry, error)
ListServiceLogsByVendor returns all service log entries for a specific vendor.
func (*Store) LoadChatHistory ¶ added in v1.22.0
LoadChatHistory returns all persisted chat inputs, oldest first.
func (*Store) MaintenanceCategories ¶
func (s *Store) MaintenanceCategories() ([]MaintenanceCategory, error)
func (*Store) MarkTesseractHintSeen ¶ added in v1.45.0
MarkTesseractHintSeen records that the tesseract hint was shown.
func (*Store) MaxDocumentSize ¶ added in v1.29.0
MaxDocumentSize returns the configured maximum file size for document imports.
func (*Store) MaxIDs ¶ added in v1.61.0
MaxIDs returns the current maximum auto-increment ID for each of the named tables. Tables with no rows are omitted from the result.
func (*Store) ProjectTypes ¶
func (s *Store) ProjectTypes() ([]ProjectType, error)
func (*Store) PutCurrency ¶ added in v1.56.0
PutCurrency persists the currency code to the database.
func (*Store) PutLastModel ¶ added in v1.22.0
PutLastModel persists the LLM model name.
func (*Store) PutSetting ¶ added in v1.22.0
PutSetting upserts a setting.
func (*Store) PutShowDashboard ¶ added in v1.24.0
PutShowDashboard persists the user's dashboard visibility preference.
func (*Store) PutUnitSystem ¶ added in v1.55.0
func (s *Store) PutUnitSystem(u UnitSystem) error
PutUnitSystem persists the user's unit system preference.
func (*Store) ReadOnlyQuery ¶ added in v1.22.0
ReadOnlyQuery executes a validated SELECT query and returns the results as string slices. Only SELECT/WITH statements are allowed; result rows are capped at maxQueryRows.
Validation is layered for defense-in-depth:
- Fast prefix check: query must start with SELECT or WITH (after stripping whitespace and SQL comments).
- Semicolon check: rejects multi-statement payloads.
- Keyword blocklist (containsWord): catches obvious mutation keywords.
- EXPLAIN opcode check: runs EXPLAIN on the query and rejects it if any write-related VDBE opcodes appear. This is the primary structural validation and catches attacks that bypass keyword matching.
- Timeout: the actual query runs under a 10-second context deadline to prevent long-running queries from hanging the app.
func (*Store) RebuildFTSIndex ¶ added in v1.75.0
RebuildFTSIndex forces a full rebuild of the FTS5 index. Useful after bulk imports or data recovery.
func (*Store) ResolveCurrency ¶ added in v1.56.0
ResolveCurrency determines the currency to use. The database value is authoritative for the currency CODE; if unset, resolves from configured/env/locale and persists the code for portability. The formatting locale is always detected from the environment (never persisted) -- like displaying a UTC timestamp in the local timezone.
func (*Store) RestoreAppliance ¶
func (*Store) RestoreDocument ¶ added in v1.27.0
func (*Store) RestoreIncident ¶ added in v1.36.0
func (*Store) RestoreMaintenance ¶
func (*Store) RestoreProject ¶
func (*Store) RestoreQuote ¶
func (*Store) RestoreServiceLog ¶
func (*Store) RestoreVendor ¶ added in v1.11.0
func (*Store) SearchDocuments ¶ added in v1.75.0
func (s *Store) SearchDocuments(query string) ([]DocumentSearchResult, error)
SearchDocuments performs a full-text search across document titles, notes, and extracted text. Returns results ranked by BM25 relevance with text snippets showing matched context. Only non-deleted documents are returned.
func (*Store) SeedDefaults ¶
func (*Store) SeedDemoData ¶
SeedDemoData populates the database with realistic demo data using a fixed seed so the demo always looks the same. Skips if data already exists.
func (*Store) SeedDemoDataFrom ¶ added in v1.10.0
SeedDemoDataFrom populates the database with demo data generated by the given HomeFaker. Callers can pass different seeds for varied test data.
func (*Store) SeedScaledData ¶ added in v1.33.0
func (s *Store) SeedScaledData(years int) (SeedSummary, error)
SeedScaledData populates the database with years of simulated home ownership data using a fixed seed for deterministic output. Skips if data already exists.
func (*Store) SeedScaledDataFrom ¶ added in v1.33.0
SeedScaledDataFrom populates the database with scaled demo data generated by the given HomeFaker. The years parameter controls how many years of simulated home ownership to generate.
func (*Store) SetCurrency ¶ added in v1.56.0
SetCurrency directly sets the cached currency without touching the database. Intended for tests that need a currency but don't require full resolution.
func (*Store) SetMaxDocumentSize ¶ added in v1.27.0
SetMaxDocumentSize overrides the maximum allowed file size for document imports. The value must be positive; zero is rejected.
func (*Store) TableColumns ¶ added in v1.22.0
func (s *Store) TableColumns(table string) ([]PragmaColumn, error)
TableColumns returns column metadata for the named table via PRAGMA. The table name is validated to contain only safe characters.
func (*Store) TableDDL ¶ added in v1.49.0
TableDDL returns the CREATE TABLE SQL for each of the named tables, as stored in sqlite_master. Tables that don't exist are silently omitted.
func (*Store) TableNames ¶ added in v1.22.0
TableNames returns the names of all non-internal tables in the database.
func (*Store) TesseractHintSeen ¶ added in v1.45.0
TesseractHintSeen returns whether the one-time "install tesseract" hint has already been shown to the user.
func (*Store) TotalProjectSpendCents ¶ added in v1.29.0
TotalProjectSpendCents returns the total actual spend across all non-deleted projects. Unlike service log entries (which have a serviced_at date), projects have no per-transaction date, so YTD filtering is not meaningful. The previous updated_at filter was incorrect: editing any project field (e.g. description) would cause its spend to appear/disappear from the total.
func (*Store) Transaction ¶ added in v1.61.0
Transaction executes fn inside a database transaction. The callback receives a transactional Store that shares all methods but operates on the transaction. If fn returns an error the transaction is rolled back; otherwise it is committed.
func (*Store) UpdateAppliance ¶
func (*Store) UpdateDocument ¶ added in v1.27.0
UpdateDocument persists changes to a document. Entity linkage (EntityID, EntityKind) is always preserved -- callers must use a dedicated method to re-link a document. When Data is empty the existing BLOB and file metadata columns are also preserved, so metadata-only edits don't erase the file.
func (*Store) UpdateDocumentExtraction ¶ added in v1.47.0
UpdateDocumentExtraction persists async extraction results on a document without touching other fields. Called from the extraction overlay after async extraction completes.
func (*Store) UpdateHouseProfile ¶
func (s *Store) UpdateHouseProfile(profile HouseProfile) error
func (*Store) UpdateIncident ¶ added in v1.36.0
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) WalCheckpoint ¶ added in v1.64.1
WalCheckpoint runs a WAL checkpoint that flushes the WAL into the main database file and truncates the WAL. This ensures the .db file is self-contained with no -wal or -shm sidecars.
type UnitSystem ¶ added in v1.55.0
type UnitSystem int
UnitSystem distinguishes imperial (sq ft) from metric (m^2) display.
const ( UnitsImperial UnitSystem = iota UnitsMetric )
func ParseUnitSystem ¶ added in v1.55.0
func ParseUnitSystem(s string) UnitSystem
ParseUnitSystem parses a setting value into a UnitSystem. Returns UnitsImperial for unrecognized or empty input.
func UnitSystemForLocale ¶ added in v1.56.0
func UnitSystemForLocale(tag language.Tag) UnitSystem
UnitSystemForLocale returns the unit system appropriate for the given locale tag. Returns imperial for US, LR, MM regions; metric otherwise. Use locale.DetectLocale() to obtain the tag from the environment.
func (UnitSystem) String ¶ added in v1.55.0
func (u UnitSystem) String() string
String returns the canonical string representation stored in settings.
type Vendor ¶
type Vendor struct {
ID uint `gorm:"primaryKey"`
Name string `gorm:"uniqueIndex"`
ContactName string
Email string
Phone string
Website string
Notes string
Documents []Document `gorm:"polymorphic:Entity;polymorphicType:EntityKind;polymorphicValue:vendor"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}