forked from angelodlfrtr/go-invoice-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
address.go
49 lines (46 loc) · 1.04 KB
/
address.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package generator
// Address represent an address
type Address struct {
Address string `json:"address,omitempty" validate:"required"`
Address2 string `json:"address_2,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
City string `json:"city,omitempty"`
Country string `json:"country,omitempty"`
BusinessID string
TaxID string
VAT string
IBAN string
BankName string
}
// ToString output address as string
// Line break are added for new lines
func (a *Address) lines() []string {
res := []string{
a.Address,
}
if len(a.Address2) > 0 {
res = append(res, a.Address2)
}
if len(a.PostalCode) > 0 {
res = append(res, a.PostalCode+" "+a.City)
}
if len(a.Country) > 0 {
res = append(res, a.Country)
}
if len(a.BusinessID) > 0 {
res = append(res, a.BusinessID)
}
if len(a.TaxID) > 0 {
res = append(res, a.TaxID)
}
if len(a.VAT) > 0 {
res = append(res, a.VAT)
}
if len(a.IBAN) > 0 {
res = append(res, a.IBAN)
}
if len(a.BankName) > 0 {
res = append(res, a.BankName)
}
return res
}