schema

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package schema contains all the data structure for a acc project.

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

GetUuid generates a new UUID.

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)

SaveYamlOnChange saves the given data if it this data has changed. This is archived by hashing the marshalled YAML and comparing it with the hash from the loaded file content.

func SuggestNextIdentifier

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

SuggestNextIdentifier suggest the next identifier for a Identifiable. This is solely done by looking at the trailing (e.g. last) number and looking for the uppermost value. The suggestion is this number plus one.

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 util.Money `yaml:"amount" default:"" 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"`
	// ObligedCustomer refers to the customer which have to pay the Expense.
	ObligedCustomer Ref `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.
	AdvancedThirdParty Ref `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"`
	// SettlementTransaction refers to a possible bank transaction which settled the Expense for the company.
	SettlementTransaction Ref `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 paid with the main account debithether the expense was directly paid with the main account debit card.
	PaidWithDebit bool `yaml:"paidWithDebit" default:"false"`
	// Internal states whether this expense is for an internal purpose or not.
	Internal bool `yaml:"internal" default:"true"`
	// Project refers to the associated project.
	Project Ref `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 representation 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:"Material 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) ExpenseByIdent

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

func (Expenses) ExpenseByRef added in v0.5.0

func (e Expenses) ExpenseByRef(ref Ref) (*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) SetReferenceDestinations added in v0.5.0

func (e Expenses) SetReferenceDestinations(cst, emp, trn, prj []Identifiable)

SetReferenceDestinations sets the destinations of the Reference fields.

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 util.Money `yaml:"amount" default:"-" 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"`
	// Customer refers to the customer the invoice was sent to.
	Customer Ref `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"`
	// SettlementTransaction refers to a possible bank transaction which settled the Expense for the company.
	SettlementTransaction Ref `yaml:"settlementTransactionId" default:"" query:"transaction"`
	// Project refers to the associated project.
	Project Ref `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 representation 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) InvoiceByIdent

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

func (Invoices) InvoiceByRef added in v0.5.0

func (i Invoices) InvoiceByRef(ref Ref) (*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) SetReferenceDestinations added in v0.5.0

func (i Invoices) SetReferenceDestinations(cst, trn, prj []Identifiable)

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"`
	Transaction Ref    `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

GetDate returns the date of the misc-records as a time.Time struct.

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 representation 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) 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) MiscRecordByRef added in v0.5.0

func (m MiscRecords) MiscRecordByRef(ref Ref) (*MiscRecord, error)

MiscRecordByRef returns the MiscRecord with the given id. 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) SetReferenceDestinations added in v0.5.0

func (m MiscRecords) SetReferenceDestinations(trn []Identifiable)

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) 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) CustomerByRef added in v0.5.0

func (p Parties) CustomerByRef(ref Ref) (*Party, error)

func (Parties) CustomerStringByRef added in v0.5.0

func (p Parties) CustomerStringByRef(ref Ref) string

func (Parties) CustomersSearchItems

func (p Parties) CustomersSearchItems() util.SearchItems

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) EmployeeByRef added in v0.5.0

func (p Parties) EmployeeByRef(ref Ref) (*Party, error)

func (Parties) EmployeeStringByRef added in v0.5.0

func (p Parties) EmployeeStringByRef(ref Ref) 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 representation 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"`
	Customer   Ref    `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 representation 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) 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) ProjectByRef added in v0.5.0

func (p Projects) ProjectByRef(ref Ref) (*Project, error)

ProjectByRef returns the Project with the given id. 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) SetReferenceDestinations added in v0.5.0

func (p Projects) SetReferenceDestinations(cst []Identifiable)

func (Projects) Validate

func (p Projects) Validate() util.ValidateResults

Validate all Projects.

type Ref added in v0.5.0

type Ref struct {
	Id          string
	Destination Identifiable
}

Ref is used to reference to other data types by using UUID's.

func NewRef added in v0.5.0

func NewRef(id string) Ref

NewRef returns a new Reference with the given id.

func (Ref) Empty added in v0.5.0

func (r Ref) Empty() bool

Empty returns whether a referencing id is set

func (Ref) MarshalYAML added in v0.5.0

func (r Ref) MarshalYAML() (interface{}, error)

MarshalYAML implements the marshalling of a Reference for YAML files.

func (Ref) Match added in v0.5.0

func (r Ref) Match(val Identifiable) bool

Match returns whether a given Identifiable matches the id of the reference.

func (*Ref) SetDestination added in v0.5.0

func (r *Ref) SetDestination(destinations []Identifiable)

SetDestination takes a slice of Identifiables and looks for the matching element in respective to the id. If found the Destination is set.

func (*Ref) UnmarshalYAML added in v0.5.0

func (r *Ref) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the unmarshaling of a Reference for YAML files.

type Schema

type Schema struct {
	Company             Company
	Expenses            Expenses
	Invoices            Invoices
	JournalConfig       JournalConfig
	Currency            string
	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
	BaseFolder          string
}

Schema is the entirety of all business data for all the functionality of acc.

func (*Schema) Filter

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

Filter all elements of the schema by date (between from and to) as well as the identifier. Suffix and overwrite are used for the AppendExpenseInvoice/AppendInvoice function.

func (Schema) FilterYear

func (s Schema) FilterYear(year int) Schema

FilterYear filters the elements of the Schema to certain year.

func (Schema) Save

func (s Schema) Save()

Save the schema.

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

ValidateProject validates all elements of the schema.

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) Repopulate added in v0.5.0

func (t Statement) Repopulate(s Schema)

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) SetReferenceDestinations added in v0.5.0

func (t Statement) SetReferenceDestinations(doc, pty []Identifiable)

func (Statement) String

func (t Statement) String() string

String returns a human readable representation of the element.

func (Statement) TransactionByRef added in v0.5.0

func (t Statement) TransactionByRef(ref Ref) (*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             util.Money           `yaml:"amount" default:"-" query:"amount"`
	Description        string               `yaml:"description" default:""`
	TransactionType    util.TransactionType `yaml:"transactionType" default:"0"`
	AssociatedParty    Ref                  `yaml:"associatedPartyId" default:"" query:"customer,employee"`
	AssociatedDocument Ref                  `yaml:"associatedDocumentId" default:"" query:"expense,invoice,misc"`
	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, currency string) 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) Repopulate added in v0.5.0

func (t *Transaction) Repopulate(s Schema)

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 representation 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