ftf 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +12 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +92 -0
- data/Rakefile +12 -0
- data/lib/ftf/generator.rb +128 -0
- data/lib/ftf/mappings/holder.rb +39 -0
- data/lib/ftf/mappings/product.rb +59 -0
- data/lib/ftf/mappings/relationship.rb +34 -0
- data/lib/ftf/mappings/report.rb +54 -0
- data/lib/ftf/records/base.rb +31 -0
- data/lib/ftf/records/footer.rb +24 -0
- data/lib/ftf/records/header.rb +24 -0
- data/lib/ftf/records/product.rb +29 -0
- data/lib/ftf/refinements.rb +11 -0
- data/lib/ftf/version.rb +5 -0
- data/lib/ftf.rb +6 -0
- data/sig/ftf.rbs +4 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b078e42531dae8b648402c545974e968802c9f6450c27f752c481c08378da09a
|
4
|
+
data.tar.gz: 70d63fe5d1644def9558e67c02f20a1968ee85f4db4cb1afa9cdfa60d46f79c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e65e19794e27d4034d7fccfd065aff72a7c2a43e8a9b094aa8d751fe916139cb664b4570a2a5b17361864e177a7f59a704639d48910565fe7cd9a66b6f58e586
|
7
|
+
data.tar.gz: 84de11185ee52af389f0d41ceec5fa9df6d2c471a0f8b07e21b2faaac0b6d7cc045e82ee36884f1c1a796fbe6015058748627f876fc18b9291d6d5f018a91174
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Aitor García Rey
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Ftf
|
2
|
+
|
3
|
+
- El procedimiento de envío de los ficheros se hará exclusivamente por vía de Editran
|
4
|
+
- Solo se enviará un fichero de texto con codificación de caracteres ISO8859-1.
|
5
|
+
- Se deben declarar las aperturas, cancelaciones y modificaciones de:
|
6
|
+
- cuentas corrientes
|
7
|
+
- cuentas de ahorro
|
8
|
+
- depósitos
|
9
|
+
- cualquier otro tipo de cuentas de pago
|
10
|
+
- los contratos de alquiler de cajas de seguridad.
|
11
|
+
- El formato de los campos con datos seguirá las siguientes especificaciones:
|
12
|
+
- Si su formato es numérico, deben alinearse a la derecha y completarse con ceros a la izquierda hasta completar el tamaño del campo. No hay cifras decimales.
|
13
|
+
- Si su formato es alfanumérico, y no se especifica lo contrario, deben alinearse a la izquierda y completarse con espacios a la derecha hasta completar el tamaño del campo.
|
14
|
+
- Tipos de registro:
|
15
|
+
- "00" - Registro de Cabecera
|
16
|
+
- "10" - Registro de producto
|
17
|
+
- Accion "A" para nuevo registro, "M" para modificar un producto existente y "X" para borrar un producto del FTF
|
18
|
+
- "11" - Cambio numeración
|
19
|
+
- Accion "A" para nueva numeración, "M" para modificar la numeración existente y "X" para borrar la numeración
|
20
|
+
- "20" - Registro interviniente
|
21
|
+
- Accion "A" para nuevo registro, "M" para modificar la relacion entre interviniente y producto
|
22
|
+
- "21" - Registro de cambio en el nombre del interviniente
|
23
|
+
- Accion "A" para nuevo indicar el nuevo nombre, "M" para corregir el nombre presentado y "X" para borrarlo.
|
24
|
+
- "22" - Registro de cambio en el documento identificativo
|
25
|
+
- Accion "A" para nuevo indicar el nuevo nombre, "M" para corregir el documento presentado y "X" para borrarlo.
|
26
|
+
- "30" - Registro de tipo de intervención
|
27
|
+
- Accion "A" para nuevo indicar el nuevo nombre, "M" para corregir el tipo y "X" para borrarlo.
|
28
|
+
- "19" - Registro de Final de producto
|
29
|
+
- Cierra el registro de tipo "10"
|
30
|
+
- "99" - Registro de Final de fichero
|
31
|
+
|
32
|
+
- Fichero negativo: 1 record 00 + 1 record 99
|
33
|
+
- Fichero mensual:
|
34
|
+
- 1 record 00
|
35
|
+
- N records 10 // Bloque de producto
|
36
|
+
- 0-N records 11
|
37
|
+
- 0-N records 20
|
38
|
+
- 1-N records 30
|
39
|
+
- 1 record 19
|
40
|
+
- N records 20 // Bloque de interviniente
|
41
|
+
- 0-N records 21
|
42
|
+
- 0-N records 22
|
43
|
+
- 1 record 99
|
44
|
+
{
|
45
|
+
"fiscal_id": "",
|
46
|
+
"request_id": "",
|
47
|
+
"type": "",
|
48
|
+
"products": [
|
49
|
+
|
50
|
+
]
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ftf`. To experiment with that code, run `bin/console` for an interactive prompt.
|
55
|
+
|
56
|
+
## Installation
|
57
|
+
|
58
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
59
|
+
|
60
|
+
Install the gem and add to the application's Gemfile by executing:
|
61
|
+
|
62
|
+
```bash
|
63
|
+
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
64
|
+
```
|
65
|
+
|
66
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
67
|
+
|
68
|
+
```bash
|
69
|
+
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
70
|
+
```
|
71
|
+
|
72
|
+
## Usage
|
73
|
+
|
74
|
+
TODO: Write usage instructions here
|
75
|
+
|
76
|
+
## Development
|
77
|
+
|
78
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
79
|
+
|
80
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/aitor/ftf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/aitor/ftf/blob/main/CODE_OF_CONDUCT.md).
|
85
|
+
|
86
|
+
## License
|
87
|
+
|
88
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
89
|
+
|
90
|
+
## Code of Conduct
|
91
|
+
|
92
|
+
Everyone interacting in the Ftf project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/aitor/ftf/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require "json"
|
2
|
+
module FTF
|
3
|
+
# Generate
|
4
|
+
class Generator
|
5
|
+
using Refinements
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@report = Mappings::Report.new(data)
|
9
|
+
@record_index = 1
|
10
|
+
validate!
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate!
|
14
|
+
if !@report.request_id.blank? && @report.file_type != ("C")
|
15
|
+
raise "Files generated for a request id must be complementary (type C)"
|
16
|
+
end
|
17
|
+
if @report.products.empty? && @report.file_type != ("N")
|
18
|
+
raise "Files generated without product records must be negative (type N)"
|
19
|
+
end
|
20
|
+
if !@report.products.empty? && !%w[M C].include?(@report.file_type)
|
21
|
+
raise "Files generated with product records must be monthly or complementary (type M or C)"
|
22
|
+
end
|
23
|
+
raise "Please include your fiscal_id in the data" if @report.fiscal_id.blank?
|
24
|
+
raise "Please include your period in the data" if @report.period.blank?
|
25
|
+
raise "Please include your file_type in the data" if @report.file_type.blank?
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse(data)
|
29
|
+
case data
|
30
|
+
when Hash
|
31
|
+
data
|
32
|
+
when String
|
33
|
+
JSON.parse(data, symbolize_names: true)
|
34
|
+
else
|
35
|
+
raise "Please provide a JSON string to parse or a symbol-keyed hash"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def generate!
|
40
|
+
@output = File.new(filename, "w", external_encoding: Encoding::ISO8859_1)
|
41
|
+
|
42
|
+
write_record(@report.render_header(@record_index))
|
43
|
+
|
44
|
+
@report.products.each do |product|
|
45
|
+
write_record(product.render(@record_index))
|
46
|
+
product.holders.each do |holder|
|
47
|
+
write_record(holder(holder))
|
48
|
+
write_record(relationship(holder.relationship))
|
49
|
+
end
|
50
|
+
write_record(product_footer(product))
|
51
|
+
end
|
52
|
+
|
53
|
+
write_record(@report.render_footer(@record_index))
|
54
|
+
@output.close
|
55
|
+
end
|
56
|
+
|
57
|
+
def write_record(record)
|
58
|
+
@output.puts(record)
|
59
|
+
@record_index += 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def holder(holder)
|
63
|
+
fields = {
|
64
|
+
record_type: "20",
|
65
|
+
action: holder.action,
|
66
|
+
fiscal_id: @report.fiscal_id,
|
67
|
+
record_index: @record_index.to_s.rjust(10, "0"),
|
68
|
+
name: holder.name.to_s.ljust(178, " "),
|
69
|
+
id_type: holder.id_type.to_s.rjust(2, "0"),
|
70
|
+
id: holder.id.to_s.rjust(30, " "),
|
71
|
+
expedition_country: holder.country.to_s.rjust(2, " "),
|
72
|
+
created_at: holder.created_at.ljust(8, " "),
|
73
|
+
nationality_country: holder.country.to_s.rjust(2, " "),
|
74
|
+
residence_country: holder.country.to_s.rjust(2, " "),
|
75
|
+
reserved_field: " " * 4
|
76
|
+
}
|
77
|
+
fields.values.join
|
78
|
+
end
|
79
|
+
|
80
|
+
def relationship(relationship)
|
81
|
+
fields = {
|
82
|
+
record_type: "30",
|
83
|
+
action: relationship.action,
|
84
|
+
fiscal_id: @report.fiscal_id,
|
85
|
+
record_index: @record_index.to_s.rjust(10, "0"),
|
86
|
+
type: relationship.type.to_s.ljust(3, " "),
|
87
|
+
created_at: relationship.created_at.ljust(8, " "),
|
88
|
+
canceled_at: relationship.canceled_at.ljust(8, " "),
|
89
|
+
previous_type: relationship.previous_type.to_s.ljust(3, " "),
|
90
|
+
reserved_field: " " * 206
|
91
|
+
}
|
92
|
+
fields.values.join
|
93
|
+
end
|
94
|
+
|
95
|
+
def product_footer(product)
|
96
|
+
fields = {
|
97
|
+
record_type: "19",
|
98
|
+
fiscal_id: @report.fiscal_id,
|
99
|
+
record_index: @record_index.to_s.rjust(10, "0"),
|
100
|
+
type: product.type.to_s.rjust(2, "0"),
|
101
|
+
id_type: product.id_type.to_s.rjust(2, "0"),
|
102
|
+
id: product.id.to_s.rjust(38, " "),
|
103
|
+
reserved_field: " " * 187
|
104
|
+
}
|
105
|
+
fields.values.join
|
106
|
+
end
|
107
|
+
|
108
|
+
def footer
|
109
|
+
fields = {
|
110
|
+
record_type: "99",
|
111
|
+
fiscal_id: @report.fiscal_id,
|
112
|
+
record_index: @record_index.to_s.rjust(10, "0"),
|
113
|
+
product_records_count: "777".rjust(10, "0"), # fix
|
114
|
+
total_records_count: @record_index.to_s.rjust(10, "0"),
|
115
|
+
reserved_field: " " * 209
|
116
|
+
}
|
117
|
+
fields.values.join
|
118
|
+
end
|
119
|
+
|
120
|
+
def filename
|
121
|
+
"FTF_#{@report.fiscal_id}_#{@report.period}_#{@report.index}.txt"
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.generate!(data)
|
125
|
+
new(data).generate!
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Mappings
|
5
|
+
class Holder
|
6
|
+
attr_reader :product, :relationship
|
7
|
+
|
8
|
+
def initialize(data, product)
|
9
|
+
@data = data
|
10
|
+
@product = product
|
11
|
+
@relationship = Relationship.new(@data[:relationship], self)
|
12
|
+
end
|
13
|
+
|
14
|
+
def action
|
15
|
+
@data[:action]
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
@data[:name]
|
20
|
+
end
|
21
|
+
|
22
|
+
def id_type
|
23
|
+
@data[:id_type]
|
24
|
+
end
|
25
|
+
|
26
|
+
def id
|
27
|
+
@data[:id]
|
28
|
+
end
|
29
|
+
|
30
|
+
def created_at
|
31
|
+
@data[:created_at]
|
32
|
+
end
|
33
|
+
|
34
|
+
def country
|
35
|
+
@data[:country]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Mappings
|
5
|
+
class Product
|
6
|
+
attr_reader :file, :holders
|
7
|
+
|
8
|
+
def initialize(data, file)
|
9
|
+
@data = data
|
10
|
+
@file = file
|
11
|
+
@holders = @data[:holders].map { |holder| Holder.new(holder, self) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(index)
|
15
|
+
Records::Product.new(index, self).render
|
16
|
+
end
|
17
|
+
|
18
|
+
def action
|
19
|
+
@data[:action]
|
20
|
+
end
|
21
|
+
|
22
|
+
def type
|
23
|
+
@data[:type]
|
24
|
+
end
|
25
|
+
|
26
|
+
def id_type
|
27
|
+
@data[:id_type]
|
28
|
+
end
|
29
|
+
|
30
|
+
def id
|
31
|
+
@data[:id]
|
32
|
+
end
|
33
|
+
|
34
|
+
def created_at
|
35
|
+
@data[:created_at]
|
36
|
+
end
|
37
|
+
|
38
|
+
def canceled_at
|
39
|
+
@data[:canceled_at]
|
40
|
+
end
|
41
|
+
|
42
|
+
def transfered_at
|
43
|
+
@data[:transfered_at]
|
44
|
+
end
|
45
|
+
|
46
|
+
def transfered_entity_id
|
47
|
+
@data[:transfered_entity_id]
|
48
|
+
end
|
49
|
+
|
50
|
+
def lease_type
|
51
|
+
@data[:lease_type]
|
52
|
+
end
|
53
|
+
|
54
|
+
def lease_period
|
55
|
+
@data[:lease_period]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Mappings
|
5
|
+
class Relationship
|
6
|
+
attr_reader :holder
|
7
|
+
|
8
|
+
def initialize(data, holder)
|
9
|
+
@data = data
|
10
|
+
@holder = holder
|
11
|
+
end
|
12
|
+
|
13
|
+
def action
|
14
|
+
@data[:action]
|
15
|
+
end
|
16
|
+
|
17
|
+
def type
|
18
|
+
@data[:type]
|
19
|
+
end
|
20
|
+
|
21
|
+
def created_at
|
22
|
+
@data[:created_at]
|
23
|
+
end
|
24
|
+
|
25
|
+
def canceled_at
|
26
|
+
@data[:canceled_at].to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def previous_type
|
30
|
+
@data[:previous_type]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Mappings
|
5
|
+
class Report
|
6
|
+
attr_reader :products
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
@data = parse(data)
|
10
|
+
@products = @data[:products].map { |product| Product.new(product, self) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse(data)
|
14
|
+
case data
|
15
|
+
when Hash
|
16
|
+
data
|
17
|
+
when String
|
18
|
+
JSON.parse(data, symbolize_names: true)
|
19
|
+
else
|
20
|
+
raise "Please provide a JSON string to parse or a symbol-keyed hash"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def render_header(index)
|
25
|
+
Records::Header.new(index, self).render
|
26
|
+
end
|
27
|
+
|
28
|
+
def render_footer(index)
|
29
|
+
Records::Footer.new(index, self).render
|
30
|
+
end
|
31
|
+
|
32
|
+
def fiscal_id
|
33
|
+
@data[:fiscal_id]
|
34
|
+
end
|
35
|
+
|
36
|
+
def period
|
37
|
+
@data[:period]
|
38
|
+
end
|
39
|
+
|
40
|
+
def file_type
|
41
|
+
@data[:file_type]
|
42
|
+
end
|
43
|
+
|
44
|
+
def request_id
|
45
|
+
@data[:request_id]
|
46
|
+
end
|
47
|
+
|
48
|
+
def index
|
49
|
+
index = @data[:index] || 1
|
50
|
+
index.to_s.rjust(3, "0")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Records
|
5
|
+
class Base
|
6
|
+
attr_reader :index, :data
|
7
|
+
|
8
|
+
def initialize(index, data)
|
9
|
+
@index = index
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def identifier
|
14
|
+
raise "Please provide a record identifier"
|
15
|
+
end
|
16
|
+
|
17
|
+
def padding(data, size)
|
18
|
+
case data
|
19
|
+
when Integer
|
20
|
+
data.to_s.rjust(size, "0")
|
21
|
+
else
|
22
|
+
data.to_s.ljust(size, " ")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def render
|
27
|
+
{ identifier: identifier }.merge(fields).values.join
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Records
|
5
|
+
class Footer < Base
|
6
|
+
def identifier
|
7
|
+
"99"
|
8
|
+
end
|
9
|
+
|
10
|
+
def fields
|
11
|
+
{
|
12
|
+
fiscal_id: data.fiscal_id,
|
13
|
+
record_index: padding(index, 10),
|
14
|
+
period: data.period,
|
15
|
+
index: data.index,
|
16
|
+
file_type: data.file_type,
|
17
|
+
reserved_field1: padding("", 18),
|
18
|
+
request_id: padding(data.request_id, 15),
|
19
|
+
reserved_field2: padding("", 186)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Records
|
5
|
+
class Header < Base
|
6
|
+
def identifier
|
7
|
+
"00"
|
8
|
+
end
|
9
|
+
|
10
|
+
def fields
|
11
|
+
{
|
12
|
+
fiscal_id: data.fiscal_id,
|
13
|
+
record_index: padding(index, 10),
|
14
|
+
period: data.period,
|
15
|
+
index: data.index,
|
16
|
+
file_type: data.file_type,
|
17
|
+
reserved_field1: padding("", 18),
|
18
|
+
request_id: padding(data.request_id, 15),
|
19
|
+
reserved_field2: padding("", 186)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FTF
|
4
|
+
module Records
|
5
|
+
class Product < Base
|
6
|
+
def identifier
|
7
|
+
"10"
|
8
|
+
end
|
9
|
+
|
10
|
+
def fields
|
11
|
+
{
|
12
|
+
action: data.action,
|
13
|
+
fiscal_id: data.file.fiscal_id,
|
14
|
+
record_index: padding(index, 10),
|
15
|
+
type: data.type.to_s.rjust(2, "0"),
|
16
|
+
id_type: data.id_type.to_s.rjust(2, "0"),
|
17
|
+
id: data.id.to_s.rjust(38, " "),
|
18
|
+
created_at: data.created_at.ljust(8, " "),
|
19
|
+
canceled_at: data.canceled_at.to_s.ljust(8, " "),
|
20
|
+
transfered_at: data.transfered_at.to_s.ljust(8, " "),
|
21
|
+
transfered_entity_id: data.transfered_entity_id.to_s.ljust(20, " "),
|
22
|
+
lease_type: data.lease_type.to_s.ljust(1, " "),
|
23
|
+
lease_period: data.lease_period.to_s.ljust(4, " "),
|
24
|
+
reserved_field: " " * 137
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/ftf/version.rb
ADDED
data/lib/ftf.rb
ADDED
data/sig/ftf.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ftf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aitor García Rey
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-02-11 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: fiddle
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.1'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '1.1'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rdoc
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.11'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '6.11'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: zeitwerk
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.7'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.7'
|
54
|
+
description: Generate SEPBLAC FTF valid files from a json
|
55
|
+
email:
|
56
|
+
- aitor@devengo.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".rspec"
|
62
|
+
- ".rubocop.yml"
|
63
|
+
- CHANGELOG.md
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/ftf.rb
|
69
|
+
- lib/ftf/generator.rb
|
70
|
+
- lib/ftf/mappings/holder.rb
|
71
|
+
- lib/ftf/mappings/product.rb
|
72
|
+
- lib/ftf/mappings/relationship.rb
|
73
|
+
- lib/ftf/mappings/report.rb
|
74
|
+
- lib/ftf/records/base.rb
|
75
|
+
- lib/ftf/records/footer.rb
|
76
|
+
- lib/ftf/records/header.rb
|
77
|
+
- lib/ftf/records/product.rb
|
78
|
+
- lib/ftf/refinements.rb
|
79
|
+
- lib/ftf/version.rb
|
80
|
+
- sig/ftf.rbs
|
81
|
+
homepage: https://github.com/devengoapp/ftf
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata:
|
85
|
+
homepage_uri: https://github.com/devengoapp/ftf
|
86
|
+
source_code_uri: https://github.com/devengoapp/ftf
|
87
|
+
rubygems_mfa_required: 'true'
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 3.0.0
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubygems_version: 3.6.2
|
103
|
+
specification_version: 4
|
104
|
+
summary: A ruby gem to generate FTF files for SEPBLAC
|
105
|
+
test_files: []
|