Documentation ¶
Index ¶
- Constants
- Variables
- type EmailService
- type IEmailService
- type ITransactionService
- type Service
- func (service Service) CalculateAverageDebitAndCredit(transactions []models.Transaction) (decimal.Decimal, decimal.Decimal)
- func (service Service) CalculateTotalBalance(transactions []models.Transaction) decimal.Decimal
- func (service Service) CalculateTransactionsPerMonth(transactions []models.Transaction) []TransactionsPerMonth
- func (service Service) Process(csvFileName, destinationEmail string) error
- type TransactionService
- type TransactionsPerMonth
- type TransactionsReader
Constants ¶
View Source
const ( IDIndex = 0 IDHeader = "Id" DateIndex = 1 DateHeader = "Date" AmountIndex = 2 AmountHeader = "Transaction" )
Variables ¶
View Source
var ErrApplyingTransactions = errors.New("error applying transactions")
View Source
var ErrParsingAmount = errors.New("can't convert transaction amount to decimal")
View Source
var ErrParsingDate = errors.New("can't convert transaction date")
View Source
var ErrParsingID = errors.New("can't convert transaction id")
View Source
var ErrReadingTransactions = errors.New("error parsing transactions csv")
Functions ¶
This section is empty.
Types ¶
type EmailService ¶
type EmailService struct { EmailSender adapters.EmailSender Template *template.Template }
type IEmailService ¶
type ITransactionService ¶
type Service ¶
type Service struct { TransactionsReader TransactionsReader EmailService IEmailService TransactionService ITransactionService }
func (Service) CalculateAverageDebitAndCredit ¶
func (service Service) CalculateAverageDebitAndCredit(transactions []models.Transaction) (decimal.Decimal, decimal.Decimal)
CalculateAverageDebitAndCredit calculates the average debit and average credit from a list of transactions
func (Service) CalculateTotalBalance ¶
func (service Service) CalculateTotalBalance(transactions []models.Transaction) decimal.Decimal
CalculateTotalBalance calculates the total balance from a list of transactions as the sum of all transactions
func (Service) CalculateTransactionsPerMonth ¶
func (service Service) CalculateTransactionsPerMonth(transactions []models.Transaction) []TransactionsPerMonth
CalculateTransactionsPerMonth calculates the amount of transactions for each month present in the list of transactions. The returned list is in ascending order by month.
type TransactionService ¶
type TransactionService struct { DB *gorm.DB UserRepository repository.IUserRepository TransactionRepository repository.ITransactionRepository }
type TransactionsPerMonth ¶
type TransactionsReader ¶
func (TransactionsReader) Read ¶
func (reader TransactionsReader) Read(csvFileName string) ([]models.Transaction, error)
Read reads a CSV file that contains a list of transactions.
If the csvFileName starts with 's3://', it reads the csv from s3. Otherwise, it reads it from local folder.
Returns the list of transactions of the CSV file or ErrReadingTransactions if an error is produced
Click to show internal directories.
Click to hide internal directories.