lib/app/taxtypeaccount-helpers.go

104 lines
3.3 KiB
Go
Raw 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"
"github.com/google/uuid"
)
2021-01-17 21:49:00 +00:00
func UnMarshalTaxTypeAccount(s *regs_models.TaxTypeAccount) *TaxTypeAccount {
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.LastModfiedDate)
endDate, e2 := time.Parse(dateFormat, s.EndDate)
startDate, e3 := time.Parse(dateFormat, s.StartDate)
return &TaxTypeAccount{
ID: s.ID,
AccountID: s.AccountID,
AccountNumber: s.AccountNumber,
Active: s.Active,
Amount: s.Amount,
ContactID: s.ContactID,
CreatedByID: s.CreatedByID,
Description: s.Description,
Interest: s.Interest,
LastModifiedByID: s.LastModfiedByID,
Notes: s.Notes,
ParentFK: s.ParentFK,
Penalty: s.Penalty,
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,
Subtotal: s.Subtotal,
Tax: s.Tax,
TaxOnTax: s.TaxOnTax,
TaxTypeID: s.TaxTypeID,
TenantID: s.TenantID,
TotalAmount: s.TotalAmount,
UnitBase: s.UnitBase,
CreatedDate: sql.NullTime{
Time: createdDate,
Valid: e0 == nil,
},
LastModifiedDate: sql.NullTime{
Time: lastModfiedDate,
Valid: e1 == nil,
},
EndDate: sql.NullTime{
Time: endDate,
Valid: e2 == nil,
},
StartDate: sql.NullTime{
Time: startDate,
Valid: e3 == nil,
},
}
}
2021-01-17 21:49:00 +00:00
func (obj *TaxTypeAccount) MarshalToSwagger() *regs_models.TaxTypeAccount {
2021-01-14 06:36:35 +00:00
return &regs_models.TaxTypeAccount{
ID: obj.ID,
AccountID: obj.AccountID,
AccountNumber: obj.AccountNumber,
Active: obj.Active,
Amount: obj.Amount,
ContactID: obj.ContactID,
CreatedByID: obj.CreatedByID,
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
Description: obj.Description,
EndDate: obj.EndDate.Time.Format(dateFormat),
Interest: obj.Interest,
LastModfiedByID: obj.LastModifiedByID,
LastModfiedDate: 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,
StartDate: obj.StartDate.Time.Format(dateFormat),
Subtotal: obj.Subtotal,
Tax: obj.Tax,
TaxOnTax: obj.TaxOnTax,
TaxTypeID: obj.TaxTypeID,
TenantID: obj.TenantID,
TotalAmount: obj.TotalAmount,
UnitBase: obj.UnitBase,
}
}