transaction

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package transaction is a generated GoMock package.

Package transaction is a generated GoMock package.

Index

Constants

View Source
const (
	TypePurchase       = "Purchase"
	TypeSale           = "Sale"
	TypeDividendPayout = "Dividends"
	TypeRoundUp        = "Round up"
	TypeSaveback       = "Saveback"
	TypeDeposit        = "Deposit"
	TypeWithdrawal     = "Withdrawal"
	TypeInterestPayout = "Interest payout"
)

Variables

View Source
var (
	ErrModelBuilderUnsupportedType          = errors.New("unsupported response")
	ErrModelBuilderInsufficientDataResolved = errors.New("insufficient data resolved")
	ErrModelBuilderUnknownType              = errors.New("unknown response")
)
View Source
var ErrNoMatch = errors.New("value did not match the pattern")

Functions

func ParseFloatWithComma

func ParseFloatWithComma(src string, isNegative bool) (float64, error)

func ParseFloatWithPeriod

func ParseFloatWithPeriod(src string) (float64, error)

func ParseNumericValueFromString

func ParseNumericValueFromString(src string) (string, error)

func ProvideTransactionRepository

func ProvideTransactionRepository(db *gorm.DB, logger *logrus.Logger) (*database.Repository[*Model], error)

Types

type BaseModelBuilder

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

func NewBaseModelBuilder

func NewBaseModelBuilder(
	response details.NormalizedResponse,
	instrumentBuilder instrument.ModelBuilderInterface,
	documentsBuilder document.ModelBuilderInterface,
	logger *log.Logger,
) BaseModelBuilder

func (BaseModelBuilder) BuildDocuments

func (b BaseModelBuilder) BuildDocuments(model Model) ([]document.Model, error)

func (BaseModelBuilder) ExtractCommissionAmount

func (b BaseModelBuilder) ExtractCommissionAmount() (float64, error)

func (BaseModelBuilder) ExtractRateValue

func (b BaseModelBuilder) ExtractRateValue() (float64, error)

func (BaseModelBuilder) ExtractSharesAmount

func (b BaseModelBuilder) ExtractSharesAmount() (float64, error)

func (BaseModelBuilder) ExtractStatus

func (b BaseModelBuilder) ExtractStatus() (string, error)

func (BaseModelBuilder) ExtractTaxAmount

func (b BaseModelBuilder) ExtractTaxAmount() (float64, error)

func (BaseModelBuilder) ExtractTimestamp

func (b BaseModelBuilder) ExtractTimestamp() (time.Time, error)

func (BaseModelBuilder) ExtractTotalAmount

func (b BaseModelBuilder) ExtractTotalAmount() (float64, error)

func (BaseModelBuilder) HandleErr

func (b BaseModelBuilder) HandleErr(err error) error

type CSVEntryFactory

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

func NewCSVEntryFactory

func NewCSVEntryFactory(logger *log.Logger) CSVEntryFactory

func (CSVEntryFactory) Make

func (f CSVEntryFactory) Make(transaction Model) (filesystem.CSVEntry, error)

type DepositBuilder

type DepositBuilder struct {
	BaseModelBuilder
}

func NewDepositBuilder

func NewDepositBuilder(baseBuilder BaseModelBuilder) DepositBuilder

func (DepositBuilder) Build

func (b DepositBuilder) Build() (Model, error)

func (DepositBuilder) ExtractTotalAmount

func (b DepositBuilder) ExtractTotalAmount() (float64, error)

type DividendPayoutBuilder

type DividendPayoutBuilder struct {
	PurchaseBuilder
}

func NewDividendPayoutBuilder

func NewDividendPayoutBuilder(purchaseBuilder PurchaseBuilder) DividendPayoutBuilder

func (DividendPayoutBuilder) Build

func (b DividendPayoutBuilder) Build() (Model, error)

type Handler

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

func NewHandler

func NewHandler(
	listClient transactions.ClientInterface,
	detailsClient details.ClientInterface,
	normalizer details.ResponseNormalizerInterface,
	eventTypeResolver transactions.EventTypeResolverInterface,
	processor ProcessorInterface,
	logger *log.Logger,
) Handler

func ProvideHandler

func ProvideHandler(responseReader reader.Interface, responseWriter writer.Interface, dbConnection *gorm.DB, logger *logrus.Logger) (Handler, error)

func (Handler) GetTimelineTransactions

func (h Handler) GetTimelineTransactions() ([]transactions.ResponseItem, error)

func (Handler) Handle

func (h Handler) Handle() error

func (Handler) ProcessTransactionResponse

func (h Handler) ProcessTransactionResponse(transaction transactions.ResponseItem) error

type HandlerInterface

type HandlerInterface interface {
	Handle() error
}

type InterestPayoutBuilder

type InterestPayoutBuilder struct {
	BaseModelBuilder
}

func NewInterestPayoutBuilder

func NewInterestPayoutBuilder(baseBuilder BaseModelBuilder) InterestPayoutBuilder

func (InterestPayoutBuilder) Build

func (b InterestPayoutBuilder) Build() (Model, error)

type MockProcessorInterface

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

MockProcessorInterface is a mock of ProcessorInterface interface.

func NewMockProcessorInterface

func NewMockProcessorInterface(ctrl *gomock.Controller) *MockProcessorInterface

NewMockProcessorInterface creates a new mock instance.

func (*MockProcessorInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProcessorInterface) Process

