types

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientIDs

func GetClientIDs(dataDir string) ([]int, error)

GetClientIDs returns a list of client IDs by scanning the directory where client data is stored.

func GetInvoicesID

func GetInvoicesID(clientIDs []int, dataDir string) (map[int]string, []int, error)

Types

type Client

type Client struct {
	// ID is the unique identifier of the client.
	ID uint `survey:"id" json:"id"`

	// Name is the name of the client.
	Name string `survey:"name" json:"name"`

	// Address is the address of the client.
	Address string `survey:"address" json:"address"`

	// Bank is a string that represents the user's bank details.
	Bank string `survey:"bank" json:"bank"`

	// Email is the email address(es) of the client.
	Email []string `survey:"email" json:"email"`

	// Currency is the currency of the client.
	Currency string `survey:"currency" json:"currency"`
}

Client represents a client of the business.

func ReadClientInfo

func ReadClientInfo(id int, dataDir string) (Client, error)

ReadClientInfo reads the client info for the given client ID from the storage. Returns an error if the client info cannot be read.

func (*Client) Print

func (client *Client) Print() error

func (*Client) WriteClientInfo

func (client *Client) WriteClientInfo(dataDir string) error

type Config

type Config struct {
	GenOnCreate bool       `survey:"generate_on_create" yaml:"generate_on_create"`
	GenOnUpdate bool       `survey:"generate_on_update" yaml:"generate_on_update"`
	SMTP        SMTPConfig `survey:"smtp" yaml:"smtp"`
}

type Invoice

type Invoice struct {
	// ID is the unique identifier of the invoice.
	ID uint `json:"id"`

	// ClientID is the unique identifier of the client associated with the invoice.
	ClientID uint `json:"client_id"`

	// Number is the invoice number.
	Number string `survey:"number" json:"number"`

	// Issued is the date the invoice was issued.
	Issued time.Time `json:"issued"`

	// Due is the due date for the invoice.
	Due time.Time `survey:"due" json:"due"`

	// Sent is the date when the invoice was sent.
	Sent time.Time `json:"sent"`

	// Notes is any additional notes associated with the invoice.
	Notes string `survey:"notes" json:"notes"`

	// Items is a list of line items on the invoice.
	Items []Item `survey:"items" json:"items"`

	// Subtotal is subtotal of the invoice.
	Subtotal float32 `json:"subtotal"`
}

Invoice represents an invoice for a client.

func ReadInvoice

func ReadInvoice(id int, path string, dataDir string) (Invoice, error)

func (*Invoice) Delete

func (invoice *Invoice) Delete(dataDir string) error

func (*Invoice) GeneratePDF

func (invoice *Invoice) GeneratePDF(client Client, profile Profile, dataDir string) (error, string)

func (*Invoice) GetInvoiceTotal

func (invoice *Invoice) GetInvoiceTotal() float64

func (*Invoice) Print

func (invoice *Invoice) Print()

func (*Invoice) WriteInvoice

func (invoice *Invoice) WriteInvoice(dataDir string) error

type Item

type Item struct {
	// ID is the unique identifier of the item.
	ID uint `json:"id"`

	// Description is a brief description of the item.
	Description string `survey:"description" json:"description"`

	// Quantity is the quantity of the item.
	Quantity float64 `survey:"quantity" json:"quantity"`

	// UnitPrice is the unit price of the item.
	UnitPrice float64 `survey:"unit_price" json:"unit_price"`
}

Item represents a line item on an invoice.

type Profile

type Profile struct {
	// Name is a string that represents the user's name.
	Name string `survey:"name" yaml:"name" json:"name"`

	// Currency is a string that represents the user's preferred currency.
	Currency string `survey:"currency" yaml:"currency" json:"currency"`

	// Due is a string that represents the user's preferred due date.
	Due string `survey:"default_due" yaml:"default_due" json:"default_due"`

	// Address is a string that represents the user's address.
	Address string `survey:"address" yaml:"address" json:"address"`

	// IBAN is a string that represents the user's International Bank Account Number (IBAN).
	IBAN string `survey:"iban" yaml:"iban" json:"iban"`

	// Bank is a string that represents the user's bank details.
	Bank string `survey:"bank_details" yaml:"bank_details" json:"bank_details"`
}

Profile represents a user's profile information.

func (*Profile) Exists

func (p *Profile) Exists(dataDir string) bool

Exists checks if the profile exists

func (*Profile) Load

func (p *Profile) Load(dataDir string) error

func (*Profile) Write

func (p *Profile) Write(dataDir string) error

Write writes the profile information to a file

type SMTPConfig

type SMTPConfig struct {
	Host     string `survey:"host" yaml:"host"`         // The hostname of the SMTP server.
	Port     int    `survey:"port" yaml:"port"`         // The port number to use for the SMTP server.
	Username string `survey:"username" yaml:"username"` // The username to use for authentication with the SMTP server.
	Password string `survey:"password" yaml:"password"` // The password to use for authentication with the SMTP server.
}

func PromptSMTP

func PromptSMTP() (SMTPConfig, error)

func (*SMTPConfig) SendEmailWithAttachment

func (cfg *SMTPConfig) SendEmailWithAttachment(to []string, subject, body, attachmentPath string) error

Jump to

Keyboard shortcuts

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