lib/app/taxnexuscode-helpers.go

78 lines
2.5 KiB
Go
Raw Permalink Normal View History

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-18 03:13:54 +00:00
// UnMarshalTaxnexusCode decodes swagger to first class object
2021-01-17 21:49:00 +00:00
func UnMarshalTaxnexusCode(s *geo_models.TaxnexusCode) *TaxnexusCode {
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 &TaxnexusCode{
ID: s.ID,
Active: s.Active,
Code: s.Code,
CreatedByID: s.CreatedByID,
Description: s.Description,
DomainID: s.DomainID,
DomainName: s.DomainName,
LastModifiedByID: s.LastModifiedByID,
Level: s.Level,
Part1: s.Part1,
Part2: s.Part2,
Part3: s.Part3,
Part4: s.Part4,
Part5: s.Part5,
PurchasingRulesetCode: s.PurchasingRulesetCode,
PurchasingRulesetID: s.PurchasingRulesetID,
Ref: s.Ref,
RevenueRulesetCode: s.RevenueRulesetCode,
RevenueRulesetID: s.RevenueRulesetID,
OwnerID: s.OwnerID,
CreatedDate: sql.NullTime{
Time: createdDate,
Valid: e0 == nil,
},
LastModifiedDate: sql.NullTime{
Time: lastModfiedDate,
Valid: e1 == nil,
},
}
}
2021-01-18 03:13:54 +00:00
// MarshalToSwagger encodes first class object
2021-01-17 21:49:00 +00:00
func (obj *TaxnexusCode) MarshalToSwagger() *geo_models.TaxnexusCode {
2021-01-14 06:36:35 +00:00
swag := geo_models.TaxnexusCode{
ID: obj.ID,
Active: obj.Active,
Code: obj.Code,
CreatedByID: obj.CreatedByID,
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
Description: obj.Description,
DomainID: obj.DomainID,
DomainName: obj.DomainName,
LastModifiedByID: obj.LastModifiedByID,
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
Level: obj.Level,
OwnerID: obj.OwnerID,
Part1: obj.Part1,
Part2: obj.Part2,
Part3: obj.Part3,
Part4: obj.Part4,
Part5: obj.Part5,
PurchasingRulesetCode: obj.PurchasingRulesetCode,
PurchasingRulesetID: obj.PurchasingRulesetID,
Ref: obj.Ref,
RevenueRulesetCode: obj.RevenueRulesetCode,
RevenueRulesetID: obj.RevenueRulesetID,
}
return &swag
}