Process mocks base method.

type MockProcessorInterfaceMockRecorder

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

MockProcessorInterfaceMockRecorder is the mock recorder for MockProcessorInterface.

func (*MockProcessorInterfaceMockRecorder) Process

func (mr *MockProcessorInterfaceMockRecorder) Process(eventType, response any) *gomock.Call

Process indicates an expected call of Process.

type MockRepositoryInterface

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

MockRepositoryInterface is a mock of RepositoryInterface interface.

func NewMockRepositoryInterface

func NewMockRepositoryInterface(ctrl *gomock.Controller) *MockRepositoryInterface

NewMockRepositoryInterface creates a new mock instance.

func (*MockRepositoryInterface) Create

func (m *MockRepositoryInterface) Create(model *Model) error

Create mocks base method.

func (*MockRepositoryInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockRepositoryInterfaceMockRecorder

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

MockRepositoryInterfaceMockRecorder is the mock recorder for MockRepositoryInterface.

func (*MockRepositoryInterfaceMockRecorder) Create

Create indicates an expected call of Create.

type Model

type Model struct {
	UUID string `gorm:"primaryKey"`

	InstrumentISIN *string
	Instrument     instrument.Model
	Documents      []document.Model `gorm:"-"`

	Type       string    `gorm:"index"`
	Timestamp  time.Time `gorm:"index"`
	Status     string
	Yield      float64
	Profit     float64
	Shares     float64
	Rate       float64
	Commission float64
	Total      float64
	TaxAmount  float64
	CreatedAt  time.Time `gorm:"index"`
	UpdatedAt  time.Time `gorm:"index"`
}

func NewTransaction

func NewTransaction(
	uuid, transactionType, status string,
	yield, profit, shares, rate, commission, total, tax float64,
	timestamp time.Time,
	instrument instrument.Model,
	documents []document.Model,
) Model

func (Model) TableName

func (Model) TableName() string

type ModelBuilderFactory

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

func NewModelBuilderFactory

func NewModelBuilderFactory(
	resolver details.TypeResolverInterface,
	instrumentBuilder instrument.ModelBuilderInterface,
	documentsBuilder document.ModelBuilderInterface,
	logger *log.Logger,
) ModelBuilderFactory

func ProvideModelBuilderFactory

func ProvideModelBuilderFactory(logger *logrus.Logger) ModelBuilderFactory

func (ModelBuilderFactory) Create

type ModelBuilderFactoryInterface

type ModelBuilderFactoryInterface interface {
	Create(eventType transactions.EventType, response details.NormalizedResponse) (ModelBuilderInterface, error)
}

type ModelBuilderInterface

type ModelBuilderInterface interface {
	Build() (Model, error)
}

type Processor

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

func NewProcessor

func NewProcessor(
	builderFactory ModelBuilderFactoryInterface,
	transactionRepo RepositoryInterface,
	factory CSVEntryFactory,
	csvReader filesystem.CSVReaderInterface,
	csvWriter filesystem.CSVWriterInterface,
	docDownloader document.DownloaderInterface,
	logger *log.Logger,
) Processor

func (Processor) Process

func (p Processor) Process(eventType transactions.EventType, response details.NormalizedResponse) error

type ProcessorInterface

type ProcessorInterface interface {
	Process(eventType transactions.EventType, response details.NormalizedResponse) error
}

type PurchaseBuilder

type PurchaseBuilder struct {
	BaseModelBuilder
}

func NewPurchaseBuilder

func NewPurchaseBuilder(baseBuilder BaseModelBuilder) PurchaseBuilder

func (PurchaseBuilder) Build

func (b PurchaseBuilder) Build() (Model, error)

type RepositoryInterface

type RepositoryInterface interface {
	database.RepositoryInterface[*Model]
}

type RoundUpBuilder

type RoundUpBuilder struct {
	PurchaseBuilder
}

func NewRoundUpBuilder

func NewRoundUpBuilder(purchaseBuilder PurchaseBuilder) RoundUpBuilder

func (RoundUpBuilder) Build

func (b RoundUpBuilder) Build() (Model, error)

type SaleBuilder

type SaleBuilder struct {
	PurchaseBuilder
}

func NewSaleBuilder

func NewSaleBuilder(purchaseBuilder PurchaseBuilder) SaleBuilder

func (SaleBuilder) Build

func (b SaleBuilder) Build() (Model, error)

func (SaleBuilder) ExtractPerformanceFloatVal

func (b SaleBuilder) ExtractPerformanceFloatVal(titles ...string) (float64, error)

func (SaleBuilder) ExtractProfitAndLoss

func (b SaleBuilder) ExtractProfitAndLoss() (float64, error)

func (SaleBuilder) ExtractYield

func (b SaleBuilder) ExtractYield() (float64, error)

type SavebackBuilder

type SavebackBuilder struct {
	PurchaseBuilder
}

func NewSavebackBuilder

func NewSavebackBuilder(purchaseBuilder PurchaseBuilder) SavebackBuilder

func (SavebackBuilder) Build

func (b SavebackBuilder) Build() (Model, error)

type WithdrawBuilder

type WithdrawBuilder struct {
	DepositBuilder
}

func NewWithdrawBuilder

func NewWithdrawBuilder(depositBuilder DepositBuilder) WithdrawBuilder

func (WithdrawBuilder) Build

func (b WithdrawBuilder) Build() (Model, error)

Jump to

Keyboard shortcuts

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