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

// Company company
//
// swagger:model Company
type Company struct {

	// Taxnexus ID of the Account that owns this Company
	Accountid string `json:"accountid,omitempty"`

	// Account Number Prefix
	Accountnumberprefix string `json:"accountnumberprefix,omitempty"`

	// The next period to be used in periodic billing
	Advancedperiodid string `json:"advancedperiodid,omitempty"`

	// billingaddress
	Billingaddress *Address `json:"billingaddress,omitempty"`

	// Billing Advice
	Billingadvice string `json:"billingadvice,omitempty"`

	// Contact ID
	Billingcontactid string `json:"billingcontactid,omitempty"`

	// Billing Email
	Billingemail string `json:"billingemail,omitempty"`

	// Billing Phone
	Billingphone string `json:"billingphone,omitempty"`

	// Billing Website
	Billingwebsite string `json:"billingwebsite,omitempty"`

	// The last closed period
	Closedperiodid string `json:"closedperiodid,omitempty"`

	// Chart of Accounts Template Account ID
	Coatemplateid string `json:"coatemplateid,omitempty"`

	// Color Accent1
	Coloraccent1 string `json:"coloraccent1,omitempty"`

	// Color Accent2
	Coloraccent2 string `json:"coloraccent2,omitempty"`

	// Color Primary
	Colorprimary string `json:"colorprimary,omitempty"`

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

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

	// The current period
	Currentperiodid string `json:"currentperiodid,omitempty"`

	// The current period's status value
	Currentperiodstatus string `json:"currentperiodstatus,omitempty"`

	// User ID of default Customer Success user
	Customersuccessid string `json:"customersuccessid,omitempty"`

	// Date Closed
	Dateclosed string `json:"dateclosed,omitempty"`

	// defaultaddress
	Defaultaddress *Address `json:"defaultaddress,omitempty"`

	// Default Company?
	Defaultcompany bool `json:"defaultcompany,omitempty"`

	// Font Name for Body Text
	Fontbody string `json:"fontbody,omitempty"`

	// Font Name for Heading
	Fontheading string `json:"fontheading,omitempty"`

	// Font Name for Heading Narrow
	Fontheadingnarrow string `json:"fontheadingnarrow,omitempty"`

	// Font Names for CSS Link
	Fontlink string `json:"fontlink,omitempty"`

	// Font Name for Monospace
	Fontmono string `json:"fontmono,omitempty"`

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

	// International Customers?
	International bool `json:"international,omitempty"`

	// Last Account Number
	Lastaccountnumber int64 `json:"lastaccountnumber,omitempty"`

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

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

	// Last TaxType Number
	Lasttaxtypenumber int64 `json:"lasttaxtypenumber,omitempty"`

	// Logo URL
	Logo string `json:"logo,omitempty"`

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

	// The ID of the contact who owns this Company
	Ownerid string `json:"ownerid,omitempty"`

	// User ID of the default tax preparer
	Preparerid string `json:"preparerid,omitempty"`

	// The ID of the default Pricebook for this company
	Pricebookid string `json:"pricebookid,omitempty"`

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

	// The ID of the contact who is the User Tech Lead for Company
	Usertechleadid string `json:"usertechleadid,omitempty"`
}

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

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

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

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

func (m *Company) validateBillingaddress(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *Company) validateDefaultaddress(formats strfmt.Registry) error {

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

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

	return nil
}

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

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