lib/app/invoice-helpers.go

117 lines
4.7 KiB
Go
Raw Permalink Normal View History

2021-01-14 06:36:35 +00:00
package app
import "code.tnxs.net/taxnexus/lib/api/ops/ops_models"
// Invoice unMarshal does validation in the Ops microservice only
2021-01-18 03:13:54 +00:00
// MarshalToSwagger encodes first class object
2021-01-17 21:49:00 +00:00
func (obj *Invoice) MarshalToSwagger() *ops_models.Invoice { //nolint:funlen // big object
2021-01-14 06:36:35 +00:00
var items []*ops_models.InvoiceItem
if obj.Items != nil {
items = []*ops_models.InvoiceItem{}
for _, itm := range obj.Items {
items = append(items, itm.MarshalToSwagger())
}
}
var taxTransactions []*ops_models.TaxTransaction
if obj.TaxTransactions != nil {
taxTransactions = []*ops_models.TaxTransaction{}
for _, txn := range obj.TaxTransactions {
taxTransactions = append(taxTransactions, txn.MarshalToSwagger())
}
}
return &ops_models.Invoice{
ID: obj.ID,
AccountID: obj.AccountID,
Advance: obj.Advance,
Amount: obj.Amount,
AmountAdjustment: obj.AmountAdjustment,
AmountDue: obj.AmountDue,
AmountPaid: obj.AmountPaid,
AuditMessage: obj.AuditMessage,
BillingAddress: obj.BillingAddress.MarshalToOps(),
BillingContactID: obj.BillingContact,
BillingRunID: obj.BillingRunID,
BusinessAddress: obj.BusinessAddress.MarshalToOps(),
BusinessTax: obj.BusinessTax,
CannabisTax: obj.CannabisTax,
ContractID: obj.ContractID,
CoordinateID: obj.CoordinateID,
CreatedByID: obj.CreatedByID,
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
CustomerID: obj.CustomerID,
DateIssued: obj.DateIssued.Time.Format(dateTimeFormat),
DaysDue: obj.DaysDue,
DepositAmount: obj.DepositAmount,
Description: obj.Description,
Discount: obj.Discount,
EstimatedAmount: obj.EstimatedAmount,
EstimatedBusinessTax: obj.EstimatedBusinessTax,
EstimatedCannabisTax: obj.EstimatedCannabisTax,
EstimatedCOGS: obj.EstimatedCOGS,
EstimatedDiscount: obj.EstimatedDiscount,
EstimatedSalesTax: obj.EstimatedSalesTax,
EstimatedSubtotal: obj.EstimatedSubtotal,
IngestID: obj.IngestID,
InvoiceDate: obj.InvoiceDate.Time.Format(dateFormat),
InvoiceNumber: obj.InvoiceNumber,
IsInternational: obj.IsInternational,
IssuedAccountBalance: obj.IssuedAccountBalance,
IssuedAmountDue: obj.IssuedAmountDue,
IssuedByID: obj.IssuedByID,
IsValid: obj.IsValid,
Items: items,
JobID: obj.JobID,
LastModifiedByID: obj.LastModifiedByID,
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
MinimumPaymentDue: obj.MinimumPaymentDue,
MonthlyAmount: obj.MonthlyAmount,
OpportunityID: obj.OpportunityID,
OrderID: obj.OrderID,
OverDue0: obj.OverDue0,
OverDue120: obj.OverDue120,
OverDue30: obj.OverDue30,
OverDue45: obj.OverDue45,
OverDue60: obj.OverDue60,
OverDue90: obj.OverDue90,
ParentFK: obj.ParentFK,
PartnerAccountID: obj.PartnerAccountID,
PaymentDue: obj.PaymentDue.Time.Format(dateTimeFormat),
PaymentMethod: obj.PaymentMethodDescription,
PaymentMethodID: obj.PaymentMethodID,
PaymentTerms: obj.PaymentTerms,
PeriodID: obj.PeriodID,
PlaceGeocode: obj.PlaceGeoCode,
Posted: obj.Posted,
PriorAccountBalance: obj.PriorAccountBalance,
PriorAdjustments: obj.PriorAdjustments,
PriorInvoiceAmount: obj.PriorInvoiceAmount,
PriorInvoiceDate: obj.PriorInvoiceDate.Time.Format(dateFormat),
PriorInvoiceID: obj.PriorInvoiceID,
PriorPaymentAmount: obj.PriorPaymentAmount,
PriorPaymentDate: obj.PriorPaymentDate.Time.Format(dateFormat),
PriorPaymentID: obj.PriorPaymentID,
PriorPaymentMemo: obj.PriorPaymentMemo,
Prorated: obj.Prorated,
ProtratedDays: obj.ProratedDays,
PurchaseAmount: obj.PurchaseAmount,
QuoteID: obj.QuoteID,
RatingEngineID: obj.RatingEngineID,
Ref: obj.Ref,
Reference: obj.Reference,
SalesRegulation: obj.SalesRegulation,
SalesTax: obj.SalesTax,
ScheduledPaymentDate: obj.ScheduledPaymentDate.Time.Format(dateFormat),
ServiceTerm: obj.ServiceTerm,
ShippingAddress: obj.ShippingAddress.MarshalToOps(),
ShippingHandling: obj.ShippingHandling,
Status: obj.Status,
Subtotal: obj.Subtotal,
TaxTransactions: taxTransactions,
TelecomTax: obj.TelecomTax,
TemplateID: obj.TemplateID,
Total: obj.Total.MarshalToSwagger(),
Type: obj.Type,
}
}