// Code generated by go-swagger; DO NOT EDIT.

// All Code Copyright(c) 2018-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package sf_gate_models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"strconv"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// Quote quote
//
// swagger:model Quote
type Quote struct {

	// accountid
	Accountid string `json:"accountid,omitempty"`

	// Additional To
	Additionaladdress interface{} `json:"additionaladdress,omitempty"`

	// Additional To Name
	Additionalname string `json:"additionalname,omitempty"`

	// Bill To
	Billingaddress interface{} `json:"billingaddress,omitempty"`

	// billingcontactid
	Billingcontactid string `json:"billingcontactid,omitempty"`

	// Bill To Name
	Billingname string `json:"billingname,omitempty"`

	// Cannabis Tax
	Cannabistax float64 `json:"cannabistax,omitempty"`

	// contactid
	Contactid string `json:"contactid,omitempty"`

	// contractid
	Contractid string `json:"contractid,omitempty"`

	// coordinateid
	Coordinateid string `json:"coordinateid,omitempty"`

	// Credit Terms
	Creditterms string `json:"creditterms,omitempty"`

	// Quote Date
	Date string `json:"date,omitempty"`

	// Description
	Description string `json:"description,omitempty"`

	// Discount
	Discount float64 `json:"discount,omitempty"`

	// Discount Amount
	Discountamount float64 `json:"discountamount,omitempty"`

	// Email
	Email string `json:"email,omitempty"`

	// enduserid
	Enduserid string `json:"enduserid,omitempty"`

	// Expiration Date
	Expirationdate string `json:"expirationdate,omitempty"`

	// Fax
	Fax string `json:"fax,omitempty"`

	// Grand Total
	Grandtotal float64 `json:"grandtotal,omitempty"`

	// Taxnexus Record Id Only; not used in POST
	ID string `json:"id,omitempty"`

	// Installation Date
	Installationdate string `json:"installationdate,omitempty"`

	// Syncing
	Issyncing bool `json:"issyncing,omitempty"`

	// items
	Items []*QuoteItem `json:"items"`

	// Line Items
	Lineitemcount int64 `json:"lineitemcount,omitempty"`

	// Monthly Amount
	Monthlyamount float64 `json:"monthlyamount,omitempty"`

	// Quote Name
	Name string `json:"name,omitempty"`

	// Opportunity Name
	Opportunityid string `json:"opportunityid,omitempty"`

	// Owner Name
	Ownerid string `json:"ownerid,omitempty"`

	// UUID Reference the master record that owns this item
	Parentfk string `json:"parentfk,omitempty"`

	// Payment Terms
	Paymentterms string `json:"paymentterms,omitempty"`

	// Phone
	Phone string `json:"phone,omitempty"`

	// Purchase Amount
	Purchaseamount float64 `json:"purchaseamount,omitempty"`

	// Quote Amount
	Quoteamount float64 `json:"quoteamount,omitempty"`

	// Quote Number
	Quotenumber string `json:"quotenumber,omitempty"`

	// Quote To
	Quotetoaddress interface{} `json:"quotetoaddress,omitempty"`

	// Quote To Name
	Quotetoname string `json:"quotetoname,omitempty"`

	// Source System identifier for this record, if any
	Ref string `json:"ref,omitempty"`

	// Sales Regulation Type
	Salesregulation string `json:"salesregulation,omitempty"`

	// Service Term
	Serviceterm string `json:"serviceterm,omitempty"`

	// Ship To
	Shippingaddress interface{} `json:"shippingaddress,omitempty"`

	// Shipping Contact
	Shippingcontactid string `json:"shippingcontactid,omitempty"`

	// Shipping and Handling
	Shippinghandling float64 `json:"shippinghandling,omitempty"`

	// Ship To Name
	Shippingname string `json:"shippingname,omitempty"`

	// Status
	Status string `json:"status,omitempty"`

	// Subtotal
	Subtotal float64 `json:"subtotal,omitempty"`

	// Suppress Workflow?
	Suppressworkflow bool `json:"suppressworkflow,omitempty"`

	// Tax
	Tax float64 `json:"tax,omitempty"`

	// The taxes associated with this Quote
	Taxitems []*TaxTransaction `json:"taxitems"`

	// Telecom Tax
	Telecomtax float64 `json:"telecomtax,omitempty"`

	// Template
	Templateid string `json:"templateid,omitempty"`

	// tenant identifier
	Tenantid string `json:"tenantid,omitempty"`

	// Total Price
	Totalprice float64 `json:"totalprice,omitempty"`

	// Quote Type
	Type string `json:"type,omitempty"`
}

// Validate validates this quote
func (m *Quote) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateItems(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateTaxitems(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *Quote) validateItems(formats strfmt.Registry) error {

	if swag.IsZero(m.Items) { // not required
		return nil
	}

	for i := 0; i < len(m.Items); i++ {
		if swag.IsZero(m.Items[i]) { // not required
			continue
		}

		if m.Items[i] != nil {
			if err := m.Items[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("items" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *Quote) validateTaxitems(formats strfmt.Registry) error {

	if swag.IsZero(m.Taxitems) { // not required
		return nil
	}

	for i := 0; i < len(m.Taxitems); i++ {
		if swag.IsZero(m.Taxitems[i]) { // not required
			continue
		}

		if m.Taxitems[i] != nil {
			if err := m.Taxitems[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("taxitems" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// MarshalBinary interface implementation
func (m *Quote) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *Quote) UnmarshalBinary(b []byte) error {
	var res Quote
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
