model

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ConsumptionIdLength = 8
View Source
const YearMonthLayout = "2006-01"

Variables

View Source
var InvoiceF100 = NewInvoice(
	"F-100",
	148,
	TestDate,
	NewYearMonth(2019, 5),
	[]int{1800, 1801},
	lines,
	payment_type.BankDirectDebit,
	"Invoice note",
	false,
	false,
	false,
)
View Source
var InvoiceF101 = NewInvoice(
	"F-101",
	148,
	TestDate,
	NewYearMonth(2019, 5),
	[]int{1801, 1802},
	lines,
	payment_type.BankDirectDebit,
	"Invoice note",
	false,
	false,
	false,
)
View Source
var InvoiceF102 = NewInvoice(
	"F-102",
	149,
	TestDate,
	NewYearMonth(2019, 5),
	[]int{1800, 1801, 1802},
	lines,
	payment_type.BankDirectDebit,
	"Invoice note",
	false,
	false,
	false,
)
View Source
var InvoiceF103 = NewInvoice(
	"F-103",
	149,
	TestDate,
	NewYearMonth(2019, 5),
	[]int{1800},
	lines,
	payment_type.BankDirectDebit,
	"Invoice note",
	false,
	false,
	false,
)
View Source
var ProductTST, _ = NewProduct(
	"TST",
	"Test product",
	"TstProduct",
	10.9,
	0.0,
	false,
)
View Source
var ProductXXX, _ = NewProduct(
	"XXX",
	"XXX product",
	"XxxProduct",
	9.1,
	0.0,
	false,
)
View Source
var ProductYYY, _ = NewProduct(
	"YYY",
	"YYY product",
	"YyyProduct",
	5,
	0.1,
	false,
)
View Source
var TestAdultFather148 = NewAdult(
	"Bob",
	"Novella",
	"Sagan",
	NewTaxIdOrEmpty("71032204Q"),
	adult_role.Father,
	NewAddress(
		"Carrer Ucraïna 2022, 1st",
		"07007",
		"Palma",
		"Illes Balears",
	),
	"bob@sgu.org",
	"654321097",
	"987654322",
	"685698788",
	"658785477",
	"987525446",
	TestDate,
	NewNationalityOrEmpty("UK"),
)
View Source
var TestAdultFather149 = NewAdult(
	"Joan",
	"Petit",
	"Galatzó",
	NewTaxIdOrEmpty("91071996T"),
	adult_role.Father,
	NewAddress(
		"Carrer de sa Tanca 2, 1er",
		"07192",
		"Estellencs",
		"Illes Balears",
	),
	"joan@cameva.org",
	"654321099",
	"987654329",
	"685698789",
	"658785479",
	"987525449",
	TestDate,
	NewNationalityOrEmpty("ES"),
)
View Source
var TestAdultMother148 = NewAdult(
	"Cara",
	"Santamaria",
	"Novella",
	NewTaxIdOrEmpty("36361882D"),
	adult_role.Mother,
	NewAddress(
		"Carrer Ucraïna 2022, 1st",
		"07007",
		"Palma",
		"Illes Balears",
	),
	"cara@sgu.org",
	"654321098",
	"987654321",
	"685698789",
	"658785478",
	"987525444",
	TestDate,
	NewNationalityOrEmpty("US"),
)
View Source
var TestAdultMother149 = NewAdult(
	"Joana",
	"Petita",
	"Puig",
	NewTaxIdOrEmpty("80587890F"),
	adult_role.Mother,
	NewAddress(
		"Carrer de sa Tanca 2, 1er",
		"07192",
		"Estellencs",
		"Illes Balears",
	),
	"joana@cameva.org",
	"654521098",
	"987674321",
	"695698789",
	"657785478",
	"987524444",
	TestDate,
	NewNationalityOrEmpty("ES"),
)
View Source
var TestChild1480 = NewChild(
	1480,
	"Laura",
	"Llull",
	"Bibiloni",
	NewTaxIdOrEmpty(""),
	TestDate,
	group_type.Ei1,
	"Note child 1480",
	true,
)
View Source
var TestChild1481 = NewChild(
	1481,
	"Aina",
	"Llull",
	"Bibiloni",
	NewTaxIdOrEmpty("60235657Z"),
	TestDate,
	group_type.Ei1,
	"Note child 1481",
	true,
)
View Source
var TestChild1490 = NewChild(
	1490,
	"Antònia",
	"Petit",
	"Petita",
	NewTaxIdOrEmpty("81620787C"),
	TestDate,
	group_type.Ei2,
	"Note child 1490",
	true,
)
View Source
var TestChild1491 = NewChild(
	1491,
	"Antoni",
	"Petit",
	"Petita",
	NewTaxIdOrEmpty("51389353Q"),
	TestDate,
	group_type.Ei3,
	"Note child 1491",
	true,
)
View Source
var TestDate = time.Date(2019, 5, 25, 0, 0, 0, 0, time.UTC)
View Source
var TestInvoiceHolder148 = NewInvoiceHolder(
	"Cara Santamaria Novella",
	NewTaxIdOrEmpty("36361882D"),
	NewAddress(
		"Carrer Ucraïna 2022, 1st",
		"07007",
		"Palma",
		"Illes Balears",
	),
	"cara@sgu.org",
	false,
	payment_type.BankDirectDebit,
	NewIbanOrEmpty("ES2830668859978258529057"),
	false,
)
View Source
var TestInvoiceHolder149 = NewInvoiceHolder(
	"Nom empresa",
	NewTaxIdOrEmpty("37866397W"),
	NewAddress(
		"Address first line",
		"07007",
		"Palma",
		"Illes Balears",
	),
	"email@gmail.com",
	false,
	payment_type.BankTransfer,
	NewIbanOrEmpty("ES2830668859978258529057"),
	true,
)

