positions

package
v0.0.0-...-dcdfded Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package positions has been introduced because the domain model has become to large, so we break into smaller and more independent parts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionID

type CollectionID string

func (CollectionID) Undefined

func (id CollectionID) Undefined() bool

type EuroCents

type EuroCents int

EuroCents represents just some money.

type InfrastructureError

type InfrastructureError struct {
	Cause error
}

func (InfrastructureError) Error

func (e InfrastructureError) Error() string

func (InfrastructureError) InvoiceDraft

func (e InfrastructureError) InvoiceDraft() bool

func (InfrastructureError) LoadingError

func (e InfrastructureError) LoadingError() bool

func (InfrastructureError) SavingError

func (e InfrastructureError) SavingError() bool

type Loader

type Loader func(id CollectionID) (Positions, LoadingError)

Loader is an alternative but more functional approach for modelling a kind of repository. The advantage is, that dependency requirements are absolutely exact and testing requires no mocks. It allows easy currying and avoids structs for modelling behavior.

type LoadingError

type LoadingError interface {
	error
	LoadingError() bool
}

type NotFoundError

type NotFoundError CollectionID

func (NotFoundError) Error

func (e NotFoundError) Error() string

func (NotFoundError) ID

func (e NotFoundError) ID() CollectionID

func (NotFoundError) LoadingError

func (e NotFoundError) LoadingError() bool

func (NotFoundError) String

func (e NotFoundError) String() string

type Position

type Position struct {
	No    int
	Title string
	Value EuroCents
}

A Position on an invoice.

type Positions

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

Positions is the aggregate root, for our positions.

func NewPositions

func NewPositions(id CollectionID, pos []Position) *Positions

func (*Positions) Add

func (p *Positions) Add(pos Position)

func (*Positions) All

func (p *Positions) All() []Position

type Repository

type Repository interface {
	Load(id CollectionID) (Positions, LoadingError)
	Save(positions Positions) SavingError
}

Repository models logical transaction states (the aggregate root) for different (typically I/O based) implementations.

type Saver

type Saver func(positions Positions) SavingError

Saver is an alternative but more functional approach for modelling a kind of repository. The advantage is, that dependency requirements are perfectly exact and testing requires no mocks. It allows easy currying and avoids structs for modelling behavior.

type SavingError

type SavingError interface {
	error
	SavingError() bool
	InvoiceDraft() bool
}

Jump to

Keyboard shortcuts

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