Documentation
¶
Overview ¶
Package transaction implements transaction entities and services
Index ¶
- type Bulk
- type ClearingStatus
- type Filter
- type FlagColor
- type Hybrid
- type OperationSummary
- type PayloadTransaction
- type Scheduled
- type ScheduledFrequency
- type ScheduledSubTransaction
- type ScheduledSummary
- type Service
- func (s *Service) BulkCreateTransactions(budgetID string, ps []PayloadTransaction) (*Bulk, error)
- func (s *Service) CreateTransaction(budgetID string, p PayloadTransaction) (*OperationSummary, error)
- func (s *Service) CreateTransactions(budgetID string, p []PayloadTransaction) (*OperationSummary, error)
- func (s *Service) GetScheduledTransaction(budgetID, scheduledTransactionID string) (*Scheduled, error)
- func (s *Service) GetScheduledTransactions(budgetID string) ([]*Scheduled, error)
- func (s *Service) GetTransaction(budgetID, transactionID string) (*Transaction, error)
- func (s *Service) GetTransactions(budgetID string, f *Filter) ([]*Transaction, error)
- func (s *Service) GetTransactionsByAccount(budgetID, accountID string, f *Filter) ([]*Transaction, error)
- func (s *Service) GetTransactionsByCategory(budgetID, categoryID string, f *Filter) ([]*Hybrid, error)
- func (s *Service) GetTransactionsByPayee(budgetID, payeeID string, f *Filter) ([]*Hybrid, error)
- func (s *Service) UpdateTransaction(budgetID, transactionID string, p PayloadTransaction) (*Transaction, error)
- func (s *Service) UpdateTransactions(budgetID string, p []PayloadTransaction) (*OperationSummary, error)
- type Status
- type SubTransaction
- type Summary
- type Transaction
- type Type
Examples ¶
- Service.BulkCreateTransactions
- Service.CreateTransaction
- Service.CreateTransactions
- Service.GetScheduledTransaction
- Service.GetScheduledTransactions
- Service.GetTransaction
- Service.GetTransactions
- Service.GetTransactions (Filtered)
- Service.GetTransactionsByAccount
- Service.GetTransactionsByAccount (Filtered)
- Service.GetTransactionsByCategory
- Service.GetTransactionsByCategory (Filtered)
- Service.GetTransactionsByPayee
- Service.GetTransactionsByPayee (Filtered)
- Service.UpdateTransaction
Constants ¶
Variables ¶
Functions ¶
Types ¶
type Bulk ¶
type Bulk struct { // TransactionIDs The list of Transaction IDs that were created TransactionIDs []string `json:"transaction_ids"` // DuplicateImportIDs If any Transactions were not created because they had an // import ID matching a transaction already on the same account, the // specified import IDs will be included in this list DuplicateImportIDs []string `json:"duplicate_import_ids"` }
Bulk represents the output of transactions being created in bulk mode Deprecated: Use BulkTransactions instead.
type ClearingStatus ¶
type ClearingStatus string
ClearingStatus represents the clearing status of a transaction
const ( // ClearingStatusUncleared identifies an uncleared transaction ClearingStatusUncleared ClearingStatus = "uncleared" // ClearingStatusCleared identifies a cleared transaction ClearingStatusCleared ClearingStatus = "cleared" // ClearingStatusReconciled identifies a reconciled transaction ClearingStatusReconciled ClearingStatus = "reconciled" )
type FlagColor ¶
type FlagColor string
FlagColor represents the flag color of a transaction
const ( // FlagColorRed identifies a transaction flagged red FlagColorRed FlagColor = "red" // FlagColorOrange identifies a transaction flagged orange FlagColorOrange FlagColor = "orange" // FlagColorYellow identifies a transaction flagged yellow FlagColorYellow FlagColor = "yellow" // FlagColorGreen identifies a transaction flagged green FlagColorGreen FlagColor = "green" // FlagColorBlue identifies a transaction flagged blue FlagColorBlue FlagColor = "blue" // FlagColorPurple identifies a transaction flagged purple FlagColorPurple FlagColor = "purple" )
type Hybrid ¶
type Hybrid struct { ID string `json:"id"` Date api.Date `json:"date"` // Amount Transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` AccountID string `json:"account_id"` AccountName string `json:"account_name"` // Deleted Deleted transactions will only be included in delta requests Deleted bool `json:"deleted"` Type Type `json:"type"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` TransferAccountID *string `json:"transfer_account_id"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` // ParentTransactionID For subtransaction types, this is the id of the parent transaction // For transaction types, this id will be always be null ParentTransactionID *string `json:"parent_transaction_id"` PayeeName *string `json:"payee_name"` CategoryName *string `json:"category_name"` }
Hybrid represents a hybrid transaction
type OperationSummary ¶
type OperationSummary struct { // TransactionIDs The list of Transaction IDs that were created TransactionIDs []string `json:"transaction_ids"` // DuplicateImportIDs If any Transactions were not created because they had an // import ID matching a transaction already on the same account, the // specified import IDs will be included in this list DuplicateImportIDs []string `json:"duplicate_import_ids"` // Transactions If multiple transactions were specified, the transactions that were saved Transactions []*Transaction `json:"transactions"` // Transactions If a single transaction was specified, the transaction that was saved Transaction *Transaction `json:"transaction"` }
OperationSummary represents the output of transactions being created
type PayloadTransaction ¶
type PayloadTransaction struct { ID string `json:"id"` AccountID string `json:"account_id"` Date api.Date `json:"date"` // Amount The transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` // PayeeID Transfer payees are not permitted and will be ignored if supplied PayeeID *string `json:"payee_id"` // PayeeName If the payee name is provided and payee ID has a null value, the // payee name value will be used to resolve the payee by either (1) a matching // payee rename rule (only if import_id is also specified) or (2) a payee with // the same name or (3) creation of a new payee PayeeName *string `json:"payee_name"` // CategoryID Split and Credit Card Payment categories are not permitted and // will be ignored if supplied. CategoryID *string `json:"category_id"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` }
PayloadTransaction is the payload contract for saving a transaction, new or existent
type Scheduled ¶
type Scheduled struct { ID string `json:"id"` DateFirst api.Date `json:"date_first"` DateNext api.Date `json:"date_next"` Frequency ScheduledFrequency `json:"frequency"` // Amount The scheduled transaction amount in milliunits format Amount int64 `json:"amount"` AccountID string `json:"account_id"` // Deleted Deleted scheduled transactions will only be included in delta requests. Deleted bool `json:"deleted"` AccountName string `json:"account_name"` SubTransactions []*ScheduledSubTransaction `json:"subtransactions"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the scheduled // transaction transfers to TransferAccountID *string `json:"transfer_account_id"` PayeeName *string `json:"payee_name"` CategoryName *string `json:"category_name"` }
Scheduled represents a scheduled transaction for a budget
type ScheduledFrequency ¶
type ScheduledFrequency string
ScheduledFrequency represents the frequency of a scheduled transaction or sub-transaction
const ( // FrequencyNever identifies a transaction that will never repeat FrequencyNever ScheduledFrequency = "never" // FrequencyDaily identifies a transaction that will repeat daily FrequencyDaily ScheduledFrequency = "daily" // FrequencyWeekly identifies a transaction that will repeat weekly FrequencyWeekly ScheduledFrequency = "weekly" // FrequencyEveryOtherWeek identifies a transaction that will repeat // every other week FrequencyEveryOtherWeek ScheduledFrequency = "everyOtherWeek" // FrequencyTwiceAMonth identifies a transaction that will repeat // twice a month FrequencyTwiceAMonth ScheduledFrequency = "twiceAMonth" // FrequencyEveryFourWeeks identifies a transaction that will repeat // every four weeks FrequencyEveryFourWeeks ScheduledFrequency = "every4Weeks" // FrequencyMonthly identifies a transaction that will repeat monthly FrequencyMonthly ScheduledFrequency = "monthly" // FrequencyEveryOtherMonth identifies a transaction that will repeat // every other month FrequencyEveryOtherMonth ScheduledFrequency = "everyOtherMonth" // FrequencyEveryThreeMonths identifies a transaction that will repeat // every three months FrequencyEveryThreeMonths ScheduledFrequency = "every3Months" // FrequencyEveryFourMonths identifies a transaction that will repeat // every four months FrequencyEveryFourMonths ScheduledFrequency = "every4Months" // FrequencyTwiceAYear identifies a transaction that will repeat // twice a year FrequencyTwiceAYear ScheduledFrequency = "twiceAYear" // FrequencyYearly identifies a transaction that will repeat yearly FrequencyYearly ScheduledFrequency = "yearly" // FrequencyEveryOtherYear identifies a transaction that will repeat // every other year FrequencyEveryOtherYear ScheduledFrequency = "everyOtherYear" )
type ScheduledSubTransaction ¶
type ScheduledSubTransaction struct { ID string `json:"id"` ScheduledTransactionID string `json:"scheduled_transaction_id"` // Amount The scheduled sub-transaction amount in milliunits format Amount int64 `json:"amount"` // Deleted Deleted scheduled sub-transactions will only be included in delta requests Deleted bool `json:"deleted"` Memo *string `json:"memo"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the scheduled // subtransaction transfers to TransferAccountID *string `json:"transfer_account_id"` }
ScheduledSubTransaction represents a scheduled sub-transaction for a scheduled transaction
type ScheduledSummary ¶
type ScheduledSummary struct { ID string `json:"id"` DateFirst api.Date `json:"date_first"` DateNext api.Date `json:"date_next"` Frequency ScheduledFrequency `json:"frequency"` // Amount The scheduled transaction amount in milliunits format Amount int64 `json:"amount"` AccountID string `json:"account_id"` // Deleted Deleted scheduled transactions will only be included in delta requests. Deleted bool `json:"deleted"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the scheduled // transaction transfers to TransferAccountID *string `json:"transfer_account_id"` }
ScheduledSummary represents the summary of a scheduled transaction for a budget
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps YNAB transaction API endpoints
func NewService ¶
func NewService(c api.ClientReaderWriter) *Service
NewService facilitates the creation of a new transaction service instance
func (*Service) BulkCreateTransactions ¶
func (s *Service) BulkCreateTransactions(budgetID string, ps []PayloadTransaction) (*Bulk, error)
BulkCreateTransactions creates multiple transactions for a budget https://api.youneedabudget.com/v1#/Transactions/bulkCreateTransactions Deprecated: Use transaction.CreateTransactions instead.
func (*Service) CreateTransaction ¶
func (s *Service) CreateTransaction(budgetID string, p PayloadTransaction) (*OperationSummary, error)
CreateTransaction creates a new transaction for a budget https://api.youneedabudget.com/v1#/Transactions/createTransaction
func (*Service) CreateTransactions ¶
func (s *Service) CreateTransactions(budgetID string, p []PayloadTransaction) (*OperationSummary, error)
CreateTransactions creates one or more new transactions for a budget https://api.youneedabudget.com/v1#/Transactions/createTransaction
func (*Service) GetScheduledTransaction ¶
func (s *Service) GetScheduledTransaction(budgetID, scheduledTransactionID string) (*Scheduled, error)
GetScheduledTransaction fetches a specific scheduled transaction from a budget https://api.youneedabudget.com/v1#/Scheduled_Transactions/getScheduledTransactionById
func (*Service) GetScheduledTransactions ¶
GetScheduledTransactions fetches the list of scheduled transactions from a budget https://api.youneedabudget.com/v1#/Scheduled_Transactions/getScheduledTransactions
func (*Service) GetTransaction ¶
func (s *Service) GetTransaction(budgetID, transactionID string) (*Transaction, error)
GetTransaction fetches a specific transaction from a budget https://api.youneedabudget.com/v1#/Transactions/getTransactionsById
func (*Service) GetTransactions ¶
func (s *Service) GetTransactions(budgetID string, f *Filter) ([]*Transaction, error)
GetTransactions fetches the list of transactions from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactions
func (*Service) GetTransactionsByAccount ¶
func (s *Service) GetTransactionsByAccount(budgetID, accountID string, f *Filter) ([]*Transaction, error)
GetTransactionsByAccount fetches the list of transactions of a specific account from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactionsByAccount
func (*Service) GetTransactionsByCategory ¶
func (s *Service) GetTransactionsByCategory(budgetID, categoryID string, f *Filter) ([]*Hybrid, error)
GetTransactionsByCategory fetches the list of transactions of a specific category from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactionsByCategory
func (*Service) GetTransactionsByPayee ¶
GetTransactionsByPayee fetches the list of transactions of a specific payee from a budget with filtering capabilities https://api.youneedabudget.com/v1#/Transactions/getTransactionsByPayee
func (*Service) UpdateTransaction ¶
func (s *Service) UpdateTransaction(budgetID, transactionID string, p PayloadTransaction) (*Transaction, error)
UpdateTransaction updates a whole transaction for a replacement https://api.youneedabudget.com/v1#/Transactions/updateTransaction
func (*Service) UpdateTransactions ¶
func (s *Service) UpdateTransactions(budgetID string, p []PayloadTransaction) (*OperationSummary, error)
UpdateTransactions creates one or more new transactions for a budget https://api.youneedabudget.com/v1#/Transactions/updateTransactions
type SubTransaction ¶
type SubTransaction struct { ID string `json:"id"` TransactionID string `json:"transaction_id"` // Amount sub-transaction amount in milliunits format Amount int64 `json:"amount"` // Deleted Deleted sub-transactions will only be included in delta requests. Deleted bool `json:"deleted"` Memo *string `json:"memo"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` // TransferAccountID If a transfer, the account_id which the // sub-transaction transfers to TransferAccountID *string `json:"transfer_account_id"` }
SubTransaction represents a sub-transaction for a transaction
type Summary ¶
type Summary struct { ID string `json:"id"` Date api.Date `json:"date"` // Amount Transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` AccountID string `json:"account_id"` // Deleted Deleted transactions will only be included in delta requests Deleted bool `json:"deleted"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` TransferAccountID *string `json:"transfer_account_id"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` }
Summary represents the summary of a transaction for a budget
type Transaction ¶
type Transaction struct { ID string `json:"id"` Date api.Date `json:"date"` // Amount Transaction amount in milliunits format Amount int64 `json:"amount"` Cleared ClearingStatus `json:"cleared"` Approved bool `json:"approved"` AccountID string `json:"account_id"` // Deleted Deleted transactions will only be included in delta requests Deleted bool `json:"deleted"` AccountName string `json:"account_name"` SubTransactions []*SubTransaction `json:"subtransactions"` Memo *string `json:"memo"` FlagColor *FlagColor `json:"flag_color"` PayeeID *string `json:"payee_id"` CategoryID *string `json:"category_id"` TransferAccountID *string `json:"transfer_account_id"` // ImportID If the Transaction was imported, this field is a unique (by account) import // identifier. If this transaction was imported through File Based Import or // Direct Import and not through the API, the import_id will have the format: // 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction // dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of // 'YNAB:-294230:2015-12-30:1’. If a second transaction on the same account // was imported and had the same date and same amount, its import_id would // be 'YNAB:-294230:2015-12-30:2’. ImportID *string `json:"import_id"` PayeeName *string `json:"payee_name"` CategoryName *string `json:"category_name"` }
Transaction represents a full transaction for a budget