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

// TaxReturn tax return
//
// swagger:model TaxReturn
type TaxReturn struct {

	// additional deductions
	AdditionalDeductions []*AdditionalDeductions `json:"AdditionalDeductions"`

	// additional deductions amount
	AdditionalDeductionsAmount float64 `json:"AdditionalDeductionsAmount,omitempty"`

	// asset sales
	AssetSales float64 `json:"AssetSales,omitempty"`

	// code
	Code string `json:"Code,omitempty"`

	// county reports
	CountyReports []*TaxReturnPanel `json:"CountyReports"`

	// district reports
	DistrictReports []*TaxReturnPanel `json:"DistrictReports"`

	// district taxes
	DistrictTaxes []*DistrictTaxes `json:"DistrictTaxes"`

	// estimated report
	EstimatedReport *TaxReturnPanel `json:"EstimatedReport,omitempty"`

	// excess tax collected
	ExcessTaxCollected float64 `json:"ExcessTaxCollected,omitempty"`

	// fixtures and equipment
	FixturesAndEquipment float64 `json:"FixturesAndEquipment,omitempty"`

	// food sales
	FoodSales float64 `json:"FoodSales,omitempty"`

	// gov sales
	GovSales float64 `json:"GovSales,omitempty"`

	// interest
	Interest float64 `json:"Interest,omitempty"`

	// interstate sales
	InterstateSales float64 `json:"InterstateSales,omitempty"`

	// month
	Month int64 `json:"Month,omitempty"`

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

	// net taxable amount to be reported
	NetTaxableAmountToBeReported float64 `json:"NetTaxableAmountToBeReported,omitempty"`

	// non taxable labor
	NonTaxableLabor float64 `json:"NonTaxableLabor,omitempty"`

	// penalty
	Penalty float64 `json:"Penalty,omitempty"`

	// period headers
	PeriodHeaders []string `json:"PeriodHeaders"`

	// quarter
	Quarter int64 `json:"Quarter,omitempty"`

	// remaining tax
	RemainingTax float64 `json:"RemainingTax,omitempty"`

	// resale sales
	ResaleSales float64 `json:"ResaleSales,omitempty"`

	// sales tax included
	SalesTaxIncluded float64 `json:"SalesTaxIncluded,omitempty"`

	// summary report
	SummaryReport *TaxReturnPanel `json:"SummaryReport,omitempty"`

	// tax due
	TaxDue float64 `json:"TaxDue,omitempty"`

	// total sales
	TotalSales float64 `json:"TotalSales,omitempty"`

	// total sales and purchases
	TotalSalesAndPurchases float64 `json:"TotalSalesAndPurchases,omitempty"`

	// total tax
	TotalTax float64 `json:"TotalTax,omitempty"`

	// total tax due before credits
	TotalTaxDueBeforeCredits float64 `json:"TotalTaxDueBeforeCredits,omitempty"`

	// total tax prepayments
	TotalTaxPrepayments float64 `json:"TotalTaxPrepayments,omitempty"`

	// use tax sales
	UseTaxSales float64 `json:"UseTaxSales,omitempty"`

	// year
	Year int64 `json:"Year,omitempty"`
}

// Validate validates this tax return
func (m *TaxReturn) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

func (m *TaxReturn) validateAdditionalDeductions(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *TaxReturn) validateCountyReports(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *TaxReturn) validateDistrictReports(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *TaxReturn) validateDistrictTaxes(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

func (m *TaxReturn) validateEstimatedReport(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *TaxReturn) validateSummaryReport(formats strfmt.Registry) error {

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

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

	return nil
}

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

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