ftf 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 494597416fe65f24c8b90643c725bb9e5eac1d1ba835a6011bc17e8894d236d0
4
- data.tar.gz: c3c15e41f7c5e7a70d89b1a80b52c527424d5413fa7d9f7d79664500d6477274
3
+ metadata.gz: 19b1f7d77e30756b15b33be896b2421b429b8b49d7188c710875c342cdc721be
4
+ data.tar.gz: 1903586cb1ac65abda1d6b2f4b093fa04a441b8f859c52d181de85a074bcb140
5
5
  SHA512:
6
- metadata.gz: 686a36889dc6347f034861a4b41283c348a3717895f481a567e80f357383e3bcad7c273d9a7904e8d2e0b4929e7fd31a24b67d8ed46ae25db6e9d2b906c786f4
7
- data.tar.gz: 57483c191f63663b9ecdfe6fe062b9898c13f3f7fcd0146781b6b7f7f54813c389b54152a4c0a1eae1c7cc684d62b6e60c4c99e53aa496ab47e073d5aac9e18e
6
+ metadata.gz: a9390c484ae07e0d91eb038fe4e4df5ec34092ec4f389c7847d1ea935e6fcff6ab4954a61249fa72e2038015d64ad98661dd31625f7830ca3454c364c675b3d7
7
+ data.tar.gz: 43bda92fb12153f5323a1625cbcdfff65cbb7db9710169a4010e36cdef33322ff5926f86fa53bbb72c26b0b9d534d18a20698759189c0f1fb97114bf3dbc6e7d
data/lib/ftf/generator.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
+ require "debug"
5
+
4
6
  module FTF
5
7
  # Generate
6
8
  class Generator
@@ -47,7 +49,9 @@ module FTF
47
49
  write_record(product.render(@record_index))
48
50
  product.holders.each do |holder|
49
51
  write_record(holder(holder))
50
- write_record(relationship(holder.relationship))
52
+ holder.relationships.each do |relationship|
53
+ write_record(relationship(relationship))
54
+ end
51
55
  end
52
56
  write_record(product_footer(product))
53
57
  end
@@ -70,10 +74,10 @@ module FTF
70
74
  name: holder.name.to_s.ljust(178, " "),
71
75
  id_type: holder.id_type.to_s.rjust(2, "0"),
72
76
  id: holder.id.to_s.ljust(30, " "),
73
- expedition_country: holder.country.to_s.ljust(2, " "),
77
+ expedition_country: holder.expedition_country.to_s.ljust(2, " "),
74
78
  created_at: holder.created_at.ljust(8, " "),
75
- nationality_country: holder.country.to_s.ljust(2, " "),
76
- residence_country: holder.country.to_s.ljust(2, " "),
79
+ nationality_country: holder.nationality_country.to_s.ljust(2, " "),
80
+ residence_country: holder.residence_country.to_s.ljust(2, " "),
77
81
  reserved_field: " " * 4
78
82
  }
79
83
  fields.values.join
@@ -3,12 +3,12 @@
3
3
  module FTF
4
4
  module Mappings
5
5
  class Holder
6
- attr_reader :product, :relationship
6
+ attr_reader :product, :relationships
7
7
 
8
8
  def initialize(data, product)
9
9
  @data = data
10
10
  @product = product
11
- @relationship = Relationship.new(@data[:relationships].first, self)
11
+ @relationships = @data[:relationships].map { |relationship| Relationship.new(relationship, self) }
12
12
  end
13
13
 
14
14
  def action
@@ -31,8 +31,16 @@ module FTF
31
31
  @data[:created_at]
32
32
  end
33
33
 
34
- def country
35
- @data[:country]
34
+ def expedition_country
35
+ @data[:expedition_country]
36
+ end
37
+
38
+ def nationality_country
39
+ @data[:nationality_country]
40
+ end
41
+
42
+ def residence_country
43
+ @data[:residence_country]
36
44
  end
37
45
  end
38
46
  end
