importers

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionTypeUnknown          = TransactionType(0)
	TransactionTypeIncome           = TransactionType(1)
	TransactionTypeExpense          = TransactionType(2)
	TransactionTypeInternalTransfer = TransactionType(3)
	TransactionTypeRemoteTransfer   = TransactionType(4)
)

Variables

View Source
var ErrNoReferenceNumbers = errors.New("no valid reference numbers to ignore")

Functions

This section is empty.

Types

type AccountSvc

type AccountSvc interface {
	GetAllAccounts(ctx context.Context) ([]*database.Account, error)
}

type BaseParser added in v0.2.9

type BaseParser struct {
	// contains filtered or unexported fields
}

func NewBaseParser added in v0.2.9

func NewBaseParser(
	svc CurrencyConverterSvc,
	txSvc TransactionSvc,
	mapper MapperSvc,
) *BaseParser

func (*BaseParser) DecodeFiles added in v0.2.9

func (b *BaseParser) DecodeFiles(
	records []string,
) ([][]byte, error)

func (*BaseParser) GenerateHash added in v0.2.9

func (b *BaseParser) GenerateHash(input string) string

func (*BaseParser) GetAccountAndAmount added in v0.2.9

func (b *BaseParser) GetAccountAndAmount(
	ctx context.Context,
	req *GetAccountRequest,
) (*GetSecondaryAccountResponse, error)

func (*BaseParser) GetAccountMapByNumbers added in v0.2.9

func (b *BaseParser) GetAccountMapByNumbers(
	accounts []*database.Account,
) (map[string]*database.Account, error)

func (*BaseParser) GetDefaultAccountAndAmount added in v0.2.9

func (b *BaseParser) GetDefaultAccountAndAmount(
	ctx context.Context,
	req *GetAccountRequest,
) (*GetSecondaryAccountResponse, error)

func (*BaseParser) ToCreateRequests added in v0.2.9

func (b *BaseParser) ToCreateRequests(
	ctx context.Context,
	transactions []*Transaction,
	skipRules bool,
	accountMap map[string]*database.Account,
	importSource importv1.ImportSource,
) ([]*transactionsv1.CreateTransactionRequest, error)

type CategoriesSvc

type CategoriesSvc interface {
	GetAllCategories(ctx context.Context) ([]*database.Category, error)
}

type CurrencyConverterSvc added in v0.2.0

type CurrencyConverterSvc interface {
	Convert(
		ctx context.Context,
		fromCurrency string,
		toCurrency string,
		amount decimal.Decimal,
	) (decimal.Decimal, error)
}

type DeduplicationItem added in v0.2.9

type DeduplicationItem struct {
	CreateRequest            *transactionsv1.CreateTransactionRequest
	DuplicationTransactionID *int64
	Ignored                  bool
}

type FireflyImporter

type FireflyImporter struct {
	*BaseParser
	// contains filtered or unexported fields
}

func NewFireflyImporter

func NewFireflyImporter(
	txSvc TransactionSvc,
	converter CurrencyConverterSvc,
	parser *BaseParser,
) *FireflyImporter

func (*FireflyImporter) Parse added in v0.2.9

func (f *FireflyImporter) Parse(
	ctx context.Context,
	req *ParseRequest,
) (*ParseResponse, error)

func (*FireflyImporter) ParseDate

func (f *FireflyImporter) ParseDate(
	date string,
	treatAsUtc bool,
) (time.Time, error)

func (*FireflyImporter) ParseSingleFile added in v0.2.9

func (f *FireflyImporter) ParseSingleFile(
	ctx context.Context,
	req *ParseRequest,
	content []byte,
) (*ParseResponse, error)

func (*FireflyImporter) Type

type GetAccountRequest added in v0.2.9

type GetAccountRequest struct {
	InitialAmount   decimal.Decimal
	InitialCurrency string

	Accounts    map[string]*database.Account
	AccountName string

	TransactionType gomoneypbv1.TransactionType
}

type GetSecondaryAccountResponse added in v0.2.0

type GetSecondaryAccountResponse struct {
	Account                 *database.Account
	AmountInAccountCurrency decimal.Decimal // always positive
}

type Implementation

