unanet

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TeamworkTimeShort = "20060102"

TeamworkTimeShort represents a Teamwork date in short form.

View Source
const UnanetTimeShort = "1/2/2006"

UnanetTimeShort represents a Unanet date in short form.

Variables

This section is empty.

Functions

func ConvertUnanetDate

func ConvertUnanetDate(d string) (string, error)

ConvertUnanetDate converts Unanet short format (MM/DD/YYYY) into Teamwork API short format (YYYYMMDD).

Types

type Report

type Report struct {
	Filename        string
	Name            string   `json:"reportName"`
	Fields          []string `json:"columns"`
	FieldIndex      map[string]int
	CompanyMappings map[string]string `json:"companyMappings"`
	ProjectMappings map[string]string `json:"projectMappings"`
	TaskMappings    map[string]string `json:"taskMappings"`
	UserMappings    map[string]string `json:"userMappings"`
	Connection      *teamworkapi.Connection
}

Report models a Unanet time report. Fields represents the required columns in the .csv file. FieldIndex maps each field to its respective column number in the .csv file.

func NewReport

func NewReport(conn *teamworkapi.Connection) (*Report, error)

NewReport creates a new Report instance and initializes the Connection to Teamwork API.

func (*Report) LoadConfig

func (r *Report) LoadConfig(pathToFile string) error

LoadConfig configures a Report based on json file.

func (*Report) VerifyColumns

func (r *Report) VerifyColumns(columns []string) error

VerifyColumns performs a sanity check to ensure the comma-separated string columns includes all required columns.

type TimeDetailsReport

type TimeDetailsReport struct {
	Report    *Report
	Entries   []*teamworkapi.TimeEntry
	StartDate time.Time
	EndDate   time.Time
}

TimeDetailsReport models a specific type of Unanet report - the Person Time Details report.

func NewTimeDetailsReport

func NewTimeDetailsReport(conn *teamworkapi.Connection) (*TimeDetailsReport, error)

NewTimeDetailsReport creates a new TimeDetailsReport and initializes the underlying parent Report object with the specific teamworkapi.Connection.

func (*TimeDetailsReport) ParseTimeDetailsReport

func (r *TimeDetailsReport) ParseTimeDetailsReport(path string) ([]*teamworkapi.TimeEntry, error)

ParseTimeDetailsReport converts Unanet time report into an array of TimeEntry objects and updates the TimeDetailsReport with applicable metadata, including the TimeEntry array, and start/end date of report.

func (*TimeDetailsReport) UploadTimeEntries

func (r *TimeDetailsReport) UploadTimeEntries() error

UploadTimeEntries uploads the time entries is the TimeDetailsReport to Teamwork. A new file is created that includes all the original data from the Unanet report, plus a new column TeamworkTimeEntryID that maps the Unanet time log to a Teamwork Time Entry. The new file is saved with the naming convention, time-details-report_YYYYMMDD-YYYYMMDD.csv.

Jump to

Keyboard shortcuts

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