invoice

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: GPL-3.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package invoice provides logic for generating invoices.

Index

Constants

This section is empty.

Variables

View Source
var Now = func() time.Time {
	return time.Now()
}

Now returns the current time. Exposed as a variable for testing.

Functions

func FormatWeekLabel

func FormatWeekLabel(w Week) string

FormatWeekLabel returns a human-readable label for a week range.

func ParseMonth

func ParseMonth(s string) (time.Month, error)

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

func ResolveMonthYear(monthStr string, year int, now time.Time) (time.Month, int, error)

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 year closest to the given month relative to today.

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
	// 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
	// Weeks is the list of weekly line items.
	Weeks []Week
}

Invoice holds all data needed to generate an invoice for one calendar month.

func (*Invoice) Total

func (inv *Invoice) Total() float64

Total returns the total invoice amount.

type Week

type Week struct {
	// Start is the Monday of the week.
	Start time.Time
	// End is the Sunday of the week.
	End time.Time
	// Hours is the number of hours worked this week.
	Hours float64
}

Week represents a single weekly line item in an invoice.

func WeeksForMonth

func WeeksForMonth(year int, month time.Month, hoursPerWeek float64) []Week

WeeksForMonth returns the weeks that belong to the given month. A week belongs to a month if its Wednesday falls in that month. Weeks run Monday through Sunday and are billed at the full hoursPerWeek.

Jump to

Keyboard shortcuts

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