type Implementation interface {
	Parse(ctx context.Context, req *ParseRequest) (*ParseResponse, error)
	Type() importv1.ImportSource
}

type ImportRequest

type ImportRequest struct {
	Data            []string
	Accounts        []*database.Account
	Tags            map[string]*database.Tag
	Categories      map[string]*database.Category
	SkipRules       bool
	TreatDatesAsUtc bool
}

type Importer

type Importer struct {
	// contains filtered or unexported fields
}

func NewImporter

func NewImporter(
	cfg *ImporterConfig,
	impl ...Implementation,
) *Importer

func (*Importer) CheckDuplicates added in v0.2.9

func (i *Importer) CheckDuplicates(
	ctx context.Context,
	requests []*transactionsv1.CreateTransactionRequest,
	skipDuplicateRefCheck bool,
) ([]*DeduplicationItem, error)

func (*Importer) ConvertRequestsToTransactions added in v0.2.9

func (i *Importer) ConvertRequestsToTransactions(
	ctx context.Context,
	requests []*DeduplicationItem,
	skipRules bool,
) ([]*importv1.ParseTransactionsResponse_ParsedTransaction, error)

func (*Importer) MarkTransactionsIgnored added in v1.7.0

func (*Importer) Parse added in v0.2.9

func (*Importer) ParseInternal added in v0.2.9

func (i *Importer) ParseInternal(
	ctx context.Context,
	req *importv1.ParseTransactionsRequest,
) ([]*DeduplicationItem, error)

type ImporterConfig added in v0.2.9

type ImporterConfig struct {
	AccountSvc     AccountSvc
	TagSvc         TagSvc
	CategoriesSvc  CategoriesSvc
	TransactionSvc TransactionSvc
	MapperSvc      MapperSvc
	RuleSvc        RuleSvc
}

type MapperSvc added in v0.2.9

type MapperSvc interface {
	MapTransaction(ctx context.Context, tx *database.Transaction) *gomoneypbv1.Transaction
}

type Mbank added in v1.3.0

type Mbank struct {
	*BaseParser
}

func NewMbank added in v1.3.0

func NewMbank(base *BaseParser) *Mbank

func (*Mbank) Parse added in v1.3.0

func (m *Mbank) Parse(ctx context.Context, req *ParseRequest) (*ParseResponse, error)

func (*Mbank) ParseMessages added in v1.3.0

func (m *Mbank) ParseMessages(
	_ context.Context,
	rawArr []*Record,
) ([]*Transaction, error)

func (*Mbank) Type added in v1.3.0

func (m *Mbank) Type() importv1.ImportSource

type Message added in v0.2.9

type Message struct {
	CreatedAt time.Time // todo
}

type Mono added in v0.2.9

type Mono struct {
	*BaseParser
}

func NewMono added in v0.2.9

func NewMono(base *BaseParser) *Mono

func (*Mono) Parse added in v0.2.9

func (m *Mono) Parse(ctx context.Context, req *ParseRequest) (*ParseResponse, error)

func (*Mono) Type added in v0.2.9

func (m *Mono) Type() importv1.ImportSource

type Paribas added in v0.2.12

type Paribas struct {
	*BaseParser
	// contains filtered or unexported fields
}

func NewParibas added in v0.2.12

func NewParibas(base *BaseParser) *Paribas

func (*Paribas) CanMatchAsInternalTransfer added in v0.2.28

func (p *Paribas) CanMatchAsInternalTransfer(f, tx *Transaction) bool

func (*Paribas) Parse added in v0.2.12

func (p *Paribas) Parse(ctx context.Context, req *ParseRequest) (*ParseResponse, error)

func (*Paribas) ParseMessages added in v0.2.12

func (p *Paribas) ParseMessages(
	ctx context.Context,
	rawArr []*Record,
) ([]*Transaction, error)

func (*Paribas) Type added in v0.2.12

func (p *Paribas) Type() importv1.ImportSource

type ParibasData added in v0.2.12

type ParibasData struct {
	Date                    time.Time
	DateFromMessage         string
	Currency                string
	TransactionCurrency     string
	Amount                  decimal.Decimal
	AmountString            string
	TransactionAmount       decimal.Decimal
	TransactionAmountString string
	Sender                  string
	Receiver                string
	Description             string
	Account                 string
	DestinationAccount      string
	TransactionType         string
	ExecutedAt              string
}