Functions

func ConsumptionListFormatValues added in v1.0.1

func ConsumptionListFormatValues(consumptions []Consumption, child Child, products map[string]Product, indentText string) (string, float64)

Types

type Address

type Address struct {
	// contains filtered or unexported fields
}

func NewAddress added in v0.23.0

func NewAddress(street string, zipCode string, city string, state string) Address

func (Address) City

func (a Address) City() string

func (Address) CompleteAddress added in v0.18.0

func (a Address) CompleteAddress() string

func (Address) State

func (a Address) State() string

func (Address) Street

func (a Address) Street() string

func (Address) ZipCode

func (a Address) ZipCode() string

type Adult

type Adult struct {
	// contains filtered or unexported fields
}

func NewAdult added in v0.23.0

func NewAdult(
	name string,
	surname string,
	secondSurname string,
	taxID TaxId,
	role adult_role.AdultRole,
	address Address,
	email string,
	mobilePhone string,
	homePhone string,
	grandMotherPhone string,
	grandParentPhone string,
	workPhone string,
	birthDate time.Time,
	nationality Nationality,
) Adult

func (Adult) Address

func (a Adult) Address() Address

func (Adult) BirthDate

func (a Adult) BirthDate() time.Time

func (Adult) Email

func (a Adult) Email() string

func (Adult) GrandMotherPhone

func (a Adult) GrandMotherPhone() string

func (Adult) GrandParentPhone

func (a Adult) GrandParentPhone() string

func (Adult) HomePhone

func (a Adult) HomePhone() string

func (Adult) MobilePhone

func (a Adult) MobilePhone() string

func (Adult) MobilePhoneFmt

func (a Adult) MobilePhoneFmt() string

func (Adult) Name

func (a Adult) Name() string

func (Adult) NameAndSurname added in v0.18.0

func (a Adult) NameAndSurname() string

func (Adult) Nationality

func (a Adult) Nationality() Nationality

func (Adult) Role

func (a Adult) Role() adult_role.AdultRole

func (Adult) SecondSurname

func (a Adult) SecondSurname() string

func (Adult) Surname

func (a Adult) Surname() string

func (Adult) TaxID

func (a Adult) TaxID() TaxId

func (Adult) WorkPhone

func (a Adult) WorkPhone() string

type Child

type Child struct {
	// contains filtered or unexported fields
}

func NewChild added in v0.23.0

func NewChild(
	id int,
	name string,
	surname string,
	secondSurname string,
	taxID TaxId,
	birthDate time.Time,
	group group_type.GroupType,
	note string,
	active bool,
) Child

func (Child) Active

func (c Child) Active() bool

func (Child) BirthDate

func (c Child) BirthDate() time.Time

func (Child) CustomerId added in v1.0.1

func (c Child) CustomerId() int

func (Child) Group

func (c Child) Group() group_type.GroupType

func (Child) Id

func (c Child) Id() int

func (Child) Name

func (c Child) Name() string

func (Child) NameAndSurname

func (c Child) NameAndSurname() string

func (Child) NameWithId

func (c Child) NameWithId() string

func (Child) Note

func (c Child) Note() string

func (Child) SecondSurname

func (c Child) SecondSurname() string

func (Child) String

func (c Child) String() string

func (Child) Surname

func (c Child) Surname() string

func (Child) TaxID

func (c Child) TaxID() TaxId

type Consumption

type Consumption struct {
	// contains filtered or unexported fields
}

func NewConsumption added in v0.23.0

func NewConsumption(
	id string,
	childId int,
	productId string,
	units float64,
	yearMonth YearMonth,
	note string,
	isRectification bool,
	invoiceId string,
) Consumption

func (Consumption) ChildId

func (c Consumption) ChildId() int

func (Consumption) Id

func (c Consumption) Id() string

func (Consumption) InvoiceId

func (c Consumption) InvoiceId() string

func (Consumption) IsRectification

func (c Consumption) IsRectification() bool

func (Consumption) Note

func (c Consumption) Note() string

func (Consumption) ProductId

func (c Consumption) ProductId() string

func (Consumption) String

func (c Consumption) String() string

func (Consumption) Units

func (c Consumption) Units() float64

func (Consumption) YearMonth

func (c Consumption) YearMonth() YearMonth

type Customer

type Customer struct {
	// contains filtered or unexported fields
}

func NewCustomer added in v0.23.0

func NewCustomer(
	id int,
	active bool,
	children []Child,
	adults []Adult,
	invoiceHolder InvoiceHolder,
	note string,
	language language.Language,
	changedOn time.Time,
) Customer

func (Customer) Active

func (c Customer) Active() bool

func (Customer) Adults

func (c Customer) Adults() []Adult

func (Customer) ChangedOn added in v0.18.0

func (c Customer) ChangedOn() time.Time

func (Customer) Children

func (c Customer) Children() []Child

func (Customer) ChildrenNames

func (c Customer) ChildrenNames(joinWith string) string

func (Customer) ChildrenNamesWithId added in v0.18.0

func (c Customer) ChildrenNamesWithId(joinWith string) string

func (Customer) ChildrenNamesWithSurname added in v0.18.0

func (c Customer) ChildrenNamesWithSurname(joinWith string) string

func (Customer) FirstAdult

func (c Customer) FirstAdult() Adult

func (Customer) FirstAdultName

func (c Customer) FirstAdultName() string

func (Customer) FirstAdultNameWithId

func (c Customer) FirstAdultNameWithId() string

func (Customer) Id

func (c Customer) Id() int

func (Customer) InvoiceHolder

func (c Customer) InvoiceHolder() InvoiceHolder

func (Customer) Language

func (c Customer) Language() language.Language

func (Customer) Note

func (c Customer) Note() string

func (Customer) String

func (c Customer) String() string

type IBAN added in v0.23.0

type IBAN struct {
	// contains filtered or unexported fields
}

func NewIban added in v0.23.0

func NewIban(iban string) (IBAN, error)

func NewIbanOrEmpty added in v0.23.0

func NewIbanOrEmpty(iban string) IBAN

func (IBAN) Format added in v0.23.0

func (i IBAN) Format() string

func (IBAN) IsEmpty added in v0.23.0

func (i IBAN) IsEmpty() bool

func (IBAN) String added in v0.23.0

func (i IBAN) String() string

type Invoice

type Invoice struct {
	// contains filtered or unexported fields
}

func NewInvoice added in v0.23.0

func NewInvoice(
	id string,
	customerId int,
	date time.Time,
	yearMonth YearMonth,
	childrenIds []int,
	lines []InvoiceLine,
	paymentType payment_type.PaymentType,
	note string,
	emailed bool,
	printed bool,
	sentToBank bool,
) Invoice

func (Invoice) Amount

func (i Invoice) Amount() float64

func (Invoice) ChildrenIds

func (i Invoice) ChildrenIds() []int

func (Invoice) CustomerId

func (i Invoice) CustomerId() int

func (Invoice) Date

func (i Invoice) Date() time.Time

func (Invoice) DateFmt

func (i Invoice) DateFmt() string

func (Invoice) Emailed

func (i Invoice) Emailed() bool

func (Invoice) Id

func (i Invoice) Id() string

func (Invoice) Lines

func (i Invoice) Lines() []InvoiceLine

func (Invoice) LinesFmt

func (i Invoice) LinesFmt(joinWith string) string

func (Invoice) Note

func (i Invoice) Note() string

func (Invoice) PaymentType

func (i Invoice) PaymentType() payment_type.PaymentType

func (Invoice) Printed

func (i Invoice) Printed() bool

func (Invoice) SendToBank added in v1.0.1

func (i Invoice) SendToBank() Invoice

SendToBank sets sentToBank to true

func (Invoice) SentToBank

func (i Invoice) SentToBank() bool

func (Invoice) String

func (i Invoice) String() string

func (Invoice) YearMonth

func (i Invoice) YearMonth() YearMonth

type InvoiceHolder

type InvoiceHolder struct {
	// contains filtered or unexported fields
}

func NewInvoiceHolder added in v0.23.0

func NewInvoiceHolder(
	name string,
	taxID TaxId,
	address Address,
	email string,
	sendEmail bool,
	paymentType payment_type.PaymentType,
	iban IBAN,
	isBusiness bool,
) InvoiceHolder

func (InvoiceHolder) Address

func (i InvoiceHolder) Address() Address

func (InvoiceHolder) Email

func (i InvoiceHolder) Email() string

func (InvoiceHolder) Iban added in v0.23.0

func (i InvoiceHolder) Iban() IBAN

func (InvoiceHolder) IsBusiness

func (i InvoiceHolder) IsBusiness() bool

func (InvoiceHolder) Mail

func (i InvoiceHolder) Mail() string

func (InvoiceHolder) Name

func (i InvoiceHolder) Name() string

func (InvoiceHolder) PaymentInfoFmt

func (i InvoiceHolder) PaymentInfoFmt() string

func (InvoiceHolder) PaymentType

func (i InvoiceHolder) PaymentType() payment_type.PaymentType

func (InvoiceHolder) SendEmail

func (i InvoiceHolder) SendEmail() bool

func (InvoiceHolder) TaxID

func (i InvoiceHolder) TaxID() TaxId

func (InvoiceHolder) Validate added in v0.23.0

func (i InvoiceHolder) Validate() error

type InvoiceLine added in v0.23.0

type InvoiceLine struct {
	// contains filtered or unexported fields
}

func NewInvoiceLine added in v0.23.0

func NewInvoiceLine(
	productId string,
	units float64,
	productPrice float64,
	taxPercentage float64,
	childId int,
) InvoiceLine

func (InvoiceLine) ChildId added in v0.23.0

func (i InvoiceLine) ChildId() int

func (InvoiceLine) Format added in v0.23.0

func (i InvoiceLine) Format() string

func (InvoiceLine) ProductId added in v0.23.0

