invoice

package
v0.0.0-...-fa32389 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Invoice

type Invoice struct {
	ID            uuid.UUID   `json:"id"`
	Status        Status      `json:"status"`
	AskingPrice   float64     `json:"asking_price"`
	IsLocked      bool        `json:"is_locked"`
	IsApproved    bool        `json:"is_approved"`
	InvoiceNumber string      `json:"invoice_number"`
	InvoiceDate   time.Time   `json:"invoice_date"`
	DueDate       time.Time   `json:"due_date"`
	AmountDue     float64     `json:"amount_due"`
	CustomerName  string      `json:"customer_name"`
	Reference     string      `json:"reference"`
	CompanyName   string      `json:"company_name"`
	Currency      string      `json:"currency"`
	TotalAmount   float64     `json:"total_amount"`
	TotalVAT      float64     `json:"total_vat"`
	IssuerID      uuid.UUID   `json:"issuer_id"`
	InvestorIDs   []uuid.UUID `json:"investor_ids"`
	Items         []*Item     `json:"items"`
}

func New

func New(
	invoiceDate,
	dueDate time.Time,
	invoiceNumber,
	reference,
	companyName,
	customerName,
	currency string,
	totalAmount,
	totalVAT,
	askingPrice float64,
	issuerID uuid.UUID,
) (*Invoice, error)

func (*Invoice) AddInvestor

func (i *Invoice) AddInvestor(investorID uuid.UUID) error

type Item

type Item struct {
	ID          uuid.UUID `json:"id"`
	Description string    `json:"description"`
	Quantity    int       `json:"quantity"`
	UnitPrice   float64   `json:"unit_price"`
	Amount      float64   `json:"amount"`
	VatRate     float64   `json:"vat_rate"`
	VatAmount   float64   `json:"vat_amount"`
}

func NewItem

func NewItem(
	description string,
	quantity int,
	unitPrice, vatAmount, total float64) (*Item, error)

type ItemRepository

type ItemRepository interface {
	Get(ctx context.Context, id uuid.UUID) (*Item, error)
	List(ctx context.Context) ([]*Item, error)
	Create(ctx context.Context, invoiceItem *Item) (*Item, error)
	Update(ctx context.Context, invoiceItem *Item) (*Item, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

type MockRepository

type MockRepository struct {
	mock.Mock
}

MockRepository is an autogenerated mock type for the Repository type

func NewMockRepository

func NewMockRepository(t mockConstructorTestingTNewMockRepository) *MockRepository

NewMockRepository creates a new instance of MockRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockRepository) CreateInvoice

func (_m *MockRepository) CreateInvoice(ctx context.Context, inv *Invoice, opts ...unitofwork.Option) error

CreateInvoice provides a mock function with given fields: ctx, inv, opts

func (*MockRepository) DeleteInvoice

func (_m *MockRepository) DeleteInvoice(ctx context.Context, id uuid.UUID, opts ...unitofwork.Option) error

DeleteInvoice provides a mock function with given fields: ctx, id, opts

func (*MockRepository) GetInvoiceByID

func (_m *MockRepository) GetInvoiceByID(ctx context.Context, id uuid.UUID, opts ...unitofwork.Option) (*Invoice, error)

GetInvoiceByID provides a mock function with given fields: ctx, id, opts

func (*MockRepository) GetInvoiceItems

func (_m *MockRepository) GetInvoiceItems(ctx context.Context, invoiceID uuid.UUID) ([]*Item, error)

GetInvoiceItems provides a mock function with given fields: ctx, invoiceID

func (*MockRepository) ListInvoices

func (_m *MockRepository) ListInvoices(ctx context.Context) ([]*Invoice, error)

ListInvoices provides a mock function with given fields: ctx

func (*MockRepository) UpdateInvoice

func (_m *MockRepository) UpdateInvoice(ctx context.Context, inv *Invoice, opts ...unitofwork.Option) error

UpdateInvoice provides a mock function with given fields: ctx, inv, opts

type Repository

type Repository interface {
	CreateInvoice(ctx context.Context, inv *Invoice, opts ...unitofwork.Option) error
	GetInvoiceByID(ctx context.Context, id uuid.UUID, opts ...unitofwork.Option) (*Invoice, error)
	UpdateInvoice(ctx context.Context, inv *Invoice, opts ...unitofwork.Option) error
	DeleteInvoice(ctx context.Context, id uuid.UUID, opts ...unitofwork.Option) error
	ListInvoices(ctx context.Context) ([]*Invoice, error)
	GetInvoiceItems(ctx context.Context, invoiceID uuid.UUID) ([]*Item, error)
}

type Service

type Service interface {
	CreateInvoice(ctx context.Context, inv *Invoice) (*Invoice, error)
	GetInvoiceByID(ctx context.Context, id uuid.UUID) (*Invoice, error)
	UpdateInvoice(ctx context.Context, inv *Invoice) (*Invoice, error)
	DeleteInvoice(ctx context.Context, id uuid.UUID) error
	ListInvoices(ctx context.Context) ([]*Invoice, error)
	ApproveTrade(ctx context.Context, id uuid.UUID) (*Invoice, error)
}

type Status

type Status string
const (
	StatusPending   Status = "pending"
	StatusProcessed Status = "processed"
)

Jump to

Keyboard shortcuts

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