schema

package
v0.0.0-...-69a507d Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCustomerPrefix = "c-"
View Source
const DefaultEmployeePrefix = "y-"
View Source
const DefaultExpensePrefix = "e-"
View Source
const DefaultExpensesFile = "expenses.yaml"
View Source
const DefaultInvoicesFile = "invoices.yaml"
View Source
const DefaultInvoicesPrefix = "i-"
View Source
const DefaultMiscRecordPrefix = "m-"
View Source
const DefaultMiscRecordsFile = "misc.yaml"
View Source
const DefaultPartiesFile = "parties.yaml"
View Source
const DefaultProjectPrefix = "p-"
View Source
const DefaultProjectsFile = "projects.yaml"
View Source
const DefaultStatementFile = "bank-statement.yaml"
View Source
const DefaultTransactionPrefix = "t-"

Variables

This section is empty.

Functions

func GetUuid

func GetUuid() string

func InteractiveNewGenericExpenseCategory

func InteractiveNewGenericExpenseCategory(arg interface{}) interface{}

func InteractiveNewGenericParty

func InteractiveNewGenericParty(arg interface{}) interface{}

func OpenYamlHashed

func OpenYamlHashed(data interface{}, path, dataType string) string

OpenYaml does the same as util.OpenYaml but returns the hash of the file.

func SaveYamlOnChange

func SaveYamlOnChange(data interface{}, path, dataType, oldHash string)

func SuggestNextIdentifier

func SuggestNextIdentifier(idt []Identifiable, prefix string) string

Types

type Company

type Company struct {
	Name       string `yaml:"name" default:"Fortuna Inc."`
	Street     string `yaml:"street" default:"Main Street"`
	StreetNr   int    `yaml:"streetNr" default:"1"`
	PostalCode int    `yaml:"postalCode" default:"8000"`
	Place      string `yaml:"place" default:"Zurich"`
	Phone      string `yaml:"phone" default:"+41 78 000 00 00"`
	Mail       string `yaml:"mail" default:"info@fortuna.com"`
	Url        string `yaml:"url" default:"https://fortuna.com"`
}

func InteractiveNewCompany

func InteractiveNewCompany(logo string) Company

func NewCompany

func NewCompany(logo string) Company

func (Company) Conditions

func (c Company) Conditions() util.Conditions

func (Company) String

func (c Company) String() string

func (Company) Type

func (c Company) Type() string

type Completable

type Completable interface {
	// SetId sets a unique id (UUID-4) for the object.
	SetId()
}

Completable describes types which automatically can resolve some missing information atomically. Example is the setting of a unique Id.

type Expense

type Expense struct {
	// Id is the internal unique identifier of the Expense.
	Id string `yaml:"id" default:"1"`
	// Value is a unique user chosen identifier, has to be the same in all source files (bank statements, bimpf dumps...).
	Identifier string `yaml:"identifier" default:"e-19-1"`
	// Name describes meaningful the kind of the Expense.
	Name string `yaml:"name" default:"Expense Name"`
	// Amount states the amount of the Expense.
	Amount float64 `yaml:"amount" default:"10.00" query:"amount"`
	// Path is the full path to the business record document.
	Path string `yaml:"path" default:"/path/to/expense.pdf" query:"path"`
	// DateOfAccrual represents the day the obligation emerged.
	DateOfAccrual string `yaml:"dateOfAccrual" default:"2019-12-20"`
	// Billable states if the costs for the Expense will be forwarded to the customer.
	Billable bool `yaml:"billable" default:"false"`
	// ObligedCustomerId refers to the customer which have to pay the Expense.
	ObligedCustomerId string `yaml:"obligedCustomerId" default:"" query:"customer"`
	// AdvancedByThirdParty states if a third party (employee, etc.) advanced the payment of this expense for the company.
	AdvancedByThirdParty bool `yaml:"advancedByThirdParty" default:"false"`
	// AdvancePartyId refers to the third party which advanced the payment.
	AdvancedThirdPartyId string `yaml:"advancedThirdPartyId" default:"" query:"emplyee"`
	// DateOfSettlement states the date of the settlement of the expense (the company has not to take further actions).
	DateOfSettlement string `yaml:"dateOfSettlement" default:"2019-12-25"`
	// SettlementTransactionId refers to a possible bank transaction which settled the Expense for the company.
	SettlementTransactionId string `yaml:"settlementTransactionId" default:"" query:"transaction"`
	// ExpenseCategory gives additional info for the categorization of the expense in the journal.
	ExpenseCategory string `yaml:"expenseCategory" default:""`
	// Debit Payment states whether the expense was directly payed with the main account debithether the expense was directly payed with the main account debit card.
	PayedWithDebit bool `yaml:"payedWithDebit" default:"false"`
	// Internal states whether this expense is for an internal purpose or not.
	Internal bool `yaml:"internal" default:"true"`
	// ProjectName refers to the associated project of the expense. Depreciated.
	ProjectName string `yaml:"projectName" default:""`
	// ProjectId refers to the associated project.
	ProjectId string `yaml:"projectId" default:""`
}

