// 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 ops_models

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

import (
	"encoding/json"
	"strconv"

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

// QuoteBasic quote basic
//
// swagger:model QuoteBasic
type QuoteBasic struct {

	// Account Identifier from Source System; ignored in tax calculations
	AccountID string `json:"AccountID,omitempty"`

	// Invoice Amount
	Amount float64 `json:"Amount,omitempty"`

	// business address
	BusinessAddress *Address `json:"BusinessAddress,omitempty"`

	// OEM Customer Identifier
	CustomerID string `json:"CustomerID,omitempty"`

	// Invoice Total from source system
	EstimatedAmount float64 `json:"EstimatedAmount,omitempty"`

	// Business tax from source system
	EstimatedBusinessTax float64 `json:"EstimatedBusinessTax,omitempty"`

	// Cannabis Tax from source system
	EstimatedCannabisTax float64 `json:"EstimatedCannabisTax,omitempty"`

	// Cost of Goods Sold from source system
	EstimatedCogs float64 `json:"EstimatedCogs,omitempty"`

	// Cannabis Tax from source system
	EstimatedDiscount float64 `json:"EstimatedDiscount,omitempty"`

	// Sales Tax from source system
	EstimatedSalesTax float64 `json:"EstimatedSalesTax,omitempty"`

	// Invoice Subtotal from source system
	EstimatedSubtotal float64 `json:"EstimatedSubtotal,omitempty"`

	// Taxnexus ID
	ID string `json:"ID,omitempty"`

	// ID of the Ingest which created this Invoice
	IngestID string `json:"IngestID,omitempty"`

	// The items associated with this Invoice
	Items []*ItemBasic `json:"Items"`

	// ID of the Job which created this Invoice
	JobID string `json:"JobID,omitempty"`

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

	// Taxnexus Period ID
	PeriodID string `json:"PeriodID,omitempty"`

	// Invoice Date; should be date only or correct time zone if in time notation
	QuoteDate string `json:"QuoteDate,omitempty"`

	// Source System Customer-Facing Invoice Number; ignored in tax calculation
	QuoteNumber string `json:"QuoteNumber,omitempty"`

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

	// Sales Regulation Type
	// Enum: [AdultUse Caregiver Consumer Medicinal MedicinalState MedicinalThirdParty Merchandise Patient Telecom]
	SalesRegulation string `json:"SalesRegulation,omitempty"`

	// Shipping and Handling fees for this document
	ShippingHandling float64 `json:"ShippingHandling,omitempty"`

	// Status used by for Billing Balances; ignored in tax calculation
	// Enum: [closed delivered hold issued new posted rated rating_failed rating_ready reissued rendered uncollectable voided]
	Status string `json:"Status,omitempty"`

	// Subtotal of items
	Subtotal float64 `json:"Subtotal,omitempty"`

	// The Tax Transactions "Source System identifier for this record, if any; copied to quoteitemid in Tax Transaction result records"
	TaxTransactions []*TaxTransaction `json:"TaxTransactions"`

	// ID of the Tenant that owns this object
	TenantID string `json:"TenantID,omitempty"`

	// total
	Total *Total `json:"Total,omitempty"`

	// Invoice Type
	Type string `json:"Type,omitempty"`
}

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

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

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

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

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

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

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

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

func (m *QuoteBasic) validateBusinessAddress(formats strfmt.Registry) error {

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

	if m.BusinessAddress != nil {
		if err := m.BusinessAddress.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("BusinessAddress")
			}
			return err
		}
	}

	return nil
}

func (m *QuoteBasic) 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
}

var quoteBasicTypeSalesRegulationPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["AdultUse","Caregiver","Consumer","Medicinal","MedicinalState","MedicinalThirdParty","Merchandise","Patient","Telecom"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		quoteBasicTypeSalesRegulationPropEnum = append(quoteBasicTypeSalesRegulationPropEnum, v)
	}
}

