model

package
v0.0.0-...-861173f Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ClientBillingAddressType = "client_billing"
View Source
const ClientShippingAddressType = "client_shipping"
View Source
const CompanyBillingAddressType = "company_billing"
View Source
const CompanyShippingAddressType = "company_shipping"

Variables

Functions

func DefaultTaxInclusive

func DefaultTaxInclusive(ctx context.Context, db *gorm.DB, gqlClient *gqlClient.Client, companyID hide.ID) bool

func DefaultTaxRate

func DefaultTaxRate(ctx context.Context, db *gorm.DB, gqlClient *gqlClient.Client, companyID hide.ID) float64

func InvoiceItemCostHelper

func InvoiceItemCostHelper(item *LineItemInput) string

func InvoiceItemTotalHelper

func InvoiceItemTotalHelper(item *LineItemInput) string

func InvoiceTotalHelper

func InvoiceTotalHelper(invoice *InvoiceTemplateData) string

Types

type Address

type Address struct {
	ID         hide.ID `gorm:"type: bigserial;primary_key" json:"id"` // int64
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  *time.Time
	Name       string
	Street1    string
	Street2    *string
	City       string
	State      *string
	PostalCode int
	Country    string

	AddresseeID   hide.ID
	AddresseeType string
}

type Client

type Client struct {
	ID        hide.ID `gorm:"type: bigserial;primary_key" json:"id"` // int64
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
	Name      string

	Website        *string
	VatNumber      *string
	BusinessNumber *string
	Phone          *string

	BillingAddress  Address `gorm:"polymorphic:Addressee;polymorphicValue:client_billing"`
	ShippingAddress Address `gorm:"polymorphic:Addressee;polymorphicValue:client_shipping"`

	Contacts  []Contact
	CompanyID hide.ID `json:"company"`
	Company   Company `json:"-"`

	Invoices []*Invoice `json:"invoices"`
}

func GetClient

func GetClient(ctx context.Context, db *gorm.DB, gqlClient *gqlClient.Client, id hide.ID) (Client, error)

func (Client) IsEntity

func (Client) IsEntity()

type Company

type Company struct {
	ID        hide.ID `gorm:"type: bigserial;primary_key" json:"id"` // int64
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
	Code      string `gorm:"unique_index:idx_code"`
	Name      string
	Website   string

	BillingAddress  Address `gorm:"polymorphic:Addressee;polymorphicValue:company_billing"`
	ShippingAddress Address `gorm:"polymorphic:Addressee;polymorphicValue:company_shipping"`

	InvoiceTaxInclusive bool `json:"invoiceTaxInclusive"`

	InvoiceTaxRate float64 `json:"invoiceTaxRate"`
}

func GetCompany

func GetCompany(ctx context.Context, db *gorm.DB, gqlClient *gqlClient.Client, id hide.ID) (Company, error)

func (Company) IsEntity

func (Company) IsEntity()

type Contact

type Contact struct {
	ID               hide.ID `gorm:"type: bigserial;primary_key" json:"id"` // int64
	CreatedAt        time.Time
	UpdatedAt        time.Time
	DeletedAt        *time.Time
	ClientID         hide.ID
	Email            *string
	Phone            *string
	Mobile           *string
	PreferredContact *PreferredContact
	Firstname        string
	Lastname         string
}

type Invoice

type Invoice struct {
	ID        hide.ID `gorm:"type: bigserial;primary_key" json:"Id"` // int64
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
	Number    InvoiceNumber `gorm:"default:1"`
	CompanyID hide.ID
	CreatedBy hide.ID
	ClientID  hide.ID
	DateDue   time.Time

	LineItems []LineItem `json:"Items"`
}

type InvoiceInput

type InvoiceInput struct {
	ClientID hide.ID          `json:"clientID"`
	Items    []*LineItemInput `json:"items"`
	DateDue  time.Time        `json:"dateDue"`
}

type InvoiceNumber

type InvoiceNumber struct {
	Number    int64
	CompanyID hide.ID
}

func (InvoiceNumber) GormDataType

