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

// Invoice invoice
//
// swagger:model Invoice
type Invoice struct {

	// Account Balance
	Accountbalance float64 `json:"accountbalance,omitempty"`

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

	// Account Name
	Accountname string `json:"accountname,omitempty"`

	// Advance?
	Advance bool `json:"advance,omitempty"`

	// Invoice Amount
	Amount float64 `json:"amount,omitempty"`

	// Amount Adjustment
	AmountAdjustment float64 `json:"amount_adjustment,omitempty"`

	// Amount Due
	Amountdue float64 `json:"amountdue,omitempty"`

	// Amount Paid
	Amountpaid float64 `json:"amountpaid,omitempty"`

	// Audit Trail Message
	Auditmessage string `json:"auditmessage,omitempty"`

	// Billing City
	Billingcity string `json:"billingcity,omitempty"`

	// Billing Country
	Billingcountry string `json:"billingcountry,omitempty"`

	// Billing Postal Code
	Billingpostalcode string `json:"billingpostalcode,omitempty"`

	// Billing Run
	Billingrunid string `json:"billingrunid,omitempty"`

	// Billing State
	Billingstate string `json:"billingstate,omitempty"`

	// Billing Street
	Billingstreet string `json:"billingstreet,omitempty"`

	// billtocontactid
	Billtocontactid string `json:"billtocontactid,omitempty"`

	// Cannabis Tax
	Cannabistax float64 `json:"cannabistax,omitempty"`

	// Contract
	Contractid string `json:"contractid,omitempty"`

	// coordinate
	Coordinate *Address `json:"coordinate,omitempty"`

	// Customer ID
	Customerid string `json:"customerid,omitempty"`

	// Date Issued
	Dateissued string `json:"dateissued,omitempty"`

	// Days Due
	Daysdue float64 `json:"daysdue,omitempty"`

	// Deposit Amount
	Depositamount float64 `json:"depositamount,omitempty"`

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

	// Discount
	Discount float64 `json:"discount,omitempty"`

	// Taxnexus Record Id Only; not used in POST
	ID string `json:"id,omitempty"`

	// Invoice Date
	Invoicedate string `json:"invoicedate,omitempty"`

	// Invoice Number
	Invoicenumber string `json:"invoicenumber,omitempty"`

	// Is International?
	Isinternational bool `json:"isinternational,omitempty"`

	// Issued Account Balance
	Issuedaccountbalance float64 `json:"issuedaccountbalance,omitempty"`

	// Issued Amount Due
	Issuedamountdue float64 `json:"issuedamountdue,omitempty"`

	// Issued By
	Issuedbyid string `json:"issuedbyid,omitempty"`

	// Is Valid?
	Isvalid bool `json:"isvalid,omitempty"`

	// The items associated with this Invoice
	Items []*InvoiceItem `json:"items"`

	// Line Item Count
	Lineitemcount int64 `json:"lineitemcount,omitempty"`

	// Minimum Payment Due
	Minimumpaymentdue float64 `json:"minimumpaymentdue,omitempty"`

	// Monthly Amount
	Monthlyamount float64 `json:"monthlyamount,omitempty"`

	// Opportunity
	Opportunityid string `json:"opportunityid,omitempty"`

	// Order
	Orderid string `json:"orderid,omitempty"`

	// Overdue0
	Overdue0 float64 `json:"overdue0,omitempty"`

	// Overdue 120 Days Amount
	Overdue120 float64 `json:"overdue120,omitempty"`

	// Overdue 30 Days Amount
	Overdue30 float64 `json:"overdue30,omitempty"`

	// Overdue 45 Days Amount
	Overdue45 float64 `json:"overdue45,omitempty"`

	// Overdue 60 Days Amount
	Overdue60 float64 `json:"overdue60,omitempty"`

	// Overdue 90 Days Amount
	Overdue90 float64 `json:"overdue90,omitempty"`

	// UUID Reference the master record that owns this item
	Parentfk string `json:"parentfk,omitempty"`

	// Partner Account
	Partneraccountid string `json:"partneraccountid,omitempty"`

	// Payment Method
	PaymentMethod string `json:"payment_method,omitempty"`

	// Payment Due
	Paymentdue string `json:"paymentdue,omitempty"`

	// Payment Method
	Paymentmethodid string `json:"paymentmethodid,omitempty"`

	// Payment Terms
	Paymentterms string `json:"paymentterms,omitempty"`

	// Period
	Periodid string `json:"periodid,omitempty"`

	// Picklist Value
	Picklistvalue string `json:"picklistvalue,omitempty"`

	// Posted
	Posted bool `json:"posted,omitempty"`

	// Prior Account Balance
	Prioraccountbalance float64 `json:"prioraccountbalance,omitempty"`

	// Prior Adjustments
	Prioradjustments float64 `json:"prioradjustments,omitempty"`

	// Prior Invoice Amount
	Priorinvoiceamount float64 `json:"priorinvoiceamount,omitempty"`

	// Prior Invoice Date
	Priorinvoicedate string `json:"priorinvoicedate,omitempty"`

	// Prior Invoice
	Priorinvoiceid string `json:"priorinvoiceid,omitempty"`

	// Prior Payment Amount
	Priorpaymentamount float64 `json:"priorpaymentamount,omitempty"`

	// Prior Payment Date
	Priorpaymentdate string `json:"priorpaymentdate,omitempty"`

	// Prior Payment
	Priorpaymentid string `json:"priorpaymentid,omitempty"`

	// Prior Payment Memo
	Priorpaymentmemo string `json:"priorpaymentmemo,omitempty"`

	// Prorated?
	Prorated bool `json:"prorated,omitempty"`

	// Prorated Days
	Prorateddays float64 `json:"prorateddays,omitempty"`

	// Purchase Amount
	Purchaseamount float64 `json:"purchaseamount,omitempty"`

	// Quote
	Quoteid string `json:"quoteid,omitempty"`

	// Rating Ingest
	Ratingingestid string `json:"ratingingestid,omitempty"`

	// Source System identifier for this record, if any
	Ref string `json:"ref,omitempty"`

	// Reference
	Reference string `json:"reference,omitempty"`

	// Sales Regulation Type (Medicinal or Recreational)
	Salesregulation string `json:"salesregulation,omitempty"`

	// Sales Tax
	Salestax float64 `json:"salestax,omitempty"`

	// Scheduled Payment Date
	Scheduledpaymentdate string `json:"scheduledpaymentdate,omitempty"`

	// Service Term
	ServiceTerm string `json:"service_term,omitempty"`

	// Shipping City
	Shippingcity string `json:"shippingcity,omitempty"`

	// Shipping Country
	Shippingcountry string `json:"shippingcountry,omitempty"`

	// Shipping & Handling
	Shippinghandling float64 `json:"shippinghandling,omitempty"`

	// Shipping Postal Code
	Shippingpostalcode string `json:"shippingpostalcode,omitempty"`

	// Shipping State
	Shippingstate string `json:"shippingstate,omitempty"`

	// Shipping Street
	Shippingstreet string `json:"shippingstreet,omitempty"`

	// Statement Item Type
	Statementitemtype string `json:"statementitemtype,omitempty"`

	// Status
	Status string `json:"status,omitempty"`

	// Subtotal
	Subtotal float64 `json:"subtotal,omitempty"`

	// Suppress Workflow?
	Suppressworkflow bool `json:"suppressworkflow,omitempty"`

	// The taxes associated with this Invoice
	Taxitems []*TaxTransaction `json:"taxitems"`

	// Telecom Tax
	Telecomtax float64 `json:"telecomtax,omitempty"`

	// Template
	Templateid string `json:"templateid,omitempty"`

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

	// Type
	Type string `json:"type,omitempty"`

	// WHMCS Client ID
	Whmcsclientid string `json:"whmcsclientid,omitempty"`

	// WHMCS Invoice ID
	Whmcsinvoiceid string `json:"whmcsinvoiceid,omitempty"`

	// Xero Invoice Id
	Xeroid string `json:"xeroid,omitempty"`

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

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

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

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

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

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

func (m *Invoice) validateCoordinate(formats strfmt.Registry) error {

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

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

	return nil
}

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

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

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