Expense represents a payment done by the company or a third party to assure the ongoing of the business.

func InteractiveNewExpense

func InteractiveNewExpense(s *Schema, asset string) Expense

InteractiveNewExpense returns a new Expense based on the user input.

func NewExpense

func NewExpense() Expense

NewExpense returns a new Expense element with the default values.

func NewExpenseWithUuid

func NewExpenseWithUuid() Expense

func (Expense) AccrualDateTime

func (e Expense) AccrualDateTime() time.Time

func (Expense) AssistedCompletion

func (e Expense) AssistedCompletion(s *Schema, doAll, autoSave, openAttachment, retainFocus bool) Expense

func (Expense) Conditions

func (e Expense) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Expense) FileString

func (e Expense) FileString() string

FileString returns the file name for exporting the expense as a document.

func (Expense) GetDate

func (e Expense) GetDate() *time.Time

func (Expense) GetId

func (e Expense) GetId() string

GetId returns the unique id of the element.

func (Expense) GetIdentifier

func (e Expense) GetIdentifier() string

func (Expense) Match

func (e Expense) Match(from *time.Time, to *time.Time, identifier string) (bool, error)

func (*Expense) Repopulate

func (e *Expense) Repopulate(s Schema)

func (Expense) SearchItem

func (e Expense) SearchItem() util.SearchItem

func (*Expense) SetId

func (e *Expense) SetId()

SetId generates a unique id for the element if there isn't already one defined.

func (Expense) Short

func (e Expense) Short() string

Short returns a short represenation of the element.

func (Expense) String

func (e Expense) String() string

String returns a human readable representation of the element.

func (Expense) Type

func (e Expense) Type() string

Type returns a string with the type name of the element.

type ExpenseCategories

type ExpenseCategories []ExpenseCategory

func InteractiveNewExpenseCategories

func InteractiveNewExpenseCategories(multiple bool) ExpenseCategories

func (ExpenseCategories) CategoryByName

func (e ExpenseCategories) CategoryByName(name string) (*ExpenseCategory, error)

func (ExpenseCategories) Conditions

func (e ExpenseCategories) Conditions() util.Conditions

func (ExpenseCategories) SearchItems

func (e ExpenseCategories) SearchItems() util.SearchItems

func (ExpenseCategories) String

func (e ExpenseCategories) String() string

func (ExpenseCategories) Type

func (e ExpenseCategories) Type() string

func (ExpenseCategories) Validate

func (e ExpenseCategories) Validate() util.ValidateResults

type ExpenseCategory

type ExpenseCategory struct {
	Name    string `yaml:"name" default:"Matrial Costs"`
	Account string `yaml:"account" default:"expenses:Betrieblicher Aufwand:Materialaufwand"`
}

func InteractiveNewExpenseCategory

func InteractiveNewExpenseCategory() ExpenseCategory

func NewExpenseCategory

func NewExpenseCategory() ExpenseCategory

func (ExpenseCategory) Conditions

func (e ExpenseCategory) Conditions() util.Conditions

func (ExpenseCategory) SearchItem

func (e ExpenseCategory) SearchItem() util.SearchItem

func (ExpenseCategory) String

func (e ExpenseCategory) String() string

func (ExpenseCategory) Type

func (e ExpenseCategory) Type() string

type Expenses

type Expenses []Expense

Expenses is a slice of multiple expenses.

