Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedProvider ¶
Types ¶
type FieldMapping ¶
type FieldMapping struct {
Source string // Manual source input (e.g., "Chase Bank")
DateColumn int // Index of date column
DescriptionColumn int // Index of description column
AmountColumn int // Index of amount column
CurrencyColumn int // Index of currency column
}
FieldMapping defines how file columns map to expense fields.
func (*FieldMapping) Validate ¶
func (m *FieldMapping) Validate(headerCount int) error
Validate checks if the field mapping is valid.
type ImportInfo ¶
func ImportJSON ¶
func ImportJSON(ctx context.Context, userID int64, expenses []JSONExpense, storage storageType.Storage, categoryMatcher *matcher.Matcher) ImportInfo
type ImportSession ¶
type ImportSession struct {
ID string
Filename string
Data *ParsedData
Mapping *FieldMapping
CreatedAt time.Time
ExpiresAt time.Time
}
ImportSession stores temporary data for a multi-step import process.
type JSONExpense ¶
type JSONExpense struct {
Source string `json:"source"`
Date time.Time `json:"date"`
Description string `json:"description"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
}
func SupportedJSONSchema ¶
func SupportedJSONSchema(reader io.Reader) (bool, []JSONExpense)
type MappingResult ¶
MappingResult contains the results of applying a field mapping.
func ApplyMapping ¶
func ApplyMapping( data *ParsedData, mapping *FieldMapping, categoryMatcher *matcher.Matcher, ) (*MappingResult, error)
ApplyMapping applies the field mapping to parsed data and creates expenses.
type ParsedData ¶
type ParsedData struct {
Headers []string // Column headers/field names
Rows [][]string // Data rows (all values as strings)
Format string // File format (csv or json)
}
ParsedData represents the raw data extracted from a file.
func ParseFile ¶
func ParseFile(filename string, reader io.Reader) (*ParsedData, error)
ParseFile parses a CSV or JSON file and extracts headers and rows without making assumptions about structure or field mapping.
func (*ParsedData) GetPreviewRows ¶
func (p *ParsedData) GetPreviewRows(n int) [][]string
GetPreviewRows returns the first N rows for preview purposes.
func (*ParsedData) GetTotalRows ¶
func (p *ParsedData) GetTotalRows() int
GetTotalRows returns the total number of data rows.
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore manages import sessions with automatic cleanup.
func NewSessionStore ¶
func NewSessionStore(ttl time.Duration) *SessionStore
NewSessionStore creates a new session store with the specified TTL.
func (*SessionStore) Create ¶
func (s *SessionStore) Create(filename string, data *ParsedData) string
Create creates a new import session and returns its ID.
func (*SessionStore) Delete ¶
func (s *SessionStore) Delete(sessionID string)
Delete removes a session from the store.
func (*SessionStore) Get ¶
func (s *SessionStore) Get(sessionID string) (*ImportSession, bool)
Get retrieves a session by ID.
func (*SessionStore) Update ¶
func (s *SessionStore) Update(sessionID string, mapping *FieldMapping) bool
Update updates an existing session.