// 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"
)

// Total total
//
// swagger:model Total
type Total struct {

	// The total amount for this object
	Amount float64 `json:"Amount,omitempty"`

	// The amount of Deferred Tax incurred with this invoice
	BusinessTax float64 `json:"BusinessTax,omitempty"`

	// The Percentage of Deffered Tax from the Total
	BusinessTaxRate float64 `json:"BusinessTaxRate,omitempty"`

	// The total amount of Cannabis Tax charged on this object
	CannabisTax float64 `json:"CannabisTax,omitempty"`

	// The percentage of Cannabis Tax from the Total
	CannabisTaxRate float64 `json:"CannabisTaxRate,omitempty"`

	// Created By User ID
	CreatedByID string `json:"CreatedByID,omitempty"`

	// Created Date
	CreatedDate string `json:"CreatedDate,omitempty"`

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

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

	// Last Modified By User ID
	LastModifiedByID string `json:"LastModifiedByID,omitempty"`

	// Last Modified Date
	LastModifiedDate string `json:"LastModifiedDate,omitempty"`

	// The monthly, pre-tax estimate of quoted and ordered periodic services
	MonthlyAmount float64 `json:"MonthlyAmount,omitempty"`

	// The type of Object for which this Total has been constructed
	ObjectType string `json:"ObjectType,omitempty"`

	// purchase amount
	PurchaseAmount float64 `json:"PurchaseAmount,omitempty"`

	// The amount of Sales Tax charged on this object
	SalesTax float64 `json:"SalesTax,omitempty"`

	// The percentage of Sales Tax from the Total
	SalesTaxRate float64 `json:"SalesTaxRate,omitempty"`

	// The shipping and delivery charges charged on this object
	ShippingHandling float64 `json:"ShippingHandling,omitempty"`

	// The sum of all the items on the object prior to tax rating and shipping & handling
	Subtotal float64 `json:"Subtotal,omitempty"`

	// The amount of Telecom Tax charged on this invoice
	TelecomTax float64 `json:"TelecomTax,omitempty"`

	// The percentage of Telecom Tax from the Total
	TelecomTaxRate float64 `json:"TelecomTaxRate,omitempty"`

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

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

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

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

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

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

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