Class: FmLayout::FmLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/fm_layout/fm_layout.rb

Instance Method Summary collapse

Constructor Details

#initializeFmLayout

Returns a new instance of FmLayout.



14
15
16
17
18
19
20
21
22
23
# File 'lib/fm_layout/fm_layout.rb', line 14

def initialize
  @encabezado = Encabezado.new
  @datos_adicionales = DatosAdicionales.new
  @emisor = Emisor.new
  @receptor= Receptor.new
  @conceptos = []
  @impuestos_trasladados =  []
  @impuestos_trasladados_locales =  []
  @impuestos_retenidos =  []
end

Instance Method Details

#conceptoObject



84
85
86
87
88
89
90
91
92
# File 'lib/fm_layout/fm_layout.rb', line 84

def concepto
  concepto = Concepto.new
  if block_given?
    yield(concepto)
    @conceptos << concepto
  else
    concepto
  end
end

#datos_adicionalesObject



33
34
35
36
37
38
39
# File 'lib/fm_layout/fm_layout.rb', line 33

def datos_adicionales
  if block_given?
    yield(@datos_adicionales)
  else
    @datos_adicionales
  end
end

#domicilioObject



66
67
68
69
70
71
72
73
# File 'lib/fm_layout/fm_layout.rb', line 66

def domicilio
  @domicilio ||= Domicilio.new
  if block_given?
    yield(@domicilio)
  else
    @domicilio
  end
end

#domicilio_fiscalObject



57
58
59
60
61
62
63
64
# File 'lib/fm_layout/fm_layout.rb', line 57

def domicilio_fiscal
  @domicilio_fiscal ||= Domicilio.new('DomicilioFiscal')
  if block_given?
    yield(@domicilio_fiscal)
  else
    @domicilio_fiscal
  end
end

#emisorObject



41
42
43
44
45
46
47
# File 'lib/fm_layout/fm_layout.rb', line 41

def emisor
  if block_given?
    yield(@emisor)
  else
    @emisor
  end
end

#encabezadoObject



25
26
27
28
29
30
31
# File 'lib/fm_layout/fm_layout.rb', line 25

def encabezado
  if block_given?
    yield(@encabezado)
  else
    @encabezado
  end
end

#expedido_enObject



75
76
77
78
79
80
81
82
# File 'lib/fm_layout/fm_layout.rb', line 75

def expedido_en
  @expedido_en ||= Domicilio.new('ExpedidoEn')
  if block_given?
    yield(@expedido_en)
  else
    @expedido_en
  end
end

#impuesto_retenidoObject



114
115
116
117
118
119
120
121
122
# File 'lib/fm_layout/fm_layout.rb', line 114

def impuesto_retenido
  impuesto = ImpuestoRetenido.new
  if block_given?
    yield(impuesto)
    @impuestos_retenidos << impuesto
  else
   impuesto
  end
end

#impuesto_trasladadoObject



94
95
96
97
98
99
100
101
102
# File 'lib/fm_layout/fm_layout.rb', line 94

def impuesto_trasladado
  impuesto = ImpuestoTrasladado.new
  if block_given?
    yield(impuesto)
    @impuestos_trasladados << impuesto
  else
   impuesto
  end
end

#impuesto_trasladado_localObject



104
105
106
107
108
109
110
111
112
# File 'lib/fm_layout/fm_layout.rb', line 104

def impuesto_trasladado_local
  impuesto = ImpuestoTrasladadoLocal.new
  if block_given?
    yield(impuesto)
    @impuestos_trasladados_locales << impuesto
  else
   impuesto
  end
end

#nominaObject



124
125
126
127
128
129
130
131
# File 'lib/fm_layout/fm_layout.rb', line 124

def nomina
  @nomina = Nomina::Nomina.new
  if block_given?
    yield(@nomina)
  else
    @nomina
  end
end

#receptorObject



49
50
51
52
53
54
55
# File 'lib/fm_layout/fm_layout.rb', line 49

def receptor
  if block_given?
    yield(@receptor)
  else
    @receptor
  end
end

#to_hObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/fm_layout/fm_layout.rb', line 143

def to_h
  encabezado.to_h
    .merge(@datos_adicionales.to_h)
    .merge(@emisor.to_h)
    .merge(@domicilio_fiscal.to_h)
    .merge(@expedido_en.to_h)
    .merge(@receptor.to_h)
    .merge(@domicilio.to_h)
    .merge(obtener_hash_conceptos)
    .merge(obtener_hash_traslados)
    .merge(obtener_hash_retenciones)
    .merge(@nomina.to_h)
    .merge(obtener_hash_traslados_locales)
end

#to_sObject



133
134
135
136
137
138
139
140
141
# File 'lib/fm_layout/fm_layout.rb', line 133

def to_s
  salida = @encabezado.to_s + @datos_adicionales.to_s + @emisor.to_s + @domicilio_fiscal.to_s + @expedido_en.to_s + @receptor.to_s + @domicilio.to_s
  salida += @conceptos.map(&:to_s).reduce(:+).to_s
  salida += @impuestos_trasladados.map(&:to_s).reduce(:+).to_s
  salida += @impuestos_retenidos.map(&:to_s).reduce(:+).to_s
  salida += @impuestos_trasladados_locales.map(&:to_s).reduce(:+).to_s
  salida += @nomina.to_s
  salida
end