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 +4 -4
- data/.gemspec +8 -7
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/saft/v2/html.rb +4 -3
- data/lib/saft/v2/types.rb +16 -16
- data/lib/saft/v2/xsd_validate.rb +3 -6
- data/lib/saft/version.rb +3 -1
- data/package.json +1 -0
- metadata +8 -8
- data/docs/Norwegian SAF-T Financial data.pdf +0 -0
- data/docs/Norwegian SAF-T Standard VAT:Tax codes.pdf +0 -0
- data/docs/saf-t v2 xsd by oecd.pdf +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cb83ea3a9f978153d3dcbb5be4575ede05fb1df38022c22f868df05e09ab7cc
|
4
|
+
data.tar.gz: cade2d53d95a5b8648cd7875769c35b07ef87c506a2bbd753ade70f2712a2db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
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")
|
23
|
-
|
24
|
-
|
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
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
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
|
-
|
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(:
|
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::
|
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::
|
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::
|
125
|
-
attribute(:months, Types::
|
126
|
-
attribute(:cash_discount_days, Types::
|
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,
|
453
|
-
SAFexchangerateType = Types::Decimal.constrained(digits: 18,
|
454
|
-
SAFquantityType = Types::Decimal.constrained(digits: 22,
|
455
|
-
SAFweightType = Types::Decimal.constrained(digits: 14,
|
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 =
|
480
|
-
SAFexchangerateType =
|
481
|
-
SAFquantityType =
|
482
|
-
SAFweightType =
|
479
|
+
SAFmonetaryType = Strict::SAFmonetaryType
|
480
|
+
SAFexchangerateType = Strict::SAFexchangerateType
|
481
|
+
SAFquantityType = Strict::SAFquantityType
|
482
|
+
SAFweightType = Strict::SAFweightType
|
483
483
|
|
484
|
-
AddressType =
|
484
|
+
AddressType = Strict::AddressType
|
485
485
|
|
486
486
|
extend ObjectStrutures
|
487
487
|
end
|
data/lib/saft/v2/xsd_validate.rb
CHANGED
@@ -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
|
-
|
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
data/package.json
CHANGED
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.
|
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:
|
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.
|
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
|
Binary file
|
Binary file
|