feat: add finance module with yearly income/expense tracking
- FinanceEntry model (income/expense x fixed/extra) - CRUD API endpoints for finance entries - FinancePage with summary cards and drill-down - Updated navigation with Finance tab - Updated todos default filter to active
This commit is contained in:
@@ -76,3 +76,35 @@ func (r *DailyLogRepository) Upsert(log *model.DailyLog) error {
|
||||
existing.Evening = log.Evening
|
||||
return r.db.Save(&existing).Error
|
||||
}
|
||||
|
||||
type FinanceRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewFinanceRepository(db *gorm.DB) *FinanceRepository {
|
||||
return &FinanceRepository{db: db}
|
||||
}
|
||||
|
||||
func (r *FinanceRepository) GetByYear(year int) ([]model.FinanceEntry, error) {
|
||||
var entries []model.FinanceEntry
|
||||
err := r.db.Where("year = ?", year).Order("month ASC, id ASC").Find(&entries).Error
|
||||
return entries, err
|
||||
}
|
||||
|
||||
func (r *FinanceRepository) Create(entry *model.FinanceEntry) error {
|
||||
return r.db.Create(entry).Error
|
||||
}
|
||||
|
||||
func (r *FinanceRepository) Update(entry *model.FinanceEntry) error {
|
||||
return r.db.Save(entry).Error
|
||||
}
|
||||
|
||||
func (r *FinanceRepository) Delete(id uint64) error {
|
||||
return r.db.Delete(&model.FinanceEntry{}, id).Error
|
||||
}
|
||||
|
||||
func (r *FinanceRepository) GetByID(id uint64) (*model.FinanceEntry, error) {
|
||||
var entry model.FinanceEntry
|
||||
err := r.db.First(&entry, id).Error
|
||||
return &entry, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user