invoice

package
v0.0.6-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Scheme is the scheme used by invoice documents
	Scheme = prefix

	// ErrInvoiceInvalidData sentinel error when data unmarshal is failed.
	ErrInvoiceInvalidData = errors.Error("invalid invoice data")
)

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 DefaultService

func DefaultService(
	srv documents.Service,
	repo documents.Repository,
	queueSrv queue.TaskQueuer,
	jobManager jobs.Manager,
	tokenRegFinder func() documents.TokenRegistry,
	anchorRepo anchors.AnchorRepository,
) documents.Service

DefaultService returns the default implementation of the service.

func UpdateValidator

func UpdateValidator(repo anchors.AnchorRepository) 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 Data

type Data struct {
	Number                   string                        `json:"number"` // invoice number or reference number
	Status                   string                        `json:"status"` // invoice status
	SenderInvoiceID          string                        `json:"sender_invoice_id"`
	RecipientInvoiceID       string                        `json:"recipient_invoice_id"`
	SenderCompanyName        string                        `json:"sender_company_name"`
	SenderContactPersonName  string                        `json:"sender_contact_person_name"`
	SenderStreet1            string                        `json:"sender_street_1"` // street and address details of the sender company
	SenderStreet2            string                        `json:"sender_street_2"`
	SenderCity               string                        `json:"sender_city"`
	SenderZipcode            string                        `json:"sender_zipcode"`
	SenderState              string                        `json:"sender_state"`
	SenderCountry            string                        `json:"sender_country"` // country ISO code of the sender of this invoice
	BillToCompanyName        string                        `json:"bill_to_company_name"`
	BillToContactPersonName  string                        `json:"bill_to_contact_person_name"`
	BillToStreet1            string                        `json:"bill_to_street_1"`
	BillToStreet2            string                        `json:"bill_to_street_2"`
	BillToCity               string                        `json:"bill_to_city"`
	BillToZipcode            string                        `json:"bill_to_zipcode"`
	BillToState              string                        `json:"bill_to_state"`
	BillToCountry            string                        `json:"bill_to_country"`
	BillToVatNumber          string                        `json:"bill_to_vat_number"`
	BillToLocalTaxID         string                        `json:"bill_to_local_tax_id"`
	RemitToCompanyName       string                        `json:"remit_to_company_name"`
	RemitToContactPersonName string                        `json:"remit_to_contact_person_name"`
	RemitToStreet1           string                        `json:"remit_to_street_1"`
	RemitToStreet2           string                        `json:"remit_to_street_2"`
	RemitToCity              string                        `json:"remit_to_city"`
	RemitToZipcode           string                        `json:"remit_to_zipcode"`
	RemitToState             string                        `json:"remit_to_state"`
	RemitToCountry           string                        `json:"remit_to_country"`
	RemitToVatNumber         string                        `json:"remit_to_vat_number"`
	RemitToLocalTaxID        string                        `json:"remit_to_local_tax_id"`
	RemitToTaxCountry        string                        `json:"remit_to_tax_country"`
	ShipToCompanyName        string                        `json:"ship_to_company_name"`
	ShipToContactPersonName  string                        `json:"ship_to_contact_person_name"`
	ShipToStreet1            string                        `json:"ship_to_street_1"`
	ShipToStreet2            string                        `json:"ship_to_street_2"`
	ShipToCity               string                        `json:"ship_to_city"`
	ShipToZipcode            string                        `json:"ship_to_zipcode"`
	ShipToState              string                        `json:"ship_to_state"`
	ShipToCountry            string                        `json:"ship_to_country"`
	Currency                 string                        `json:"currency"`                                    // ISO currency code
	GrossAmount              *documents.Decimal            `json:"gross_amount" swaggertype:"primitive,string"` // invoice amount including tax
	NetAmount                *documents.Decimal            `json:"net_amount" swaggertype:"primitive,string"`   // invoice amount excluding tax
	TaxAmount                *documents.Decimal            `json:"tax_amount" swaggertype:"primitive,string"`
	TaxRate                  *documents.Decimal            `json:"tax_rate" swaggertype:"primitive,string"`
	TaxOnLineLevel           bool                          `json:"tax_on_line_level"`
	Recipient                *identity.DID                 `json:"recipient,string" swaggertype:"primitive,string"` // centrifuge ID of the recipient
	Sender                   *identity.DID                 `json:"sender,string" swaggertype:"primitive,string"`    // centrifuge ID of the sender
	Payee                    *identity.DID                 `json:"payee,string" swaggertype:"primitive,string"`     // centrifuge ID of the payee
	Comment                  string                        `json:"comment"`
	ShippingTerms            string                        `json:"shipping_terms"`
	RequesterEmail           string                        `json:"requester_email"`
	RequesterName            string                        `json:"requester_name"`
	DeliveryNumber           string                        `json:"delivery_number"` // number of the delivery note
	IsCreditNote             bool                          `json:"is_credit_note"`
	CreditNoteInvoiceNumber  string                        `json:"credit_note_invoice_number"`
	CreditForInvoiceDate     *time.Time                    `json:"credit_for_invoice_date"`
	DateDue                  *time.Time                    `json:"date_due" swaggertype:"primitive,string"`
	DatePaid                 *time.Time                    `json:"date_paid" swaggertype:"primitive,string"`
	DateUpdated              *time.Time                    `json:"date_updated" swaggertype:"primitive,string"`
	DateCreated              *time.Time                    `json:"date_created" swaggertype:"primitive,string"`
	Attachments              []*documents.BinaryAttachment `json:"attachments"`
	LineItems                []*LineItem                   `json:"line_items"`
	PaymentDetails           []*documents.PaymentDetails   `json:"payment_details"`
	TaxItems                 []*TaxItem                    `json:"tax_items"`
}

