mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 10:42:57 +00:00
261 lines
10 KiB
Go
261 lines
10 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Budget represents a budget category with limits and tracking
|
|
type Budget struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
Name string `json:"name" gorm:"not null;size:255"`
|
|
Description string `json:"description" gorm:"type:text"`
|
|
Category string `json:"category" gorm:"size:100;index"` // např. "Týmové provoz", "Stadion", "Marketing", "Cestování"
|
|
|
|
// Budget limits and tracking
|
|
YearlyLimit float64 `json:"yearly_limit" gorm:"type:decimal(12,2)"`
|
|
MonthlyLimit float64 `json:"monthly_limit" gorm:"type:decimal(12,2)"`
|
|
CurrentSpend float64 `json:"current_spend" gorm:"type:decimal(12,2);default:0"`
|
|
|
|
// Budget period
|
|
FiscalYear int `json:"fiscal_year" gorm:"index"`
|
|
StartDate time.Time `json:"start_date"`
|
|
EndDate time.Time `json:"end_date"`
|
|
|
|
// Status and management
|
|
Active bool `json:"active" gorm:"default:true"`
|
|
AlertThreshold float64 `json:"alert_threshold" gorm:"type:decimal(5,2);default:80"` // % pro varování
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
|
|
// Relations
|
|
Expenses []Expense `json:"expenses,omitempty" gorm:"foreignKey:BudgetID"`
|
|
}
|
|
|
|
// Sponsorship represents sponsorship contracts and tracking
|
|
type Sponsorship struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
SponsorName string `json:"sponsor_name" gorm:"not null;size:255"`
|
|
SponsorLogo string `json:"sponsor_logo" gorm:"size:500"`
|
|
ContactPerson string `json:"contact_person" gorm:"size:255"`
|
|
ContactEmail string `json:"contact_email" gorm:"size:255"`
|
|
ContactPhone string `json:"contact_phone" gorm:"size:50"`
|
|
|
|
// Contract details
|
|
ContractNumber string `json:"contract_number" gorm:"size:100;uniqueIndex"`
|
|
ContractType string `json:"contract_type" gorm:"size:100"` // "Hlavní", "Technický", "Mediální", "Akce"
|
|
|
|
// Financial terms
|
|
TotalValue float64 `json:"total_value" gorm:"type:decimal(12,2)"`
|
|
PaymentSchedule string `json:"payment_schedule" gorm:"size:100"` // "Měsíčně", "Čtvrtletně", "Ročně", "Jednorázově"
|
|
Currency string `json:"currency" gorm:"size:3;default:'CZK'"`
|
|
|
|
// Contract period
|
|
StartDate time.Time `json:"start_date"`
|
|
EndDate time.Time `json:"end_date"`
|
|
AutoRenewal bool `json:"auto_renewal" gorm:"default:false"`
|
|
RenewalNotice int `json:"renewal_notice" gorm:"default:90"` // dní předem
|
|
|
|
// Benefits and obligations
|
|
Benefits string `json:"benefits" gorm:"type:text"` // JSON s detaily benefitů
|
|
Obligations string `json:"obligations" gorm:"type:text"`
|
|
|
|
// Status tracking
|
|
Status string `json:"status" gorm:"size:50;default:'active'"` // "active", "expired", "terminated", "pending"
|
|
LastPaymentDate time.Time `json:"last_payment_date"`
|
|
NextPaymentDate time.Time `json:"next_payment_date"`
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
|
|
// Relations
|
|
Payments []SponsorshipPayment `json:"payments,omitempty" gorm:"foreignKey:SponsorshipID"`
|
|
Documents []SponsorshipDocument `json:"documents,omitempty" gorm:"foreignKey:SponsorshipID"`
|
|
}
|
|
|
|
// SponsorshipPayment tracks individual payments from sponsors
|
|
type SponsorshipPayment struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
SponsorshipID uint `json:"sponsorship_id" gorm:"not null;index"`
|
|
|
|
// Payment details
|
|
Amount float64 `json:"amount" gorm:"type:decimal(12,2)"`
|
|
Currency string `json:"currency" gorm:"size:3;default:'CZK'"`
|
|
PaymentDate time.Time `json:"payment_date"`
|
|
PaymentMethod string `json:"payment_method" gorm:"size:100"` // "Bankovní převod", "Hotovost", "Karta"
|
|
|
|
// Reference and status
|
|
ReferenceNumber string `json:"reference_number" gorm:"size:255"`
|
|
Status string `json:"status" gorm:"size:50;default:'received'"` // "expected", "received", "overdue", "cancelled"
|
|
Notes string `json:"notes" gorm:"type:text"`
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
|
|
// Relations
|
|
Sponsorship Sponsorship `json:"sponsorship,omitempty" gorm:"foreignKey:SponsorshipID"`
|
|
}
|
|
|
|
// SponsorshipDocument stores contract documents and related files
|
|
type SponsorshipDocument struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
SponsorshipID uint `json:"sponsorship_id" gorm:"not null;index"`
|
|
|
|
// Document details
|
|
Name string `json:"name" gorm:"not null;size:255"`
|
|
Type string `json:"type" gorm:"size:100"` // "Smlouva", "Faktura", "Dodatek", "Jiný"
|
|
FileName string `json:"file_name" gorm:"size:500"`
|
|
FilePath string `json:"file_path" gorm:"size:500"`
|
|
FileSize int64 `json:"file_size"`
|
|
MimeType string `json:"mime_type" gorm:"size:100"`
|
|
|
|
// Document metadata
|
|
Description string `json:"description" gorm:"type:text"`
|
|
Version string `json:"version" gorm:"size:20;default:'1.0'"`
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
|
|
// Relations
|
|
Sponsorship Sponsorship `json:"sponsorship,omitempty" gorm:"foreignKey:SponsorshipID"`
|
|
}
|
|
|
|
// Expense represents individual expenses with receipt tracking
|
|
type Expense struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
|
|
// Basic expense info
|
|
Title string `json:"title" gorm:"not null;size:255"`
|
|
Description string `json:"description" gorm:"type:text"`
|
|
Category string `json:"category" gorm:"size:100;index"` // "Cestování", "Materiál", "Služby", "Strava", "Ubytování"
|
|
Subcategory string `json:"subcategory" gorm:"size:100"`
|
|
|
|
// Financial details
|
|
Amount float64 `json:"amount" gorm:"type:decimal(12,2)"`
|
|
Currency string `json:"currency" gorm:"size:3;default:'CZK'"`
|
|
VATRate float64 `json:"vat_rate" gorm:"type:decimal(5,2);default:21"` // DPH sazba v %
|
|
VATAmount float64 `json:"vat_amount" gorm:"type:decimal(12,2)"`
|
|
TotalAmount float64 `json:"total_amount" gorm:"type:decimal(12,2)"`
|
|
|
|
// Expense details
|
|
ExpenseDate time.Time `json:"expense_date"`
|
|
PaymentMethod string `json:"payment_method" gorm:"size:100"` // "Hotovost", "Karta", "Faktura", "Proforma"
|
|
|
|
// Receipt and documentation
|
|
HasReceipt bool `json:"has_receipt" gorm:"default:false"`
|
|
ReceiptData string `json:"receipt_data" gorm:"type:text"` // OCR data z paragonu
|
|
ReceiptImage string `json:"receipt_image" gorm:"size:500"` // cesta k obrázku paragonu
|
|
|
|
// Approval workflow
|
|
Status string `json:"status" gorm:"size:50;default:'pending'"` // "pending", "approved", "rejected", "reimbursed"
|
|
ApprovedBy uint `json:"approved_by"`
|
|
ApprovedAt *time.Time `json:"approved_at"`
|
|
RejectionReason string `json:"rejection_reason" gorm:"type:text"`
|
|
|
|
// Budget tracking
|
|
BudgetID *uint `json:"budget_id" gorm:"index"`
|
|
TeamID *uint `json:"team_id" gorm:"index"` // přiřazení k týmu
|
|
ProjectID *uint `json:"project_id" gorm:"index"` // přiřazení k projektu
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
|
|
// Relations
|
|
Budget *Budget `json:"budget,omitempty" gorm:"foreignKey:BudgetID"`
|
|
Documents []ExpenseDocument `json:"documents,omitempty" gorm:"foreignKey:ExpenseID"`
|
|
}
|
|
|
|
// ExpenseDocument stores expense-related documents
|
|
type ExpenseDocument struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
ExpenseID uint `json:"expense_id" gorm:"not null;index"`
|
|
|
|
// Document details
|
|
Name string `json:"name" gorm:"not null;size:255"`
|
|
Type string `json:"type" gorm:"size:100"` // "Paragon", "Faktura", "Smlouva", "Jiný"
|
|
FileName string `json:"file_name" gorm:"size:500"`
|
|
FilePath string `json:"file_path" gorm:"size:500"`
|
|
FileSize int64 `json:"file_size"`
|
|
MimeType string `json:"mime_type" gorm:"size:100"`
|
|
|
|
// OCR data for receipts
|
|
OCRData string `json:"ocr_data" gorm:"type:text"`
|
|
OCRAccuracy float64 `json:"ocr_accuracy" gorm:"type:decimal(5,2)"` // spolehlivost OCR v %
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
|
|
// Relations
|
|
Expense Expense `json:"expense,omitempty" gorm:"foreignKey:ExpenseID"`
|
|
}
|
|
|
|
// FinancialReport represents generated financial reports
|
|
type FinancialReport struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
|
|
// Report details
|
|
Name string `json:"name" gorm:"not null;size:255"`
|
|
Type string `json:"type" gorm:"size:100"` // "monthly", "quarterly", "yearly", "custom"
|
|
Period string `json:"period" gorm:"size:50"` // "2024-01", "Q1-2024", "2024", "custom"
|
|
|
|
// Report data
|
|
ReportData string `json:"report_data" gorm:"type:text"` // JSON s daty reportu
|
|
Summary string `json:"summary" gorm:"type:text"`
|
|
|
|
// File generation
|
|
FilePath string `json:"file_path" gorm:"size:500"`
|
|
GeneratedAt time.Time `json:"generated_at"`
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedBy uint `json:"created_by"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
}
|
|
|
|
// FinancialSettings stores club-wide financial configuration
|
|
type FinancialSettings struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
|
|
// Budget settings
|
|
DefaultCurrency string `json:"default_currency" gorm:"size:3;default:'CZK'"`
|
|
DefaultVATRate float64 `json:"default_vat_rate" gorm:"type:decimal(5,2);default:21"`
|
|
FiscalYearStart string `json:"fiscal_year_start" gorm:"size:10;default:'01-01'"` // MM-DD format
|
|
|
|
// Approval settings
|
|
ExpenseApprovalRequired bool `json:"expense_approval_required" gorm:"default:true"`
|
|
MaxExpenseAutoApprove float64 `json:"max_expense_auto_approve" gorm:"type:decimal(12,2);default:1000"`
|
|
|
|
// Notification settings
|
|
BudgetAlertEnabled bool `json:"budget_alert_enabled" gorm:"default:true"`
|
|
BudgetAlertThreshold float64 `json:"budget_alert_threshold" gorm:"type:decimal(5,2);default:80"`
|
|
SponsorshipAlertEnabled bool `json:"sponsorship_alert_enabled" gorm:"default:true"`
|
|
|
|
// OCR settings
|
|
OCRServiceEnabled bool `json:"ocr_service_enabled" gorm:"default:true"`
|
|
OCRProvider string `json:"ocr_provider" gorm:"size:50;default:'tesseract'"` // "tesseract", "google", "azure"
|
|
|
|
// Metadata
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
UpdatedBy uint `json:"updated_by"`
|
|
}
|