type ParibasDataExtractor added in v0.2.12

type ParibasDataExtractor interface {
	Extract(ctx context.Context, cells []*xlsx.Cell) (ParibasData, error)
}

type ParibasDataExtractorV1 added in v0.2.12

type ParibasDataExtractorV1 struct{}

func (ParibasDataExtractorV1) Extract added in v0.2.12

func (d ParibasDataExtractorV1) Extract(_ context.Context, cells []*xlsx.Cell) (ParibasData, error)

type ParibasDataExtractorV2 added in v0.2.12

type ParibasDataExtractorV2 struct{}

func (ParibasDataExtractorV2) Extract added in v0.2.12

func (d ParibasDataExtractorV2) Extract(_ context.Context, cells []*xlsx.Cell) (ParibasData, error)

type ParseRequest added in v0.2.9

type ParseRequest struct {
	ImportRequest
}

type ParseResponse added in v0.2.9

type ParseResponse struct {
	CreateRequests []*transactionsv1.CreateTransactionRequest
}

type Privat24 added in v0.2.9

type Privat24 struct {
	*BaseParser
}

func NewPrivat24 added in v0.2.9

func NewPrivat24(base *BaseParser) *Privat24

func (*Privat24) Parse added in v0.2.9

func (p *Privat24) Parse(ctx context.Context, req *ParseRequest) (*ParseResponse, error)

func (*Privat24) ParseMessages added in v0.2.9

func (p *Privat24) ParseMessages(
	_ context.Context,
	rawArr []*Record,
) ([]*Transaction, error)

func (*Privat24) Type added in v0.2.9

func (p *Privat24) Type() importv1.ImportSource

type Record added in v0.2.9

type Record struct {
	Message *Message
	Data    []byte
}

type Revolut added in v0.2.12

type Revolut struct {
	*BaseParser
}

func NewRevolut added in v0.2.12

func NewRevolut(base *BaseParser) *Revolut

func (*Revolut) AccountName added in v0.2.12

func (r *Revolut) AccountName(input string) string

func (*Revolut) Parse added in v0.2.12

func (r *Revolut) Parse(ctx context.Context, req *ParseRequest) (*ParseResponse, error)

func (*Revolut) ParseMessages added in v0.2.12

func (r *Revolut) ParseMessages(
	ctx context.Context,
	rawArr []*Record,
) ([]*Transaction, error)

func (*Revolut) Type added in v0.2.12

func (r *Revolut) Type() importv1.ImportSource

type RuleSvc added in v1.7.0

type RuleSvc interface {
	ProcessTransactions(
		ctx context.Context,
		inputTxs []*database.Transaction,
	) ([]*database.Transaction, error)
}

type TagSvc

type TagSvc interface {
	GetAllTags(ctx context.Context) ([]*database.Tag, error)
}

type Transaction added in v0.2.9

type Transaction struct {
	ID   string
	Type TransactionType

	SourceAmount        decimal.Decimal
	SourceCurrency      string
	DestinationAmount   decimal.Decimal
	DestinationCurrency string

	Date               time.Time
	Description        string
	SourceAccount      string
	DestinationAccount string
	DateFromMessage    string
	Raw                string

	InternalTransferDirectionTo bool
	DuplicateTransactions       []*Transaction

	OriginalMessage   *Message `json:"-"`
	DeduplicationKeys []string

	OriginalTxType      string
	OriginalNadawcaName string
	ParsingError        error `json:"-"`
}

type TransactionSvc

type TransactionSvc interface {
	CreateBulkInternal(
		ctx context.Context,
		reqs []*transactions.BulkRequest,
		tx *gorm.DB,
		opts transactions.UpsertOptions,
	) ([]*transactionsv1.CreateTransactionResponse, error)
	ConvertRequestToTransaction(
		ctx context.Context,
		req *transactionsv1.CreateTransactionRequest,
		originalTx *database.Transaction,
	) (*database.Transaction, error)
}

type TransactionType added in v0.2.9

type TransactionType int32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址