Documentation ¶
Index ¶
- Constants
- func CreateValidator() documents.ValidatorGroup
- func DefaultService(srv documents.Service, repo documents.Repository, queueSrv queue.TaskQueuer, ...) documents.Service
- func UpdateValidator(repo anchors.AnchorRepository) documents.ValidatorGroup
- type Bootstrapper
- type Data
- type Invoice
- func (i *Invoice) AddAttributes(ca documents.CollaboratorsAccess, prepareNewVersion bool, ...) error
- func (i *Invoice) AddNFT(grantReadAccess bool, registry common.Address, tokenID []byte) error
- func (i *Invoice) CalculateDataRoot() ([]byte, error)
- func (i *Invoice) CalculateDocumentRoot() ([]byte, error)
- func (i *Invoice) CalculateSigningRoot() ([]byte, error)
- func (i *Invoice) CollaboratorCanUpdate(updated documents.Model, collaborator identity.DID) error
- func (i *Invoice) CreateNFTProofs(account identity.DID, registry common.Address, tokenID []byte, ...) (proofs []*proofspb.Proof, err error)
- func (i *Invoice) CreateProofs(fields []string) (proofs []*proofspb.Proof, err error)
- func (i *Invoice) DeleteAttribute(key documents.AttrKey, prepareNewVersion bool) error
- func (i *Invoice) DeriveFromCreatePayload(_ context.Context, payload documents.CreatePayload) error
- func (i *Invoice) DeriveFromUpdatePayload(_ context.Context, payload documents.UpdatePayload) (documents.Model, error)
- func (i *Invoice) DocumentRootTree() (tree *proofs.DocumentTree, err error)
- func (*Invoice) DocumentType() string
- func (i *Invoice) FromJSON(jsonData []byte) error
- func (i *Invoice) GetData() interface{}
- func (i *Invoice) JSON() ([]byte, error)
- func (i *Invoice) PackCoreDocument() (cd coredocumentpb.CoreDocument, err error)
- func (i *Invoice) Patch(payload documents.UpdatePayload) error
- func (i *Invoice) Scheme() string
- func (i *Invoice) Type() reflect.Type
- func (i *Invoice) UnpackCoreDocument(cd coredocumentpb.CoreDocument) error
- type LineItem
- type TaxItem
Constants ¶
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) CalculateDataRoot ¶
CalculateDataRoot calculates the data root and sets the root to core document.
func (*Invoice) CalculateDocumentRoot ¶
CalculateDocumentRoot calculates the document root
func (*Invoice) CalculateSigningRoot ¶
CalculateSigningRoot calculates the signing root of the document.
func (*Invoice) CollaboratorCanUpdate ¶
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 ¶
CreateProofs generates proofs for given fields.
func (*Invoice) DeleteAttribute ¶
DeleteAttribute deletes the attribute from the model.
func (*Invoice) DeriveFromCreatePayload ¶
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 ¶
DocumentType returns the invoice document type.
func (*Invoice) PackCoreDocument ¶
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) UnpackCoreDocument ¶
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.