parent
a8b0005336
commit
8ff5a0c443
|
@ -38,7 +38,6 @@ const getTimeout = 6 * time.Minute
|
|||
const postTimeout = 6 * time.Minute
|
||||
const constNotFound = "not found"
|
||||
const percentFactor = 100
|
||||
const dateFormatDB = "2006-01-02"
|
||||
const dateFormat = "2006-01-02"
|
||||
const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
||||
const dateTimeFormatAlt = "2006-01-02 15:04:05"
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
|
||||
// UnMarshalTaxType decodes swagger to a first class object
|
||||
func UnMarshalTaxType(s *geo_models.TaxType) *TaxType {
|
||||
createdDate, _ := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||
lastModifiedDate, _ := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
||||
effectiveDate, _ := time.Parse(dateFormatDB, s.EffectiveDate)
|
||||
endDate, _ := time.Parse(dateFormatDB, s.EndDate)
|
||||
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||
lastModifiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
||||
effectiveDate, e2 := time.Parse(dateFormat, s.EffectiveDate)
|
||||
endDate, e3 := time.Parse(dateFormat, s.EndDate)
|
||||
formatted := TaxTypeFormatted{
|
||||
CreatedDate: createdDate.Format(dateTimeFormat),
|
||||
EffectiveDate: effectiveDate.Format(dateFormat),
|
||||
|
@ -37,26 +37,6 @@ func UnMarshalTaxType(s *geo_models.TaxType) *TaxType {
|
|||
if s.ID == "" {
|
||||
s.ID = uuid.New().String()
|
||||
}
|
||||
dateTime, dateErr := time.Parse(dateTimeFormat, s.CreatedDate)
|
||||
createdDateSQL := sql.NullTime{
|
||||
Time: dateTime,
|
||||
Valid: dateErr == nil,
|
||||
}
|
||||
dateTime, dateErr = time.Parse(dateTimeFormat, s.LastModifiedDate)
|
||||
modifiedDateSQL := sql.NullTime{
|
||||
Time: dateTime,
|
||||
Valid: dateErr == nil,
|
||||
}
|
||||
date, dateErr := time.Parse(dateFormat, s.EffectiveDate)
|
||||
effectiveDateSQL := sql.NullTime{
|
||||
Time: date,
|
||||
Valid: dateErr == nil,
|
||||
}
|
||||
date, dateErr = time.Parse(dateFormat, s.EndDate)
|
||||
endDateSQL := sql.NullTime{
|
||||
Time: date,
|
||||
Valid: dateErr == nil,
|
||||
}
|
||||
return &TaxType{
|
||||
ID: s.ID,
|
||||
AccountID: s.AccountID,
|
||||
|
@ -71,10 +51,7 @@ func UnMarshalTaxType(s *geo_models.TaxType) *TaxType {
|
|||
CompanyID: s.CompanyID,
|
||||
ContactID: s.ContactID,
|
||||
CreatedByID: s.CreatedByID,
|
||||
CreatedDate: createdDateSQL,
|
||||
Description: s.Description,
|
||||
EffectiveDate: effectiveDateSQL,
|
||||
EndDate: endDateSQL,
|
||||
EnrollmentStatus: s.EnrollmentStatus,
|
||||
FilingCity: s.FilingCity,
|
||||
FilingCountry: s.FilingCountry,
|
||||
|
@ -91,7 +68,6 @@ func UnMarshalTaxType(s *geo_models.TaxType) *TaxType {
|
|||
IsMedicinal: s.IsMedicinal,
|
||||
IsRecreational: s.IsRecreational,
|
||||
LastModifiedByID: s.LastModifiedByID,
|
||||
LastModifiedDate: modifiedDateSQL,
|
||||
MarkupRate: s.MarkupRate,
|
||||
Name: s.Name,
|
||||
OwnerID: s.OwnerID,
|
||||
|
@ -110,11 +86,39 @@ func UnMarshalTaxType(s *geo_models.TaxType) *TaxType {
|
|||
TemplateID: s.TemplateID,
|
||||
UnitBase: s.UnitBase,
|
||||
Units: s.Units,
|
||||
CreatedDate: sql.NullTime{
|
||||
Time: createdDate, Valid: e0 == nil && !createdDate.IsZero(),
|
||||
},
|
||||
LastModifiedDate: sql.NullTime{
|
||||
Time: lastModifiedDate, Valid: e1 == nil && !lastModifiedDate.IsZero(),
|
||||
},
|
||||
EffectiveDate: sql.NullTime{
|
||||
Time: effectiveDate, Valid: e2 == nil && !effectiveDate.IsZero(),
|
||||
},
|
||||
EndDate: sql.NullTime{
|
||||
Time: endDate, Valid: e3 == nil && !endDate.IsZero(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalToSwagger encodes a first class object to swagger
|
||||
func (obj *TaxType) MarshalToSwagger() *geo_models.TaxType {
|
||||
var createdDate string
|
||||
if obj.CreatedDate.Valid {
|
||||
createdDate = obj.CreatedDate.Time.Format(dateTimeFormat)
|
||||
}
|
||||
var lastModifiedDate string
|
||||
if obj.LastModifiedDate.Valid {
|
||||
lastModifiedDate = obj.LastModifiedDate.Time.Format(dateTimeFormat)
|
||||
}
|
||||
var effectiveDate string
|
||||
if obj.EffectiveDate.Valid {
|
||||
effectiveDate = obj.EffectiveDate.Time.Format(dateFormat)
|
||||
}
|
||||
var endDate string
|
||||
if obj.EndDate.Valid {
|
||||
endDate = obj.EndDate.Time.Format(dateFormat)
|
||||
}
|
||||
return &geo_models.TaxType{
|
||||
ID: obj.ID,
|
||||
AccountID: obj.AccountID,
|
||||
|
@ -129,10 +133,10 @@ func (obj *TaxType) MarshalToSwagger() *geo_models.TaxType {
|
|||
CompanyID: obj.CompanyID,
|
||||
ContactID: obj.ContactID,
|
||||
CreatedByID: obj.CreatedByID,
|
||||
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormatAlt),
|
||||
CreatedDate: createdDate,
|
||||
Description: obj.Description,
|
||||
EffectiveDate: obj.EffectiveDate.Time.Format(dateFormat),
|
||||
EndDate: obj.EndDate.Time.Format(dateFormat),
|
||||
EffectiveDate: effectiveDate,
|
||||
EndDate: endDate,
|
||||
EnrollmentStatus: obj.EnrollmentStatus,
|
||||
FilingCity: obj.FilingCity,
|
||||
FilingCountry: obj.FilingCountry,
|
||||
|
@ -148,7 +152,7 @@ func (obj *TaxType) MarshalToSwagger() *geo_models.TaxType {
|
|||
IsMedicinal: obj.IsMedicinal,
|
||||
IsRecreational: obj.IsRecreational,
|
||||
LastModifiedByID: obj.LastModifiedByID,
|
||||
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormatAlt),
|
||||
LastModifiedDate: lastModifiedDate,
|
||||
MarkupRate: obj.MarkupRate,
|
||||
Name: obj.Name,
|
||||
OwnerID: obj.OwnerID,
|
||||
|
|
6
go.sum
6
go.sum
|
@ -65,6 +65,7 @@ github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4
|
|||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
|
@ -531,7 +532,9 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
|
|||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/uber-go/tally v3.3.17+incompatible h1:nFHIuW3VQ22wItiE9kPXic8dEgExWOsVOHwpmoIvsMw=
|
||||
github.com/uber-go/tally v3.3.17+incompatible/go.mod h1:YDTIBxdXyOU/sCWilKB4bgyufu1cEi0jdVnRdxvjnmU=
|
||||
github.com/uber/jaeger-client-go v2.23.1+incompatible h1:uArBYHQR0HqLFFAypI7RsWTzPSj/bDpmZZuQjMLSg1A=
|
||||
github.com/uber/jaeger-client-go v2.23.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
|
||||
github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw=
|
||||
github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
|
@ -605,12 +608,14 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl
|
|||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
@ -736,6 +741,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
|||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114 h1:DnSr2mCsxyCE6ZgIkmcWUQY2R5cH/6wL7eIxEmQOMSE=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200605181038-cef9fc3bc8f0 h1:gxU2P+MOOGAWge5BKP+BzqSeegxvDBRib5rk3yZDDuI=
|
||||
golang.org/x/tools v0.0.0-20200605181038-cef9fc3bc8f0/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
Loading…
Reference in New Issue