fm_layout 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc3101fb36eedb26df0b50f612e184978aaae1c5
4
+ data.tar.gz: c243e20ea6efe43bcb0f6449ebe85d5524738275
5
+ SHA512:
6
+ metadata.gz: 6c62e781696a69ce1fd12c15a70df1f8e5a8670f366801e7bac592e9cdedef9bb6751813b2e54bb0e8e9605bcde924ffd0cc08fee13b52c77550267fa8496088
7
+ data.tar.gz: 8fa06f080a0ff054b27fa1eec4d7b93211c4098b9a76d121126379e514a24b738e6e5498bc0759510e38d2408d6004f61877d397c9a37bb567060dec9ca802df
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'coveralls', require: false
4
+
5
+ # Specify your gem's dependencies in fm_layout.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 LogicalBricks Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 hermes-logicalbricks
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # FmLayout
2
+ [![Build Status](https://travis-ci.org/LogicalBricks/fm_layout.png?branch=master)](https://travis-ci.org/LogicalBricks/fm_layout)
3
+ [![Code Climate](https://codeclimate.com/github/LogicalBricks/fm_layout.png)](https://codeclimate.com/github/LogicalBricks/fm_layout)
4
+ [![Coverage Status](https://coveralls.io/repos/LogicalBricks/fm_layout/badge.png)](https://coveralls.io/r/LogicalBricks/fm_layout)
5
+ Generador del Layout para la conexión con Facturación Moderna a través de un DSL
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'fm_layout'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fm_layout
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
32
+ =======
33
+ fm_layout
34
+ =========
35
+
36
+ Generador del Layout para la conexión con Facturación Moderna a través de un DSL
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/fm_layout.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fm_layout/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "fm_layout"
8
+ gem.version = FmLayout::VERSION
9
+ gem.authors = ["Hermes Ojeda Ruiz"]
10
+ gem.email = ["hermes.ojeda@logicalbricks.com"]
11
+ gem.description = %q{Generador del Layout para la conexión con Facturación Moderna a través de un DSL}
12
+ gem.summary = %q{Generador del Layout para la conexión con Facturación Moderna a través de un DSL}
13
+ gem.homepage = ""
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency "bundler", "~> 1.3"
22
+ gem.add_development_dependency "rake"
23
+ gem.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,38 @@
1
+ require 'fm_layout/fm_seccion'
2
+
3
+ module FmLayout
4
+ class Concepto
5
+ include FmSeccion
6
+
7
+ def initialize
8
+ @titulo = 'Concepto'
9
+ @datos = {}
10
+ valores_iniciales
11
+ end
12
+
13
+ def self.campos_vs_metodos
14
+ {
15
+ 'cantidad' => 'cantidad',
16
+ 'unidad' => 'unidad',
17
+ 'noIdentificacion' => 'numero_de_identificacion',
18
+ 'descripcion' => 'descripcion',
19
+ 'valorUnitario' => 'valor_unitario',
20
+ 'importe' => 'importe',
21
+ 'CuentaPredial' => 'cuenta_predial',
22
+ }
23
+ end
24
+
25
+ # Creación de los métodos de acceso dinámicamente
26
+ campos_vs_metodos.each do |campo, metodo|
27
+ define_method(metodo) do |dato|
28
+ @datos[campo] = dato
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def valores_iniciales
35
+ @datos['cantidad'] = 1
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require 'fm_layout/fm_seccion'
2
+
3
+ module FmLayout
4
+ class DatosAdicionales
5
+ include FmSeccion
6
+
7
+ def initialize
8
+ @titulo = "Datos Adicionales"
9
+ @datos= {}
10
+ valores_iniciales
11
+ end
12
+
13
+ def self.campos_vs_metodos
14
+ {
15
+ 'tipoDocumento' => 'tipo_de_documento',
16
+ 'numeropedido' => 'numero_de_pedido',
17
+ 'observaciones' => 'observaciones',
18
+ 'idNomina' => 'id_de_nomina',
19
+ 'idTrabajador' => 'id_de_trabajador',
20
+ 'leyenda' => 'leyenda',
21
+ }
22
+ end
23
+
24
+ # Creación de los métodos de acceso dinámicamente
25
+ campos_vs_metodos.each do |campo, metodo|
26
+ define_method(metodo) do |dato|
27
+ @datos[campo] = dato
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def valores_iniciales
34
+ @datos['tipoDocumento'] = 'Factura'
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+ require 'fm_layout/fm_seccion'
3
+
4
+ module FmLayout
5
+ class Domicilio
6
+ include FmSeccion
7
+
8
+ def initialize(titulo = 'Domicilio')
9
+ @titulo = titulo
10
+ @datos = {}
11
+ valores_iniciales
12
+ end
13
+
14
+ def self.campos_vs_metodos
15
+ {
16
+ 'calle' => 'calle',
17
+ 'noExterior' => 'numero_exterior',
18
+ 'noInterior' => 'numero_interior',
19
+ 'colonia' => 'colonia',
20
+ 'localidad' => 'localidad',
21
+ 'municipio' => 'municipio',
22
+ 'estado' => 'estado',
23
+ 'pais' => 'pais',
24
+ 'codigoPostal' => 'codigo_postal',
25
+ }
26
+ end
27
+
28
+ # Creación de los métodos de acceso dinámicamente
29
+ campos_vs_metodos.each do |campo, metodo|
30
+ define_method(metodo) do |dato|
31
+ @datos[campo] = dato
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def valores_iniciales
38
+ @datos['pais'] = 'México'
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ require 'fm_layout/fm_seccion'
2
+
3
+ module FmLayout
4
+ class Emisor
5
+ include FmSeccion
6
+
7
+ def initialize
8
+ @titulo = 'Emisor'
9
+ @datos = {}
10
+ valores_iniciales
11
+ end
12
+
13
+ def self.campos_vs_metodos
14
+ {
15
+ 'rfc' => 'rfc',
16
+ 'nombre' => 'nombre',
17
+ 'RegimenFiscal' => 'regimen_fiscal',
18
+ }
19
+ end
20
+
21
+ # Creación de los métodos de acceso dinámicamente
22
+ campos_vs_metodos.each do |campo, metodo|
23
+ define_method(metodo) do |dato|
24
+ @datos[campo] = dato
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def valores_iniciales
31
+ @datos['rfc'] = nil
32
+ @datos['nombre'] = nil
33
+ @datos['RegimenFiscal'] = nil
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,54 @@
1
+ require 'fm_layout/fm_seccion'
2
+ module FmLayout
3
+ class Encabezado
4
+ include FmSeccion
5
+
6
+ def initialize
7
+ @titulo= 'Encabezado'
8
+ @datos= {}
9
+ valores_iniciales
10
+ end
11
+
12
+ def self.campos_vs_metodos
13
+ {
14
+ 'serie' => 'serie',
15
+ 'fecha' => 'fecha',
16
+ 'folio' => 'folio',
17
+ 'tipoDeComprobante' => 'tipo_de_comprobante',
18
+ 'formaDePago' => 'forma_de_pago',
19
+ 'metodoDePago' => 'metodo_de_pago',
20
+ 'condicionesDePago' => 'condiciones_de_pago',
21
+ 'NumCtaPago' => 'numero_de_cuenta_de_pago',
22
+ 'subTotal' => 'subtotal',
23
+ 'descuento' => 'descuento',
24
+ 'motivoDescuento' => 'motivo_de_descuento',
25
+ 'total' => 'total',
26
+ 'Moneda' => 'moneda',
27
+ 'TipoCambio' => 'tipo_de_cambio',
28
+ 'noCertificado' => 'numero_de_certificado',
29
+ 'LugarExpedicion' => 'lugar_de_expedicion'
30
+ }
31
+ end
32
+
33
+ # Creación de los métodos de acceso dinámicamente
34
+ campos_vs_metodos.each do |campo, metodo|
35
+ define_method(metodo) do |dato|
36
+ @datos[campo] = dato
37
+ end
38
+ end
39
+
40
+
41
+ private
42
+
43
+ def valores_iniciales
44
+ @datos['fecha'] = 'asignarFecha'
45
+ @datos['folio'] = 'asignarFolio'
46
+ @datos['NumCtaPago'] = 'No identificado'
47
+ @datos['noCertificado'] = nil
48
+ @datos['subTotal'] = nil
49
+ @datos['descuento'] = nil
50
+ @datos['total'] = nil
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,149 @@
1
+ require 'fm_layout/encabezado'
2
+ require 'fm_layout/datos_adicionales'
3
+ require 'fm_layout/emisor'
4
+ require 'fm_layout/receptor'
5
+ require 'fm_layout/domicilio'
6
+ require 'fm_layout/concepto'
7
+ require 'fm_layout/impuesto_trasladado'
8
+ require 'fm_layout/impuesto_retenido'
9
+ require 'fm_layout/nomina/nomina'
10
+
11
+ module FmLayout
12
+ class FmLayout
13
+ def initialize
14
+ @encabezado = Encabezado.new
15
+ @datos_adicionales = DatosAdicionales.new
16
+ @emisor = Emisor.new
17
+ @receptor= Receptor.new
18
+ @conceptos = []
19
+ @impuestos_trasladados = []
20
+ @impuestos_retenidos = []
21
+ end
22
+
23
+ def encabezado
24
+ if block_given?
25
+ yield(@encabezado)
26
+ else
27
+ @encabezado
28
+ end
29
+ end
30
+
31
+ def datos_adicionales
32
+ if block_given?
33
+ yield(@datos_adicionales)
34
+ else
35
+ @datos_adicionales
36
+ end
37
+ end
38
+
39
+ def emisor
40
+ if block_given?
41
+ yield(@emisor)
42
+ else
43
+ @emisor
44
+ end
45
+ end
46
+
47
+ def receptor
48
+ if block_given?
49
+ yield(@receptor)
50
+ else
51
+ @receptor
52
+ end
53
+ end
54
+
55
+ def domicilio_fiscal
56
+ @domicilio_fiscal ||= Domicilio.new('DomicilioFiscal')
57
+ if block_given?
58
+ yield(@domicilio_fiscal)
59
+ else
60
+ @domicilio_fiscal
61
+ end
62
+ end
63
+
64
+ def domicilio
65
+ @domicilio ||= Domicilio.new
66
+ if block_given?
67
+ yield(@domicilio)
68
+ else
69
+ @domicilio
70
+ end
71
+ end
72
+
73
+ def expedido_en
74
+ @expedido_en ||= Domicilio.new('ExpedidoEn')
75
+ if block_given?
76
+ yield(@expedido_en)
77
+ else
78
+ @expedido_en
79
+ end
80
+ end
81
+
82
+ def concepto
83
+ concepto = Concepto.new
84
+ if block_given?
85
+ yield(concepto)
86
+ @conceptos << concepto
87
+ else
88
+ concepto
89
+ end
90
+ end
91
+
92
+ def impuesto_trasladado
93
+ impuesto = ImpuestoTrasladado.new
94
+ if block_given?
95
+ yield(impuesto)
96
+ @impuestos_trasladados << impuesto
97
+ else
98
+ impuesto
99
+ end
100
+ end
101
+
102
+ def impuesto_retenido
103
+ impuesto = ImpuestoRetenido.new
104
+ if block_given?
105
+ yield(impuesto)
106
+ @impuestos_retenidos << impuesto
107
+ else
108
+ impuesto
109
+ end
110
+ end
111
+
112
+ def nomina
113
+ @nomina = Nomina::Nomina.new
114
+ if block_given?
115
+ yield(@nomina)
116
+ else
117
+ @nomina
118
+ end
119
+ end
120
+
121
+ def to_s
122
+ 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
123
+ salida += @conceptos.map(&:to_s).reduce(:+).to_s
124
+ salida += @impuestos_trasladados.map(&:to_s).reduce(:+).to_s
125
+ salida += @impuestos_retenidos.map(&:to_s).reduce(:+).to_s
126
+ salida += @nomina.to_s
127
+ salida
128
+ end
129
+
130
+ def to_h
131
+ {}.merge(@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)
132
+ end
133
+
134
+ private
135
+
136
+ def obtener_hash_conceptos
137
+ { 'Conceptos' => @conceptos.map(&:to_h) }
138
+ end
139
+
140
+ def obtener_hash_retenciones
141
+ {'ImpuestosRetenidos' => @impuestos_retenidos.map(&:to_h) }
142
+ end
143
+
144
+ def obtener_hash_traslados
145
+ { 'ImpuestosTrasladados' => @impuestos_trasladados.map(&:to_h) }
146
+ end
147
+
148
+ end
149
+ end
@@ -0,0 +1,21 @@
1
+ module FmLayout
2
+ module FmSeccion
3
+ def titulo
4
+ @titulo
5
+ end
6
+
7
+ def to_h
8
+ { @titulo => @datos }
9
+ end
10
+
11
+ def to_s
12
+ salida = "[#{@titulo}]\r\n\r\n"
13
+ @datos.each do |k,v|
14
+ salida += "#{k}|#{v}\r\n"
15
+ end
16
+ salida += "\r\n"
17
+ salida
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ require 'fm_layout/fm_seccion'
2
+
3
+ module FmLayout
4
+ class ImpuestoRetenido
5
+ include FmSeccion
6
+
7
+ def initialize
8
+ @titulo = 'ImpuestoRetenido'
9
+ @datos = {}
10
+ end
11
+
12
+ def self.campos_vs_metodos
13
+ {
14
+ 'impuesto' => 'impuesto',
15
+ 'importe' => 'importe',
16
+ }
17
+ end
18
+
19
+ # Creación de los métodos de acceso dinámicamente
20
+ campos_vs_metodos.each do |campo, metodo|
21
+ define_method(metodo) do |dato|
22
+ @datos[campo] = dato
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ require 'fm_layout/fm_seccion'
2
+
3
+ module FmLayout
4
+ class ImpuestoTrasladado
5
+ include FmSeccion
6
+
7
+ def initialize
8
+ @titulo = 'ImpuestoTrasladado'
9
+ @datos = {}
10
+ end
11
+
12
+ def self.campos_vs_metodos
13
+ {
14
+ 'impuesto' => 'impuesto',
15
+ 'importe' => 'importe',
16
+ 'tasa' => 'tasa',
17
+ }
18
+ end
19
+
20
+ # Creación de los métodos de acceso dinámicamente
21
+ campos_vs_metodos.each do |campo, metodo|
22
+ define_method(metodo) do |dato|
23
+ @datos[campo] = dato
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,48 @@
1
+ module FmLayout
2
+ module Nomina
3
+ class ComplementoNomina
4
+
5
+ include ::FmLayout::FmSeccion
6
+
7
+ def initialize
8
+ @titulo= 'ComplementoNomina'
9
+ @datos= {}
10
+ #valores_iniciales
11
+ end
12
+
13
+ def self.campos_vs_metodos
14
+ {
15
+ 'RegistroPatronal' => 'registro_patronal',
16
+ 'NumEmpleado' => 'numero_de_empleado',
17
+ 'CURP' => 'curp',
18
+ 'TipoRegimen' => 'tipo_de_regimen',
19
+ 'NumSeguridadSocial' => 'numero_de_seguridad_social',
20
+ 'FechaPago' => 'fecha_de_pago',
21
+ 'FechaInicialPago' => 'fecha_inicial_de_pago',
22
+ 'FechaFinalPago' => 'fecha_final_de_pago',
23
+ 'NumDiasPagados' => 'dias_pagados',
24
+ 'Departamento' => 'departamento',
25
+ 'CLABE' => 'clabe',
26
+ 'Banco' => 'banco',
27
+ 'FechaInicioRelLaboral' => 'inicio_de_relacion_laboral',
28
+ 'Antiguedad' => 'antiguedad',
29
+ 'Puesto' => 'puesto',
30
+ 'TipoContrato' => 'tipo_de_contrato',
31
+ 'TipoJornada' => 'tipo_de_jornada',
32
+ 'PeriodicidadPago' => 'periodicidad_de_pago',
33
+ 'SalarioBaseCotApor' => 'salario_base',
34
+ 'RiesgoPuesto' => 'riesgo_del_puesto',
35
+ 'SalarioDiarioIntegrado' => 'salario_diario_integrado',
36
+ }
37
+ end
38
+
39
+ # Creación de los métodos de acceso dinámicamente
40
+ campos_vs_metodos.each do |campo, metodo|
41
+ define_method(metodo) do |dato|
42
+ @datos[campo] = dato
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,32 @@
1
+ module FmLayout
2
+ module Nomina
3
+ class Deduccion
4
+
5
+ include ::FmLayout::FmSeccion
6
+
7
+ def initialize
8
+ @titulo= 'Deduccion'
9
+ @datos= {}
10
+ #valores_iniciales
11
+ end
12
+
13
+ def self.campos_vs_metodos
14
+ {
15
+ 'TipoPercepcion' => 'tipo',
16
+ 'Clave' => 'clave',
17
+ 'Concepto' => 'concepto',
18
+ 'ImporteGravado' => 'importe_gravado',
19
+ 'ImporteExento' => 'importe_exento',
20
+ }
21
+ end
22
+
23
+ # Creación de los métodos de acceso dinámicamente
24
+ campos_vs_metodos.each do |campo, metodo|
25
+ define_method(metodo) do |dato|
26
+ @datos[campo] = dato
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end