func NewExpenses

func NewExpenses(useDefaults bool) Expenses

NewExpenses returns a new Expense slice with the one Expense in it.

func OpenExpenses

func OpenExpenses(path string) Expenses

OpenExpenses opens a Expenses saved in the YAML file given by the path.

func (Expenses) AssistedCompletion

func (e Expenses) AssistedCompletion(s *Schema, doAll, autoSave, openAttachment, retainFocus bool)

func (Expenses) ExpenseById

func (e Expenses) ExpenseById(id string) (*Expense, error)

func (Expenses) ExpenseByIdent

func (e Expenses) ExpenseByIdent(ident string) (*Expense, error)

func (Expenses) Filter

func (e Expenses) Filter(from *time.Time, to *time.Time, identifier string) (Expenses, error)

func (Expenses) GetIdentifiables

func (e Expenses) GetIdentifiables() []Identifiable

func (Expenses) Len

func (e Expenses) Len() int

func (Expenses) Less

func (e Expenses) Less(i, j int) bool

func (Expenses) Repopulate

func (e Expenses) Repopulate(s Schema)

func (Expenses) Save

func (e Expenses) Save(s *Schema, path string)

Save writes the element as a YAML to the given path. If s is not nil, the id fields will be commented with the linked element.

func (Expenses) SearchItems

func (e Expenses) SearchItems() util.SearchItems

func (Expenses) SetId

func (e Expenses) SetId()

SetId sets a unique id to all elements in the slice.

func (Expenses) SortByYear

func (e Expenses) SortByYear() map[int]Expenses

SortByYear returns a map with the given elements sorted by year.

func (Expenses) Swap

func (e Expenses) Swap(i, j int)

func (Expenses) Validate

func (e Expenses) Validate() util.ValidateResults

type Identifiable

type Identifiable interface {
	GetId() string
	GetIdentifier() string
	String() string
}

Identifiable describes types which are uniquely identifiable trough out the utils structure.

type Invoice

type Invoice struct {
	// Id is the internal unique identifier of the Expense.
	Id string `yaml:"id" default:"1"`
	// Value is a unique user chosen identifier, has to be the same in all source files (bank statements, bimpf dumps...).
	Identifier string `yaml:"identifier" default:"i-19-1"`
	// Name describes meaningful the kind of the Expense.
	Name string `yaml:"name" default:"Expense Name"`
	// Amount states the amount of the Expense.
	Amount float64 `yaml:"amount" default:"10.00" query:"amount"`
	// Path is the full path to the voucher utils.
	Path string `yaml:"path" default:"/path/to/file.utils" query:"path"`
	// Revoked invoices are disabled an no longer taken into account.
	Revoked bool `yaml:"revoked" default:"false"`
	// CustomerId refers to the customer the invoice was sent to.
	CustomerId string `yaml:"customerId" default:"" query:"customer"`
	// SendDate states the date, the invoice was sent to the customer.
	SendDate string `yaml:"sendDate" default:"2019-12-20"`
	// DateOfSettlement states the date the customer paid the outstanding amount.
	DateOfSettlement string `yaml:"dateOfSettlement" default:"2019-12-25"`
	// SettlementTransactionId refers to a possible bank transaction which settled the Expense for the company.
	SettlementTransactionId string `yaml:"settlementTransactionId" default:"" query:"transaction"`
	// ProjectName refers to the associated project of the expense. Depreciated.
	ProjectName string `yaml:"projectName" default:""`
	// ProjectId refers to the associated project.
	ProjectId string `yaml:"projectId" default:""`
}

Invoice represents an invoice sent to a customer for some services.

func InteractiveNewInvoice

func InteractiveNewInvoice(s Schema, asset string) Invoice

func NewInvoice

func NewInvoice() Invoice

NewInvoice returns a new Acc element with the default values.

func NewInvoiceWithUuid

func NewInvoiceWithUuid() Invoice

func (Invoice) AssistedCompletion

func (i Invoice) AssistedCompletion(s Schema, doAll, openAttachment, retainFocus bool) Invoice

func (Invoice) Conditions

func (i Invoice) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Invoice) FileString

func (i Invoice) FileString() string

func (Invoice) GetDate

func (i Invoice) GetDate() *time.Time

