operation

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package operation is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	// The amount value in the smallest unit of the asset (e.g., cents)
	// example: 1500
	// minimum: 0
	Value *decimal.Decimal `json:"value" example:"1500" minimum:"0"`

} // @name Amount

Amount structure for marshaling/unmarshalling JSON.

swagger:model Amount @Description Amount is the struct designed to represent the amount of an operation. Contains the value and scale (decimal places) of an operation amount.

func (Amount) IsEmpty

func (a Amount) IsEmpty() bool

IsEmpty method that set empty or nil in fields

type Balance

type Balance struct {
	// Amount available for transactions (in the smallest unit of asset)
	// example: 1500
	// minimum: 0
	Available *decimal.Decimal `json:"available" example:"1500" minimum:"0"`

	// Amount on hold and unavailable for transactions (in the smallest unit of asset)
	// example: 500
	// minimum: 0
	OnHold *decimal.Decimal `json:"onHold" example:"500" minimum:"0"`

} // @name Balance

Balance structure for marshaling/unmarshalling JSON.

swagger:model Balance @Description Balance is the struct designed to represent the account balance. Contains available and on-hold amounts along with the scale (decimal places).

func (Balance) IsEmpty

func (b Balance) IsEmpty() bool

IsEmpty method that set empty or nil in fields

type MockRepository

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

MockRepository is a mock of Repository interface.

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance.

func (*MockRepository) Create

func (m *MockRepository) Create(ctx context.Context, operation *Operation) (*Operation, error)

Create mocks base method.

func (*MockRepository) Delete

