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

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

// AccountingRuleset accounting ruleset
//
// swagger:model AccountingRuleset
type AccountingRuleset struct {

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

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

	// Created By
	Createdbyid string `json:"createdbyid,omitempty"`

	// Created Date
	Createddate string `json:"createddate,omitempty"`

	// Ruleset Description
	Description string `json:"description,omitempty"`

	// Taxnexus Record Id
	ID string `json:"id,omitempty"`

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

	// Last Modified By
	Lastmodifiedbyid string `json:"lastmodifiedbyid,omitempty"`

	// Last Modified Date
	Lastmodifieddate string `json:"lastmodifieddate,omitempty"`

	// Taxnexus Ruleset Number
	Number string `json:"number,omitempty"`

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

// Validate validates this accounting ruleset
func (m *AccountingRuleset) 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 *AccountingRuleset) 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 *AccountingRuleset) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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