func (Invoice) GetId

func (i Invoice) GetId() string

GetId returns the unique id of the element.

func (Invoice) GetIdentifier

func (i Invoice) GetIdentifier() string

func (*Invoice) Repopulate

func (i *Invoice) Repopulate(s Schema)

func (Invoice) SearchItem

func (i Invoice) SearchItem(s Schema) util.SearchItem

func (Invoice) SendDateTime

func (i Invoice) SendDateTime() time.Time

func (*Invoice) SetId

func (i *Invoice) SetId()

SetId generates a unique id for the element if there isn't already one defined.

func (Invoice) Short

func (i Invoice) Short() string

Short returns a short represenation of the element.

func (Invoice) String

func (i Invoice) String() string

String returns a human readable representation of the element.

func (Invoice) Type

func (i Invoice) Type() string

Type returns a string with the type name of the element.

type Invoices

type Invoices []Invoice

Invoices is a slice of invoices.

func NewInvoices

func NewInvoices(useDefaults bool) Invoices

NewInvoices returns a new Expense slice with the one Expense in it.

func OpenInvoices

func OpenInvoices(path string) Invoices

OpenInvoices opens a Expenses saved in the json file given by the path.

func (Invoices) AssistedCompletion

func (i Invoices) AssistedCompletion(s Schema, doAll, autoSave, openAttachment, retainFocus bool)

func (Invoices) Filter

func (i Invoices) Filter(from *time.Time, to *time.Time) (Invoices, error)

func (Invoices) GetIdentifiables

func (i Invoices) GetIdentifiables() []Identifiable

func (Invoices) InvoiceById

func (i Invoices) InvoiceById(id string) (*Invoice, error)

func (Invoices) InvoiceByIdent

func (i Invoices) InvoiceByIdent(ident string) (*Invoice, error)

func (Invoices) Len

func (i Invoices) Len() int

func (Invoices) Less

func (i Invoices) Less(j, k int) bool

func (Invoices) Repopulate

func (i Invoices) Repopulate(s Schema)

func (*Invoices) Save

func (i *Invoices) Save(path string)

Save writes the element as a json to the given path. Indented states whether «prettify» the json output.

func (Invoices) SearchItems

func (i Invoices) SearchItems(s Schema) util.SearchItems

func (Invoices) SetId

func (i Invoices) SetId()

SetId sets a unique id to all elements in the slice.

func (Invoices) Swap

func (i Invoices) Swap(j, k int)

func (Invoices) Validate

func (i Invoices) Validate() util.ValidateResults

type JournalConfig

type JournalConfig struct {
	Currency                                string            `yaml:"currency" default:"SFr."`
	BankAccount                             string            `yaml:"bankAccount" default:"assets:Umlaufvermögen:Flüssige Mittel:Raiffeisenbank Bern"`
	ReceivableAccount                       string            `yaml:"receivableAccount" default:"assets:Umlaufvermögen:Debitoren"`
	RevenueAccount                          string            `yaml:"revenueAccount" default:"revenues:Betrieblicher Ertrag:Dienstleistungserlös"`
	PayableAccount                          string            `yaml:"payableAccount" default:"liabilities:Kurzfristiges Fremdkapital:Kreditoren"`
	EmployeeLiabilitiesAccount              string            `` /* 129-byte string literal not displayed */
	InvoicingTransactionDescription         string            `yaml:"invoicingTransactionDescription" default:"Rechnungsstellung {{ .Identifier }} an {{ .Party }}"`
	InvoiceSettlementTransactionDescription string            `yaml:"invoiceSettlementTransactionDescription" default:"Erhalt Zahlung für die Rechnung {{ .Identifier }} von {{ .Party }}"`
	ExpenseAdvancedByEmployeeDescription    string            `` /* 133-byte string literal not displayed */
	InternalExpenseOccurenceDescription     string            `yaml:"internalExpenseOccurenceDescription" default:"Aufwand für {{.Name}} ({{.Identifier}})"`
	ProductionExpenseOccurenceDescription   string            `yaml:"productionExpenseOccurenceDescription" default:"Einkauf von {{.Name}} ({{.Identifier}}) für Projekt {{.Project}}"`
	InternalExpenseTransactionDescription   string            `yaml:"internalExpenseTransactionDescription" default:"Bezahlung der Rechnung {{.Identifier}}"`
	AdvancedExpenseSettlementDescription    string            `yaml:"advancedExpenseSettlementDescription" default:"Rückerstattung der Zahlung von {{.Party}} für {{.Identifier}}"`
	CompanyPaidExpenseSettlementDescription string            `yaml:"companyPaidExpenseSettlementDescription" default:"Bezahlen des Aufwands {{.Identifier}}"`
	AccountAliases                          []string          `yaml:"accountAliases" default:"[]"`
	ExpenseCategories                       ExpenseCategories `yaml:"expenseCategories" default:"[]"`
}

