// 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 (
	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// OrderBasic order basic
//
// swagger:model OrderBasic
type OrderBasic struct {

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

	// Order Amount
	Amount float64 `json:"amount,omitempty"`

	// Amount Due
	Amountdue float64 `json:"amountdue,omitempty"`

	// coordinate
	Coordinate *Address `json:"coordinate,omitempty"`

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

	// items
	Items *ItemBasic `json:"items,omitempty"`

	// Order Date
	Orderdate string `json:"orderdate,omitempty"`

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

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

	// Sales Regulation Type (Medicinal or Recreational)
	Salesregulation string `json:"salesregulation,omitempty"`

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

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

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

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

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

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

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

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

func (m *OrderBasic) validateCoordinate(formats strfmt.Registry) error {

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

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

	return nil
}

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

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

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

	return nil
}

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

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