All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
115 lines
3.5 KiB
Go
115 lines
3.5 KiB
Go
package static
|
|
|
|
import (
|
|
"strings"
|
|
"unicode"
|
|
|
|
"golang.org/x/text/runes"
|
|
"golang.org/x/text/transform"
|
|
"golang.org/x/text/unicode/norm"
|
|
)
|
|
|
|
var institutionList *instList
|
|
|
|
type Institution struct {
|
|
ID int64
|
|
Name string
|
|
ShortName string
|
|
}
|
|
type instList struct {
|
|
inst []*Institution
|
|
}
|
|
|
|
func NewInstList() *instList {
|
|
return &instList{}
|
|
}
|
|
|
|
func (i instList) GetName(name string) []*Institution {
|
|
inititate()
|
|
// strip banco dominicano asociacion de ahorros y prestamos
|
|
replacer := strings.NewReplacer(
|
|
"banco", "",
|
|
"dominicano", "",
|
|
"asociacion ", "",
|
|
"ahorros", "",
|
|
"prestamos", "",
|
|
" de ", "",
|
|
" y ", "",
|
|
" ", " ",
|
|
)
|
|
name = replacer.Replace(name)
|
|
list := []*Institution{}
|
|
if len(name) <= 1 {
|
|
return []*Institution{}
|
|
}
|
|
for _, inst := range institutionList.inst {
|
|
if strings.Contains(inst.Name, name) || strings.Contains(inst.ShortName, name) {
|
|
list = append(list, inst)
|
|
}
|
|
}
|
|
return list
|
|
}
|
|
func (i instList) GetAbbrev(name string) string {
|
|
inititate()
|
|
for _, i := range institutionList.inst {
|
|
if i.Name == name {
|
|
return i.ShortName
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
func inititate() {
|
|
if institutionList == nil || len(institutionList.inst) <= 0 {
|
|
institutionList = &instList{
|
|
inst: []*Institution{
|
|
{ID: 1, Name: "banco central dominicano", ShortName: "bcd"},
|
|
{ID: 2, Name: "banco popular", ShortName: "bpd"},
|
|
{ID: 3, Name: "banco hipotecario dominicano", ShortName: "bhd"},
|
|
{ID: 4, Name: "banreservas", ShortName: "brd"},
|
|
{ID: 5, Name: "asociacion peravia de ahorros y prestamos", ShortName: "apeap"},
|
|
{ID: 6, Name: "asociacion popular de ahorros y prestamos", ShortName: "apap"},
|
|
{ID: 7, Name: "asociacion cibao de ahorros y prestamos", ShortName: "acap"},
|
|
{ID: 8, Name: "asociacion la nacional de ahorros y prestamos", ShortName: "alnap"},
|
|
{ID: 9, Name: "banco promerica", ShortName: "bpr"},
|
|
{ID: 10, Name: "banco bdi", ShortName: "bbd"},
|
|
{ID: 11, Name: "banco caribe", ShortName: "bca"},
|
|
{ID: 12, Name: "banco santa cruz", ShortName: "bsc"},
|
|
{ID: 13, Name: "banco vimenca", ShortName: "bvi"},
|
|
{ID: 14, Name: "scotiabank cambio online", ShortName: "scline"},
|
|
{ID: 15, Name: "scotiabank", ShortName: "scotiabank"},
|
|
{ID: 16, Name: "bonanza banco", ShortName: "bba"},
|
|
{ID: 17, Name: "banco atlantico", ShortName: "bat"},
|
|
{ID: 18, Name: "banco lopez de haro", ShortName: "blh"},
|
|
{ID: 19, Name: "banco ademi", ShortName: "bad"},
|
|
{ID: 20, Name: "banco lafise", ShortName: "bla"},
|
|
{ID: 21, Name: "banesco", ShortName: "banesco"},
|
|
{ID: 22, Name: "banco activo dominicana", ShortName: "bacd"},
|
|
{ID: 23, Name: "girosol", ShortName: "girosol"},
|
|
{ID: 24, Name: "moneycorps", ShortName: "moneycorps"},
|
|
{ID: 25, Name: "imbert y balbuena", ShortName: "imb"},
|
|
{ID: 26, Name: "rm", ShortName: "rm"},
|
|
{ID: 27, Name: "motor credito", ShortName: "mcr"},
|
|
{ID: 28, Name: "cambio extranjero", ShortName: "cex"},
|
|
{ID: 29, Name: "capla", ShortName: "capla"},
|
|
{ID: 30, Name: "taveras", ShortName: "taveras"},
|
|
{ID: 31, Name: "gamelin", ShortName: "gamelin"},
|
|
{ID: 32, Name: "sct", ShortName: "sct"},
|
|
{ID: 33, Name: "panora exchange", ShortName: "inf"},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
// RemoveAccent
|
|
// helps normalize names in db
|
|
// https://stackoverflow.com/questions/24588295/go-removing-accents-from-strings
|
|
func RemoveAccent(str string) string {
|
|
if str == "" {
|
|
return ""
|
|
}
|
|
t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
|
|
s, _, _ := transform.String(t, str)
|
|
|
|
return s
|
|
}
|