func InteractiveNewJournalConfig

func InteractiveNewJournalConfig() JournalConfig

func NewJournalConfig

func NewJournalConfig() JournalConfig

func (JournalConfig) Aliases

func (c JournalConfig) Aliases() [][]string

func (JournalConfig) Conditions

func (c JournalConfig) Conditions() util.Conditions

func (JournalConfig) String

func (c JournalConfig) String() string

func (JournalConfig) Type

func (JournalConfig) Type() string

func (JournalConfig) Validate

func (c JournalConfig) Validate() util.ValidateResults

type JournalMode

type JournalMode int
const (
	UnknownJournalMode JournalMode = iota
	ManualJournalMode
	AutoJournalMode
)

type MiscRecord

type MiscRecord struct {
	Id            string `yaml:"id" default:"1"`
	Identifier    string `yaml:"identifier" default:"m-19-1"`
	Name          string `yaml:"name" default:""`
	Path          string `yaml:"path" default:"/path/to/record.pdf" query:"path"`
	Date          string `yaml:"date" default:"2019-12-20"`
	TransactionId string `yaml:"settlementTransactionId" default:"" query:"transaction"`
}

MiscRecord represents business records which are not invoices or expenses but still important for accounting. Example: A credit note from an insurance.

func InteractiveNewMiscRecord

func InteractiveNewMiscRecord(s Schema, asset string) MiscRecord

InteractiveNewMiscRecord returns a new MiscRecord based on the user input.

func NewMiscRecord

func NewMiscRecord() MiscRecord

NewMiscRecord returns a new MiscRecord element with the default values.

func (MiscRecord) Conditions

func (m MiscRecord) Conditions() util.Conditions

Conditions returns the validation conditions.

func (MiscRecord) FileString

func (m MiscRecord) FileString() string

FileString returns the file name for exporting the misc record as a document.

func (MiscRecord) GetDate

func (m MiscRecord) GetDate() *time.Time

func (MiscRecord) GetId

func (m MiscRecord) GetId() string

GetId returns the id of the MiscRecord.

func (MiscRecord) GetIdentifier

func (m MiscRecord) GetIdentifier() string

GetIdentifier return the identifier of the MiscRecord.

func (*MiscRecord) Repopulate

func (m *MiscRecord) Repopulate(s Schema)

Repopulate MiscRecord based on the transactions.

func (MiscRecord) SearchItem

func (m MiscRecord) SearchItem() util.SearchItem

SearchItem returns a searchable representation of the MiscRecord.

func (*MiscRecord) SetId

func (m *MiscRecord) SetId()

SetId generates a unique id for the element if there isn't already one defined.

func (MiscRecord) Short

func (m MiscRecord) Short() string

Short returns a short represenation of the element.

func (MiscRecord) String

func (m MiscRecord) String() string

String returns a human readable representation of the element.

func (MiscRecord) Type

func (m MiscRecord) Type() string

Type returns a string with the type name of the element.

type MiscRecords

type MiscRecords []MiscRecord

MiscRecord is a collection of Miscellaneous Record elements.

func NewMiscRecords

func NewMiscRecords() MiscRecords

NewMiscRecords returns an empty new MiscRecords collection.

func OpenMiscRecords

func OpenMiscRecords(path string) MiscRecords

OpenMiscRecords opens the MiscRecords saved in the YAML file given by the path.

func (MiscRecords) GetIdentifiables

func (m MiscRecords) GetIdentifiables() []Identifiable

GetIdentifiables returns the a sliche of all identifiers. This is used for the identifier suggestion while interactively adding a new MiscRecord.

