Documentation ¶
Index ¶
- func CreateValidator() documents.ValidatorGroup
- func GRPCHandler() (clientinvoicepb.DocumentServiceServer, error)
- func UpdateValidator() documents.ValidatorGroup
- type Bootstrapper
- type Invoice
- func (i *Invoice) FromJSON(jsonData []byte) error
- func (i *Invoice) ID() ([]byte, error)
- func (i *Invoice) InitInvoiceInput(payload *clientinvoicepb.InvoiceCreatePayload, ...) error
- func (i *Invoice) JSON() ([]byte, error)
- func (i *Invoice) PackCoreDocument() (*coredocumentpb.CoreDocument, error)
- func (i *Invoice) Type() reflect.Type
- func (i *Invoice) UnpackCoreDocument(coreDoc *coredocumentpb.CoreDocument) error
- type Service
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 ¶
func GRPCHandler() (clientinvoicepb.DocumentServiceServer, error)
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) 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) PackCoreDocument ¶
PackCoreDocument packs the Invoice into a Core Document If the, Invoice is new, it creates a valid identifiers
func (*Invoice) UnpackCoreDocument ¶
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