moving insert to another model and done so in database internal

This commit is contained in:
samantha42
2026-03-25 21:58:08 +01:00
parent 2dccca5da1
commit d491b9c14c
11 changed files with 85 additions and 83 deletions

View File

@@ -3,7 +3,6 @@ package handlers
import (
"Portifolio/internal/database"
"Portifolio/internal/model"
"Portifolio/internal/service"
"database/sql"
"encoding/json"
"fmt"
@@ -41,7 +40,16 @@ func AddRevenueEntryHandler(db *sql.DB) http.HandlerFunc {
return
}
if err := service.InsertRevenue(db, input.CompanyID, input.CurrencyID, input.Category, nil, input.Value, period); err != nil {
rev := model.RevenueInsert{
CompanyID: input.CompanyID,
CurrencyID: input.CurrencyID,
CategoryName: input.Category,
Period: period,
Value: input.Value,
}
err := database.InsertRevenue(db, rev)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}