transaction

package
v0.0.0-...-f3a18e2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(api *operations.LedgerAPI, service Service)

Configure setups handlers on api with Service

func CreateAccount

func CreateAccount(repo *repository, params *models.CreateTransaction) (string, error)

CreateAccount creates a new account

func CreateEntity

func CreateEntity(repo *repository, params *models.CreateTransaction) (string, error)

CreateEntity creates a new entity

func DoesTransactionExist

func DoesTransactionExist(repo *repository, id string) (bool, string)

DoesTransactionExist checks if a given transaction exists

func GetExistingAccount

func GetExistingAccount(repo *repository, params *models.CreateTransaction) string

GetExistingAccount checks if a given account exists and returns the account ID

func GetExistingEntity

func GetExistingEntity(repo *repository, entityEntityID string, entityType string) string

GetExistingEntity checks if a given entity exists and returns the entity.id

func HandleAccount

func HandleAccount(repo *repository, params *models.CreateTransaction) (string, error)

HandleAccount checks if a given account exists and returns the account ID If it does not exist it creates the account and returns the new account ID

func HandleEntity

func HandleEntity(repo *repository, params *models.CreateTransaction) (string, error)

HandleEntity checks if a given entity exists and returns the entity.id If it does not exist it creates the entity and returns the new entity.id

Types

type Repository

type Repository interface {
	ListTransactions(ctx context.Context, params *transactions.ListTransactionsParams) ([]*models.Transaction, error)
	GetTransactionCount(ctx context.Context) (int64, error)
	CreateTransaction(ctx context.Context, params *models.CreateTransaction) (*models.Transaction, error)
	GetTransaction(ctx context.Context, transactionID string) (*models.Transaction, error)
}

Repository interface for repo calls

func NewRepository

func NewRepository(db *sqlx.DB) Repository

NewRepository ...

type RunningBalance

type RunningBalance struct {
	TransactionID         string `json:"transaction_id,omitempty"`
	CurrentRunningBalance int64  `json:"current_running_balance"`
	TotalCredit           int64  `json:"total_credit"`
	TotalDebit            int64  `json:"total_debit"`
}

RunningBalance is a struct to hold balance details for a set of transactions for an entity

type Service

type Service interface {
	ListTransactions(ctx context.Context, params *transactions.ListTransactionsParams) (*models.TransactionList, error)
	CreateTransaction(ctx context.Context, params *transactions.CreateTransactionParams) (*models.Transaction, error)
	GetTransaction(ctx context.Context, params *transactions.GetTransactionParams) (*models.Transaction, error)
}

Service ...

func NewService

func NewService(repo Repository) Service

NewService create a service instance

Jump to

Keyboard shortcuts

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