Documentation ¶
Overview ¶
Ledger provides the functionality of generating hledger journals.
Index ¶
- Constants
- type Comment
- type Entry
- func EntriesForExpense(s schema.Schema, exp schema.Expense) []Entry
- func EntriesForInvoicing(s schema.Schema, inv schema.Invoice) []Entry
- func EntriesForTransaction(s schema.Schema, trn schema.Transaction) []Entry
- func SettlementEntriesForExpense(s schema.Schema, trn schema.Transaction, exp schema.Expense) []Entry
- func SettlementEntriesForInvoice(s schema.Schema, trn schema.Transaction, inv schema.Invoice) []Entry
- type EntryStatus
- type Journal
Constants ¶
const HLedgerDateFormat = "2006-01-02"
HLedgerDateFormat defines the default date format as required by hledger.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
Comment reassembles a comment which can be generated based on the state of this struct.
func NewManualComment ¶
NewManualComment returns a new Comment with the request to the user to manually correct the given journal entry.
type Entry ¶
type Entry struct { TransactionType util.TransactionType Date time.Time Status EntryStatus Code string Description string Comment Comment Account1 string Account2 string Amount util.Money }
Entry is a single journal entry.
func EntriesForExpense ¶
EntriesForExpense returns the journal entries for a given schema.Expense. Depending on the nature of the expense the appropriate function will be called.
func EntriesForInvoicing ¶
EntriesForInvoicing returns the journal entries for invoicing of the given schema.Invoice.
func EntriesForTransaction ¶
func EntriesForTransaction(s schema.Schema, trn schema.Transaction) []Entry
EntriesForTransaction returns the journal entries for a given schema.Transaction.
func SettlementEntriesForExpense ¶
func SettlementEntriesForExpense(s schema.Schema, trn schema.Transaction, exp schema.Expense) []Entry
SettlementEntriesForExpense takes the related schema.Transaction and schema.Expense and returns the settlement entries.
func SettlementEntriesForInvoice ¶
func SettlementEntriesForInvoice(s schema.Schema, trn schema.Transaction, inv schema.Invoice) []Entry
SettlementEntriesForInvoice returns the entries for the settlement (aka receiving the money from the customer) of the related invoice.
func (Entry) Transaction ¶
Transaction renders the hledger transaction for the given entry.
type EntryStatus ¶
type EntryStatus int
EntryStatus reassembles the three states a transaction can have in hledger. This information isn't necessary but is here implemented for future usage.
const ( UnmarkedStatus EntryStatus = iota PendingStatus ClearedStatus )
func (EntryStatus) TrnEle ¶
func (s EntryStatus) TrnEle() string
TrnEle renders the representation of the state in a hledger journal.
type Journal ¶
Journal is a data structure which can be converted into a hledger journal.
On Aliases ¶
Some standard chart of accounts uses multiple root accounts for the same account type. An example is Switzerland where "Personalaufwand" and "Betriebsfremder Aufwand" are both root accounts. In hledger both of them have to be children of the "expense" account. To accomplish this the use of aliases is possible. Alias declaration for the given example:
aliases := [][]string{ []string{"Personalaufwand", "expenses"}, []string{"Betriebsfremder Aufwand", "expenses"}}
func JournalFromAcc ¶
JournalFromAcc takes an schema.Schema project and converts it into an Journal. This is mainly used to export the Journal afterwards into a hledger journal. Optionally the year can be filtered, if the given year parameter is > 0, only events happened in this year will be converted into transactions.
TODO: Es brauch ein separates acc für alle Jahre und eins für d
func NewJournal ¶
NewJournalConfig returns a new Journal with the given aliases.
func (*Journal) AddEntries ¶
AddEntries adds new entries to the journal.
func (Journal) HLedgerHeader ¶
HLedgerHeader generates the header of the hledger journal as a string.
func (Journal) Less ¶
Less states whether the entry at index i is less as the entry at index k. Used for sorting.
func (Journal) SaveHLedgerFile ¶
SaveHLedgerFile saves the given Journal as a hledger journal at the given path.