Documentation ¶
Overview ¶
Package index provides constants and functions for reading a spreadsheet that lists other spreadsheets: each one a budget covering a particular date range. The app uses these functions to look up the budget spreadsheets and determine which one(s) a transaction should be added to.
Index ¶
- Constants
- type Record
- func Filter(history []Record, test func(Record) bool) (ret []Record)
- func FilterActiveRecords(history []Record, start time.Time, end time.Time) []Record
- func FromGoogleSheet(srv *sheets.Service, spreadsheetID string) ([]Record, error)
- func FromSpreadsheetRow(index int, row []interface{}) (Record, error)
Constants ¶
const Range = "Index!A2:E"
Range is a constant that indicates where in the index spreadsheet to find the list of budget spreadsheets.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Record ¶
type Record struct { Index int Filename string Start time.Time End time.Time LastUpdated time.Time SpreadsheetID string IndexID string }
Record holds one index entry, representing one budget spreadsheet. It identifies the sheet ID, its start and end dates (inclusive), and the last date and time that sheet was updated.
func Filter ¶
Filter accepts an array of Records and a "test" function that accepts a Record and returns a boolean. It returns an array of those records for which the test function returned true.
func FilterActiveRecords ¶
FilterActiveRecords accepts an array of Records and a start and end date. It returns an array of records dated between start and end.
func FromGoogleSheet ¶
FromGoogleSheet uses the Google sheets service and specified spreadsheet ID to read all the index Records on that sheet, which it returns as an array.
func FromSpreadsheetRow ¶
FromSpreadsheetRow reads a row of spreadsheet data to initialize a Record. It return the Record and/or an error. If an optional field fails to parse, it will return both an error and a record.