pdfinvoice

package module
v0.0.0-...-4ed90be Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

README

invoice generator

Summary

A simple api to create invoices in pdf format. Based on fpdf package.

Dependencies

Installation

go get -u github.com/buffos/go-aade/pdfinvoice

Usage

First, We need to set to environment variables to use the api.

  • FONT_PATH: The path to the fonts directory
  • LOGO_FILE_PATH: the path to the logo file (including the file name and extension)

In the default options struct, we are expecting the following font files:

`FONT_PATH`/Roboto-Regular.ttf
`FONT_PATH`/Roboto-Bold.ttf

Font files are not included

We create a document that holds the required data

doc, err := NewInvoice(nil)

If we pass nil as the options struct, the default options are used. You can view and create custom options. The options struct is defined in the options.go file.

Then we add data to the document.


doc.LogoFileName = os.Getenv("LOGO_FILE_PATH")
doc.SetIssuer(&Contact{
		Name:            "Κωνσταντίνος Παπαδόπουλος",
		AFM:             "090000000",
		WorkDescription: "Τίποτα Απολύτως",
		Address: &Address{
			Address:    "Εγνατίας 12",
			Address2:   "",
			City:       "Θεσσαλονίκη",
			PostalCode: "12345",
		},
		DOY:            "Α΄ ΘΕΣΣΑΛΟΝΙΚΗΣ",
		AdditionalInfo: []string{"ΓΕΜΗ: 231506418987897 · email: support@test.gr \nΤηλ: 2210000111 · Κιν: 697777777"},
	})
	doc.SetCustomer(&Contact{
		Name:            "Παπαδόπουλος Ανδρέας",
		AFM:             "090000000",
		WorkDescription: "Παροχή Υπηρεσιών",
		Address: &Address{
			Address:    "Τσιμισκή 12",
			Address2:   "",
			City:       "Θεσσαλονίκη",
			PostalCode: "12345",
		},
		DOY: "Β΄ Θεσσαλονίκης",
	})

doc.Type = "Τιμολόγιο Παροχής Υπηρεσιών"
doc.Series = "ΤΠΥ-Α"
doc.Number = "1"
doc.Date = "01/01/2021"
doc.Mark = "4000000012351351"
doc.PaymentMethod = "Μετρητά"
doc.Notes = `Η παραγγελία θα εκτελεσθεί μέχρι τις 24 Ιουνίου 2021. Αριθμός συναλλαγής 40909345`
doc.QRCodeString = "https://www.example.gr"

Now we need to add the invoice entries for each item. For example:

	doc.InvoiceDetails.AddEntry(&InvoiceEntry{
		Description:       "Παροχή υπηρεσιών κατασκευής ιστοσελίδας",
		Quantity:          1,
		UnitOfMeasurement: "",
		NetPrice:          100,
		Discount:          0,
		FinalPrice:        0,
		TaxPercent:        24,
		TaxAmount:         24,
	})
	doc.InvoiceDetails.AddEntry(&InvoiceEntry{
		Description:       "Παροχή συντήρηση ιστοσελίδας για ένα έτος.",
		Quantity:          1,
		UnitOfMeasurement: "",
		NetPrice:          100,
		Discount:          0,
		FinalPrice:        0,
		TaxPercent:        24,
		TaxAmount:         24,
	})

Call the doc.CalculateTotals() function to calculate the totals row of the invoice. Next, we need to complete the taxes entries.

	doc.Taxes.WithHoldingTaxes = 20
	doc.Taxes.Deductions = 0
	doc.Taxes.StampDuty = 0
	doc.Taxes.Fees = 0
	doc.Taxes.OtherTaxes = 0

Finally, we need to create the document.

err = doc.CreateAndSave("test.pdf", SimpleA4Invoice{})

The second argument is a struct that implements the InvoiceCreator interface. This interface has three functions that 'draw' the header, footer and middle part of the invoice using the data we provided before.

We can create different implementations of this interface that create different invoices.

If we need to get a buffer, instead of a file, to upload it to a service, for example, S3, we can use

buffer, err := doc.CreateAndBuffer(SimpleA4Invoice{})

where buffer is a *bytes.Buffer pointer.

Documentation

Overview

Package pdfinvoice is a library for generating PDF invoices.

Defining the required environment variables

The following environment variables are required:

`FONT_PATH` - the path to the font files to be used
`LOGO_FILE_PATH` - the path to the logo file to be used.

In the default options struct, we are expecting the following font files:

