invoice

package
v0.0.1-alpha1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateValidator

func CreateValidator() documents.ValidatorGroup

CreateValidator returns a validator group that should be run before creating the invoice and persisting it to DB

func GRPCHandler

GRPCHandler returns an implementation of invoice.DocumentServiceServer

func UpdateValidator

func UpdateValidator() documents.ValidatorGroup

UpdateValidator returns a validator group that should be run before updating the invoice

Types

type Bootstrapper

type Bootstrapper struct{}

func (*Bootstrapper) Bootstrap

func (*Bootstrapper) Bootstrap(context map[string]interface{}) error

Bootstrap sets the required storage and registers

type Invoice

type Invoice struct {
	// invoice number or reference number
	InvoiceNumber string
	// name of the sender company
	SenderName string
	// street and address details of the sender company
	SenderStreet  string
	SenderCity    string
	SenderZipcode string
	// country ISO code of the sender of this invoice
	SenderCountry string
	// name of the recipient company
	RecipientName    string
	RecipientStreet  string
	RecipientCity    string
	RecipientZipcode string
	// country ISO code of the receipient of this invoice
	RecipientCountry string
	// ISO currency code
	Currency string
	// invoice amount including tax
	GrossAmount int64
	// invoice amount excluding tax
	NetAmount   int64
	TaxAmount   int64
	TaxRate     int64
	Recipient   *identity.CentID
	Sender      *identity.CentID
	Payee       *identity.CentID
	Comment     string
	DueDate     *timestamp.Timestamp
	DateCreated *timestamp.Timestamp
	ExtraData   []byte

	InvoiceSalts *invoicepb.InvoiceDataSalts
	CoreDocument *coredocumentpb.CoreDocument
}

Invoice implements the documents.Model keeps track of invoice related fields and state

func (*Invoice) FromJSON

func (i *Invoice) FromJSON(jsonData []byte) error

FromJSON unmarshals the json bytes into Invoice

func (*Invoice) ID

func (i *Invoice) ID() ([]byte, error)

func (*Invoice) InitInvoiceInput

func (i *Invoice) InitInvoiceInput(payload *clientinvoicepb.InvoiceCreatePayload, contextHeader *documents.ContextHeader) error

InitInvoiceInput initialize the model based on the received parameters from the rest api call

func (*Invoice) JSON

func (i *Invoice) JSON() ([]byte, error)

JSON marshals Invoice into a json bytes

func (*Invoice) PackCoreDocument

func (i *Invoice) PackCoreDocument() (*coredocumentpb.CoreDocument, error)

PackCoreDocument packs the Invoice into a Core Document If the, Invoice is new, it creates a valid identifiers

func (*Invoice) Type

func (i *Invoice) Type() reflect.Type

Type gives the Invoice type

func (*Invoice) UnpackCoreDocument

func (i *Invoice) UnpackCoreDocument(coreDoc *coredocumentpb.CoreDocument) error

UnpackCoreDocument unpacks the core document into Invoice

type Service

type Service interface {
	documents.Service

	// DeriverFromPayload derives Invoice from clientPayload
	DeriveFromCreatePayload(*clientinvoicepb.InvoiceCreatePayload, *documents.ContextHeader) (documents.Model, error)

	// DeriveFromUpdatePayload derives invoice model from update payload
	DeriveFromUpdatePayload(*clientinvoicepb.InvoiceUpdatePayload, *documents.ContextHeader) (documents.Model, error)

	// Create validates and persists invoice Model and returns a Updated model
	Create(ctx context.Context, inv documents.Model) (documents.Model, error)

	// Update validates and updates the invoice model and return the updated model
	Update(ctx context.Context, inv documents.Model) (documents.Model, error)

	// DeriveInvoiceData returns the invoice data as client data
	DeriveInvoiceData(inv documents.Model) (*clientinvoicepb.InvoiceData, error)

	// DeriveInvoiceResponse returns the invoice model in our standard client format
	DeriveInvoiceResponse(inv documents.Model) (*clientinvoicepb.InvoiceResponse, error)
}

Service defines specific functions for invoice

func DefaultService

func DefaultService(repo documents.Repository, processor coredocumentprocessor.Processor, anchorRepository anchors.AnchorRepository) Service

DefaultService returns the default implementation of the service

Jump to

Keyboard shortcuts

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