Documentation
¶
Overview ¶
Package invoice provides logic for generating invoices.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Now = func() time.Time { return time.Now() }
Now returns the current time. Exposed as a variable for testing.
Functions ¶
func FormatWeekLabel ¶
FormatWeekLabel returns a human-readable label for a week range.
func ParseMonth ¶
ParseMonth parses a month string (text or numeric) and returns the time.Month value. Returns an error if the string is not a valid month.
func ResolveMonthYear ¶
ResolveMonthYear resolves the month and year to use for an invoice. If monthStr is empty, defaults to the previous month. If year is 0, defaults to the current year, unless the month is omitted and the previous month falls in the prior year.
Types ¶
type Invoice ¶
type Invoice struct {
// ID is the store's identifier for the invoice. It is empty until the
// invoice is saved.
ID string
// Month is the calendar month (1-12).
Month time.Month
// Year is the calendar year.
Year int
// Vendor is the name of the contractor sending the invoice.
Vendor string
// Customer is the name of the customer receiving the invoice.
Customer string
// ContactEmail is the email address that receives the invoice.
ContactEmail string
// Project is the optional name of the project this invoice is for.
Project string
// Rate is the hourly rate in dollars.
Rate float64
// Paid reports whether the customer has paid the invoice.
Paid bool
// EmailSentAt is when the invoice email was sent. It is zero until a send
// succeeds.
EmailSentAt time.Time
// Weeks is the list of weekly line items.
Weeks []Week
}
Invoice holds all data needed to generate an invoice for one calendar month.