`FONT_PATH`/Roboto-Regular.ttf
`FONT_PATH`/Roboto-Bold.ttf

Creating the document

doc, err := NewInvoice(nil)

By passing nil as the first argument, the default configuration will be used.

Filling the document with the required information

  • Issuer
  • Customer
  • Type
  • Number
  • Date
  • Series
  • Mark
  • PaymentMethod
  • Notes
  • QrCodeString

Adding invoice entries

Using the doc.InvoiceDetails.AddEntry method, you can add invoice entries. Those are the items sold or services provided.

Calculate Totals and Taxes

  • call doc.CalculateTotals() to calculate the totals

and fill all Taxes entries

doc.Taxes.WithHoldingTaxes =
doc.Taxes.Deductions =
doc.Taxes.StampDuty =
doc.Taxes.Fees =
doc.Taxes.OtherTaxes =

Generate the PDF

After providing all the required data we need to create the actual document. Each document has a header, a middle body and a footer. Three corresponding functions are responsible to place on the pdf document the data provided before. We need to provide any struct or data type, that implements the InvoiceCreator interface, which provides those three functions.

We have already one implementation of this interface, the simpleA4Invoice.

We create the document with the following code:

err := doc.CreateAndSave("test.pdf", SimpleA4Invoice{})

Index

Constants

View Source
const (
	// BaseMargin define base margin used in documents
	BaseMargin float64 = 10

	// BaseMarginTop define base margin top used in documents
	BaseMarginTop float64 = 10
)

margins

View Source
const (
	// BaseTextFontSize define the base font size for text in a document
	BaseTextFontSize float64 = 12

	// MediumTextFontSize define the base font size for text in a document
	MediumTextFontSize float64 = 10

	// SmallTextFontSize define the small font size for text in document
	SmallTextFontSize float64 = 8

	// 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 = 14
)
View Source
const (
	A4PageWidth  = 210.0
	A4PageHeight = 297.0
	A5PageWidth  = 148.0
	A5PageHeight = 210.0
	A6PageWidth  = 105.0
	A6PageHeight = 148.0
	A7PageWidth  = 74.0
	A7PageHeight = 105.0
)
View Source
const (
	LineHeight = 8
)

Variables

This section is empty.

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"`
}

Address is a struct that holds the address of a company or a person

func (*Address) String

func (a *Address) String() string

String output address as string. Line break is added for new lines

func (*Address) ToStringSingleLine

func (a *Address) ToStringSingleLine() string

type Contact

type Contact struct {
	Name            string   `json:"name" validate:"required,min=1,max=256"`
	AFM             string   `json:"afm" validate:"required,min=9,max=9"`
	WorkDescription string   `json:"work_description" validate:"required,min=1,max=256"`
	Address         *Address `json:"address" validate:"required,min=1,max=256"`
	DOY             string   `json:"doy" validate:"required,min=1,max=256"`
	AdditionalInfo  []string `json:"additional_info,omitempty"`
}

Contact represents contact information.

type Document

type Document struct {
	Options       Options `json:"options,omitempty"`
	Type          string  `json:"type,omitempty" validate:"required"`
	Date          string  `json:"date,omitempty"`
	Mark          string  `json:"mark,omitempty" validate:"required"`
	Number        string  `json:"number,omitempty" validate:"required"`
	Notes         string  `json:"notes,omitempty" validate:"min_length=1,max_length=256"`
	Series        string  `json:"series,omitempty" validate:"required"`
	PaymentMethod string  `json:"paymentMethod,omitempty" validate:"required"`
	UID           string  `json:"uid,omit"`
	QRCodeString  string  `json:"qr_code_string,omitempty"`

	InvoiceDetails *InvoiceDetails `json:"invoices_details,omitempty" validate:"required"`
	Taxes          *TaxEntry       `json:"taxes,omitempty" validate:"required"`
	TotalDiscount  float64         `json:"total_discount,omitempty" validate:"required"`

	LogoFileName string   `json:"logo_file_name,omitempty"`
	Issuer       *Contact `json:"company,omitempty" validate:"required"`
	CounterPart  *Contact `json:"customer,omitempty"`
	// contains filtered or unexported fields
}

Document represents an invoice document.

func NewInvoice

func NewInvoice(options *Options) (*Document, error)

NewInvoice creates a new invoice document. If the option struct is nil, default options are used.

func (*Document) AddPage

func (doc *Document) AddPage()

AddPage adds a new page to the underlying pdf document

func (*Document) AppendBoxToDocument