func (MiscRecords) MiscRecordById

func (m MiscRecords) MiscRecordById(id string) (*MiscRecord, error)

MiscRecordById returns the MiscRecord with the given id. If no record could be found an error will be returned.

func (MiscRecords) MiscRecordByIdent

func (m MiscRecords) MiscRecordByIdent(ident string) (*MiscRecord, error)

MiscRecordByIdent returns the MiscRecord with the given identifier. If no record could be found an error will be returned.

func (MiscRecords) Repopulate

func (m MiscRecords) Repopulate(s Schema)

Repopulate all MiscRecords based on the transactions.

func (MiscRecords) Save

func (m MiscRecords) Save(path string)

Save writes the element as YAML file to the given path.

func (MiscRecords) SearchItems

func (m MiscRecords) SearchItems() util.SearchItems

SearchItems returns a searchable structure of the MiscRecords. So the user can search for MiscRecords in the interactive mode.

func (MiscRecords) Validate

func (m MiscRecords) Validate() util.ValidateResults

Validate all MiscRecords.

type Parties

type Parties struct {
	Employees []Party `yaml:"employees"`
	Customers []Party `yaml:"customers"`
}

func NewParties

func NewParties(useDefault bool) Parties

NewParties returns a new Parties struct with the one Expense in it.

func OpenParties

func OpenParties(path string) Parties

OpenParties opens a Parties element saved in the json file given by the path.

func (Parties) CustomerById

func (p Parties) CustomerById(id string) (*Party, error)

func (Parties) CustomerByIdent

func (p Parties) CustomerByIdent(ident string) (*Party, error)

func (Parties) CustomerByIdentifier

func (p Parties) CustomerByIdentifier(ident string) (*Party, error)

CustomerByIdentifier returns a Customer if there is one with the given identifier. Otherwise an error will be returned.

func (Parties) CustomerStringById

func (p Parties) CustomerStringById(id string) string

func (Parties) CustomersSearchItems

func (p Parties) CustomersSearchItems() util.SearchItems

func (Parties) EmployeeById

func (p Parties) EmployeeById(id string) (*Party, error)

func (Parties) EmployeeByIdent

func (p Parties) EmployeeByIdent(ident string) (*Party, error)

func (Parties) EmployeeByIdentifier

func (p Parties) EmployeeByIdentifier(ident string) (*Party, error)

EmployeeByIdentifier returns a Employee if there is one with the given identifier. Otherwise an error will be returned.

func (Parties) EmployeeStringById

func (p Parties) EmployeeStringById(id string) string

func (Parties) EmployeesSearchItems

func (p Parties) EmployeesSearchItems() util.SearchItems

func (Parties) GetCustomerIdentifiables

func (p Parties) GetCustomerIdentifiables() []Identifiable

func (Parties) GetEmployeeIdentifiables

func (p Parties) GetEmployeeIdentifiables() []Identifiable

func (Parties) Save

func (p Parties) Save(path string)

Save writes the element as a json to the given path.

func (Parties) SetId

func (p Parties) SetId()

SetId sets a unique id to all elements in the struct.

func (Parties) Validate

func (p Parties) Validate() util.ValidateResults

type Party

type Party struct {
	// Id is the internal unique identifier of the Expense.
	Id string `yaml:"id" default:""`
	// Value is a unique user chosen identifier, has to be the same in all source files (bank statements, bimpf dumps...).
	Identifier string    `yaml:"identifier" default:"?-1"`
	Name       string    `yaml:"name" default:"Max Mustermann"`
	Street     string    `yaml:"street" default:"Main Street"`
	StreetNr   int       `yaml:"streetNr" default:"1"`
	PostalCode int       `yaml:"postalCode" default:"8000"`
	Place      string    `yaml:"place" default:"Zurich"`
	PartyType  PartyType `yaml:"partyType" default:"0"`
}

Party represents some person or organisation.

func InteractiveNewCustomer

func InteractiveNewCustomer(s Schema) Party

func InteractiveNewEmployee

func InteractiveNewEmployee(s Schema) Party

func InteractiveNewParty

func InteractiveNewParty(partyType string) Party

func NewParty

func NewParty() Party

NewParty returns a new Party with the default values.