const (

	// QuoteBasicSalesRegulationAdultUse captures enum value "AdultUse"
	QuoteBasicSalesRegulationAdultUse string = "AdultUse"

	// QuoteBasicSalesRegulationCaregiver captures enum value "Caregiver"
	QuoteBasicSalesRegulationCaregiver string = "Caregiver"

	// QuoteBasicSalesRegulationConsumer captures enum value "Consumer"
	QuoteBasicSalesRegulationConsumer string = "Consumer"

	// QuoteBasicSalesRegulationMedicinal captures enum value "Medicinal"
	QuoteBasicSalesRegulationMedicinal string = "Medicinal"

	// QuoteBasicSalesRegulationMedicinalState captures enum value "MedicinalState"
	QuoteBasicSalesRegulationMedicinalState string = "MedicinalState"

	// QuoteBasicSalesRegulationMedicinalThirdParty captures enum value "MedicinalThirdParty"
	QuoteBasicSalesRegulationMedicinalThirdParty string = "MedicinalThirdParty"

	// QuoteBasicSalesRegulationMerchandise captures enum value "Merchandise"
	QuoteBasicSalesRegulationMerchandise string = "Merchandise"

	// QuoteBasicSalesRegulationPatient captures enum value "Patient"
	QuoteBasicSalesRegulationPatient string = "Patient"

	// QuoteBasicSalesRegulationTelecom captures enum value "Telecom"
	QuoteBasicSalesRegulationTelecom string = "Telecom"
)

// prop value enum
func (m *QuoteBasic) validateSalesRegulationEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, quoteBasicTypeSalesRegulationPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *QuoteBasic) validateSalesRegulation(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateSalesRegulationEnum("SalesRegulation", "body", m.SalesRegulation); err != nil {
		return err
	}

	return nil
}

var quoteBasicTypeStatusPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["closed","delivered","hold","issued","new","posted","rated","rating_failed","rating_ready","reissued","rendered","uncollectable","voided"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		quoteBasicTypeStatusPropEnum = append(quoteBasicTypeStatusPropEnum, v)
	}
}

const (

	// QuoteBasicStatusClosed captures enum value "closed"
	QuoteBasicStatusClosed string = "closed"

	// QuoteBasicStatusDelivered captures enum value "delivered"
	QuoteBasicStatusDelivered string = "delivered"

	// QuoteBasicStatusHold captures enum value "hold"
	QuoteBasicStatusHold string = "hold"

	// QuoteBasicStatusIssued captures enum value "issued"
	QuoteBasicStatusIssued string = "issued"

	// QuoteBasicStatusNew captures enum value "new"
	QuoteBasicStatusNew string = "new"

	// QuoteBasicStatusPosted captures enum value "posted"
	QuoteBasicStatusPosted string = "posted"

	// QuoteBasicStatusRated captures enum value "rated"
	QuoteBasicStatusRated string = "rated"

	// QuoteBasicStatusRatingFailed captures enum value "rating_failed"
	QuoteBasicStatusRatingFailed string = "rating_failed"

	// QuoteBasicStatusRatingReady captures enum value "rating_ready"
	QuoteBasicStatusRatingReady string = "rating_ready"

	// QuoteBasicStatusReissued captures enum value "reissued"
	QuoteBasicStatusReissued string = "reissued"

	// QuoteBasicStatusRendered captures enum value "rendered"
	QuoteBasicStatusRendered string = "rendered"

	// QuoteBasicStatusUncollectable captures enum value "uncollectable"
	QuoteBasicStatusUncollectable string = "uncollectable"

	// QuoteBasicStatusVoided captures enum value "voided"
	QuoteBasicStatusVoided string = "voided"
)

// prop value enum
func (m *QuoteBasic) validateStatusEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, quoteBasicTypeStatusPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *QuoteBasic) validateStatus(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateStatusEnum("Status", "body", m.Status); err != nil {
		return err
	}

	return nil
}

func (m *QuoteBasic) validateTaxTransactions(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *QuoteBasic) validateTotal(formats strfmt.Registry) error {

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

	if m.Total != nil {
		if err := m.Total.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("Total")
			}
			return err
		}
	}

	return nil
}

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

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