Documentation
¶
Index ¶
- Constants
- Variables
- func NewClient(config *PostgresConfig) (*sqlx.DB, error)
- type Account
- type AccountSign
- type AccountStore
- func (store AccountStore) CloseSpotInTree(afterValue, spread uint64) error
- func (store AccountStore) GetAccountByID(id uint64) (*Account, error)
- func (store AccountStore) GetAccountWithChildrenByLevel(acctID uint64) ([]AccountWithLevel, error)
- func (store AccountStore) GetAccounts() ([]Account, error)
- func (store AccountStore) GetAllChildren(acctID uint64) ([]Account, error)
- func (store AccountStore) GetBalance(accountID uint64) (int64, error)
- func (store AccountStore) GetBalances(accountID uint64) ([]Account, error)
- func (store AccountStore) GetDirectChildren(acctID uint64) ([]Account, error)
- func (store AccountStore) GetParents(acctID uint64) ([]Account, error)
- func (store AccountStore) OpenSpotInTree(afterValue, spread uint64) error
- func (store AccountStore) SetAccountReconciledDate(acct *Account) error
- func (store AccountStore) Store(acct *Account) error
- func (store AccountStore) Update(acct *Account) error
- func (store AccountStore) UpdateBalance(acct *Account) error
- func (store AccountStore) UpdateSubtotal(acct *Account) error
- type AccountSubtotal
- type AccountType
- type AccountWithLevel
- type Datastores
- type PostgresConfig
- type Report
- type ReportAccountSetType
- type ReportBody
- type ReportDataSetType
- type ReportStore
- func (store ReportStore) Delete(rpt *Report) error
- func (store ReportStore) Retrieve() ([]*Report, error)
- func (store ReportStore) RetrieveByID(id uint64) (*Report, error)
- func (store ReportStore) Store(myReport *Report) error
- func (store ReportStore) StoreOrUpdate(myReport *Report) error
- func (store ReportStore) Update(myReport *Report) error
- type Transaction
- type TransactionDebitCredit
- type TransactionDebitCreditStore
- func (store TransactionDebitCreditStore) DeleteForTransactionID(id uint64) ([]*TransactionDebitCredit, error)
- func (store TransactionDebitCreditStore) GetDCForTransactionID(id uint64) ([]*TransactionDebitCredit, error)
- func (store TransactionDebitCreditStore) GetReconciledSubtotals(accountLeft, accountRight uint64, reconciledCutoffDate time.Time) ([]*AccountSubtotal, error)
- func (store TransactionDebitCreditStore) GetSubtotals(accountID uint64) ([]*AccountSubtotal, error)
- func (store TransactionDebitCreditStore) Store(trn *TransactionDebitCredit) error
- type TransactionLedger
- type TransactionReconciliation
- type TransactionStore
- func (store TransactionStore) Delete(trn *Transaction) error
- func (store TransactionStore) GetByID(id uint64) (*Transaction, error)
- func (store TransactionStore) GetCreditsForAccounts(accountID []uint64) (int64, error)
- func (store TransactionStore) GetCreditsForAccountsFiltered(accountID []uint64, filteredAccounts []uint64) (int64, error)
- func (store TransactionStore) GetCreditsForAccountsFilteredForDates(accountID []uint64, filteredAccounts []uint64, startDate time.Time, ...) (int64, error)
- func (store TransactionStore) GetCreditsForAccountsForDates(accountID []uint64, startDate time.Time, endDate time.Time) (int64, error)
- func (store TransactionStore) GetDebitTotalForAccounts(accountIDs []uint64) (int64, error)
- func (store TransactionStore) GetDebitTotalForAccountsFiltered(accountID []uint64, filteredAccounts []uint64) (int64, error)
- func (store TransactionStore) GetDebitTotalForAccountsFilteredForDates(accountID []uint64, filteredAccounts []uint64, startDate time.Time, ...) (int64, error)
- func (store TransactionStore) GetDebitTotalForAccountsForDates(accountIDs []uint64, startDate time.Time, endDate time.Time) (int64, error)
- func (store TransactionStore) GetTransactionsForAccount(accountID uint64) ([]*TransactionLedger, error)
- func (store TransactionStore) GetUnreconciledTransactionsOnAccountForDate(accountLeft, accountRight uint64, searchLimitDate time.Time, ...) ([]*TransactionReconciliation, error)
- func (store TransactionStore) RetrieveTransactionsNetForDates(accountIDSet []uint64, startDate time.Time, endDate time.Time) ([]*TransactionLedger, error)
- func (store TransactionStore) SetIsReconciled(trn *Transaction) error
- func (store TransactionStore) SetTransactionReconcileDate(trn *Transaction) error
- func (store TransactionStore) Store(trn *Transaction) error
- func (store TransactionStore) Update(trn *Transaction) error
Constants ¶
const ( // AccountSignDebit is the AccountSign status for DEBIT Accounts. AccountSignDebit = AccountSign("DEBIT") // AccountSignCredit is the AccountSign status for CREDIT Accounts. AccountSignCredit = AccountSign("CREDIT") AccountTypeAsset = AccountType("ASSET") AccountTypeLiability = AccountType("LIABILITY") AccountTypeEquity = AccountType("EQUITY") AccountTypeIncome = AccountType("INCOME") AccountTypeExpense = AccountType("EXPENSE") AccountTypeGain = AccountType("GAIN") AccountTypeLoss = AccountType("LOSS") )
const ( ReportAccountSetNone = ReportAccountSetType("NONE") ReportAccountSetGroup = ReportAccountSetType("GROUP") ReportAccountSetPredefined = ReportAccountSetType("PREDEFINED") ReportAccountSetUserSupplied = ReportAccountSetType("USER_SUPPLIED") )
const ( ReportDataSetTypeBalance = ReportDataSetType("BALANCE") ReportDataSetTypeLedger = ReportDataSetType("LEDGER") ReportDataSetTypeIncome = ReportDataSetType("INCOME") ReportDataSetTypeExpense = ReportDataSetType("EXPENSE") )
Variables ¶
var AccountTypeToSign = map[AccountType]AccountSign{ AccountTypeAsset: AccountSignDebit, AccountTypeLiability: AccountSignCredit, AccountTypeEquity: AccountSignCredit, AccountTypeIncome: AccountSignCredit, AccountTypeExpense: AccountSignDebit, AccountTypeGain: AccountSignCredit, AccountTypeLoss: AccountSignDebit}
Functions ¶
Types ¶
type Account ¶
type Account struct {
AccountID uint64 `db:"account_id,omitempty"`
AccountParent uint64 `db:"account_parent"`
AccountName string `db:"account_name"`
AccountFullName string `db:"account_full_name"`
AccountMemo string `db:"account_memo"`
AccountCurrent bool `db:"account_current"`
AccountLeft uint64 `db:"account_left"`
AccountRight uint64 `db:"account_right"`
AccountBalance int64 `db:"account_balance"`
AccountSubtotal int64 `db:"account_subtotal"`
AccountDecimals uint64 `db:"account_decimals"`
AccountReconcileDate sql.NullTime `db:"account_reconcile_date"`
AccountFlagged bool `db:"account_flagged"`
AccountLocked bool `db:"account_locked"`
AccountOpenDate time.Time `db:"account_open_date"`
AccountCloseDate sql.NullTime `db:"account_close_date"`
AccountCode sql.NullString `db:"account_code"`
AccountSign AccountSign `db:"account_sign"`
AccountType AccountType `db:"account_type"`
}
type AccountSign ¶
type AccountSign string
AccountSign is an enum for account signs "DEBIT" or "CREDIT".
type AccountStore ¶
func (AccountStore) CloseSpotInTree ¶
func (store AccountStore) CloseSpotInTree(afterValue, spread uint64) error
CloseSpotInTree closes a gap in our account tree.
func (AccountStore) GetAccountByID ¶
func (store AccountStore) GetAccountByID(id uint64) (*Account, error)
Gets one account by account ID.
func (AccountStore) GetAccountWithChildrenByLevel ¶
func (store AccountStore) GetAccountWithChildrenByLevel(acctID uint64) ([]AccountWithLevel, error)
Gets the Account and Children with Levels
func (AccountStore) GetAccounts ¶
func (store AccountStore) GetAccounts() ([]Account, error)
Gets All Accounts.
func (AccountStore) GetAllChildren ¶
func (store AccountStore) GetAllChildren(acctID uint64) ([]Account, error)
Gets All Children of a given account, regardless of dept.
func (AccountStore) GetBalance ¶
func (store AccountStore) GetBalance(accountID uint64) (int64, error)
GetBalancel gets the sum of all the subtotals for this accountID and all child accounts.
func (AccountStore) GetBalances ¶
func (store AccountStore) GetBalances(accountID uint64) ([]Account, error)
GetBalances gets the sum of all the subtotals for this accountID and all child accounts.
func (AccountStore) GetDirectChildren ¶
func (store AccountStore) GetDirectChildren(acctID uint64) ([]Account, error)
GetDirectChildren gets first level children of an account.
func (AccountStore) GetParents ¶
func (store AccountStore) GetParents(acctID uint64) ([]Account, error)
GetDirectChildren gets first level children of an account.
func (AccountStore) OpenSpotInTree ¶
func (store AccountStore) OpenSpotInTree(afterValue, spread uint64) error
OpenSpotInTree opens a spot in our nested set.
func (AccountStore) SetAccountReconciledDate ¶
func (store AccountStore) SetAccountReconciledDate(acct *Account) error
Set AccountReconcileDate.
func (AccountStore) Store ¶
func (store AccountStore) Store(acct *Account) error
Store inserts an Account into postgres.
func (AccountStore) Update ¶
func (store AccountStore) Update(acct *Account) error
Update updates Accounts into postgres.
func (AccountStore) UpdateBalance ¶
func (store AccountStore) UpdateBalance(acct *Account) error
account_balance updates the account_balance into postgres.
func (AccountStore) UpdateSubtotal ¶
func (store AccountStore) UpdateSubtotal(acct *Account) error
UpdateSubtotal updates the account_subtotal into postgres.
type AccountSubtotal ¶
type AccountSubtotal struct {
Subtotal uint64 `db:"subtotal"`
DebitOrCredit AccountSign `db:"debit_or_credit"`
}
type AccountWithLevel ¶
type Datastores ¶
type Datastores struct {
// contains filtered or unexported fields
}
func NewDatastores ¶
func NewDatastores(conn *sqlx.DB) *Datastores
func (*Datastores) AccountStore ¶
func (ds *Datastores) AccountStore() AccountStore
AccountStore is the way to access the AccountStore.
func (*Datastores) PGClient ¶
func (ds *Datastores) PGClient() *sqlx.DB
PGClient is the way to access the Postgres Client
func (*Datastores) ReportStore ¶
func (ds *Datastores) ReportStore() ReportStore
ReportStore is the way to access the ReportStore.
func (*Datastores) TransactionDebitCreditStore ¶
func (ds *Datastores) TransactionDebitCreditStore() TransactionDebitCreditStore
TransactionDebitCreditStore is the way to access the TransactionDebitCreditStore.
func (*Datastores) TransactionStore ¶
func (ds *Datastores) TransactionStore() TransactionStore
TransactionStore is the way to access the TransactionStore.
type PostgresConfig ¶
type PostgresConfig struct {
Host, Username, Password, DBName string
Port, MaxConnLifetime int
DisableSSL bool
}
func LoadPostgresConfigFromEnv ¶
func LoadPostgresConfigFromEnv() PostgresConfig
type Report ¶
type Report struct {
ReportID uint64 `db:"report_id,omitempty"`
ReportName string `db:"report_name"`
ReportBody ReportBody `db:"report_body"`
}
type ReportAccountSetType ¶
type ReportAccountSetType string
AccountType is an enum for account type.
type ReportBody ¶
type ReportBody struct {
SourceAccountSetType ReportAccountSetType `json:"sourceAccountSetType"`
SourceAccountGroup AccountType `json:"sourceAccountGroup,omitempty"`
SourcePredefinedAccounts []uint64 `json:"sourcePredefinedAccounts"`
SourceRecurseSubAccounts bool `json:"sourceRecurseSubAccounts"`
SourceRecurseSubAccountsDepth int `json:"sourceRecurseSubAccountsDepth"`
FilterAccountSetType ReportAccountSetType `json:"filterAccountSetType"`
FilterAccountGroup AccountType `json:"filterAccountGroup,omitempty"`
FilterPredefinedAccounts []uint64 `json:"filterPredefinedAccounts"`
FilterRecurseSubAccounts bool `json:"filterRecurseSubAccounts"`
FilterRecurseSubAccountsDepth int `json:"filterRecurseSubAccountsDepth"`
DataSetType ReportDataSetType `json:"dataSetType"`
}
func (*ReportBody) Scan ¶
func (rb *ReportBody) Scan(value interface{}) error
Make the struct implement the sql.Scanner interface. This method simply decodes a JSON-encoded value into the struct fields.
type ReportDataSetType ¶
type ReportDataSetType string
type ReportStore ¶
func (ReportStore) Retrieve ¶
func (store ReportStore) Retrieve() ([]*Report, error)
Gets All Reports.
func (ReportStore) RetrieveByID ¶
func (store ReportStore) RetrieveByID(id uint64) (*Report, error)
func (ReportStore) Store ¶
func (store ReportStore) Store(myReport *Report) error
Store inserts a UserNotification into postgres, we do not include :report_id in our insert
func (ReportStore) StoreOrUpdate ¶
func (store ReportStore) StoreOrUpdate(myReport *Report) error
StoreOrUpdate inserts a Report into postgres, or updates the existing record
func (ReportStore) Update ¶
func (store ReportStore) Update(myReport *Report) error
Store inserts a UserNotification into postgres, we do not include :report_id in our insert
type Transaction ¶
type Transaction struct {
TransactionID uint64 `db:"transaction_id,omitempty"`
TransactionDate time.Time `db:"transaction_date,omitempty"`
TransactionReconcileDate sql.NullTime `db:"transaction_reconcile_date"`
TransactionComment string `db:"transaction_comment"`
TransactionAmount uint64 `db:"transaction_amount"`
TransactionReference string `db:"transaction_reference"` // this could be a check number, batch ,etc
IsReconciled bool `db:"is_reconciled"`
IsSplit bool `db:"is_split"`
}
type TransactionDebitCredit ¶
type TransactionDebitCredit struct {
TransactionDCID uint64 `db:"transaction_dc_id,omitempty"`
TransactionID uint64 `db:"transaction_id"`
AccountID uint64 `db:"account_id"`
TransactionDCAmount uint64 `db:"transaction_dc_amount"`
DebitOrCredit AccountSign `db:"debit_or_credit"`
}
type TransactionDebitCreditStore ¶
func (TransactionDebitCreditStore) DeleteForTransactionID ¶
func (store TransactionDebitCreditStore) DeleteForTransactionID(id uint64) ([]*TransactionDebitCredit, error)
func (TransactionDebitCreditStore) GetDCForTransactionID ¶
func (store TransactionDebitCreditStore) GetDCForTransactionID(id uint64) ([]*TransactionDebitCredit, error)
func (TransactionDebitCreditStore) GetReconciledSubtotals ¶
func (store TransactionDebitCreditStore) GetReconciledSubtotals(accountLeft, accountRight uint64, reconciledCutoffDate time.Time) ([]*AccountSubtotal, error)
func (TransactionDebitCreditStore) GetSubtotals ¶
func (store TransactionDebitCreditStore) GetSubtotals(accountID uint64) ([]*AccountSubtotal, error)
Gets one account by account ID
func (TransactionDebitCreditStore) Store ¶
func (store TransactionDebitCreditStore) Store(trn *TransactionDebitCredit) error
Store inserts a UserNotification into postgres
type TransactionLedger ¶
type TransactionLedger struct {
TransactionID uint64 `db:"transaction_id"`
TransactionDate time.Time `db:"transaction_date"`
TransactionReconcileDate sql.NullTime `db:"transaction_reconcile_date"`
TransactionComment string `db:"transaction_comment"`
TransactionReference string `db:"transaction_reference"` // this could be a check number, batch ,etc
IsReconciled bool `db:"is_reconciled"`
IsSplit bool `db:"is_split"`
TransactionDCAmount uint64 `db:"transaction_dc_amount"`
DebitOrCredit AccountSign `db:"debit_or_credit"`
// split is a generated field, a comma separated list of the other d/c
Split string `db:"split"`
}
type TransactionReconciliation ¶
type TransactionReconciliation struct {
TransactionID uint64 `db:"transaction_id"`
AccountID uint64 `db:"account_id"`
TransactionDate time.Time `db:"transaction_date"`
TransactionReconcileDate sql.NullTime `db:"transaction_reconcile_date"`
TransactionComment string `db:"transaction_comment"`
TransactionReference string `db:"transaction_reference"` // this could be a check number, batch ,etc
IsReconciled bool `db:"is_reconciled"`
IsSplit bool `db:"is_split"`
TransactionDCAmount uint64 `db:"transaction_dc_amount"`
DebitOrCredit AccountSign `db:"debit_or_credit"`
// split is a generated field, a comma separated list of the other d/c
Split string `db:"split"`
}
type TransactionStore ¶
func (TransactionStore) Delete ¶
func (store TransactionStore) Delete(trn *Transaction) error
Delete a transaction
func (TransactionStore) GetByID ¶
func (store TransactionStore) GetByID(id uint64) (*Transaction, error)
func (TransactionStore) GetCreditsForAccounts ¶
func (store TransactionStore) GetCreditsForAccounts(accountID []uint64) (int64, error)
func (TransactionStore) GetCreditsForAccountsFiltered ¶
func (store TransactionStore) GetCreditsForAccountsFiltered(accountID []uint64, filteredAccounts []uint64) (int64, error)
func (TransactionStore) GetCreditsForAccountsFilteredForDates ¶
func (TransactionStore) GetCreditsForAccountsForDates ¶
func (TransactionStore) GetDebitTotalForAccounts ¶
func (store TransactionStore) GetDebitTotalForAccounts(accountIDs []uint64) (int64, error)
func (TransactionStore) GetDebitTotalForAccountsFiltered ¶
func (store TransactionStore) GetDebitTotalForAccountsFiltered(accountID []uint64, filteredAccounts []uint64) (int64, error)
func (TransactionStore) GetDebitTotalForAccountsFilteredForDates ¶
func (TransactionStore) GetDebitTotalForAccountsForDates ¶
func (TransactionStore) GetTransactionsForAccount ¶
func (store TransactionStore) GetTransactionsForAccount(accountID uint64) ([]*TransactionLedger, error)
func (TransactionStore) GetUnreconciledTransactionsOnAccountForDate ¶
func (store TransactionStore) GetUnreconciledTransactionsOnAccountForDate(accountLeft, accountRight uint64, searchLimitDate time.Time, reconciledCutoffDate time.Time) ([]*TransactionReconciliation, error)
func (TransactionStore) RetrieveTransactionsNetForDates ¶
func (store TransactionStore) RetrieveTransactionsNetForDates(accountIDSet []uint64, startDate time.Time, endDate time.Time) ([]*TransactionLedger, error)
func (TransactionStore) SetIsReconciled ¶
func (store TransactionStore) SetIsReconciled(trn *Transaction) error
Set Transaction Reconsciled
func (TransactionStore) SetTransactionReconcileDate ¶
func (store TransactionStore) SetTransactionReconcileDate(trn *Transaction) error
Set TransactionReconcileDate
func (TransactionStore) Store ¶
func (store TransactionStore) Store(trn *Transaction) error
Store inserts a UserNotification into postgres
func (TransactionStore) Update ¶
func (store TransactionStore) Update(trn *Transaction) error