Documentation ¶
Index ¶
- Constants
- func CreateValidator() documents.ValidatorGroup
- func GRPCHandler(config config.Service, srv Service) clientinvoicepb.DocumentServiceServer
- func UpdateValidator() documents.ValidatorGroup
- type Bootstrapper
- type Invoice
- func (i *Invoice) CalculateDataRoot() error
- func (i *Invoice) CreateProofs(fields []string) (coreDoc *coredocumentpb.CoreDocument, proofs []*proofspb.Proof, err error)
- func (i *Invoice) FromJSON(jsonData []byte) error
- func (i *Invoice) ID() ([]byte, error)
- func (i *Invoice) InitInvoiceInput(payload *clientinvoicepb.InvoiceCreatePayload, self string) 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 ¶
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 ¶
func GRPCHandler(config config.Service, srv Service) clientinvoicepb.DocumentServiceServer
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 ¶
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) ID ¶
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) 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(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.