index

package
v0.0.0-...-787ceec Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

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

View Source
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

func Filter(history []Record, test func(Record) bool) (ret []Record)

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

func FilterActiveRecords(history []Record, start time.Time, end time.Time) []Record

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

func FromGoogleSheet(srv *sheets.Service, spreadsheetID string) ([]Record, error)

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

func FromSpreadsheetRow(index int, row []interface{}) (Record, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL