saft 0.1.1 → 0.2.1

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: 0dbac905e282930a2cb6da9bcbecdecf0ef0bd071aa5c45418f3795204d161d8
4
- data.tar.gz: 316fe426fbac259057ffdfa4f279741f3d3c3cba22dac1ee854e7448843fe35e
3
+ metadata.gz: 7cb83ea3a9f978153d3dcbb5be4575ede05fb1df38022c22f868df05e09ab7cc
4
+ data.tar.gz: cade2d53d95a5b8648cd7875769c35b07ef87c506a2bbd753ade70f2712a2db7
5
5
  SHA512:
6
- metadata.gz: 2f307ff77d1749615135d194bfc2eda65352a856330c22a79a6db32575ea1c074362b2e9b73f3429328622673eddc5c76d847896ba0a17b61bcab6803ca8e198
7
- data.tar.gz: 26d34531bea91a1981e3bcd47204d648f222890ff0f74c3c46530d1a887e40d7174968cc4872eecf31ce191b4fb9fa9300f0b515780e664b146f6c2e317a9350
6
+ metadata.gz: '0209f4df73c503e4c2d3e60ba9c0c50cf95861a3468d13177e47e489a3348099ed0a41211088d5db8863393ea00ed2e2ad8e79818c7a446a3085b119778db139'
7
+ data.tar.gz: c6c3d1e4f618b19ecfc90e537d2c620e350a6d8c2d18b51e729b1f59a59a7faaaba2c3399db71d5adba4bca750683e071f0b2af22ba56f3c31005db30a49a629
data/.gemspec CHANGED
@@ -8,20 +8,21 @@ Gem::Specification.new do |spec|
8
8
  spec.summary = "SAF-T parser and writer"
9
9
  spec.authors = ["Dodo developer", "Simon Toivo Telhaug"]
10
10
  spec.email = ["simon.toivo.telhaug@dev.dodo.no"]
11
- # spec.homepage = "http://tba.no"
11
+ spec.homepage = "https://github.com/dodoas/ruby-saft"
12
12
 
13
13
  spec.license = "MIT"
14
14
  spec.required_ruby_version = ">= 2.6.0"
15
- # spec.metadata["homepage_uri"] = spec.homepage
16
- # spec.metadata["source_code_uri"] = spec.homepage
17
- # spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject do |f|
23
- (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git))})
24
- end
22
+ `git ls-files -z`.split("\x0")
23
+ .reject { |f| f == __FILE__ }
24
+ .reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git))}) }
25
+ .reject { |f| f.start_with? "docs/" }
25
26
  end
26
27
 
27
28
  spec.bindir = "exe"
data/.rubocop.yml CHANGED
@@ -19,7 +19,7 @@ inherit_from:
19
19
  - .rubocop_strict.yml
20
20
 
21
21
  AllCops:
22
- TargetRubyVersion: 3.1
22
+ TargetRubyVersion: 3.2
23
23
 
24
24
  # Sometimes we enable metrics cops
25
25
  # (which are disabled in Standard by default)
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1]
4
+
5
+ - add invalid? to SAFT::V2::XsdValidate
6
+
3
7
  ## [0.1.0] - 2022-11-23
4
8
 
5
9
  - Initial release
data/lib/saft/v2/html.rb CHANGED
@@ -14,10 +14,11 @@ module SAFT::V2
14
14
  end
15
15
 
16
16
  def self.format_big_decimal(big_decimal)
17
- integer, decimal = big_decimal.to_s("F").split(".")
17
+ negative = big_decimal.negative?
18
+ integer, decimal = big_decimal.abs.to_s("F").split(".")
18
19
  integer = integer.reverse.scan(/.{1,3}/).join(" ").reverse
19
20
 
20
- "#{integer},#{decimal.ljust(2, "0")}"
21
+ "#{negative ? "-" : ""}#{integer},#{decimal.ljust(2, "0")}"
21
22
  end
22
23
 
23
24
  module DryStructRenderTubby
@@ -121,7 +122,7 @@ module SAFT::V2
121
122
  end
122
123
 
123
124
  if tax_table
124
- t.strong("Tax able")
125
+ t.strong("Tax table")
125
126
  t.div(class: "pl-2 border-l-2") { t << TaxTable.new(tax_table) }
126
127
  end
127
128
 
data/lib/saft/v2/types.rb CHANGED
@@ -19,7 +19,7 @@ module SAFT::V2::Types
19
19
  Decimal = Coercible::Decimal
20
20
  Bool = Params::Bool
21
21
  String = Strict::String
22
- PositiveInteger = Types::Integer.constrained(gteq: 0)
22
+ NonNegativeIntegers = Types::Integer.constrained(gteq: 0)
23
23
  end
24
24
 
25
25
  # not Ideal as we are extending the global scope
@@ -30,7 +30,7 @@ module SAFT::V2::Types
30
30
  n_significant_digits <= num
31
31
  end
32
32
 
33
- Dry::Logic::Predicates.predicate(:fraction_digitst?) do |num, input|
33
+ Dry::Logic::Predicates.predicate(:fraction_digits?) do |num, input|
34
34
  digits?(num, input.frac)
35
35
  end
36
36
 
@@ -97,9 +97,9 @@ module SAFT::V2::Types
97
97
  attribute(:company_entity, base::SAFmiddle2textType.optional.meta(omittable: true))
98
98
  attribute(:selection_start_date, Types::Date.optional.meta(omittable: true))
99
99
  attribute(:selection_end_date, Types::Date.optional.meta(omittable: true))
100
- attribute(:period_start, Types::PositiveInteger.optional.meta(omittable: true))
100
+ attribute(:period_start, Types::NonNegativeIntegers.optional.meta(omittable: true))
101
101
  attribute(:period_start_year, Types::Integer.constrained(gteq: 1970).constrained(lteq: 2100).optional.meta(omittable: true))
102
- attribute(:period_end, Types::PositiveInteger.optional.meta(omittable: true))
102
+ attribute(:period_end, Types::NonNegativeIntegers.optional.meta(omittable: true))
103
103
  attribute(:period_end_year, Types::Integer.constrained(gteq: 1970).constrained(lteq: 2100).optional.meta(omittable: true))
104
104
  attribute(:document_type, base::SAFlongtextType.optional.meta(omittable: true))
105
105
  attribute(:other_criterias, Types::Array.of(base::SAFlongtextType).optional.meta(omittable: true))
@@ -121,9 +121,9 @@ module SAFT::V2::Types
121
121
  base.const_set(:PersonNameStructure, klass)
122
122
 
123
123
  klass = Class.new(Dry::Struct) do
124
- attribute(:days, Types::PositiveInteger.optional.meta(omittable: true))
125
- attribute(:months, Types::PositiveInteger.optional.meta(omittable: true))
126
- attribute(:cash_discount_days, Types::PositiveInteger.optional.meta(omittable: true))
124
+ attribute(:days, Types::NonNegativeIntegers.optional.meta(omittable: true))
125
+ attribute(:months, Types::NonNegativeIntegers.optional.meta(omittable: true))
126
+ attribute(:cash_discount_days, Types::NonNegativeIntegers.optional.meta(omittable: true))
127
127
  attribute(:cash_discount_rate, Types::Decimal.constrained(gteq: 0).constrained(lteq: 100).optional.meta(omittable: true))
128
128
  attribute(:free_billing_month, Types::Bool.optional.meta(omittable: true))
129
129
  end
@@ -449,10 +449,10 @@ module SAFT::V2::Types
449
449
  SAFmiddle1textType = Types::String.constrained(max_size: 35)
450
450
  SAFmiddle2textType = Types::String.constrained(max_size: 70)
451
451
  SAFlongtextType = Types::String.constrained(max_size: 256)
452
- SAFmonetaryType = Types::Decimal.constrained(digits: 18, fraction_digitst: 2)
453
- SAFexchangerateType = Types::Decimal.constrained(digits: 18, fraction_digitst: 8)
454
- SAFquantityType = Types::Decimal.constrained(digits: 22, fraction_digitst: 6)
455
- SAFweightType = Types::Decimal.constrained(digits: 14, fraction_digitst: 3)
452
+ SAFmonetaryType = Types::Decimal.constrained(digits: 18, fraction_digits: 2)
453
+ SAFexchangerateType = Types::Decimal.constrained(digits: 18, fraction_digits: 8)
454
+ SAFquantityType = Types::Decimal.constrained(digits: 22, fraction_digits: 6)
455
+ SAFweightType = Types::Decimal.constrained(digits: 14, fraction_digits: 3)
456
456
  AddressType = Types::String.enum("StreetAddress", "PostalAddress", "BillingAddress", "ShipToAddress", "ShipFromAddress")
457
457
 
458
458
  extend ObjectStrutures
@@ -476,12 +476,12 @@ module SAFT::V2::Types
476
476
  SAFmiddle1textType = Types.Constructor(Strict::SAFmiddle1textType, &slice_string(35))
477
477
  SAFmiddle2textType = Types.Constructor(Strict::SAFmiddle2textType, &slice_string(70))
478
478
  SAFlongtextType = Types.Constructor(Strict::SAFlongtextType, &slice_string(256))
479
- SAFmonetaryType = Types::Decimal.constrained(digits: 18, fraction_digitst: 2)
480
- SAFexchangerateType = Types::Decimal.constrained(digits: 18, fraction_digitst: 8)
481
- SAFquantityType = Types::Decimal.constrained(digits: 22, fraction_digitst: 6)
482
- SAFweightType = Types::Decimal.constrained(digits: 14, fraction_digitst: 3)
479
+ SAFmonetaryType = Strict::SAFmonetaryType
480
+ SAFexchangerateType = Strict::SAFexchangerateType
481
+ SAFquantityType = Strict::SAFquantityType
482
+ SAFweightType = Strict::SAFweightType
483
483
 
484
- AddressType = Types::String.enum("StreetAddress", "PostalAddress", "BillingAddress", "ShipToAddress", "ShipFromAddress")
484
+ AddressType = Strict::AddressType
485
485
 
486
486
  extend ObjectStrutures
487
487
  end
@@ -17,12 +17,9 @@ module SAFT::V2
17
17
  # https://nokogiri.org/rdoc/Nokogiri/XML/SyntaxError.html
18
18
  end
19
19
 
20
- def valid?
21
- @xml_errors.none?
22
- end
20
+ def valid? = @xml_errors.none?
21
+ def invalid? = !valid?
23
22
 
24
- def errors
25
- @xml_errors
26
- end
23
+ def errors = @xml_errors
27
24
  end
28
25
  end
data/lib/saft/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SAFT
2
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
3
5
  end
data/package.json CHANGED
@@ -3,6 +3,7 @@
3
3
  "version": "1.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
+ "private": true,
6
7
  "scripts": {
7
8
  "test": "echo \"Error: no test specified\" && exit 1"
8
9
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dodo developer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-12-15 00:00:00.000000000 Z
12
+ date: 2023-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: zeitwerk
@@ -68,9 +68,6 @@ files:
68
68
  - CHANGELOG.md
69
69
  - Gemfile
70
70
  - Rakefile
71
- - docs/Norwegian SAF-T Financial data.pdf
72
- - docs/Norwegian SAF-T Standard VAT:Tax codes.pdf
73
- - docs/saf-t v2 xsd by oecd.pdf
74
71
  - lib/saft.rb
75
72
  - lib/saft/v2.rb
76
73
  - lib/saft/v2/html.css
@@ -95,10 +92,13 @@ files:
95
92
  - vendor/norway/standard_tax_codes.csv
96
93
  - vendor/norway/standard_tax_codes.xml
97
94
  - vendor/norway/standard_tax_codes.xsd
98
- homepage:
95
+ homepage: https://github.com/dodoas/ruby-saft
99
96
  licenses:
100
97
  - MIT
101
- metadata: {}
98
+ metadata:
99
+ homepage_uri: https://github.com/dodoas/ruby-saft
100
+ source_code_uri: https://github.com/dodoas/ruby-saft
101
+ changelog_uri: https://github.com/dodoas/ruby-saft/CHANGELOG.md
102
102
  post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.2.32
117
+ rubygems_version: 3.4.10
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: SAF-T parser and writer
Binary file