func (m *MockRepository) Delete(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error

Delete mocks base method.

func (*MockRepository) EXPECT

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

func (*MockRepository) Find

func (m *MockRepository) Find(ctx context.Context, organizationID, ledgerID, transactionID, id uuid.UUID) (*Operation, error)

Find mocks base method.

func (*MockRepository) FindAll

func (m *MockRepository) FindAll(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID, filter http0.Pagination) ([]*Operation, http.CursorPagination, error)

FindAll mocks base method.

func (*MockRepository) FindAllByAccount

func (m *MockRepository) FindAllByAccount(ctx context.Context, organizationID, ledgerID, accountID uuid.UUID, operationType *string, filter http0.Pagination) ([]*Operation, http.CursorPagination, error)

FindAllByAccount mocks base method.

func (*MockRepository) FindByAccount

func (m *MockRepository) FindByAccount(ctx context.Context, organizationID, ledgerID, accountID, id uuid.UUID) (*Operation, error)

FindByAccount mocks base method.

func (*MockRepository) ListByIDs

func (m *MockRepository) ListByIDs(ctx context.Context, organizationID, ledgerID uuid.UUID, ids []uuid.UUID) ([]*Operation, error)

ListByIDs mocks base method.

func (*MockRepository) Update

func (m *MockRepository) Update(ctx context.Context, organizationID, ledgerID, transactionID, id uuid.UUID, operation *Operation) (*Operation, error)

Update mocks base method.

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository.

func (*MockRepositoryMockRecorder) Create

func (mr *MockRepositoryMockRecorder) Create(ctx, operation any) *gomock.Call

Create indicates an expected call of Create.

func (*MockRepositoryMockRecorder) Delete

func (mr *MockRepositoryMockRecorder) Delete(ctx, organizationID, ledgerID, id any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockRepositoryMockRecorder) Find

func (mr *MockRepositoryMockRecorder) Find(ctx, organizationID, ledgerID, transactionID, id any) *gomock.Call

Find indicates an expected call of Find.

func (*MockRepositoryMockRecorder) FindAll

func (mr *MockRepositoryMockRecorder) FindAll(ctx, organizationID, ledgerID, transactionID, filter any) *gomock.Call

FindAll indicates an expected call of FindAll.

func (*MockRepositoryMockRecorder) FindAllByAccount

func (mr *MockRepositoryMockRecorder) FindAllByAccount(ctx, organizationID, ledgerID, accountID, operationType, filter any) *gomock.Call

FindAllByAccount indicates an expected call of FindAllByAccount.

func (*MockRepositoryMockRecorder) FindByAccount

func (mr *MockRepositoryMockRecorder) FindByAccount(ctx, organizationID, ledgerID, accountID, id any) *gomock.Call

FindByAccount indicates an expected call of FindByAccount.

func (*MockRepositoryMockRecorder) ListByIDs

func (mr *MockRepositoryMockRecorder) ListByIDs(ctx, organizationID, ledgerID, ids any) *gomock.Call

ListByIDs indicates an expected call of ListByIDs.

func (*MockRepositoryMockRecorder) Update

func (mr *MockRepositoryMockRecorder) Update(ctx, organizationID, ledgerID, transactionID, id, operation any) *gomock.Call

Update indicates an expected call of Update.

type Operation

type Operation struct {
	// Unique identifier for the operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	ID string `json:"id" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Parent transaction identifier
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	TransactionID string `json:"transactionId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Human-readable description of the operation
	// example: Credit card operation
	// maxLength: 256
	Description string `json:"description" example:"Credit card operation" maxLength:"256"`

	// Type of operation (e.g., DEBIT, CREDIT)
	// example: DEBIT
	// maxLength: 50
	Type string `json:"type" example:"DEBIT" maxLength:"50"`

	// Asset code for the operation
	// example: BRL
	// minLength: 2
	// maxLength: 10
	AssetCode string `json:"assetCode" example:"BRL" minLength:"2" maxLength:"10"`

	// Chart of accounts code for accounting purposes
	// example: 1000
	// maxLength: 20
	ChartOfAccounts string `json:"chartOfAccounts" example:"1000" maxLength:"20"`

	// Operation amount information
	Amount Amount `json:"amount"`

	// Balance before the operation
	Balance Balance `json:"balance"`

	// Balance after the operation
	BalanceAfter Balance `json:"balanceAfter"`

	// Operation status information
	Status Status `json:"status"`

	// Account identifier associated with this operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	AccountID string `json:"accountId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Human-readable alias for the account
	// example: @person1
	// maxLength: 256
	AccountAlias string `json:"accountAlias" example:"@person1" maxLength:"256"`

	// Balance identifier affected by this operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	BalanceID string `json:"balanceId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Organization identifier
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	OrganizationID string `json:"organizationId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Ledger identifier
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	LedgerID string `json:"ledgerId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Route
	// example: 00000000-0000-0000-0000-000000000000
	// format: string
	Route string `json:"route" example:"00000000-0000-0000-0000-000000000000" format:"string"`

	// Timestamp when the operation was created
	// example: 2021-01-01T00:00:00Z
	// format: date-time
	CreatedAt time.Time `json:"createdAt" example:"2021-01-01T00:00:00Z" format:"date-time"`

	// Timestamp when the operation was last updated
	// example: 2021-01-01T00:00:00Z
	// format: date-time
	UpdatedAt time.Time `json:"updatedAt" example:"2021-01-01T00:00:00Z" format:"date-time"`

	// Timestamp when the operation was deleted (if soft-deleted)
	// example: 2021-01-01T00:00:00Z
	// format: date-time
	DeletedAt *time.Time `json:"deletedAt" example:"2021-01-01T00:00:00Z" format:"date-time"`

	// Additional custom attributes
	// example: {"reason": "Purchase refund", "reference": "INV-12345"}
	Metadata map[string]any `json:"metadata"`

} // @name Operation

Operation is a struct designed to encapsulate response payload data.

swagger:model Operation @Description Operation is a struct designed to store operation data. Represents a financial operation that affects account balances, including details such as amount, balance before and after, transaction association, and metadata.

func (*Operation) ToLog

func (o *Operation) ToLog() *OperationLog

ToLog converts an Operation excluding the fields that are not immutable

type OperationLog

type OperationLog struct {
	// Unique identifier for the operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	ID string `json:"id" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Parent transaction identifier
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	TransactionID string `json:"transactionId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Type of operation (e.g., creditCard, transfer, payment)
	// example: creditCard
	// maxLength: 50
	Type string `json:"type" example:"creditCard" maxLength:"50"`

	// Asset code for the operation
	// example: BRL
	// minLength: 2
	// maxLength: 10
	AssetCode string `json:"assetCode" example:"BRL" minLength:"2" maxLength:"10"`

	// Chart of accounts code for accounting purposes
	// example: 1000
	// maxLength: 20
	ChartOfAccounts string `json:"chartOfAccounts" example:"1000" maxLength:"20"`

	// Operation amount information
	Amount Amount `json:"amount"`

	// Balance before the operation
	Balance Balance `json:"balance"`

	// Balance after the operation
	BalanceAfter Balance `json:"balanceAfter"`

	// Operation status information
	Status Status `json:"status"`

	// Account identifier associated with this operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	AccountID string `json:"accountId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Human-readable alias for the account
	// example: @person1
	// maxLength: 256
	AccountAlias string `json:"accountAlias" example:"@person1" maxLength:"256"`

	// Balance identifier affected by this operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: uuid
	BalanceID string `json:"balanceId" example:"00000000-0000-0000-0000-000000000000" format:"uuid"`

	// Timestamp when the operation log was created
	// example: 2021-01-01T00:00:00Z
	// format: date-time
	CreatedAt time.Time `json:"createdAt" example:"2021-01-01T00:00:00Z" format:"date-time"`

	// Route for the operation
	// example: 00000000-0000-0000-0000-000000000000
	// format: string
	Route string `json:"route" example:"00000000-0000-0000-0000-000000000000" format:"string"`
}

OperationLog is a struct designed to represent the operation data that should be stored in the audit log

@Description Immutable log entry for audit purposes representing a snapshot of operation state at a specific point in time.

type OperationPostgreSQLModel

type OperationPostgreSQLModel struct {
	ID                    string           // Unique identifier (UUID format)
	TransactionID         string           // Parent transaction ID
	Description           string           // Operation description
	Type                  string           // Operation type (e.g., "DEBIT", "CREDIT")
	AssetCode             string           // Asset code for the operation
	Amount                *decimal.Decimal // Operation amount value
	AvailableBalance      *decimal.Decimal // Available balance before operation
	OnHoldBalance         *decimal.Decimal // On-hold balance before operation
	AvailableBalanceAfter *decimal.Decimal // Available balance after operation
	OnHoldBalanceAfter    *decimal.Decimal // On-hold balance after operation
	Status                string           // Status code (e.g., "ACTIVE", "PENDING")
	StatusDescription     *string          // Status description
	AccountID             string           // Account ID associated with operation
	AccountAlias          string           // Account alias
	BalanceID             string           // Balance ID affected by operation
	ChartOfAccounts       string           // Chart of accounts code
	OrganizationID        string           // Organization ID
	LedgerID              string           // Ledger ID
	CreatedAt             time.Time        // Creation timestamp
	UpdatedAt             time.Time        // Last update timestamp
	DeletedAt             sql.NullTime     // Deletion timestamp (if soft-deleted)
	Route                 *string          // Route
	Metadata              map[string]any   // Additional custom attributes
}

OperationPostgreSQLModel represents the entity OperationPostgreSQLModel into SQL context in Database

@Description Database model for storing operation information in PostgreSQL

func (*OperationPostgreSQLModel) FromEntity

func (t *OperationPostgreSQLModel) FromEntity(operation *Operation)

FromEntity converts an entity Operation to OperationPostgreSQLModel

func (*OperationPostgreSQLModel) ToEntity

func (t *OperationPostgreSQLModel) ToEntity() *Operation

ToEntity converts an OperationPostgreSQLModel to entity Operation

type OperationPostgreSQLRepository

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

OperationPostgreSQLRepository is a Postgresql-specific implementation of the OperationRepository.

func NewOperationPostgreSQLRepository

func NewOperationPostgreSQLRepository(pc *libPostgres.PostgresConnection) *OperationPostgreSQLRepository

NewOperationPostgreSQLRepository returns a new instance of OperationPostgreSQLRepository using the given Postgres connection.

func (*OperationPostgreSQLRepository) Create

func (r *OperationPostgreSQLRepository) Create(ctx context.Context, operation *Operation) (*Operation, error)

Create a new Operation entity into Postgresql and returns it.

func (*OperationPostgreSQLRepository) Delete

func (r *OperationPostgreSQLRepository) Delete(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error

Delete removes a Operation entity from the database using the provided IDs.

func (*OperationPostgreSQLRepository) Find

func (r *OperationPostgreSQLRepository) Find(ctx context.Context, organizationID, ledgerID, transactionID, id uuid.UUID) (*Operation, error)

Find retrieves a Operation entity from the database using the provided ID.

func (*OperationPostgreSQLRepository) FindAll

func (r *OperationPostgreSQLRepository) FindAll(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID, filter http.Pagination) ([]*Operation, libHTTP.CursorPagination, error)

FindAll retrieves Operations entities from the database.

func (*OperationPostgreSQLRepository) FindAllByAccount

func (r *OperationPostgreSQLRepository) FindAllByAccount(ctx context.Context, organizationID, ledgerID, accountID uuid.UUID, operationType *string, filter http.Pagination) ([]*Operation, libHTTP.CursorPagination, error)

FindAllByAccount retrieves Operations entities from the database using the provided account ID.

func (*OperationPostgreSQLRepository) FindByAccount

func (r *OperationPostgreSQLRepository) FindByAccount(ctx context.Context, organizationID, ledgerID, accountID, id uuid.UUID) (*Operation, error)

FindByAccount retrieves a Operation entity from the database using the provided account ID.

func (*OperationPostgreSQLRepository) ListByIDs

func (r *OperationPostgreSQLRepository) ListByIDs(ctx context.Context, organizationID, ledgerID uuid.UUID, ids []uuid.UUID) ([]*Operation, error)

ListByIDs retrieves Operation entities from the database using the provided IDs.

func (*OperationPostgreSQLRepository) Update

func (r *OperationPostgreSQLRepository) Update(ctx context.Context, organizationID, ledgerID, transactionID, id uuid.UUID, operation *Operation) (*Operation, error)

Update an Operation entity into Postgresql and returns the Operation updated.

type OperationResponse

type OperationResponse struct {
	// in: body
	Body Operation
}

OperationResponse represents a success response containing a single operation.

swagger:response OperationResponse @Description Successful response containing a single operation entity.

type OperationsResponse

type OperationsResponse struct {
	// in: body
	Body struct {
		Items      []Operation `json:"items"`
		Pagination struct {
			Limit      int     `json:"limit"`
			NextCursor *string `json:"next_cursor,omitempty"`
			PrevCursor *string `json:"prev_cursor,omitempty"`
		} `json:"pagination"`
	}
}

OperationsResponse represents a success response containing a paginated list of operations.

swagger:response OperationsResponse @Description Successful response containing a paginated list of operations.

type Repository

type Repository interface {
	Create(ctx context.Context, operation *Operation) (*Operation, error)
	FindAll(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID, filter http.Pagination) ([]*Operation, libHTTP.CursorPagination, error)
	FindAllByAccount(ctx context.Context, organizationID, ledgerID, accountID uuid.UUID, operationType *string, filter http.Pagination) ([]*Operation, libHTTP.CursorPagination, error)
	Find(ctx context.Context, organizationID, ledgerID, transactionID, id uuid.UUID) (*Operation, error)
	FindByAccount(ctx context.Context, organizationID, ledgerID, accountID, id uuid.UUID) (*Operation, error)
	ListByIDs(ctx context.Context, organizationID, ledgerID uuid.UUID, ids []uuid.UUID) ([]*Operation, error)
	Update(ctx context.Context, organizationID, ledgerID, transactionID, id uuid.UUID, operation *Operation) (*Operation, error)
	Delete(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error
}

Repository provides an interface for operations related to operation template entities. It defines methods for creating, retrieving, updating, and deleting operation templates.

type Status

type Status struct {
	// Status code identifying the state of the operation
	// example: ACTIVE
	// maxLength: 100
	Code string `json:"code" validate:"max=100" example:"ACTIVE" maxLength:"100"`

	// Optional descriptive text explaining the status
	// example: Active status
	// maxLength: 256
	Description *string `json:"description" validate:"omitempty,max=256" example:"Active status" maxLength:"256"`

} // @name Status

Status structure for marshaling/unmarshalling JSON.

swagger:model Status @Description Status is the struct designed to represent the status of an operation. Contains code and optional description for operation states.

func (Status) IsEmpty

func (s Status) IsEmpty() bool

IsEmpty method that set empty or nil in fields

type UpdateOperationInput

type UpdateOperationInput struct {
	// Human-readable description of the operation
	// example: Credit card operation
	// maxLength: 256
	Description string `json:"description" validate:"max=256" example:"Credit card operation" maxLength:"256"`

	// Additional custom attributes
	// example: {"reason": "Purchase refund", "reference": "INV-12345"}
	Metadata map[string]any `json:"metadata" validate:"dive,keys,keymax=100,endkeys,omitempty,nonested,valuemax=2000"`

} // @name UpdateOperationInput

UpdateOperationInput is a struct design to encapsulate payload data.

swagger:model UpdateOperationInput @Description UpdateOperationInput is the input payload to update an operation. Contains fields that can be modified after an operation is created.

Jump to

Keyboard shortcuts

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