func NewPartyWithUuid

func NewPartyWithUuid() Party

func (Party) AddressLines

func (p Party) AddressLines() string

func (Party) Conditions

func (p Party) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Party) GetId

func (p Party) GetId() string

GetId returns the unique id of the element.

func (Party) GetIdentifier

func (p Party) GetIdentifier() string

func (Party) SearchItem

func (p Party) SearchItem(typ string) util.SearchItem

func (*Party) SetId

func (p *Party) SetId()

SetId generates a unique id for the element if there isn't already one defined.

func (Party) Short

func (p Party) Short() string

Short returns a short represenation of the element.

func (Party) String

func (p Party) String() string

String returns a human readable representation of the element.

func (Party) Type

func (p Party) Type() string

Type returns a string with the type name of the element.

type PartyType

type PartyType int
const (
	EmployeeType PartyType = iota
	CustomerType
)

type Project

type Project struct {
	Id         string `yaml:"id" default:"1"`
	Identifier string `yaml:"identifier" default:"p-1"`
	Name       string `yaml:"name" default:"Building a space rocket"`
	CustomerId string `yaml:"customerId" default:""`
}

Project represents a project for a customer.

func InteractiveNewProject

func InteractiveNewProject(s Schema) Project

InteractiveNewProject returns a new Project based on the user input.

func NewProject

func NewProject() Project

NewProject returns a new Project element with the default values.

func (Project) Conditions

func (p Project) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Project) GetId

func (p Project) GetId() string

GetId returns the id of the Project.

func (Project) GetIdentifier

func (p Project) GetIdentifier() string

GetIdentifier return the identifier of the Project.

func (Project) SearchItem

func (p Project) SearchItem() util.SearchItem

SearchItem returns a searchable representation of the Project.

func (*Project) SetId

func (p *Project) SetId()

SetId generates a unique id for the element if there isn't already one defined.

func (Project) Short

func (p Project) Short() string

Short returns a short represenation of the element.

func (Project) String

func (p Project) String() string

String returns a human readable representation of the element.

func (Project) Type

func (p Project) Type() string

Type returns a string with the type name of the element.

type Projects

type Projects []Project

Projects represents a collection of multiple Project elements.

func NewProjects

func NewProjects() Projects

NewProjects returns an empty Projects collection.

func OpenProjects

func OpenProjects(path string) Projects

OpenProjects opens the Projects saved in the YAML file given by the path.

func (Projects) GetIdentifiables

func (p Projects) GetIdentifiables() []Identifiable

GetIdentifiables returns the a sliche of all identifiers. This is used for the identifier suggestion while interactively adding a new Project.

func (Projects) ProjectById

func (p Projects) ProjectById(id string) (*Project, error)

ProjectById returns the Project with the given id. If no record could be found an error will be returned.

func (Projects) ProjectByIdent

func (p Projects) ProjectByIdent(ident string) (*Project, error)

ProjectByIdent returns the Project with the given identifier. If no record could be found an error will be returned.

func (Projects) Save

func (p Projects) Save(path string)

Save writes the element as YAML file to the given path.

func (Projects) SearchItems

func (p Projects) SearchItems() util.SearchItems

SearchItems returns a searchable structure of the Projects. So the user can search for Projects in the interactive mode.

func (Projects) Validate

func (p Projects) Validate() util.ValidateResults

Validate all Projects.

type Schema

type Schema struct {
	Company             Company
	Expenses            Expenses
	Invoices            Invoices
	JournalConfig       JournalConfig
	MiscRecords         MiscRecords
	Parties             Parties
	Projects            Projects
	Statement           Statement
	AppendExpenseSuffix func(suffix string, overwrite bool)
	AppendInvoiceSuffix func(suffix string, overwrite bool)
	SaveFunc            func(s Schema)
	FileHashes          map[string]string
}

func (*Schema) Filter

func (s *Schema) Filter(types []string, from *time.Time, to *time.Time, suffix string, overwrite bool, identifier string)

func (Schema) FilterYear

func (s Schema) FilterYear(year int) Schema

func (Schema) Save

func (s Schema) Save()

func (Schema) ValidateAndReportProject

func (s Schema) ValidateAndReportProject(path string)