data/lib/ftf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FTF
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
data/test.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "fiscal_id": "B89896427",
3
+ "period": "202512",
4
+ "file_index": 1,
5
+ "request_id": "",
6
+ "file_type": "M",
7
+ "products": [
8
+ {
9
+ "action": "A",
10
+ "type": "01",
11
+ "id_type": "01",
12
+ "id": "ES7531602870987210103471",
13
+ "created_at": "20251201",
14
+ "holders": [
15
+ {
16
+ "action": "A",
17
+ "name": "WESIZE SL",
18
+ "id_type": "01",
19
+ "id": "A72605108",
20
+ "created_at": "20251113",
21
+ "expedition_country": "ES",
22
+ "nationality_country": "ES",
23
+ "residence_country": "ES",
24
+ "relationships": [
25
+ {
26
+ "action": "A",
27
+ "type": "TIT",
28
+ "created_at": "20251201"
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "action": "A",
34
+ "name": "Antonio García López",
35
+ "id_type": "01",
36
+ "id": "99971126Q",
37
+ "created_at": "19810213",
38
+ "expedition_country": "ES",
39
+ "nationality_country": "ES",
40
+ "residence_country": "ES",
41
+ "relationships": [
42
+ {
43
+ "action": "A",
44
+ "type": "TRE",
45
+ "created_at": "20251215"
46
+ },
47
+ {
48
+ "action": "A",
49
+ "type": "REP",
50
+ "created_at": "20251215"
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "action": "A",
58
+ "type": "01",
59
+ "id_type": "01",
60
+ "id": "ES1600853664879672604126",
61
+ "created_at": "20251201",
62
+ "holders": [
63
+ {
64
+ "action": "A",
65
+ "name": "DOMIMINT SL",
66
+ "id_type": "04",
67
+ "id": "GB633223668",
68
+ "created_at": "20230129",
69
+ "expedition_country": "ES",
70
+ "nationality_country": "GB",
71
+ "residence_country": "GB",
72
+ "relationships": [
73
+ {
74
+ "action": "A",
75
+ "type": "TIT",
76
+ "created_at": "20251201"
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ "action": "A",
82
+ "name": "Benicio Mathews",
83
+ "id_type": "02",
84
+ "id": "Y3777307P",
85
+ "created_at": "19880604",
86
+ "expedition_country": "IT",
87
+ "nationality_country": "IT",
88
+ "residence_country": "GB",
89
+ "relationships": [
90
+ {
91
+ "action": "A",
92
+ "type": "TRE",
93
+ "created_at": "20251222"
94
+ },
95
+ {
96
+ "action": "A",
97
+ "type": "REP",
98
+ "created_at": "20251222"
99
+ }
100
+ ]
101
+ }
102
+ ]
103
+ }
104
+ ]
105
+ }
data/test_generate.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "lib/ftf"
5
+
6
+ json = File.read("test.json")
7
+ JSON.parse(json)
8
+ puts "Generating FTF file..."
9
+ FTF::Generator.new(json).generate!
10
+ puts "FTF file generated successfully"
data/test_validate.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "lib/ftf"
5
+
6
+ begin
7
+ json = File.read("test.json")
8
+ JSON.parse(json)
9
+ puts "JSON file is valid"
10
+ FTF::Generator.new(json).validate!
11
+ rescue JSON::ParserError => e
12
+ puts "JSON file is invalid: #{e.message}"
13
+ rescue FTF::Generator::ValidationError => e
14
+ puts "File is not a valid FTF JSON File: #{e.message}"
15
+ end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aitor García Rey
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-01-16 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: fiddle
@@ -86,6 +87,9 @@ files:
86
87
  - lib/ftf/refinements.rb
87
88
  - lib/ftf/version.rb
88
89
  - sig/ftf.rbs
90
+ - test.json
91
+ - test_generate.rb
92
+ - test_validate.rb
89
93
  homepage: https://github.com/devengoapp/ftf
90
94
  licenses:
91
95
  - MIT
@@ -93,6 +97,7 @@ metadata:
93
97
  homepage_uri: https://github.com/devengoapp/ftf
94
98
  source_code_uri: https://github.com/devengoapp/ftf
95
99
  rubygems_mfa_required: 'true'
100
+ post_install_message:
96
101
  rdoc_options: []
97
102
  require_paths:
98
103
  - lib
@@ -107,7 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
112
  - !ruby/object:Gem::Version
108
113
  version: '0'
109
114
  requirements: []
110
- rubygems_version: 3.6.7
115
+ rubygems_version: 3.3.3
116
+ signing_key:
111
117
  specification_version: 4
112
118
  summary: A ruby gem to generate FTF files for SEPBLAC
113
119
  test_files: []