func (doc *Document) AppendBoxToDocument(x, y, w, h, r float64, color []int, styleStr string)

AppendBoxToDocument appends a box to the document at position x, y, with width w, and height h. The box is rounded with radius r. The color is specified by the color array [r, g, b] and is the draw color of the box. The styleStr is the style of the box. It can be "D" for dashed, "F" for filled, "DF" for dashed and filled.

func (*Document) AppendCounterPartToDoc

func (doc *Document) AppendCounterPartToDoc(x, y float64) float64

AppendCounterPartToDoc appends the counterpart's contact to the document on the top left of the page.

func (*Document) AppendFootnote

func (doc *Document) AppendFootnote(note string)

AppendFootnote appends the footer to the document note is the text to be appended to the page number. if the note is equal to, "-", then it includes the mark and the uid of the document.

func (*Document) AppendImage

func (doc *Document) AppendImage(x, y, w, h float64, imageBytes []byte, name string)

AppendImage appends an image to the document at position x, y, with width w, and height h. The image is specified by the imageBytes, and the name is the name to store the image internally.

func (*Document) AppendInvoiceDetail

func (doc *Document) AppendInvoiceDetail(y float64, entry *InvoiceEntry) float64

AppendInvoiceDetail appends an invoice detail to the document. This is a row of the table we create

func (*Document) AppendInvoiceDetailsHeader

func (doc *Document) AppendInvoiceDetailsHeader(y float64) float64

AppendInvoiceDetailsHeader appends the invoice details to the document. This is the header of the table we create

func (*Document) AppendIssuerToDoc

func (doc *Document) AppendIssuerToDoc(x, y float64) float64

AppendIssuerToDoc appends the issuer's contact to the document on the specified position. the logo, if provided, is added to the left of the contact.

func (*Document) AppendLogoToDocument

func (doc *Document) AppendLogoToDocument(x, y float64)

AppendLogoToDocument appends the logo to the document at position x, y. The logo is offset by logoOffsetX, and the height is also defined in options by Layout.LogoHeight.

func (*Document) AppendNotes

func (doc *Document) AppendNotes()

AppendNotes appends the notes to the document. Its box with some "remarks".

func (*Document) AppendQRCode

func (doc *Document) AppendQRCode(x, y, w, h float64, qrCodeString string)

AppendQRCode appends the QR code to the document at position x, y, with width w, and height h.

func (*Document) AppendTableRow

func (doc *Document) AppendTableRow(
	x float64, y float64, w []float64, h float64, gap float64,
	color []int, textColor []int, values []string, fontSize float64, borderStr string) float64

AppendTableRow appends a table row to the document at position x, y, with width w, and height h. The gap is the gap between the cells. The color is specified by the color array [r, g, b] and is the fill color of the row. The textColor is specified by the textColor array [r, g, b] and is the text color of the row. The values are the values of the cells. The fontSize is the font size of the cells. borderStr specifies how the cell border will be drawn. An empty string indicates no border, "1" indicates a full border, and one or more of "L", "T", "R" and "B" indicate the left, top, right and bottom sides of the border.

func (*Document) AppendTableRowMultiCell

func (doc *Document) AppendTableRowMultiCell(
	x float64, y float64, w []float64, h float64, gap float64,
	color []int, textColor []int, values []string, fontSize float64, borderStr string) float64

func (*Document) AppendTaxes

func (doc *Document) AppendTaxes(endOfDoc bool)

AppendTaxes appends the taxes section to the document The position is specified in Options.Layout struct by TaxesX and TaxesY. The row height is specified in Options.Layout struct by TaxesRowHeight. The gap is set at 0.5. The fill color is the Options.DarkBgColor, and the text color is the Options.LightTextColor It displays empty values if we are not at the end of the document, on invoices that span multiple pages. This is controlled by endOfDoc.

func (*Document) AppendTotals

func (doc *Document) AppendTotals(endOfDoc bool)

AppendTotals appends the totals section to the document Those are the totals of the document and should be displayed at the footer of the document. The position is specified in Options.Layout struct by TotalsX and TotalsY. If endOfDoc is false, the values displayed are -. The labels for the taxes have the Options.AccentColors The values have the Options.DarkTextColor The background color is the Options.LightBgColor

func (*Document) CalculateTotals

func (doc *Document) CalculateTotals()

CalculateTotals calculates the totals of the invoice and appends it to the Taxes struct

func (*Document) Create

func (doc *Document) Create(creator InvoiceCreator) (*fpdf.Fpdf, error)

