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.



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

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

Instance Method Details

#conceptoObject



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

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

#datos_adicionalesObject



35
36
37
38
39
40
41
# File 'lib/fm_layout/fm_layout.rb', line 35

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

#domicilioObject



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

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

#domicilio_fiscalObject



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

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

#emisorObject



43
44
45
46
47
48
49
# File 'lib/fm_layout/fm_layout.rb', line 43

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

#encabezadoObject



27
28
29
30
31
32
33
# File 'lib/fm_layout/fm_layout.rb', line 27

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

#expedido_enObject



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

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

#impuesto_retenidoObject



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

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

#impuesto_retenido_localObject



126
127
128
129
130
131
132
133
134
# File 'lib/fm_layout/fm_layout.rb', line 126

def impuesto_retenido_local 
  impuesto = ImpuestoRetenidoLocal.new
  if block_given?
    yield(impuesto)
    @impuestos_retenidos_locales << impuesto
  else
    impuesto
  end
end

#impuesto_trasladadoObject



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

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

#impuesto_trasladado_localObject



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

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

#nominaObject



136
137
138
139
140
141
142
143
# File 'lib/fm_layout/fm_layout.rb', line 136

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

#receptorObject



51
52
53
54
55
56
57
# File 'lib/fm_layout/fm_layout.rb', line 51

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

#to_hObject



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/fm_layout/fm_layout.rb', line 156

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)
    .merge(obtener_hash_retenciones_locales)
end

#to_sObject



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

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 += @impuestos_retenidos_locales.map(&:to_s).reduce(:+).to_s
  salida += @nomina.to_s
  salida
end