2021-01-14 06:36:35 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"code.tnxs.net/taxnexus/lib/api/geo/geo_models"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
2021-01-17 21:49:00 +00:00
|
|
|
func UnMarshalTaxInstance(s *geo_models.TaxInstance) *TaxInstance {
|
2021-01-14 06:36:35 +00:00
|
|
|
if s.ID == "" {
|
|
|
|
s.ID = uuid.New().String()
|
|
|
|
}
|
|
|
|
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
|
|
|
|
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
|
|
|
|
return &TaxInstance{
|
|
|
|
ID: s.ID,
|
|
|
|
CountryID: s.CountryID,
|
|
|
|
CountyID: s.CountyID,
|
|
|
|
CreatedByID: s.CreatedByID,
|
|
|
|
LastModifiedByID: s.LastModifiedByID,
|
|
|
|
PlaceID: s.PlaceID,
|
|
|
|
StateID: s.StateID,
|
|
|
|
TaxTypeID: s.TaxTypeID,
|
|
|
|
Type: s.Type,
|
|
|
|
CreatedDate: sql.NullTime{
|
|
|
|
Time: createdDate,
|
|
|
|
Valid: e0 == nil,
|
|
|
|
},
|
|
|
|
LastModifiedDate: sql.NullTime{
|
|
|
|
Time: lastModfiedDate,
|
|
|
|
Valid: e1 == nil,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 21:49:00 +00:00
|
|
|
func (obj *TaxInstance) MarshalToSwagger() *geo_models.TaxInstance {
|
2021-01-14 06:36:35 +00:00
|
|
|
return &geo_models.TaxInstance{
|
|
|
|
ID: obj.ID,
|
|
|
|
CountryID: obj.CountryID,
|
|
|
|
CountyID: obj.CountyID,
|
|
|
|
CreatedByID: obj.CreatedByID,
|
|
|
|
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
|
|
|
|
LastModifiedByID: obj.LastModifiedByID,
|
|
|
|
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
|
|
|
|
PlaceID: obj.PlaceID,
|
|
|
|
StateID: obj.StateID,
|
|
|
|
TaxTypeID: obj.TaxTypeID,
|
|
|
|
Type: obj.Type,
|
|
|
|
}
|
|
|
|
}
|