lib/app/transaction-helpers.go

46 lines
1.3 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/regs/regs_models"
)
func UnMarshalTransaction(s *regs_models.Transaction) *Transaction {
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
return &Transaction{
ID: s.ID,
AccountID: s.AccountID,
CreatedByID: s.CreatedByID,
LastModifiedByID: s.LastModifiedByID,
TaxTransactionID: s.TaxTransactionID,
TaxTypeID: s.TaxTypeID,
TenantID: s.TenantID,
Valid: s.Valid,
CreatedDate: sql.NullTime{
Time: createdDate,
Valid: e0 == nil,
},
LastModifiedDate: sql.NullTime{
Time: lastModfiedDate,
Valid: e1 == nil,
},
}
}
func (obj *Transaction) MarshalToSwagger() *regs_models.Transaction {
return &regs_models.Transaction{
ID: obj.ID,
AccountID: obj.AccountID,
CreatedByID: obj.CreatedByID,
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
LastModifiedByID: obj.LastModifiedByID,
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
TaxTransactionID: obj.TaxTransactionID,
TaxTypeID: obj.TaxTypeID,
TenantID: obj.TenantID,
Valid: obj.Valid,
}
}