invoice

package
v0.0.3-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BootstrappedInvoiceHandler maps to grpc handler for invoices
	BootstrappedInvoiceHandler string = "BootstrappedInvoiceHandler"
)

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{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

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

Bootstrap sets the required storage and registers

type Invoice

type Invoice struct {
	InvoiceNumber    string // invoice number or reference number
	SenderName       string // name of the sender company
	SenderStreet     string // street and address details of the sender company
	SenderCity       string
	SenderZipcode    string // country ISO code of the sender of this invoice
	SenderCountry    string
	RecipientName    string // name of the recipient company
	RecipientStreet  string
	RecipientCity    string
	RecipientZipcode string
	RecipientCountry string // country ISO code of the recipient of this invoice
	Currency         string // country ISO code of the recipient of this invoice
	GrossAmount      int64  // invoice amount including tax
	NetAmount        int64  // invoice amount excluding tax
	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) CalculateDataRoot

func (i *Invoice) CalculateDataRoot() error

CalculateDataRoot calculates the data root and sets the root to core document

func (*Invoice) CreateProofs

func (i *Invoice) CreateProofs(fields []string) (coreDoc *coredocumentpb.CoreDocument, proofs []*proofspb.Proof, err error)

CreateProofs generates proofs for given fields

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)

ID returns document identifier. Note: this is not a unique identifier for each version of the document.

func (*Invoice) InitInvoiceInput

func (i *Invoice) InitInvoiceInput(payload *clientinvoicepb.InvoiceCreatePayload, self string) 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(ctx context.Context, payload *clientinvoicepb.InvoiceCreatePayload) (documents.Model, error)

	// DeriveFromUpdatePayload derives invoice model from update payload
	DeriveFromUpdatePayload(ctx context.Context, payload *clientinvoicepb.InvoiceUpdatePayload) (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(
	srv documents.Service,
	repo documents.Repository,
	queueSrv queue.TaskQueuer,
	txService transactions.Service,
) 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