func (n InvoiceNumber) GormDataType() string

func (InvoiceNumber) GormValue

func (n InvoiceNumber) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (*InvoiceNumber) Scan

func (n *InvoiceNumber) Scan(v interface{}) error

type InvoicePaymentStatus

type InvoicePaymentStatus string
const (
	InvoicePaymentStatusPending  InvoicePaymentStatus = "PENDING"
	InvoicePaymentStatusComplete InvoicePaymentStatus = "COMPLETE"
	InvoicePaymentStatusOverdue  InvoicePaymentStatus = "OVERDUE"
)

func (InvoicePaymentStatus) IsValid

func (e InvoicePaymentStatus) IsValid() bool

func (InvoicePaymentStatus) MarshalGQL

func (e InvoicePaymentStatus) MarshalGQL(w io.Writer)

func (InvoicePaymentStatus) String

func (e InvoicePaymentStatus) String() string

func (*InvoicePaymentStatus) UnmarshalGQL

func (e *InvoicePaymentStatus) UnmarshalGQL(v interface{}) error

type InvoiceRenderMQ

type InvoiceRenderMQ struct {
	Invoice      Invoice
	NotifyConfig Notify
}

type InvoiceStatus

type InvoiceStatus string
const (
	InvoiceStatusDraft  InvoiceStatus = "DRAFT"
	InvoiceStatusSent   InvoiceStatus = "SENT"
	InvoiceStatusViewed InvoiceStatus = "VIEWED"
)

func (InvoiceStatus) IsValid

func (e InvoiceStatus) IsValid() bool

func (InvoiceStatus) MarshalGQL

func (e InvoiceStatus) MarshalGQL(w io.Writer)

func (InvoiceStatus) String

func (e InvoiceStatus) String() string

func (*InvoiceStatus) UnmarshalGQL

func (e *InvoiceStatus) UnmarshalGQL(v interface{}) error

type InvoiceTemplateData

type InvoiceTemplateData struct {
	Number  int
	Client  Client
	Company Company
	Items   []*LineItemInput
}

type LineItem

type LineItem struct {
	ID           hide.ID `gorm:"type: bigserial;primary_key" json:"id"` // int64
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    gorm.DeletedAt `gorm:"index"`
	InvoiceID    hide.ID
	Name         string
	Description  string
	UnitCost     decimal.Decimal
	TaxRate      decimal.Decimal
	Quantity     float64
	TaxInclusive bool
}

func (*LineItem) Tax

func (l *LineItem) Tax() decimal.Decimal

func (*LineItem) TaxRatePercent

func (l *LineItem) TaxRatePercent() decimal.Decimal

func (*LineItem) Total

func (l *LineItem) Total() decimal.Decimal

type LineItemInput

type LineItemInput struct {
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	UnitCost     float64  `json:"unitCost"`
	TaxRate      *float64 `json:"taxRate"`
	Quantity     float64  `json:"quantity"`
	TaxInclusive *bool    `json:"taxInclusive"`
}

type Notify

type Notify struct {
	Users []int64
}

Notify holds data for sending notifications back to users

type Orm

type Orm struct {
	DB *gorm.DB
}

func Init

func Init(cfg *util.DatabaseConfig) *Orm

func (*Orm) Close

func (o *Orm) Close()

type PreferredContact

type PreferredContact string
const (
	PreferredContactPhone  PreferredContact = "PHONE"
	PreferredContactMobile PreferredContact = "MOBILE"
	PreferredContactEmail  PreferredContact = "EMAIL"
)

func (PreferredContact) IsValid

func (e PreferredContact) IsValid() bool

func (PreferredContact) MarshalGQL

func (e PreferredContact) MarshalGQL(w io.Writer)

func (PreferredContact) String

func (e PreferredContact) String() string

func (*PreferredContact) UnmarshalGQL

func (e *PreferredContact) UnmarshalGQL(v interface{}) error

type User

type User struct {
	ID hide.ID `json:"id"`
}

func (User) IsEntity

func (User) IsEntity()

Jump to

Keyboard shortcuts

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