-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagador.go
49 lines (42 loc) · 789 Bytes
/
pagador.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 cobranca
type Avalista struct {
Nome string
Documento string
}
type Pagador struct {
Nome string
Documento string
Endereco string
Bairro string
Cidade string
UF string
CEP string
}
func (p Pagador) GetCEP() string {
return OnlyNumbers(p.CEP)
}
func (p Pagador) GetDocumento() string {
return OnlyNumbers(p.Documento)
}
func (p Pagador) PessoaFisica() bool {
doc := p.GetDocumento()
return len(doc) == 11
}
func (p Pagador) TipoInscricao() string {
return tipoInscricao(p.Documento)
}
// TipoInscricao retorna o tipo de inscrição
// 00 - ISENTO
// 01 - CPF
// 02 - CNPJ
func tipoInscricao(doc string) string {
doc = SemMascara(doc)
switch len(doc) {
case 11:
return "01"
case 14:
return "02"
default:
return "00"
}
}