Data holds the invoice specific fields.

type Invoice

type Invoice struct {
	*documents.CoreDocument
	Data Data
}

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

func (*Invoice) AddAttributes

func (i *Invoice) AddAttributes(ca documents.CollaboratorsAccess, prepareNewVersion bool, attrs ...documents.Attribute) error

AddAttributes adds attributes to the Invoice model.

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) DeleteAttribute

func (i *Invoice) DeleteAttribute(key documents.AttrKey, prepareNewVersion bool) error

DeleteAttribute deletes the attribute from the model.

func (*Invoice) DeriveFromCreatePayload

func (i *Invoice) DeriveFromCreatePayload(_ context.Context, payload documents.CreatePayload) error

DeriveFromCreatePayload unpacks the invoice data from the Payload.

func (*Invoice) DeriveFromUpdatePayload

func (i *Invoice) DeriveFromUpdatePayload(_ context.Context, payload documents.UpdatePayload) (documents.Model, error)

DeriveFromUpdatePayload unpacks the update payload and prepares a new version.

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) GetData

func (i *Invoice) GetData() interface{}

GetData returns Invoice Data.

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) Patch

func (i *Invoice) Patch(payload documents.UpdatePayload) error

Patch merges payload data into model

func (*Invoice) Scheme

func (i *Invoice) Scheme() string

Scheme returns the invoice Scheme.

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             `json:"item_number"`
	Description             string             `json:"description"`
	SenderPartNo            string             `json:"sender_part_no"`
	PricePerUnit            *documents.Decimal `json:"price_per_unit" swaggertype:"primitive,string"`
	Quantity                *documents.Decimal `json:"quantity" swaggertype:"primitive,string"`
	UnitOfMeasure           string             `json:"unit_of_measure"`
	NetWeight               *documents.Decimal `json:"net_weight" swaggertype:"primitive,string"`
	TaxAmount               *documents.Decimal `json:"tax_amount" swaggertype:"primitive,string"`
	TaxRate                 *documents.Decimal `json:"tax_rate" swaggertype:"primitive,string"`
	TaxCode                 *documents.Decimal `json:"tax_code" swaggertype:"primitive,string"`
	TotalAmount             *documents.Decimal `json:"total_amount" swaggertype:"primitive,string"` // the total amount of the line item
	PurchaseOrderNumber     string             `json:"purchase_order_number"`
	PurchaseOrderItemNumber string             `json:"purchase_order_item_number"`
	DeliveryNoteNumber      string             `json:"delivery_note_number"`
}

LineItem represents a single invoice line item.

type TaxItem

type TaxItem struct {
	ItemNumber        string             `json:"item_number"`
	InvoiceItemNumber string             `json:"invoice_item_number"`
	TaxAmount         *documents.Decimal `json:"tax_amount" swaggertype:"primitive,string"`
	TaxRate           *documents.Decimal `json:"tax_rate" swaggertype:"primitive,string"`
	TaxCode           *documents.Decimal `json:"tax_code" swaggertype:"primitive,string"`
	TaxBaseAmount     *documents.Decimal `json:"tax_base_amount" swaggertype:"primitive,string"`
}

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