ValidateAndReportProject validates the Schema and saves the report to the given path.

func (Schema) ValidateProject

func (s Schema) ValidateProject() util.ValidateResults

type Statement

type Statement struct {
	Name         string        `yaml:"name" default:"e-19-01"`
	Period       string        `yaml:"period" default:"2019"`
	Transactions []Transaction `yaml:"transactions" default:"[]"`
}

BankStatement represents a bank statement.

func NewBankStatement

func NewBankStatement(useDefaults bool) Statement

NewBankStatement returns a new BankStatement struct with the one Expense in it.

func OpenBankStatement

func OpenBankStatement(path string) Statement

OpenBankStatement opens a BankStatement struct saved in the json file given by the path.

func (*Statement) AddTransaction

func (t *Statement) AddTransaction(trn []Transaction)

func (*Statement) AssistedCompletion

func (t *Statement) AssistedCompletion(s Schema, doAll, autoSave, autoMode, askSkip, documentsOnly bool)

func (Statement) Conditions

func (t Statement) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Statement) FilterTransactions

func (t Statement) FilterTransactions(from *time.Time, to *time.Time) ([]Transaction, error)

func (Statement) GetIdentifiables

func (t Statement) GetIdentifiables() []Identifiable

func (Statement) Save

func (t Statement) Save(path string)

Save writes the element as a json to the given path. Indented states whether «prettify» the json output.

func (Statement) SetId

func (t Statement) SetId()

SetId sets a unique id to all elements in the slice.

func (Statement) String

func (t Statement) String() string

String returns a human readable representation of the element.

func (Statement) TransactionById

func (t Statement) TransactionById(id string) (*Transaction, error)

func (Statement) TransactionForDocument

func (t Statement) TransactionForDocument(id string) (*Transaction, error)

func (Statement) TransactionSearchItems

func (t Statement) TransactionSearchItems() util.SearchItems

func (Statement) Type

func (t Statement) Type() string

Type returns a string with the type name of the element.

func (Statement) Validate

func (t Statement) Validate() util.ValidateResults

Validate the element and return the result.

type Transaction

type Transaction struct {
	Id                   string               `yaml:"id" default:""`
	Identifier           string               `yaml:"identifier" default:""`
	Amount               float64              `yaml:"amount" default:"10.00" query:"amount"`
	Description          string               `yaml:"description" default:""`
	TransactionType      util.TransactionType `yaml:"transactionType" default:"0"`
	AssociatedPartyId    string               `yaml:"associatedPartyId" default:"" query:"customer,employee"`
	AssociatedDocumentId string               `yaml:"associatedDocumentId" default:"" query:"expense,invoice"`
	Date                 string               `yaml:"date" default:""`
	JournalMode          JournalMode          `yaml:"journalMode" default:"0"`
}

Transaction represents a single transaction of a bank statement.

func InteractiveNewTransaction

func InteractiveNewTransaction(s Statement) Transaction

func NewTransaction

func NewTransaction() Transaction

func NewTransactionWithUuid

func NewTransactionWithUuid() Transaction

func (Transaction) AssistedCompletion

func (t Transaction) AssistedCompletion(s Schema, doAll, autoMode, askSkip, documentsOnly bool) Transaction

func (Transaction) Conditions

func (t Transaction) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Transaction) DateTime

func (t Transaction) DateTime() time.Time

func (Transaction) GetDate

func (t Transaction) GetDate() *time.Time

func (Transaction) GetId

func (t Transaction) GetId() string

GetId returns the unique id of the element.

func (Transaction) GetIdentifier

func (t Transaction) GetIdentifier() string

func (Transaction) SearchItem

func (t Transaction) SearchItem() util.SearchItem

func (*Transaction) SetId

func (t *Transaction) SetId()

SetId generates a unique id for the element if there isn't already one defined.

func (Transaction) Short

func (t Transaction) Short() string

Short returns a short represenation of the element.

func (Transaction) String

func (t Transaction) String() string

String returns a human readable representation of the element.

func (Transaction) Type

func (Transaction) Type() string

Type returns a string with the type name of the element.

func (Transaction) Validate

func (t Transaction) Validate() util.ValidateResults

Validate the element and return the result.

Jump to

Keyboard shortcuts

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