invoice

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 25 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 {
	*documents.CoreDocument

	Number                   string // invoice number or reference number
	Status                   string // invoice status
	SenderInvoiceID          string
	RecipientInvoiceID       string
	SenderCompanyName        string
	SenderContactPersonName  string
	SenderStreet1            string // street and address details of the sender company
	SenderStreet2            string
	SenderCity               string
	SenderZipcode            string
	SenderState              string
	SenderCountry            string // country ISO code of the sender of this invoice
	BillToCompanyName        string
	BillToContactPersonName  string
	BillToStreet1            string
	BillToStreet2            string
	BillToCity               string
	BillToZipcode            string
	BillToState              string
	BillToCountry            string
	BillToVatNumber          string
	BillToLocalTaxID         string
	RemitToCompanyName       string
	RemitToContactPersonName string
	RemitToStreet1           string
	RemitToStreet2           string
	RemitToCity              string
	RemitToZipcode           string
	RemitToState             string
	RemitToCountry           string
	RemitToVatNumber         string
	RemitToLocalTaxID        string
	RemitToTaxCountry        string
	ShipToCompanyName        string
	ShipToContactPersonName  string
	ShipToStreet1            string
	ShipToStreet2            string
	ShipToCity               string
	ShipToZipcode            string
	ShipToState              string
	ShipToCountry            string
	Currency                 string             // ISO currency code
	GrossAmount              *documents.Decimal // invoice amount including tax
	NetAmount                *documents.Decimal // invoice amount excluding tax
	TaxAmount                *documents.Decimal
	TaxRate                  *documents.Decimal
	TaxOnLineLevel           bool
	Recipient                *identity.DID `json:"recipient,string"` // centrifuge ID of the recipient
	Sender                   *identity.DID `json:"sender,string"`    // centrifuge ID of the sender
	Payee                    *identity.DID `json:"payee,string"`     // centrifuge ID of the payee
	Comment                  string
	ShippingTerms            string
	RequesterEmail           string
	RequesterName            string
	DeliveryNumber           string // number of the delivery note
	IsCreditNote             bool
	CreditNoteInvoiceNumber  string
	CreditForInvoiceDate     *timestamp.Timestamp
	DateDue                  *timestamp.Timestamp
	DatePaid                 *timestamp.Timestamp
	DateUpdated              *timestamp.Timestamp
	DateCreated              *timestamp.Timestamp
	Attachments              []*documents.BinaryAttachment
	LineItems                []*LineItem
	PaymentDetails           []*documents.PaymentDetails
	TaxItems                 []*TaxItem
}

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

func (*Invoice) AddNFT

func (i *Invoice) AddNFT(grantReadAccess bool, registry common.Address, tokenID []byte) error

AddNFT adds NFT to the Invoice.

func (*Invoice) CalculateDataRoot

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

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

func (*Invoice) CalculateDocumentRoot

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

CalculateDocumentRoot calculates the document root

func (*Invoice) CalculateSigningRoot

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

CalculateSigningRoot calculates the signing root of the document.

func (*Invoice) CollaboratorCanUpdate

func (i *Invoice) CollaboratorCanUpdate(updated documents.Model, collaborator identity.DID) error

CollaboratorCanUpdate checks if the collaborator can update the document.

func (*Invoice) CreateNFTProofs

func (i *Invoice) CreateNFTProofs(
	account identity.DID,
	registry common.Address,
	tokenID []byte,
	nftUniqueProof, readAccessProof bool) (proofs []*proofspb.Proof, err error)

CreateNFTProofs creates proofs specific to NFT minting.

func (*Invoice) CreateProofs

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

CreateProofs generates proofs for given fields.

func (*Invoice) DocumentRootTree

func (i *Invoice) DocumentRootTree() (tree *proofs.DocumentTree, err error)

DocumentRootTree creates and returns the document root tree

func (*Invoice) DocumentType

func (*Invoice) DocumentType() string

DocumentType returns the invoice document type.

func (*Invoice) FromJSON

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

FromJSON unmarshals the json bytes into Invoice

func (*Invoice) InitInvoiceInput

func (i *Invoice) InitInvoiceInput(payload *clientinvoicepb.InvoiceCreatePayload, self identity.DID) 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() (cd coredocumentpb.CoreDocument, err error)

PackCoreDocument packs the Invoice into a CoreDocument.

func (*Invoice) PrepareNewVersion

func (i *Invoice) PrepareNewVersion(old documents.Model, data *clientinvoicepb.InvoiceData, collaborators documents.CollaboratorsAccess) error

PrepareNewVersion prepares new version from the old invoice.

func (*Invoice) Type

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

Type gives the Invoice type

func (*Invoice) UnpackCoreDocument

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

UnpackCoreDocument unpacks the core document into Invoice.

type LineItem

type LineItem struct {
	ItemNumber              string
	Description             string
	SenderPartNo            string
	PricePerUnit            *documents.Decimal
	Quantity                *documents.Decimal
	UnitOfMeasure           string
	NetWeight               *documents.Decimal
	TaxAmount               *documents.Decimal
	TaxRate                 *documents.Decimal
	TaxCode                 *documents.Decimal
	TotalAmount             *documents.Decimal // the total amount of the line item
	PurchaseOrderNumber     string
	PurchaseOrderItemNumber string
	DeliveryNoteNumber      string
}

LineItem represents a single invoice line item.

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,
	jobManager jobs.Manager,
	tokenRegFinder func() documents.TokenRegistry,
) Service

DefaultService returns the default implementation of the service.

type TaxItem

type TaxItem struct {
	ItemNumber        string
	InvoiceItemNumber string
	TaxAmount         *documents.Decimal
	TaxRate           *documents.Decimal
	TaxCode           *documents.Decimal
	TaxBaseAmount     *documents.Decimal
}

TaxItem represents a single invoice tax item.

Jump to

Keyboard shortcuts

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