Documentation
¶
Overview ¶
Package reporting provides a way to import CSV files into the database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoHomeboxHeaders = errors.New("no headers found") ErrMissingRequiredHeaders = errors.New("missing required headers `HB.location` or `HB.name`") )
Functions ¶
Types ¶
type BillOfMaterialsEntry ¶
type BillOfMaterialsEntry struct { PurchaseDate types.Date `csv:"Purchase Date"` Name string `csv:"Name"` Description string `csv:"Description"` Manufacturer string `csv:"Manufacturer"` SerialNumber string `csv:"Serial Number"` ModelNumber string `csv:"Model Number"` Quantity int `csv:"Quantity"` Price float64 `csv:"Price"` TotalPrice float64 `csv:"Total Price"` }
type ExportItemFields ¶
type ExportTSVRow ¶
type ExportTSVRow struct { ImportRef string `csv:"HB.import_ref"` Location LocationString `csv:"HB.location"` LabelStr LabelString `csv:"HB.labels"` AssetID repo.AssetID `csv:"HB.asset_id"` Archived bool `csv:"HB.archived"` Name string `csv:"HB.name"` Quantity int `csv:"HB.quantity"` Description string `csv:"HB.description"` Insured bool `csv:"HB.insured"` Notes string `csv:"HB.notes"` PurchasePrice float64 `csv:"HB.purchase_price"` PurchaseFrom string `csv:"HB.purchase_from"` PurchaseTime types.Date `csv:"HB.purchase_time"` Manufacturer string `csv:"HB.manufacturer"` ModelNumber string `csv:"HB.model_number"` SerialNumber string `csv:"HB.serial_number"` LifetimeWarranty bool `csv:"HB.lifetime_warranty"` WarrantyExpires types.Date `csv:"HB.warranty_expires"` WarrantyDetails string `csv:"HB.warranty_details"` SoldTo string `csv:"HB.sold_to"` SoldPrice float64 `csv:"HB.sold_price"` SoldTime types.Date `csv:"HB.sold_time"` SoldNotes string `csv:"HB.sold_notes"` Fields []ExportItemFields `csv:"-"` }
type IOSheet ¶
type IOSheet struct { Rows []ExportTSVRow // contains filtered or unexported fields }
IOSheet is the representation of a CSV/TSV sheet that is used for importing/exporting items from homebox. It is used to read/write the data from/to a CSV/TSV file given the standard format of the file.
See ExportTSVRow for the format of the data in the sheet.
func (*IOSheet) Read ¶
Read reads a CSV/TSV and populates the "Rows" field with the data from the sheet Custom Fields are supported via the `HB.field.*` headers. The `HB.field.*` the "Name" of the field is the part after the `HB.field.` prefix. Additionally, Custom Fields with no value are excluded from the row.Fields slice, this includes empty strings.
Note That
- the first row is assumed to be the header
- at least 1 row of data is required
- rows and columns must be rectangular (i.e. all rows must have the same number of columns)
type LabelString ¶
type LabelString []string
LabelString is a string slice that is used to represent a list of labels.
For example, a list of labels "Important; Work" would be represented as a LabelString with the following values:
LabelString{"Important", "Work"}
func (LabelString) String ¶
func (ls LabelString) String() string
type LocationString ¶
type LocationString []string
LocationString is a string slice that is used to represent a location hierarchy.
For example, a location hierarchy of "Home / Bedroom / Desk" would be represented as a LocationString with the following values:
LocationString{"Home", "Bedroom", "Desk"}
func (LocationString) String ¶
func (csf LocationString) String() string