func (i InvoiceLine) ProductId() string

func (InvoiceLine) ProductPrice added in v0.23.0

func (i InvoiceLine) ProductPrice() float64

func (InvoiceLine) TaxPercentage added in v0.23.0

func (i InvoiceLine) TaxPercentage() float64

func (InvoiceLine) Units added in v0.23.0

func (i InvoiceLine) Units() float64

type Nationality added in v0.23.0

type Nationality struct {
	// contains filtered or unexported fields
}

func NewNationality added in v0.23.0

func NewNationality(alpha2Code string) (Nationality, error)

func NewNationalityOrEmpty added in v0.23.0

func NewNationalityOrEmpty(alpha2Code string) Nationality

func (Nationality) String added in v0.23.0

func (n Nationality) String() string

type Product

type Product struct {
	// contains filtered or unexported fields
}

func NewProduct added in v0.23.0

func NewProduct(id string, name string, shortName string, price float64, taxPercentage float64, isSubsidy bool) (Product, error)

func (Product) Id

func (p Product) Id() string

func (Product) IsSubsidy

func (p Product) IsSubsidy() bool

func (Product) Name

func (p Product) Name() string

func (Product) Price

func (p Product) Price() float64

func (Product) ShortName

func (p Product) ShortName() string

func (Product) String

func (p Product) String() string

func (Product) TaxPercentage

func (p Product) TaxPercentage() float64

func (Product) Validate added in v0.23.0

func (p Product) Validate() error

type Sequence

type Sequence struct {
	// contains filtered or unexported fields
}

func NewSequence added in v0.23.0

func NewSequence(id sequence_type.SequenceType, counter int) Sequence

func (Sequence) Counter

func (s Sequence) Counter() int

func (Sequence) Id

type TaxId added in v0.23.0

type TaxId struct {
	// contains filtered or unexported fields
}

func NewTaxId added in v0.23.0

func NewTaxId(taxId string) (TaxId, error)

func NewTaxIdOrEmpty added in v0.23.0

func NewTaxIdOrEmpty(taxId string) TaxId

func (TaxId) String added in v0.23.0

func (t TaxId) String() string

type TransientChild added in v0.23.0

type TransientChild struct {
	Name          string
	Surname       string
	SecondSurname string
	TaxID         TaxId
	BirthDate     time.Time
	Group         group_type.GroupType
	Note          string
}

func (TransientChild) Validate added in v0.23.0

func (t TransientChild) Validate() error

type TransientConsumption added in v0.23.0

type TransientConsumption struct {
	Id              string
	ChildId         int
	ProductId       string
	Units           float64
	YearMonth       YearMonth
	Note            string
	IsRectification bool
}

type TransientCustomer added in v0.23.0

type TransientCustomer struct {
	Children      []TransientChild
	Adults        []Adult
	InvoiceHolder InvoiceHolder
	Note          string
	Language      language.Language
}

func (TransientCustomer) Validate added in v0.23.0

func (t TransientCustomer) Validate() error

type TransientInvoice added in v0.23.0

type TransientInvoice struct {
	IsRectification bool
	CustomerId      int
	Date            time.Time
	YearMonth       YearMonth
	ChildrenIds     []int
	Lines           []InvoiceLine
	PaymentType     payment_type.PaymentType
	Note            string
}

type YearMonth added in v0.20.0

type YearMonth struct {
	// contains filtered or unexported fields
}

func NewYearMonth added in v0.20.0

func NewYearMonth(year int, month time.Month) YearMonth

func StringToYearMonth added in v0.20.0

func StringToYearMonth(yearMonth string) (YearMonth, error)

func TimeToYearMonth added in v0.20.0

func TimeToYearMonth(tm time.Time) YearMonth

func (YearMonth) Month added in v0.20.0

func (ym YearMonth) Month() time.Month

func (YearMonth) String added in v0.20.0

func (ym YearMonth) String() string

func (YearMonth) Year added in v0.20.0

func (ym YearMonth) Year() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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