2021-01-14 06:36:35 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"code.tnxs.net/taxnexus/lib/api/regs/regs_models"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
2021-01-17 21:49:00 +00:00
|
|
|
func UnMarshalSubmission(s *regs_models.Submission) *Submission {
|
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)
|
|
|
|
submissionDate, e2 := time.Parse(dateFormat, s.SubmissionDate)
|
|
|
|
if e2 != nil {
|
|
|
|
submissionDate, e2 = time.Parse(dateFormatAlt, s.SubmissionDate)
|
|
|
|
}
|
|
|
|
return &Submission{
|
|
|
|
ID: s.ID,
|
|
|
|
CompanyID: s.CompanyID,
|
|
|
|
ContactID: s.ContactID,
|
|
|
|
CreatedByID: s.CreatedByID,
|
|
|
|
LastModifiedByID: s.LastModifiedByID,
|
|
|
|
Notes: s.Notes,
|
|
|
|
Penalty: s.Penalty,
|
|
|
|
ParentFK: s.ParentFK,
|
|
|
|
Ref: s.Ref,
|
|
|
|
ReportedAdjustments: s.ReportedAdjustments,
|
|
|
|
ReportedDeductions: s.ReportedDeductions,
|
|
|
|
ReportedNetRevenue: s.ReportedNetRevenue,
|
|
|
|
ReportedRate: s.ReportedRate,
|
|
|
|
ReportedRevenue: s.ReportedRevenue,
|
|
|
|
RevenueBase: s.RevenueBase,
|
|
|
|
RevenueNet: s.RevenueNet,
|
|
|
|
RevenueNotTaxable: s.RevenueNotTaxable,
|
|
|
|
Status: s.Status,
|
|
|
|
Subtotal: s.Subtotal,
|
|
|
|
SubmissionNumber: s.SubmissionNumber,
|
|
|
|
TaxTypeID: s.TaxTypeID,
|
|
|
|
TenantID: s.TenantID,
|
|
|
|
TotalAmount: s.TotalAmount,
|
|
|
|
CreatedDate: sql.NullTime{
|
|
|
|
Time: createdDate,
|
|
|
|
Valid: e0 == nil,
|
|
|
|
},
|
|
|
|
LastModifiedDate: sql.NullTime{
|
|
|
|
Time: lastModfiedDate,
|
|
|
|
Valid: e1 == nil,
|
|
|
|
},
|
|
|
|
SubmissionDate: sql.NullTime{
|
|
|
|
Time: submissionDate,
|
|
|
|
Valid: e2 == nil,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-17 21:49:00 +00:00
|
|
|
func (obj *Submission) MarshalToSwagger() *regs_models.Submission {
|
2021-01-14 06:36:35 +00:00
|
|
|
return ®s_models.Submission{
|
|
|
|
ID: obj.ID,
|
|
|
|
CompanyID: obj.CompanyID,
|
|
|
|
ContactID: obj.ContactID,
|
|
|
|
CreatedByID: obj.CreatedByID,
|
|
|
|
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
|
|
|
|
LastModifiedByID: obj.LastModifiedByID,
|
|
|
|
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
|
|
|
|
Notes: obj.Notes,
|
|
|
|
ParentFK: obj.ParentFK,
|
|
|
|
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,
|
|
|
|
Status: obj.Status,
|
|
|
|
SubmissionDate: obj.SubmissionDate.Time.Format(dateFormat),
|
|
|
|
SubmissionNumber: obj.SubmissionNumber,
|
|
|
|
Subtotal: obj.Subtotal,
|
|
|
|
TaxTypeID: obj.TaxTypeID,
|
|
|
|
TenantID: obj.TenantID,
|
|
|
|
TotalAmount: obj.TotalAmount,
|
|
|
|
}
|
|
|
|
}
|