package model import ( "electricity_bill_calc/tools" "electricity_bill_calc/types" "github.com/shopspring/decimal" ) type InvoiceTitle struct { Name string `json:"name"` USCI string `json:"usci"` Address string `json:"address"` Phone string `json:"phone"` Bank string `json:"bank"` Account string `json:"account"` } type InvoiceCargo struct { Name string `json:"name"` Price decimal.Decimal `json:"price"` Unit string `json:"unit"` Quantity decimal.Decimal `json:"quantity"` TaxRate decimal.Decimal `json:"taxRate"` Tax decimal.Decimal `json:"tax"` Total decimal.Decimal `json:"total"` } type Invoice struct { InvoiceNo string `json:"invoiceNo"` Park string `json:"parkId" db:"park_id"` Tenement string `json:"tenementId" db:"tenement_id"` InvoiceType *string `json:"type" db:"type"` Info InvoiceTitle `json:"invoiceInfo" db:"invoice_info"` Cargos []InvoiceCargo `json:"cargos"` TaxRate decimal.Decimal `json:"taxRate" db:"tax_rate"` TaxMethod int16 `json:"taxMethod" db:"tax_method"` Total decimal.Decimal `json:"total" db:"total"` IssuedAt types.DateTime `json:"issuedAt" db:"issued_at"` Covers []string `json:"covers"` } func (i Invoice) Type() string { return tools.DefaultOrEmptyStr(i.InvoiceType, "") }