Class: Nfe::StateTaxLegalEntity

Inherits:
Data
  • Object
show all
Defined in:
lib/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rb,
sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs

Overview

Immutable value object for the legalEntity object returned by the NFE.io state-tax lookup endpoints (+stateTaxInfo+, stateTaxForInvoice, stateTaxSuggestedForInvoice) on legalentity.api.nfe.io.

This is a DIFFERENT shape from the basicInfo LegalEntity: it carries the company-level tax-regime fields plus a stateTaxes collection of state registrations (Inscrições Estaduais). All fields are optional; StateTaxLegalEntity.from_api maps API camelCase keys onto snake_case members and is nil-tolerant (+from_api(nil)+ returns nil).

Defined Under Namespace

Classes: Address, EconomicActivity, FiscalDocumentInfo, StateTax

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStateTaxLegalEntity

Returns a new instance of StateTaxLegalEntity.

Parameters:

  • federal_tax_number: (String, nil)
  • name: (String, nil)
  • trade_name: (String, nil)
  • tax_regime: (Object)
  • legal_nature: (Object)
  • fiscal_unit: (String, nil)
  • created_unit: (String, nil)
  • created_on: (String, nil)
  • check_code: (String, nil)
  • state_taxes: (Object)


69
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 69

def initialize: (federal_tax_number: String?, name: String?, trade_name: String?, tax_regime: untyped, legal_nature: untyped, fiscal_unit: String?, created_unit: String?, created_on: String?, check_code: String?, state_taxes: untyped) -> void

Instance Attribute Details

#check_codeString? (readonly)

Returns the value of attribute check_code.

Returns:

  • (String, nil)


64
65
66
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 64

def check_code
  @check_code
end

#created_onString? (readonly)

Returns the value of attribute created_on.

Returns:

  • (String, nil)


63
64
65
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 63

def created_on
  @created_on
end

#created_unitString? (readonly)

Returns the value of attribute created_unit.

Returns:

  • (String, nil)


62
63
64
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 62

def created_unit
  @created_unit
end

#federal_tax_numberString? (readonly)

Returns the value of attribute federal_tax_number.

Returns:

  • (String, nil)


56
57
58
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 56

def federal_tax_number
  @federal_tax_number
end

#fiscal_unitString? (readonly)

Returns the value of attribute fiscal_unit.

Returns:

  • (String, nil)


61
62
63
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 61

def fiscal_unit
  @fiscal_unit
end

Returns the value of attribute legal_nature.

Returns:

  • (Object)


60
61
62
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 60

def legal_nature
  @legal_nature
end

#nameString? (readonly)

Returns the value of attribute name.

Returns:

  • (String, nil)


57
58
59
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 57

def name
  @name
end

#state_taxesObject (readonly)

Returns the value of attribute state_taxes.

Returns:

  • (Object)


65
66
67
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 65

def state_taxes
  @state_taxes
end

#tax_regimeObject (readonly)

Returns the value of attribute tax_regime.

Returns:

  • (Object)


59
60
61
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 59

def tax_regime
  @tax_regime
end

#trade_nameString? (readonly)

Returns the value of attribute trade_name.

Returns:

  • (String, nil)


58
59
60
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 58

def trade_name
  @trade_name
end

Class Method Details

.from_api(payload) ⇒ Nfe::StateTaxLegalEntity?

Returns nil when payload is nil.

Parameters:

  • payload (Hash, nil)

    the unwrapped legalEntity state-tax object.

Returns:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rb', line 110

def self.from_api(payload)
  return nil if payload.nil?

  new(
    federal_tax_number: payload["federalTaxNumber"]&.to_s,
    name: payload["name"],
    trade_name: payload["tradeName"],
    tax_regime: payload["taxRegime"],
    legal_nature: payload["legalNature"],
    fiscal_unit: payload["fiscalUnit"],
    created_unit: payload["createdUnit"],
    created_on: payload["createdOn"],
    check_code: payload["checkCode"]&.to_s,
    state_taxes: (payload["stateTaxes"] || []).map { |t| StateTax.from_api(t) }
  )
end

.newinstance

Parameters:

  • federal_tax_number: (String, nil)
  • name: (String, nil)
  • trade_name: (String, nil)
  • tax_regime: (Object)
  • legal_nature: (Object)
  • fiscal_unit: (String, nil)
  • created_unit: (String, nil)
  • created_on: (String, nil)
  • check_code: (String, nil)
  • state_taxes: (Object)

Returns:

  • (instance)


68
# File 'sig/nfe/resources/dto/legal_entity_lookup/state_tax_legal_entity.rbs', line 68

def self.new: (federal_tax_number: String?, name: String?, trade_name: String?, tax_regime: untyped, legal_nature: untyped, fiscal_unit: String?, created_unit: String?, created_on: String?, check_code: String?, state_taxes: untyped) -> instance