Documentation
¶
Overview ¶
Package generator allows you to easily generate invoices, delivery notes and quotations in GoLang.
Index ¶
- Constants
- Variables
- type Address
- type Contact
- type Discount
- type Document
- func (d *Document) AppendItem(item *Item) *Document
- func (doc *Document) Build() (*gopdf.GoPdf, error)
- func (d *Document) SetCompany(company *Contact) *Document
- func (d *Document) SetCustomer(customer *Contact) *Document
- func (d *Document) SetDate(date string) *Document
- func (d *Document) SetDefaultTax(tax *Tax) *Document
- func (d *Document) SetDescription(desc string) *Document
- func (d *Document) SetDiscount(discount *Discount) *Document
- func (d *Document) SetFooter(footer *HeaderFooter) *Document
- func (d *Document) SetHeader(header *HeaderFooter) *Document
- func (d *Document) SetNotes(notes string) *Document
- func (d *Document) SetPaymentTerm(term string) *Document
- func (d *Document) SetRef(ref string) *Document
- func (d *Document) SetType(docType string) *Document
- func (d *Document) SetVersion(version string) *Document
- func (d *Document) Validate() error
- type HeaderFooter
- type Item
- type Options
- type Tax
Constants ¶
const ( // Invoice define the "invoice" document type Invoice string = "INVOICE" // Quotation define the "quotation" document type Quotation string = "QUOTATION" // DeliveryNote define the "delievry note" document type DeliveryNote string = "DELIVERY_NOTE" // BaseMargin define base margin used in documents BaseMargin float64 = 30 // BaseMarginTop define base margin top used in documents BaseMarginTop float64 = 40 // HeaderMarginTop define base header margin top used in documents HeaderMarginTop float64 = 5 // MaxPageHeight define the maximum height for a single page MaxPageHeight float64 = 900 )
const ( // ItemColUnitPriceOffset ... ItemColUnitPriceOffset float64 = PageWidth * 0.4 // ItemColQuantityOffset ... ItemColQuantityOffset float64 = PageWidth * 0.5 // ItemColTotalHTOffset ... ItemColTotalHTOffset float64 = PageWidth * 0.55 // ItemColDiscountOffset ... ItemColDiscountOffset float64 = PageWidth * 0.69 // ItemColTaxOffset ... ItemColTaxOffset float64 = PageWidth * 0.75 // ItemColTotalTTCOffset ... ItemColTotalTTCOffset float64 = PageWidth * 0.85 )
Cols offsets
const ( ColumnWidth = 250 PageWidth = 592 )
Variables ¶
var ( // BaseTextFontSize define the base font size for text in document BaseTextFontSize float64 = 8 // SmallTextFontSize define the small font size for text in document SmallTextFontSize float64 = 7 // ExtraSmallTextFontSize define the extra small font size for text in document ExtraSmallTextFontSize float64 = 6 // LargeTextFontSize define the large font size for text in document LargeTextFontSize float64 = 10 )
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Address string `json:"address,omitempty" validate:"required"`
Address2 string `json:"address_2,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
City string `json:"city,omitempty"`
Country string `json:"country,omitempty"`
BusinessID string
TaxID string
VAT string
IBAN string
BankName string
}
Address represent an address
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty" validate:"required,min=1,max=256"`
Logo *[]byte `json:"logo,omitempty"` // Logo byte array
Address *Address `json:"address,omitempty"`
}
Contact contact a company informations
type Discount ¶
type Discount struct {
Percent string `json:"percent,omitempty"` // Discount in percent ex 17
Amount string `json:"amount,omitempty"` // Discount in amount ex 123.40
}
Discount define discount as percent or fixed amount
type Document ¶
type Document struct {
Options *Options `json:"options,omitempty"`
Header *HeaderFooter `json:"header,omitempty"`
Type string `json:"type,omitempty" validate:"required,oneof=INVOICE DELIVERY_NOTE QUOTATION"`
Ref string `json:"ref,omitempty" validate:"required,min=1,max=32"`
Version string `json:"version,omitempty" validate:"max=32"`
ClientRef string `json:"client_ref,omitempty" validate:"max=64"`
Description string `json:"description,omitempty" validate:"max=1024"`
Notes string `json:"notes,omitempty"`
Company *Contact `json:"company,omitempty" validate:"required"`
Customer *Contact `json:"customer,omitempty" validate:"required"`
Items []*Item `json:"items,omitempty"`
Date string `json:"date,omitempty"`
ValidityDate string `json:"validity_date,omitempty"`
PaymentTerm string `json:"payment_term,omitempty"`
DefaultTax *Tax `json:"default_tax,omitempty"`
Discount *Discount `json:"discount,omitempty"`
// contains filtered or unexported fields
}
Document define base document
func (*Document) AppendItem ¶
AppendItem to document items
func (*Document) SetCompany ¶
SetCompany of document
func (*Document) SetCustomer ¶
SetCustomer of document
func (*Document) SetDefaultTax ¶
SetDefaultTax of document
func (*Document) SetDescription ¶
SetDescription of document
func (*Document) SetDiscount ¶
SetDiscount of document
func (*Document) SetFooter ¶
func (d *Document) SetFooter(footer *HeaderFooter) *Document
SetFooter set footer of document
func (*Document) SetHeader ¶
func (d *Document) SetHeader(header *HeaderFooter) *Document
SetHeader set header of document
func (*Document) SetPaymentTerm ¶
SetPaymentTerm of document
func (*Document) SetVersion ¶
SetVersion of document
type HeaderFooter ¶
type HeaderFooter struct {
}
HeaderFooter define header or footer informations on document
func (*HeaderFooter) ApplyFunc ¶
func (hf *HeaderFooter) ApplyFunc(pdf *gopdf.GoPdf, fn fnc)
ApplyFunc allow user to apply custom func
type Item ¶
type Item struct {
Name string `json:"name,omitempty" validate:"required"`
Description string `json:"description,omitempty"`
UnitCost string `json:"unit_cost,omitempty"`
Quantity string `json:"quantity,omitempty"`
Tax *Tax `json:"tax,omitempty"`
Discount *Discount `json:"discount,omitempty"`
}
Item represent a 'product' or a 'service'
type Options ¶
type Options struct {
CurrencySymbol string `default:"€ " json:"currency_symbol,omitempty"`
CurrencyPrecision int `default:"2" json:"currency_precision,omitempty"`
CurrencyDecimal string `default:"." json:"currency_decimal,omitempty"`
CurrencyThousand string `default:" " json:"currency_thousand,omitempty"`
TextTypeInvoice string `default:"INVOICE" json:"text_type_invoice,omitempty"`
TextTypeQuotation string `default:"QUOTATION" json:"text_type_quotation,omitempty"`
TextTypeDeliveryNote string `default:"DELIVERY NOTE" json:"text_type_delivery_note,omitempty"`
TextRefTitle string `default:"Ref." json:"text_ref_title,omitempty"`
TextVersionTitle string `default:"Version" json:"text_version_title,omitempty"`
TextDateTitle string `default:"Date" json:"text_date_title,omitempty"`
TextPaymentTermTitle string `default:"Payment term" json:"text_payment_term_title,omitempty"`
TextItemsNameTitle string `default:"Name" json:"text_items_name_title,omitempty"`
TextItemsUnitCostTitle string `default:"Unit price" json:"text_items_unit_cost_title,omitempty"`
TextItemsQuantityTitle string `default:"Qty" json:"text_items_quantity_title,omitempty"`
TextItemsTotalHTTitle string `default:"Price no tax" json:"text_items_total_ht_title,omitempty"`
TextItemsTaxTitle string `default:"Tax" json:"text_items_tax_title,omitempty"`
TextItemsDiscountTitle string `default:"Discount" json:"text_items_discount_title,omitempty"`
TextItemsTotalTTCTitle string `default:"Total" json:"text_items_total_ttc_title,omitempty"`
TextTotalTotal string `default:"TOTAL" json:"text_total_total,omitempty"`
TextTotalDiscounted string `default:"TOTAL DISCOUNTED" json:"text_total_discounted,omitempty"`
TextTotalTax string `default:"TAX" json:"text_total_tax,omitempty"`
TextTotalWithTax string `default:"TOTAL WITH TAX" json:"text_total_with_tax,omitempty"`
TextTotalNoTax string `default:"TOTAL WITHOUTH TAX" json:"text_total_with_tax,omitempty"`
BaseTextColor []uint8 `default:"[35,35,35]" json:"base_text_color,omitempty"`
GreyTextColor []uint8 `default:"[82,82,82]" json:"grey_text_color,omitempty"`
GreyBgColor []uint8 `default:"[232,232,232]" json:"grey_bg_color,omitempty"`
DarkBgColor []uint8 `default:"[192,192,192]" json:"dark_bg_color,omitempty"`
}
Options for Document