Create creates a new pdf document using the provided header, middle and footer functions that define the document's content.

func (*Document) CreateAndBuffer

func (doc *Document) CreateAndBuffer(creator InvoiceCreator) (*bytes.Buffer, error)

CreateAndBuffer creates a new pdf document using the provided header, middle and footer functions that define the document's content and returns a buffer with the pdf content.

func (*Document) CreateAndSave

func (doc *Document) CreateAndSave(filename string, creator InvoiceCreator) error

CreateAndSave creates a new pdf document using the provided header, middle and footer functions that define the document's content and saves it to the specified filename.

func (*Document) CreateLabeledLines

func (doc *Document) CreateLabeledLines(
	x float64, wLabel float64, wValue float64, height float64, fontSizeLabel float64, fontSizeValue float64,
	colorLabel []int, colorValue []int, bgColor []int, labels []string, values []string, valueAlign string)

CreateLabeledLines creates labeled lines with label: value The function uses the current y position of the document. The x position is specified by the x parameter. The wLabel is the width of the label, and wValue is the width of the value. The height is the height of the line, and the fontSizeLabel and fontSizeValue are the font sizes of the label and value respectively. The colorLabel is the color of the label, and the colorValue is the color of the value.

func (*Document) EncodeString

func (doc *Document) EncodeString(str string) string

EncodeString encodes the string using doc.Options.UnicodeTranslateFunc This function can be used if we use a unicode translation function, which I could not make it work with greek encodings. So I just return the string as is.

func (*Document) GetAA

func (doc *Document) GetAA() string

GetAA returns the number of the document as a labeled string

func (*Document) GetDate

func (doc *Document) GetDate() string

GetDate returns the date of the document as a labeled string

func (*Document) GetMark

func (doc *Document) GetMark() string

GetMark returns the mark of the document as a labeled string

func (*Document) GetPDF

func (doc *Document) GetPDF() *fpdf.Fpdf

GetPDF returns the underlying fpdf object

func (*Document) GetSeries

func (doc *Document) GetSeries() string

GetSeries returns the series of the document as a labeled string

func (*Document) GetUID

func (doc *Document) GetUID() string

GetUID returns the uid of the document as a labeled string

func (*Document) SetCustomer

func (doc *Document) SetCustomer(customer *Contact)

SetCustomer set the customer contact

func (*Document) SetDrawColor

func (doc *Document) SetDrawColor(color []int)

SetDrawColor sets the color of the draw

func (*Document) SetFillColor

func (doc *Document) SetFillColor(color []int)

SetFillColor sets the color of the fill

func (*Document) SetFont

func (doc *Document) SetFont(font string, style string, size float64)

SetFont sets the font of the document

func (*Document) SetIssuer

func (doc *Document) SetIssuer(issuer *Contact)

SetIssuer sets the issuer's contact

func (*Document) SetTextColor

func (doc *Document) SetTextColor(color []int)

SetTextColor sets the color of the text

func (*Document) SetXY

func (doc *Document) SetXY(x, y float64)

SetXY sets the current position

type InvoiceCreator

type InvoiceCreator interface {
	InvoiceHeader(doc *Document)
	InvoiceFooter(doc *Document, endOfDoc bool)
	InvoiceMiddle(doc *Document)
}

type InvoiceDetails

type InvoiceDetails struct {
	Entries []*InvoiceEntry `json:"entries,omitempty" validate:"required"`
}

InvoiceDetails represents the details of an invoice

func (*InvoiceDetails) AddEntry

func (inv *InvoiceDetails) AddEntry(entry *InvoiceEntry)

func (*InvoiceDetails) CalculateTotals

func (inv *InvoiceDetails) CalculateTotals() (net, tax, total, discount float64)

type InvoiceEntry

type InvoiceEntry struct {
	Description       string  `json:"description,omitempty" validate:"required,min=1,max=41"`
	Quantity          float64 `json:"quantity,omitempty" validate:"required"`
	UnitOfMeasurement string  `json:"unit_of_measurement,omitempty"`
	NetPrice          float64 `json:"net_price,omitempty" validate:"required"`
	Discount          float64 `json:"discount,omitempty"`
	FinalPrice        float64 `json:"final_price,omitempty"`
	TaxPercent        float64 `json:"tax,omitempty"`
	TaxAmount         float64 `json:"tax_amount,omitempty"`
}

InvoiceEntry represents an invoice entry. Theses are the data we need to create an invoice entry row

type Layout

