Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sshaplygin committed Jan 7, 2024
1 parent 996c91d commit 8aae853
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion inn/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func GenerateCheckSums(innType INNType, nums []int) CheckSums {
nums = append(nums, f(nums))
}

fmt.Println(nums[len(nums)+shiftIdx:])
return nums[len(nums)+shiftIdx:]
}

Expand Down
12 changes: 9 additions & 3 deletions ogrn/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,15 @@ const (
)

func ParseOGRN(requiredType OGRNType, ogrn string) (*OGRNStruct, error) {
if ((requiredType == Legal || requiredType == Government) && len(ogrn) != legalLength) ||
(requiredType == Physical && len(ogrn) != physicalLength) {
if requiredType != Physical && len(ogrn) != legalLength {
return nil, &models.CommonError{
Method: packageName,
Err: models.ErrInvalidLength,
}
}

if requiredType == Physical && len(ogrn) != physicalLength {
fmt.Println(requiredType, len(ogrn))
return nil, &models.CommonError{
Method: packageName,
Err: models.ErrInvalidLength,
Expand Down Expand Up @@ -277,7 +284,6 @@ func (o *OGRNStruct) makeSliceInts() []int {

utils.FillSlice(o.yearsNumbers.Ints(), res, 2)
utils.FillSlice(o.region.Ints(), res, 4)
fmt.Println("fillSlice", o.serialNumbers.Ints(), res)
utils.FillSlice(o.serialNumbers.Ints(), res, n-2)

return res
Expand Down
2 changes: 1 addition & 1 deletion ogrnip/ogrnip.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// Validate check to valid OGRNIP format
// example: input format is 304500116000157
func Validate(ogrnip string) (bool, error) {
ogrnData, err := ogrn.ParseOGRN(ogrn.Legal, ogrnip)
ogrnData, err := ogrn.ParseOGRN(ogrn.Physical, ogrnip)
if err != nil {
return false, fmt.Errorf("parse %s model: %w", packageName, err)
}
Expand Down
3 changes: 1 addition & 2 deletions utils/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func Random(min, max int) int {

randomNumber, err := rand.Int(rand.Reader, big.NewInt(int64(max-min+1)))
if err != nil {
fmt.Println("Error generating random number:", err)
return 0
panic(fmt.Errorf("generate random number: %w", err))
}

return int(randomNumber.Int64()) + min
Expand Down

0 comments on commit 8aae853

Please sign in to comment.