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 UnMarshalCounty(s *geo_models.County) *County {
|
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)
|
|
|
|
theInstances := []*TaxInstance{}
|
|
|
|
for _, itm := range s.TaxInstances {
|
2021-01-17 21:49:00 +00:00
|
|
|
theInstances = append(theInstances, UnMarshalTaxInstance(itm))
|
2021-01-14 06:36:35 +00:00
|
|
|
}
|
|
|
|
return &County{
|
|
|
|
ID: s.ID,
|
|
|
|
AccountID: s.AccountID,
|
|
|
|
Amount: s.Amount,
|
|
|
|
AreaDescription: s.AreaDescription,
|
|
|
|
ContactID: s.ContactID,
|
|
|
|
CountryID: s.CountryID,
|
|
|
|
EnrollmentStatus: s.EnrollmentStatus,
|
|
|
|
FIPS: s.FIPS,
|
|
|
|
FIPSclass: s.FIPSclass,
|
|
|
|
FunctionalStatus: s.FunctionalStatus,
|
|
|
|
Geocode: s.Geocode,
|
|
|
|
GNIS: s.GNIS,
|
|
|
|
Interest: s.Interest,
|
|
|
|
LandArea: s.LandArea,
|
|
|
|
LegalName: s.LegalName,
|
|
|
|
Latitude: s.Latitude,
|
|
|
|
Longitude: s.Longitude,
|
|
|
|
Name: s.Name,
|
|
|
|
Penalty: s.Penalty,
|
|
|
|
Ref: s.Ref,
|
|
|
|
ReportedAdjustments: s.ReportedAdjustments,
|
|
|
|
ReportedDeductions: s.ReportedDeductions,
|
|
|
|
ReportedNetRevenue: s.ReportedNetRevenue,
|
|
|
|
ReportedRate: s.ReportedRate,
|
|
|
|
ReportedRevenue: s.ReportedNetRevenue,
|
|
|
|
RevenueBase: s.RevenueBase,
|
|
|
|
RevenueNet: s.RevenueNet,
|
|
|
|
RevenueNotTaxable: s.RevenueNotTaxable,
|
|
|
|
StateID: s.StateID,
|
|
|
|
Status: s.Status,
|
|
|
|
Subtotal: s.Subtotal,
|
|
|
|
TaxInstances: theInstances,
|
|
|
|
TemplateID: s.TemplateID,
|
|
|
|
TotalAmount: s.TotalAmount,
|
|
|
|
TotalArea: s.TotalArea,
|
|
|
|
UnitBase: s.UnitBase,
|
|
|
|
WaterArea: s.WaterArea,
|
|
|
|
CreatedByID: s.CreatedByID,
|
|
|
|
HasDistrictTaxes: s.HasDistrictTaxes,
|
|
|
|
LastModifiedByID: s.LastModifiedByID,
|
|
|
|
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 *County) MarshalToSwagger() *geo_models.County {
|
2021-01-14 06:36:35 +00:00
|
|
|
theInstances := []*geo_models.TaxInstance{}
|
|
|
|
for _, itm := range obj.TaxInstances {
|
2021-01-17 21:49:00 +00:00
|
|
|
theInstances = append(theInstances, itm.MarshalToSwagger())
|
2021-01-14 06:36:35 +00:00
|
|
|
}
|
|
|
|
var salesTaxRate *geo_models.TaxRate
|
|
|
|
if obj.SalesTaxRate != nil {
|
|
|
|
salesTaxRate = &geo_models.TaxRate{
|
|
|
|
CombinedRate: obj.SalesTaxRate.CombinedRate,
|
|
|
|
County: obj.SalesTaxRate.County,
|
|
|
|
CountyID: obj.SalesTaxRate.CountyID,
|
|
|
|
CountyRate: obj.SalesTaxRate.CountyRate,
|
|
|
|
Date: obj.SalesTaxRate.Date,
|
|
|
|
Focus: obj.SalesTaxRate.Focus,
|
|
|
|
Geocode: obj.SalesTaxRate.Geocode,
|
|
|
|
Place: obj.SalesTaxRate.Place,
|
|
|
|
PlaceID: obj.SalesTaxRate.PlaceID,
|
|
|
|
PlaceRate: obj.SalesTaxRate.PlaceRate,
|
|
|
|
State: obj.SalesTaxRate.State,
|
|
|
|
StateID: obj.SalesTaxRate.StateID,
|
|
|
|
StateRate: obj.SalesTaxRate.StateRate,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return &geo_models.County{
|
|
|
|
ID: obj.ID,
|
|
|
|
AccountID: obj.AccountID,
|
|
|
|
Amount: obj.Amount,
|
|
|
|
AreaDescription: obj.AreaDescription,
|
|
|
|
ContactID: obj.ContactID,
|
|
|
|
CountryID: obj.CountryID,
|
|
|
|
EnrollmentStatus: obj.EnrollmentStatus,
|
|
|
|
FIPS: obj.FIPS,
|
|
|
|
FIPSclass: obj.FIPSclass,
|
|
|
|
FunctionalStatus: obj.FunctionalStatus,
|
|
|
|
Geocode: obj.Geocode,
|
|
|
|
GNIS: obj.GNIS,
|
|
|
|
HasDistrictTaxes: obj.HasDistrictTaxes,
|
|
|
|
Interest: obj.Interest,
|
|
|
|
LandArea: obj.LandArea,
|
|
|
|
LegalName: obj.LegalName,
|
|
|
|
Latitude: obj.Latitude,
|
|
|
|
Longitude: obj.Longitude,
|
|
|
|
Name: obj.Name,
|
|
|
|
Penalty: obj.Penalty,
|
|
|
|
Ref: obj.Ref,
|
|
|
|
ReportedAdjustments: obj.ReportedAdjustments,
|
|
|
|
ReportedDeductions: obj.ReportedDeductions,
|
|
|
|
ReportedNetRevenue: obj.ReportedNetRevenue,
|
|
|
|
ReportedRate: obj.ReportedRate,
|
|
|
|
ReportedRevenue: obj.ReportedRevenue,
|
|
|
|
RevenueBase: obj.RevenueBase,
|
|
|
|
RevenueNet: obj.RevenueNet,
|
|
|
|
RevenueNotTaxable: obj.RevenueNotTaxable,
|
|
|
|
SalesTaxRate: salesTaxRate,
|
|
|
|
StateID: obj.StateID,
|
|
|
|
Status: obj.Status,
|
|
|
|
Subtotal: obj.Subtotal,
|
|
|
|
TaxInstances: theInstances,
|
|
|
|
TemplateID: obj.TemplateID,
|
|
|
|
TotalAmount: obj.TotalAmount,
|
|
|
|
TotalArea: obj.TotalArea,
|
|
|
|
UnitBase: obj.UnitBase,
|
|
|
|
WaterArea: obj.WaterArea,
|
|
|
|
CreatedByID: obj.CreatedByID,
|
|
|
|
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
|
|
|
|
LastModifiedByID: obj.LastModifiedByID,
|
|
|
|
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
|
|
|
|
OwnerID: obj.OwnerID,
|
|
|
|
}
|
|
|
|
}
|