type Layout struct {
	CustomerColumnTwoX      float64 `json:"customer_column_two_x,omitempty" validate:"required"`      // x position of customer column two
	CustomerLabelFontSize   float64 `json:"customer_label_font_size,omitempty" validate:"required"`   // font size of customer label
	CustomerValueFontSize   float64 `json:"customer_value_font_size,omitempty" validate:"required"`   // font size of customer value
	CustomerLabelWidth      float64 `json:"customer_label_width,omitempty" validate:"required"`       // width of customer label
	CustomerValueWidth      float64 `json:"customer_value_width,omitempty" validate:"required"`       // width of customer value
	CustomerLineHeight      float64 `json:"customer_line_height,omitempty" validate:"required"`       // height of customer line
	IssuerPX                float64 `json:"issuer_px,omitempty" validate:"required"`                  // x position of issuer contact
	IssuerPY                float64 `json:"issuer_py,omitempty" validate:"required"`                  // y position of issuer contact
	IssuerFontSize          float64 `json:"issuer_font_size,omitempty" validate:"required"`           // font size of issuer contact
	FooterX                 float64 `json:"footer_x,omitempty" validate:"required"`                   // x position of footer
	FooterY                 float64 `json:"footer_y,omitempty" validate:"required"`                   // y position of footer
	FooterFontSize          float64 `json:"footer_font_size,omitempty" validate:"required"`           // font size of footer
	InvoiceRowOffset        float64 `json:"invoice_row_offset,omitempty" validate:"required"`         // offset of invoice row
	InvoiceColumnGap        float64 `json:"invoice_column_gap,omitempty" validate:"required"`         // gap between invoice columns
	LogoOffsetX             float64 `json:"logo_offset,omitempty" validate:"required"`                // offsetX of logo
	LogoHeight              float64 `json:"logo_height,omitempty" validate:"required"`                // height of logo
	MaxAllowedDetailsHeight float64 `json:"max_allowed_details_height,omitempty" validate:"required"` // max allowed height of details
	NotesX                  float64 `json:"notes_x,omitempty" validate:"required"`                    // x position of notes
	NotesY                  float64 `json:"notes_y,omitempty" validate:"required"`                    // y position of notes
	NotesWidth              float64 `json:"notes_width,omitempty" validate:"required"`                // width of notes
	NotesHeight             float64 `json:"notes_height,omitempty" validate:"required"`               // height of notes
	QRCodeX                 float64 `json:"qrcode_x,omitempty" validate:"required"`                   // x position of qrcode
	QRCodeY                 float64 `json:"qrcode_y,omitempty" validate:"required"`                   // y position of qrcode
	QRCodeWidth             float64 `json:"qrcode_width,omitempty" validate:"required"`               // width of qrcode in mm
	QRCodeSize              float64 `json:"qrcode_size,omitempty" validate:"required"`                // size of qrcode in pixels
	TaxesX                  float64 `json:"taxes_x,omitempty" validate:"required"`                    // x position of taxes
	TaxesY                  float64 `json:"taxes_y,omitempty" validate:"required"`                    // y position of taxes
	TaxesRowHeight          float64 `json:"taxes_row_height,omitempty" validate:"required"`           // height of taxes row
	TaxesFontSize           float64 `json:"taxes_font_size,omitempty" validate:"required"`            // font size of taxes
	TotalsX                 float64 `json:"totals_x,omitempty" validate:"required"`                   // x position of totals
	TotalsY                 float64 `json:"totals_y,omitempty" validate:"required"`                   // y position of totals
	TotalsFontLabelSize     float64 `json:"totals_label_font_size,omitempty" validate:"required"`     // font size of totals
	TotalsFontValueSize     float64 `json:"totals_value_font_size,omitempty" validate:"required"`     // font size of totals
	TotalsLabelWidth        float64 `json:"totals_label_width,omitempty" validate:"required"`         // width of "totals" label
	TotalsValueWidth        float64 `json:"totals_value_width,omitempty" validate:"required"`         // width of "totals" value
	TotalsLineHeight        float64 `json:"totals_line_height,omitempty" validate:"required"`         // height of totals line
}

Layout of the document

type Options

