Skip to content

Commit

Permalink
Refactor and bugs fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltns35 committed Oct 24, 2021
1 parent 083f0c1 commit 0cd1dd1
Show file tree
Hide file tree
Showing 62 changed files with 726 additions and 884 deletions.
18 changes: 7 additions & 11 deletions countries/albania/albania.go → countries/albania.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package albania

import (
"github.com/ltns35/go-vat/countries"
)
package countries

type albania struct {
countries.Country
Country
}

var VAT = albania{
Country: countries.Country{
var Albania = albania{
Country: Country{
Name: "Albania",
Codes: []string{
"AL",
"ALB",
"008",
},
Rules: countries.CountryRules{
Rules: CountryRules{
Regex: []string{
"^(AL)([JKL]\\d{8}[A-Z])$",
},
Expand All @@ -28,6 +24,6 @@ func (a albania) Calc(vat string) bool {
return len(vat) == 10
}

func (a albania) GetCountry() *countries.Country {
return &a.Country
func (a albania) GetCountry() Country {
return a.Country
}
18 changes: 7 additions & 11 deletions countries/andorra/andorra.go → countries/andorra.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package andorra

import (
"github.com/ltns35/go-vat/countries"
)
package countries

type andorra struct {
countries.Country
Country
}

var VAT = andorra{
Country: countries.Country{
var Andorra = andorra{
Country: Country{
Name: "Andorra",
Codes: []string{
"AD",
"AND",
"020",
},
Rules: countries.CountryRules{
Rules: CountryRules{
Regex: []string{
"^(AD)([fealecdgopuFEALECDGOPU]{1}\\d{6}[fealecdgopuFEALECDGOPU]{1})$",
},
Expand All @@ -28,6 +24,6 @@ func (a andorra) Calc(vat string) bool {
return len(vat) == 8
}

func (a andorra) GetCountry() *countries.Country {
return &a.Country
func (a andorra) GetCountry() Country {
return a.Country
}
29 changes: 29 additions & 0 deletions countries/argentina.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package countries

type argentina struct {
Country
}

var Argentina = argentina{
Country: Country{
Name: "Argentina",
Codes: []string{
"AR",
"ARG",
"032",
},
Rules: CountryRules{
Regex: []string{
"^(AR)(\\d{11})$",
},
},
},
}

func (a argentina) Calc(vat string) bool {
return len(vat) == 11
}

func (a argentina) GetCountry() Country {
return a.Country
}
33 changes: 0 additions & 33 deletions countries/argentina/argentina.go

This file was deleted.

15 changes: 7 additions & 8 deletions countries/austria/austria.go → countries/austria.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package austria
package countries

import (
"math"

"github.com/ltns35/go-vat/countries"
"github.com/ltns35/go-vat/countries/utils"
)

type austria struct {
countries.Country
Country
}

var VAT = austria{
Country: countries.Country{
var Austria = austria{
Country: Country{
Name: "Austria",
Codes: []string{
"AT",
"AUT",
"040",
},
Rules: countries.CountryRules{
Rules: CountryRules{
Multipliers: map[string][]int{
"common": {
1,
Expand Down Expand Up @@ -65,6 +64,6 @@ func (a austria) Calc(vat string) bool {
return int(total) == lastNum
}

func (a austria) GetCountry() *countries.Country {
return &a.Country
func (a austria) GetCountry() Country {
return a.Country
}
29 changes: 29 additions & 0 deletions countries/belarus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package countries

type belarus struct {
Country
}

var Belarus = belarus{
Country: Country{
Name: "Belarus",
Codes: []string{
"BY",
"BLR",
"112",
},
Rules: CountryRules{
Regex: []string{
"^(BY)(\\d{9})$",
},
},
},
}

func (b belarus) Calc(vat string) bool {
return len(vat) == 9
}

func (b belarus) GetCountry() Country {
return b.Country
}
33 changes: 0 additions & 33 deletions countries/belarus/belarus.go

This file was deleted.

15 changes: 7 additions & 8 deletions countries/belgium/belgium.go → countries/belgium.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package belgium
package countries

import (
"math"
"strconv"

"github.com/ltns35/go-vat/countries"
"github.com/ltns35/go-vat/countries/utils"
)

type belgium struct {
countries.Country
Country
}

var VAT = belgium{
Country: countries.Country{
var Belgium = belgium{
Country: Country{
Name: "Belgium",
Codes: []string{
"BE",
"BEL",
"056",
},
Rules: countries.CountryRules{
Rules: CountryRules{
Regex: []string{
"^(BE)(0?\\d{9})$",
},
Expand Down Expand Up @@ -51,6 +50,6 @@ func (b belgium) Calc(vat string) bool {
return check == float64(lastDigits)
}

func (b belgium) GetCountry() *countries.Country {
return &b.Country
func (b belgium) GetCountry() Country {
return b.Country
}
29 changes: 29 additions & 0 deletions countries/bolivia.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package countries

type bolivia struct {
Country
}

var Bolivia = bolivia{
Country: Country{
Name: "Bolivia",
Codes: []string{
"BO",
"BOL",
"068",
},
Rules: CountryRules{
Regex: []string{
"^(BO)(\\d{7})$",
},
},
},
}

func (b bolivia) Calc(vat string) bool {
return len(vat) == 7
}

func (b bolivia) GetCountry() Country {
return b.Country
}
33 changes: 0 additions & 33 deletions countries/bolivia/bolivia.go

This file was deleted.

Loading

0 comments on commit 0cd1dd1

Please sign in to comment.