// 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 (
	"strconv"

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

// TotalItem Tabulates Tax Transactions on this object
//
// swagger:model TotalItem
type TotalItem struct {

	// The amount of this total item
	Amount float64 `json:"Amount,omitempty"`

	// The number of taxtransactions totaled
	Count int64 `json:"Count,omitempty"`

	// Total Item description to be used in bill presentment
	DisplayName string `json:"DisplayName,omitempty"`

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

	// tax items
	TaxItems []*TotalTaxItem `json:"TaxItems"`

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

// Validate validates this total item
func (m *TotalItem) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *TotalItem) 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 *TotalItem) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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