type Options struct {
	Layout Layout `json:"layout,omitempty"` // layout of the document

	AutoPrint bool `json:"auto_print,omitempty"` // print without the dialogue box?

	Orientation   string `json:"orientation,omitempty"`    // orientation of the document
	DocumentUnits string `json:"document_units,omitempty"` // units of the document
	DocumentSize  string `json:"document_size,omitempty"`  // size of the document

	CurrencySymbol string `json:"currency_symbol,omitempty"`

	TextTypeInvoice      string `json:"text_type_invoice,omitempty"`
	TextTypeQuotation    string `json:"text_type_quotation,omitempty"`
	TextTypeDeliveryNote string `json:"text_type_delivery_note,omitempty"`

	TextRefTitle         string `json:"text_ref_title,omitempty"`
	TextVersionTitle     string `json:"text_version_title,omitempty"`
	TextDateTitle        string `json:"text_date_title,omitempty"`
	TextPaymentTermTitle string `json:"text_payment_term_title,omitempty"`

	TextItemsNameTitle       string `json:"text_items_name_title,omitempty"`
	TextItemsUnitCostTitle   string `json:"text_items_unit_cost_title,omitempty"`
	TextItemsMeasurementUnit string `json:"text_items_measurement_unit,omitempty"`
	TextItemsQuantityTitle   string `json:"text_items_quantity_title,omitempty"`
	TextItemsTotalHTTitle    string `json:"text_items_total_ht_title,omitempty"`
	TextItemsTaxTitle        string `json:"text_items_tax_title,omitempty"`
	TextItemsDiscountTitle   string `json:"text_items_discount_title,omitempty"`
	TextItemsTotalTTCTitle   string `json:"text_items_total_ttc_title,omitempty"`

	TextItemNotesTitle string `json:"text_item_notes_title,omitempty"`

	TextTotalTotal            string `json:"text_total_total,omitempty"`
	TextTotalDiscounted       string `json:"text_total_discounted,omitempty"`
	TextTotalVatTax           string `json:"text_total_vat_tax,omitempty"`
	TextTotalVariousTaxes     string `json:"text_total_various_taxes,omitempty"`
	TextTotalWithHoldingTaxes string `json:"text_total_with_holding_taxes,omitempty"`
	TextTotalWithTax          string `json:"text_total_with_tax,omitempty"`

	TextWithHoldingTaxes string `json:"text_with_holding_taxes,omitempty"`
	TextMiscTaxes        string `json:"text_misc_taxes,omitempty"`
	TextDeductions       string `json:"text_deductions,omitempty"`
	TextFeesTaxes        string `json:"text_fees_taxes,omitempty"`
	TextStampTaxes       string `json:"text_stamp_taxes,omitempty"`

	BaseTextColor  []int `json:"base_text_color,omitempty"`
	LightTextColor []int `json:"grey_text_color,omitempty"`
	LightBgColor   []int `json:"grey_bg_color,omitempty"`
	DarkBgColor    []int `json:"dark_bg_color,omitempty"`
	DarkTextColor  []int `json:"dark_text_color,omitempty"`
	DefaultBgColor []int `json:"default_bg_color,omitempty"`
	AccentColor    []int `json:"accent_color,omitempty"`

	FontPathEnvName  string
	Font             string
	FontFileName     string
	BoldFont         string
	BoldFontFileName string

	UnicodeTranslateFunc UnicodeTranslateFunc
}

Options for Document

type SimpleA4Invoice

type SimpleA4Invoice struct{}

func (SimpleA4Invoice) InvoiceFooter

func (s SimpleA4Invoice) InvoiceFooter(doc *Document, endOfDoc bool)

func (SimpleA4Invoice) InvoiceHeader

func (s SimpleA4Invoice) InvoiceHeader(doc *Document)

func (SimpleA4Invoice) InvoiceMiddle

func (s SimpleA4Invoice) InvoiceMiddle(doc *Document)

type TaxEntry

type TaxEntry struct {
	NetAmount        float64 `json:"net_amount,omitempty" validate:"required"`
	TaxAmount        float64 `json:"tax_amount,omitempty" validate:"required"`
	FinalAmount      float64 `json:"final_amount,omitempty" validate:"required"`
	WithHoldingTaxes float64 `json:"with_holding_taxes,omitempty" validate:"required"`
	Deductions       float64 `json:"deductions,omitempty" validate:"required"`
	StampDuty        float64 `json:"stamp_duty,omitempty" validate:"required"`
	Fees             float64 `json:"fees,omitempty" validate:"required"`
	OtherTaxes       float64 `json:"other_taxes,omitempty" validate:"required"`
}

TaxEntry represents the taxes of an invoice

type UnicodeTranslateFunc

type UnicodeTranslateFunc func(string) string

UnicodeTranslateFunc ...

Jump to

Keyboard shortcuts

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