util

package
v0.0.0-...-0746445 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Terminal color codes used to print things in color
	Red          = "31"
	Green        = "32"
	Yellow       = "33"
	Blue         = "34"
	BrightYellow = "33;1"
)
View Source
const DonorConfigFile = "donors.json"

Variables

This section is empty.

Functions

func Colorize

func Colorize(color string, msg string) string

func FormatDate

func FormatDate(t time.Time) string

func FormatDateTime

func FormatDateTime(t time.Time) string
func PrintLogo()

func StringToMonth

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

Types

type ByTotal

type ByTotal struct{ Donors }

func (ByTotal) Less

func (s ByTotal) Less(i, j int) bool

type CurrencyAmounts

type CurrencyAmounts map[string]float32

Use a map because of multiple currencies

func (CurrencyAmounts) Add

func (CurrencyAmounts) GrandTotal

func (ca CurrencyAmounts) GrandTotal(eurToUsdRate float32) float32

func (CurrencyAmounts) String

func (ca CurrencyAmounts) String() string

type Donor

type Donor struct {
	Name      string
	Email     string
	Total     CurrencyAmounts
	Count     int
	Anonymous bool
}

type DonorConfig

type DonorConfig struct {
	Anonymous          []string          `json:"anonymous,omitempty"`
	EmailToCorrectName map[string]string `json:"names,omitempty"`
	// contains filtered or unexported fields
}

func LoadDonorConfig

func LoadDonorConfig() (*DonorConfig, error)

func (*DonorConfig) Handle

func (d *DonorConfig) Handle(p *Donor)

type Donors

type Donors []*Donor

func (Donors) Len

func (p Donors) Len() int

func (Donors) Sort

func (p Donors) Sort()

func (Donors) Swap

func (p Donors) Swap(i, j int)

type MonthlySummaries

type MonthlySummaries map[time.Month]*Summary

func LoadSummaries

func LoadSummaries(prefix string) (MonthlySummaries, error)

TODO: Not needed now?

func (MonthlySummaries) ByMonth

func (ms MonthlySummaries) ByMonth(cb func(time.Month, *Summary))

func (MonthlySummaries) ForMonth

func (ms MonthlySummaries) ForMonth(month time.Month) *Summary

func (MonthlySummaries) LatestMonth

func (ms MonthlySummaries) LatestMonth() time.Month

func (MonthlySummaries) MarshalJSON

func (ms MonthlySummaries) MarshalJSON() ([]byte, error)

func (MonthlySummaries) Save

func (ms MonthlySummaries) Save(prefix string) error

func (MonthlySummaries) Total

func (ms MonthlySummaries) Total() *Summary

func (MonthlySummaries) UnmarshalJSON

func (ms MonthlySummaries) UnmarshalJSON(data []byte) error

type Summary

type Summary struct {
	OneTimeAmt        CurrencyAmounts
	OneTimeCount      int
	SubscriptionAmt   CurrencyAmounts
	SubscriptionCount int
	FeeAmt            CurrencyAmounts
}

func NewSummary

func NewSummary() *Summary

func (*Summary) AddOneTime

func (s *Summary) AddOneTime(amt, fee float32, currency string)

func (*Summary) AddSubscription

func (s *Summary) AddSubscription(amt, fee float32, currency string)

func (*Summary) GrossTotal

func (s *Summary) GrossTotal() CurrencyAmounts

func (*Summary) NetTotal

func (s *Summary) NetTotal() CurrencyAmounts

func (*Summary) String

func (s *Summary) String() string

Jump to

Keyboard shortcuts

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