Class: NuvemfiscalSdkRuby::DocDedRed

Inherits:
Object
  • Object
show all
Defined in:
lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb

Overview

Grupo de informações de documento utilizado para Dedução/Redução do valor do serviço.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ DocDedRed

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 110

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `NuvemfiscalSdkRuby::DocDedRed` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `NuvemfiscalSdkRuby::DocDedRed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'ch_nfse')
    self.ch_nfse = attributes[:'ch_nfse']
  end

  if attributes.key?(:'ch_nfe')
    self.ch_nfe = attributes[:'ch_nfe']
  end

  if attributes.key?(:'nfse_mun')
    self.nfse_mun = attributes[:'nfse_mun']
  end

  if attributes.key?(:'nfnfs')
    self.nfnfs = attributes[:'nfnfs']
  end

  if attributes.key?(:'n_doc_fisc')
    self.n_doc_fisc = attributes[:'n_doc_fisc']
  end

  if attributes.key?(:'n_doc')
    self.n_doc = attributes[:'n_doc']
  end

  if attributes.key?(:'tp_ded_red')
    self.tp_ded_red = attributes[:'tp_ded_red']
  else
    self.tp_ded_red = nil
  end

  if attributes.key?(:'x_desc_out_ded')
    self.x_desc_out_ded = attributes[:'x_desc_out_ded']
  end

  if attributes.key?(:'dt_emi_doc')
    self.dt_emi_doc = attributes[:'dt_emi_doc']
  else
    self.dt_emi_doc = nil
  end

  if attributes.key?(:'v_dedutivel_redutivel')
    self.v_dedutivel_redutivel = attributes[:'v_dedutivel_redutivel']
  else
    self.v_dedutivel_redutivel = nil
  end

  if attributes.key?(:'v_deducao_reducao')
    self.v_deducao_reducao = attributes[:'v_deducao_reducao']
  else
    self.v_deducao_reducao = nil
  end

  if attributes.key?(:'fornec')
    self.fornec = attributes[:'fornec']
  end
end

Instance Attribute Details

#ch_nfeObject

Chave de Acesso da NF-e.



23
24
25
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 23

def ch_nfe
  @ch_nfe
end

#ch_nfseObject

Chave de Acesso da NFS-e (Padrão Nacional).



20
21
22
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 20

def ch_nfse
  @ch_nfse
end

#dt_emi_docObject

Data da emissão do documento dedutível. Ano, mês e dia (AAAA-MM-DD).



42
43
44
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 42

def dt_emi_doc
  @dt_emi_doc
end

#fornecObject

Returns the value of attribute fornec.



50
51
52
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 50

def fornec
  @fornec
end

#n_docObject

Número de documento não fiscal.



33
34
35
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 33

def n_doc
  @n_doc
end

#n_doc_fiscObject

Número de documento fiscal.



30
31
32
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 30

def n_doc_fisc
  @n_doc_fisc
end

#nfnfsObject

Returns the value of attribute nfnfs.



27
28
29
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 27

def nfnfs
  @nfnfs
end

#nfse_munObject

Returns the value of attribute nfse_mun.



25
26
27
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 25

def nfse_mun
  @nfse_mun
end

#tp_ded_redObject

Identificação da Dedução/Redução: * 1 - Alimentação e bebidas/frigobar * 2 - Materiais * 3 - Produção externa * 4 - Reembolso de despesas * 5 - Repasse consorciado * 6 - Repasse plano de saúde * 7 - Serviços * 8 - Subempreitada de mão de obra * 99 - Outras deduções



36
37
38
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 36

def tp_ded_red
  @tp_ded_red
end

#v_deducao_reducaoObject

Valor monetário utilizado para dedução/redução do valor do serviço da NFS-e que está sendo emitida (R$). Deve ser menor ou igual ao valor deduzível/redutível (vDedutivelRedutivel).



48
49
50
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 48

def v_deducao_reducao
  @v_deducao_reducao
end

#v_dedutivel_redutivelObject

Valor monetário total dedutível/redutível no documento informado (R$). Este é o valor total no documento informado que é passível de dedução/redução.



45
46
47
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 45

def v_dedutivel_redutivel
  @v_dedutivel_redutivel
end

#x_desc_out_dedObject

Descrição da Dedução/Redução quando a opção é "99 - Outras Deduções".



39
40
41
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 39

def x_desc_out_ded
  @x_desc_out_ded
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 385

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = NuvemfiscalSdkRuby.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



71
72
73
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 71

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 53

def self.attribute_map
  {
    :'ch_nfse' => :'chNFSe',
    :'ch_nfe' => :'chNFe',
    :'nfse_mun' => :'NFSeMun',
    :'nfnfs' => :'NFNFS',
    :'n_doc_fisc' => :'nDocFisc',
    :'n_doc' => :'nDoc',
    :'tp_ded_red' => :'tpDedRed',
    :'x_desc_out_ded' => :'xDescOutDed',
    :'dt_emi_doc' => :'dtEmiDoc',
    :'v_dedutivel_redutivel' => :'vDedutivelRedutivel',
    :'v_deducao_reducao' => :'vDeducaoReducao',
    :'fornec' => :'fornec'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 361

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 94

def self.openapi_nullable
  Set.new([
    :'ch_nfse',
    :'ch_nfe',
    :'n_doc_fisc',
    :'n_doc',
    :'tp_ded_red',
    :'x_desc_out_ded',
    :'dt_emi_doc',
    :'v_dedutivel_redutivel',
    :'v_deducao_reducao',
  ])
end

.openapi_typesObject

Attribute type mapping.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 76

def self.openapi_types
  {
    :'ch_nfse' => :'String',
    :'ch_nfe' => :'String',
    :'nfse_mun' => :'DocOutNFSe',
    :'nfnfs' => :'DocNFNFS',
    :'n_doc_fisc' => :'String',
    :'n_doc' => :'String',
    :'tp_ded_red' => :'Integer',
    :'x_desc_out_ded' => :'String',
    :'dt_emi_doc' => :'Date',
    :'v_dedutivel_redutivel' => :'Float',
    :'v_deducao_reducao' => :'Float',
    :'fornec' => :'InfoFornecDocDedRed'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 329

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      ch_nfse == o.ch_nfse &&
      ch_nfe == o.ch_nfe &&
      nfse_mun == o.nfse_mun &&
      nfnfs == o.nfnfs &&
      n_doc_fisc == o.n_doc_fisc &&
      n_doc == o.n_doc &&
      tp_ded_red == o.tp_ded_red &&
      x_desc_out_ded == o.x_desc_out_ded &&
      dt_emi_doc == o.dt_emi_doc &&
      v_dedutivel_redutivel == o.v_dedutivel_redutivel &&
      v_deducao_reducao == o.v_deducao_reducao &&
      fornec == o.fornec
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 456

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


348
349
350
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 348

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



354
355
356
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 354

def hash
  [ch_nfse, ch_nfe, nfse_mun, nfnfs, n_doc_fisc, n_doc, tp_ded_red, x_desc_out_ded, dt_emi_doc, v_dedutivel_redutivel, v_deducao_reducao, fornec].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 182

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@ch_nfse.nil? && @ch_nfse.to_s.length > 50
    invalid_properties.push('invalid value for "ch_nfse", the character length must be smaller than or equal to 50.')
  end

  if !@ch_nfe.nil? && @ch_nfe.to_s.length > 44
    invalid_properties.push('invalid value for "ch_nfe", the character length must be smaller than or equal to 44.')
  end

  if !@n_doc_fisc.nil? && @n_doc_fisc.to_s.length > 255
    invalid_properties.push('invalid value for "n_doc_fisc", the character length must be smaller than or equal to 255.')
  end

  if !@n_doc_fisc.nil? && @n_doc_fisc.to_s.length < 1
    invalid_properties.push('invalid value for "n_doc_fisc", the character length must be great than or equal to 1.')
  end

  if !@n_doc.nil? && @n_doc.to_s.length > 255
    invalid_properties.push('invalid value for "n_doc", the character length must be smaller than or equal to 255.')
  end

  if !@n_doc.nil? && @n_doc.to_s.length < 1
    invalid_properties.push('invalid value for "n_doc", the character length must be great than or equal to 1.')
  end

  if !@x_desc_out_ded.nil? && @x_desc_out_ded.to_s.length > 150
    invalid_properties.push('invalid value for "x_desc_out_ded", the character length must be smaller than or equal to 150.')
  end

  if !@x_desc_out_ded.nil? && @x_desc_out_ded.to_s.length < 1
    invalid_properties.push('invalid value for "x_desc_out_ded", the character length must be great than or equal to 1.')
  end

  if @v_dedutivel_redutivel < 0
    invalid_properties.push('invalid value for "v_dedutivel_redutivel", must be greater than or equal to 0.')
  end

  if @v_deducao_reducao < 0
    invalid_properties.push('invalid value for "v_deducao_reducao", must be greater than or equal to 0.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



432
433
434
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 432

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 438

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



426
427
428
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 426

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/nuvemfiscal_sdk_ruby/models/doc_ded_red.rb', line 230

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@ch_nfse.nil? && @ch_nfse.to_s.length > 50
  return false if !@ch_nfe.nil? && @ch_nfe.to_s.length > 44
  return false if !@n_doc_fisc.nil? && @n_doc_fisc.to_s.length > 255
  return false if !@n_doc_fisc.nil? && @n_doc_fisc.to_s.length < 1
  return false if !@n_doc.nil? && @n_doc.to_s.length > 255
  return false if !@n_doc.nil? && @n_doc.to_s.length < 1
  return false if !@x_desc_out_ded.nil? && @x_desc_out_ded.to_s.length > 150
  return false if !@x_desc_out_ded.nil? && @x_desc_out_ded.to_s.length < 1
  return false if @v_dedutivel_redutivel < 0
  return false if @v_deducao_reducao < 0
  true
end