xrechnung 0.6.5 → 0.7.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 +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/.github/workflows/validate-fixtures.yml +3 -3
- data/Gemfile +1 -0
- data/Gemfile.lock +49 -21
- data/README.md +3 -42
- data/Rakefile +22 -21
- data/lib/xrechnung/allowance_charge.rb +7 -17
- data/lib/xrechnung/currency.rb +16 -0
- data/lib/xrechnung/member_container.rb +6 -1
- data/lib/xrechnung/tax_category.rb +10 -0
- data/lib/xrechnung/tax_subtotal.rb +7 -0
- data/lib/xrechnung/tax_total.rb +16 -0
- data/lib/xrechnung/version.rb +1 -1
- data/lib/xrechnung.rb +64 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c12b2ff2f51a6c12f63a584dddc23fd38d5c67f7c153c6c3457622438a82b348
|
|
4
|
+
data.tar.gz: ed9e52088c5c6a821de9022b89cd201b3ef44de4591e781bee40c8bcf43ff990
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b58288653e2945cfd22d578e8a069b4f6b9d4a932e4b07331f03d71bf02c79aa5dc31760912fada8c3cd6314365a2f89fe27e83c0a1fd3531b9e3adc37f20cec
|
|
7
|
+
data.tar.gz: 37465df554df646bdc974f1a0c056866f30afc6f711d88a9886330e08546e2817342ea5a1367b3b576590d3a9c753dda51dc91c8d7ed74f01a929916af7edf95
|
data/.github/workflows/rspec.yml
CHANGED
|
@@ -11,12 +11,12 @@ jobs:
|
|
|
11
11
|
|
|
12
12
|
- uses: actions/setup-java@v5
|
|
13
13
|
with:
|
|
14
|
-
distribution: "
|
|
15
|
-
java-version: "
|
|
14
|
+
distribution: "temurin"
|
|
15
|
+
java-version: "25"
|
|
16
16
|
|
|
17
17
|
- uses: ruby/setup-ruby@v1
|
|
18
18
|
with:
|
|
19
|
-
ruby-version: "
|
|
19
|
+
ruby-version: "4.0"
|
|
20
20
|
bundler-cache: true
|
|
21
21
|
|
|
22
22
|
- name: Prepare validator
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
xrechnung (0.
|
|
4
|
+
xrechnung (0.7.2)
|
|
5
5
|
activesupport
|
|
6
6
|
base64
|
|
7
7
|
bigdecimal
|
|
@@ -10,7 +10,7 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
activesupport (8.1.
|
|
13
|
+
activesupport (8.1.3.1)
|
|
14
14
|
base64
|
|
15
15
|
bigdecimal
|
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
@@ -25,37 +25,62 @@ GEM
|
|
|
25
25
|
uri (>= 0.13.1)
|
|
26
26
|
ast (2.4.3)
|
|
27
27
|
base64 (0.3.0)
|
|
28
|
-
bigdecimal (4.
|
|
28
|
+
bigdecimal (4.1.2)
|
|
29
29
|
builder (3.3.0)
|
|
30
|
-
concurrent-ruby (1.3.
|
|
30
|
+
concurrent-ruby (1.3.8)
|
|
31
31
|
connection_pool (3.0.2)
|
|
32
|
-
csv (3.3.
|
|
32
|
+
csv (3.3.6)
|
|
33
|
+
debug (1.11.1)
|
|
34
|
+
irb (~> 1.10)
|
|
35
|
+
reline (>= 0.3.8)
|
|
33
36
|
diff-lcs (1.6.2)
|
|
34
37
|
drb (2.2.3)
|
|
38
|
+
erb (6.0.6)
|
|
35
39
|
httparty (0.24.2)
|
|
36
40
|
csv
|
|
37
41
|
mini_mime (>= 1.0.0)
|
|
38
42
|
multi_xml (>= 0.5.2)
|
|
39
|
-
i18n (1.
|
|
43
|
+
i18n (1.15.2)
|
|
40
44
|
concurrent-ruby (~> 1.0)
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
io-console (0.8.2)
|
|
46
|
+
irb (1.18.0)
|
|
47
|
+
pp (>= 0.6.0)
|
|
48
|
+
prism (>= 1.3.0)
|
|
49
|
+
rdoc (>= 4.0.0)
|
|
50
|
+
reline (>= 0.4.2)
|
|
51
|
+
json (2.21.2)
|
|
52
|
+
language_server-protocol (3.17.0.6)
|
|
43
53
|
lint_roller (1.1.0)
|
|
44
54
|
logger (1.7.0)
|
|
45
55
|
mini_mime (1.1.5)
|
|
46
|
-
minitest (6.0.
|
|
56
|
+
minitest (6.0.6)
|
|
57
|
+
drb (~> 2.0)
|
|
47
58
|
prism (~> 1.5)
|
|
48
|
-
multi_xml (0.
|
|
59
|
+
multi_xml (0.9.1)
|
|
49
60
|
bigdecimal (>= 3.1, < 5)
|
|
50
|
-
parallel (1.
|
|
51
|
-
parser (3.3.
|
|
61
|
+
parallel (1.28.0)
|
|
62
|
+
parser (3.3.12.0)
|
|
52
63
|
ast (~> 2.4.1)
|
|
53
64
|
racc
|
|
65
|
+
pp (0.6.4)
|
|
66
|
+
prettyprint
|
|
67
|
+
prettyprint (0.2.0)
|
|
54
68
|
prism (1.9.0)
|
|
55
69
|
racc (1.8.1)
|
|
56
70
|
rainbow (3.1.1)
|
|
57
|
-
rake (13.
|
|
58
|
-
|
|
71
|
+
rake (13.4.2)
|
|
72
|
+
rbs (4.1.1)
|
|
73
|
+
logger
|
|
74
|
+
prism (>= 1.6.0)
|
|
75
|
+
tsort
|
|
76
|
+
rdoc (8.0.0)
|
|
77
|
+
erb
|
|
78
|
+
prism (>= 1.6.0)
|
|
79
|
+
rbs (>= 4.0.0)
|
|
80
|
+
tsort
|
|
81
|
+
regexp_parser (2.12.0)
|
|
82
|
+
reline (0.6.3)
|
|
83
|
+
io-console (~> 0.5)
|
|
59
84
|
rspec (3.13.2)
|
|
60
85
|
rspec-core (~> 3.13.0)
|
|
61
86
|
rspec-expectations (~> 3.13.0)
|
|
@@ -65,33 +90,35 @@ GEM
|
|
|
65
90
|
rspec-expectations (3.13.5)
|
|
66
91
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
67
92
|
rspec-support (~> 3.13.0)
|
|
68
|
-
rspec-mocks (3.13.
|
|
93
|
+
rspec-mocks (3.13.8)
|
|
69
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
70
95
|
rspec-support (~> 3.13.0)
|
|
71
96
|
rspec-support (3.13.7)
|
|
72
|
-
rubocop (1.
|
|
97
|
+
rubocop (1.88.2)
|
|
73
98
|
json (~> 2.3)
|
|
74
99
|
language_server-protocol (~> 3.17.0.2)
|
|
75
100
|
lint_roller (~> 1.1.0)
|
|
76
|
-
parallel (
|
|
101
|
+
parallel (>= 1.10)
|
|
77
102
|
parser (>= 3.3.0.2)
|
|
78
103
|
rainbow (>= 2.2.2, < 4.0)
|
|
79
104
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
80
105
|
rubocop-ast (>= 1.49.0, < 2.0)
|
|
81
106
|
ruby-progressbar (~> 1.7)
|
|
82
107
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
83
|
-
rubocop-ast (1.
|
|
108
|
+
rubocop-ast (1.50.0)
|
|
84
109
|
parser (>= 3.3.7.2)
|
|
85
110
|
prism (~> 1.7)
|
|
86
111
|
rubocop-rake (0.7.1)
|
|
87
112
|
lint_roller (~> 1.1)
|
|
88
113
|
rubocop (>= 1.72.1)
|
|
89
|
-
rubocop-rspec (3.
|
|
114
|
+
rubocop-rspec (3.10.2)
|
|
90
115
|
lint_roller (~> 1.1)
|
|
91
|
-
|
|
116
|
+
regexp_parser (>= 2.0)
|
|
117
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
92
118
|
ruby-progressbar (1.13.0)
|
|
93
|
-
rubyzip (3.
|
|
119
|
+
rubyzip (3.4.1)
|
|
94
120
|
securerandom (0.4.1)
|
|
121
|
+
tsort (0.2.0)
|
|
95
122
|
tzinfo (2.0.6)
|
|
96
123
|
concurrent-ruby (~> 1.0)
|
|
97
124
|
unicode-display_width (3.2.0)
|
|
@@ -103,6 +130,7 @@ PLATFORMS
|
|
|
103
130
|
ruby
|
|
104
131
|
|
|
105
132
|
DEPENDENCIES
|
|
133
|
+
debug
|
|
106
134
|
httparty
|
|
107
135
|
rake
|
|
108
136
|
rspec
|
data/README.md
CHANGED
|
@@ -1,44 +1,5 @@
|
|
|
1
1
|
# Xrechnung
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Add this line to your application's Gemfile:
|
|
10
|
-
|
|
11
|
-
```ruby
|
|
12
|
-
gem 'xrechnung'
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
And then execute:
|
|
16
|
-
|
|
17
|
-
$ bundle install
|
|
18
|
-
|
|
19
|
-
Or install it yourself as:
|
|
20
|
-
|
|
21
|
-
$ gem install xrechnung
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
TODO: Write usage instructions here
|
|
26
|
-
|
|
27
|
-
## Development
|
|
28
|
-
|
|
29
|
-
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.
|
|
30
|
-
|
|
31
|
-
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
-
|
|
33
|
-
## Contributing
|
|
34
|
-
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/digineo/xrechnung. 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/digineo/xrechnung/blob/master/CODE_OF_CONDUCT.md).
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## License
|
|
39
|
-
|
|
40
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
41
|
-
|
|
42
|
-
## Code of Conduct
|
|
43
|
-
|
|
44
|
-
Everyone interacting in the Xrechnung project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/digineo/xrechnung/blob/master/CODE_OF_CONDUCT.md).
|
|
3
|
+
This repository has been archived.
|
|
4
|
+
Please migrate to https://github.com/AlexZeitler/zugpferd
|
|
5
|
+
which supports XRechnung and ZUGFeRD.
|
data/Rakefile
CHANGED
|
@@ -9,45 +9,46 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
9
9
|
|
|
10
10
|
task default: :spec
|
|
11
11
|
|
|
12
|
+
Source = Data.define(:filename, :release_url)
|
|
13
|
+
|
|
12
14
|
VALIDATOR_SOURCES = {
|
|
13
|
-
tool:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
scenarios:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
tool: Source.new(
|
|
16
|
+
"validator/validator-1.6.2-standalone.jar",
|
|
17
|
+
"https://github.com/itplr-kosit/validator/releases/download/v1.6.2/validator-1.6.2-standalone.jar",
|
|
18
|
+
),
|
|
19
|
+
scenarios: Source.new(
|
|
20
|
+
"validator/scenarios.xml",
|
|
21
|
+
"https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/v2026-01-31/xrechnung-3.0.2-validator-configuration-2026-01-31.zip",
|
|
22
|
+
),
|
|
21
23
|
}.freeze
|
|
22
24
|
|
|
23
25
|
namespace :validator do
|
|
24
26
|
VALIDATOR_SOURCES.each_value do |v|
|
|
25
|
-
base
|
|
26
|
-
zipfile = base.join(File.basename(v[:release_url]))
|
|
27
|
+
base = Pathname.new(__dir__).join("validator").tap(&:mkpath)
|
|
27
28
|
|
|
28
|
-
file
|
|
29
|
-
|
|
29
|
+
file v.filename do
|
|
30
|
+
basename = base.join(File.basename(v.release_url))
|
|
30
31
|
|
|
31
|
-
res = HTTParty.get(v
|
|
32
|
-
File.binwrite(
|
|
33
|
-
end
|
|
32
|
+
res = HTTParty.get(v.release_url, follow_redirects: true)
|
|
33
|
+
File.binwrite(basename, res.body)
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if basename.extname == ".zip"
|
|
36
|
+
Zip::File.foreach(basename) do |entry|
|
|
37
|
+
entry.extract destination_directory: base
|
|
38
|
+
end
|
|
38
39
|
end
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
desc "Download official validator and scenarios"
|
|
43
|
-
task download: VALIDATOR_SOURCES.map
|
|
44
|
+
task download: VALIDATOR_SOURCES.values.map(&:filename)
|
|
44
45
|
|
|
45
46
|
desc "Run validator on test fixtures"
|
|
46
47
|
task run: :download do
|
|
47
48
|
fixtures = Pathname.new(__dir__).join("spec/fixtures/*.xml")
|
|
48
49
|
output = Pathname.new(__dir__).join("validator/results").tap(&:mkpath)
|
|
49
|
-
tool = VALIDATOR_SOURCES[:tool]
|
|
50
|
-
scenarios = VALIDATOR_SOURCES[:scenarios]
|
|
50
|
+
tool = VALIDATOR_SOURCES[:tool].filename
|
|
51
|
+
scenarios = VALIDATOR_SOURCES[:scenarios].filename
|
|
51
52
|
|
|
52
53
|
sh "java -jar #{tool} -r validator -s #{scenarios} --output-directory #{output} --html #{fixtures}"
|
|
53
54
|
end
|
|
@@ -8,7 +8,7 @@ module Xrechnung
|
|
|
8
8
|
|
|
9
9
|
# @!attribute allowance_charge_reason_code
|
|
10
10
|
# @return [String]
|
|
11
|
-
member :allowance_charge_reason_code, type:
|
|
11
|
+
member :allowance_charge_reason_code, type: String
|
|
12
12
|
|
|
13
13
|
# @!attribute allowance_charge_reason
|
|
14
14
|
# @return [String]
|
|
@@ -31,15 +31,13 @@ module Xrechnung
|
|
|
31
31
|
member :tax_category, type: Xrechnung::TaxCategory
|
|
32
32
|
|
|
33
33
|
def initialize(**kwargs)
|
|
34
|
-
unless kwargs[:amount].is_a?(Currency)
|
|
35
|
-
kwargs[:amount] = Currency::EUR(kwargs[:amount])
|
|
36
|
-
end
|
|
34
|
+
kwargs[:amount] = Currency::EUR(kwargs[:amount]) unless kwargs[:amount].is_a?(Currency)
|
|
37
35
|
|
|
38
36
|
unless kwargs[:base_amount].is_a?(Currency) || kwargs[:base_amount].nil?
|
|
39
37
|
kwargs[:base_amount] = Currency::EUR(kwargs[:base_amount])
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
super
|
|
40
|
+
super
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
# noinspection RubyResolve
|
|
@@ -47,23 +45,15 @@ module Xrechnung
|
|
|
47
45
|
xml.cac :AllowanceCharge do
|
|
48
46
|
xml.cbc :ChargeIndicator, charge_indicator
|
|
49
47
|
|
|
50
|
-
if allowance_charge_reason_code
|
|
51
|
-
xml.cbc :AllowanceChargeReasonCode, allowance_charge_reason_code
|
|
52
|
-
end
|
|
48
|
+
xml.cbc :AllowanceChargeReasonCode, allowance_charge_reason_code if allowance_charge_reason_code
|
|
53
49
|
|
|
54
|
-
if allowance_charge_reason
|
|
55
|
-
xml.cbc :AllowanceChargeReason, allowance_charge_reason
|
|
56
|
-
end
|
|
50
|
+
xml.cbc :AllowanceChargeReason, allowance_charge_reason if allowance_charge_reason
|
|
57
51
|
|
|
58
|
-
if multiplier_factor_numeric
|
|
59
|
-
xml.cbc :MultiplierFactorNumeric, format("%.2f", multiplier_factor_numeric)
|
|
60
|
-
end
|
|
52
|
+
xml.cbc :MultiplierFactorNumeric, format("%.2f", multiplier_factor_numeric) if multiplier_factor_numeric
|
|
61
53
|
|
|
62
54
|
xml.cbc :Amount, *amount.xml_args
|
|
63
55
|
|
|
64
|
-
if base_amount
|
|
65
|
-
xml.cbc :BaseAmount, *base_amount.xml_args
|
|
66
|
-
end
|
|
56
|
+
xml.cbc :BaseAmount, *base_amount.xml_args if base_amount
|
|
67
57
|
|
|
68
58
|
tax_category&.to_xml(xml)
|
|
69
59
|
end
|
data/lib/xrechnung/currency.rb
CHANGED
|
@@ -10,6 +10,22 @@ module Xrechnung
|
|
|
10
10
|
def xml_args
|
|
11
11
|
[value_to_s, { currencyID: currency_id }]
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
def self.check_matching_attributes(one, other)
|
|
15
|
+
raise ArgumentError, "other must be a Currency" unless one.is_a? Currency
|
|
16
|
+
raise ArgumentError, "other must be a Currency" unless other.is_a? Currency
|
|
17
|
+
raise ArgumentError, "currency_id must match" unless one.currency_id == other.currency_id
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def +(other)
|
|
21
|
+
self.class.check_matching_attributes(self, other)
|
|
22
|
+
Currency.new(currency_id: currency_id, value: value + other.value)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def -(other)
|
|
26
|
+
self.class.check_matching_attributes(self, other)
|
|
27
|
+
Currency.new(currency_id: currency_id, value: value - other.value)
|
|
28
|
+
end
|
|
13
29
|
end
|
|
14
30
|
|
|
15
31
|
class << Currency
|
|
@@ -24,7 +24,7 @@ module Xrechnung
|
|
|
24
24
|
send("#{key}=", value)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
Member = Struct.new(:type, :default, :optional, :transform_value, keyword_init: true)
|
|
27
|
+
Member = Struct.new(:type, :default, :optional, :is_private, :transform_value, keyword_init: true)
|
|
28
28
|
|
|
29
29
|
module ClassMethods
|
|
30
30
|
def members
|
|
@@ -53,6 +53,11 @@ module Xrechnung
|
|
|
53
53
|
|
|
54
54
|
instance_variable_set :"@#{member_name}", in_value
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
return unless member.is_private
|
|
58
|
+
|
|
59
|
+
private member_name
|
|
60
|
+
private setter_name
|
|
56
61
|
end
|
|
57
62
|
end
|
|
58
63
|
end
|
|
@@ -43,6 +43,16 @@ module Xrechnung
|
|
|
43
43
|
# @return [String]
|
|
44
44
|
member :tax_exemption_reason, type: String
|
|
45
45
|
|
|
46
|
+
def ==(other)
|
|
47
|
+
return false unless other.is_a?(Xrechnung::TaxCategory)
|
|
48
|
+
|
|
49
|
+
id == other.id &&
|
|
50
|
+
percent == other.percent &&
|
|
51
|
+
tax_scheme_id == other.tax_scheme_id &&
|
|
52
|
+
tax_exemption_reason_code == other.tax_exemption_reason_code &&
|
|
53
|
+
tax_exemption_reason == other.tax_exemption_reason
|
|
54
|
+
end
|
|
55
|
+
|
|
46
56
|
# noinspection RubyResolve
|
|
47
57
|
def to_xml(xml, root_tag_name: :TaxCategory)
|
|
48
58
|
xml.cac root_tag_name do
|
|
@@ -32,6 +32,7 @@ module Xrechnung
|
|
|
32
32
|
|
|
33
33
|
def initialize(**kwargs)
|
|
34
34
|
super
|
|
35
|
+
self.tax_amount ||= Currency::EUR(0)
|
|
35
36
|
self.taxable_amount ||= Currency::EUR(0)
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -43,5 +44,11 @@ module Xrechnung
|
|
|
43
44
|
tax_category&.to_xml(xml)
|
|
44
45
|
end
|
|
45
46
|
end
|
|
47
|
+
|
|
48
|
+
def update_amount
|
|
49
|
+
value = taxable_amount.value * tax_category.percent / 100
|
|
50
|
+
self.tax_amount = Currency::EUR(value)
|
|
51
|
+
value
|
|
52
|
+
end
|
|
46
53
|
end
|
|
47
54
|
end
|
data/lib/xrechnung/tax_total.rb
CHANGED
|
@@ -42,5 +42,21 @@ module Xrechnung
|
|
|
42
42
|
end
|
|
43
43
|
xml.target!
|
|
44
44
|
end
|
|
45
|
+
|
|
46
|
+
def update_amounts
|
|
47
|
+
value = tax_subtotals.sum(&:update_amount)
|
|
48
|
+
self.tax_amount = Xrechnung::Currency::EUR(value)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def get_tax_subtotal(tax_category)
|
|
52
|
+
element = tax_subtotals.find { _1.tax_category == tax_category }
|
|
53
|
+
|
|
54
|
+
unless element
|
|
55
|
+
element = Xrechnung::TaxSubtotal.new(tax_category: tax_category)
|
|
56
|
+
tax_subtotals << element
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
element
|
|
60
|
+
end
|
|
45
61
|
end
|
|
46
62
|
end
|
data/lib/xrechnung/version.rb
CHANGED
data/lib/xrechnung.rb
CHANGED
|
@@ -172,6 +172,9 @@ module Xrechnung
|
|
|
172
172
|
# @return [String]
|
|
173
173
|
member :tax_currency_code, type: String
|
|
174
174
|
|
|
175
|
+
# Buyer accounting reference BT-19
|
|
176
|
+
member :buyer_accounting_reference, type: String, optional: true
|
|
177
|
+
|
|
175
178
|
# Buyer reference BT-10
|
|
176
179
|
#
|
|
177
180
|
# Ein vom Erwerber zugewiesener und für interne Lenkungszwecke benutzter Bezeichner.
|
|
@@ -262,7 +265,7 @@ module Xrechnung
|
|
|
262
265
|
#
|
|
263
266
|
# @!attribute tax_total
|
|
264
267
|
# @return [Xrechnung::TaxTotal]
|
|
265
|
-
member :tax_total, type: Xrechnung::TaxTotal
|
|
268
|
+
member :tax_total, type: Xrechnung::TaxTotal, is_private: true
|
|
266
269
|
|
|
267
270
|
# DOCUMENT TOTALS BG-22
|
|
268
271
|
#
|
|
@@ -271,7 +274,7 @@ module Xrechnung
|
|
|
271
274
|
#
|
|
272
275
|
# @!attribute legal_monetary_total
|
|
273
276
|
# @return [Xrechnung::LegalMonetaryTotal]
|
|
274
|
-
member :legal_monetary_total, type: Xrechnung::LegalMonetaryTotal
|
|
277
|
+
member :legal_monetary_total, type: Xrechnung::LegalMonetaryTotal, is_private: true
|
|
275
278
|
|
|
276
279
|
# INVOICE LINE BG-25
|
|
277
280
|
#
|
|
@@ -301,7 +304,18 @@ module Xrechnung
|
|
|
301
304
|
"xsi:schemaLocation" => "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd",
|
|
302
305
|
}.freeze
|
|
303
306
|
|
|
307
|
+
def initialize(...)
|
|
308
|
+
super
|
|
309
|
+
self.legal_monetary_total ||= Xrechnung::LegalMonetaryTotal.new
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def prepaid_amount=(value)
|
|
313
|
+
legal_monetary_total.prepaid_amount = value
|
|
314
|
+
end
|
|
315
|
+
|
|
304
316
|
def to_xml(indent: 2, target: "")
|
|
317
|
+
update_amounts
|
|
318
|
+
|
|
305
319
|
xml = Builder::XmlMarkup.new(indent: indent, target: target)
|
|
306
320
|
xml.instruct! :xml, version: "1.0", encoding: "UTF-8"
|
|
307
321
|
|
|
@@ -320,6 +334,7 @@ module Xrechnung
|
|
|
320
334
|
xml.cbc :TaxPointDate, tax_point_date unless tax_point_date.nil?
|
|
321
335
|
xml.cbc :DocumentCurrencyCode, document_currency_code
|
|
322
336
|
xml.cbc :TaxCurrencyCode, tax_currency_code unless tax_currency_code.nil?
|
|
337
|
+
xml.cbc :AccountingCost, buyer_accounting_reference unless buyer_accounting_reference.nil?
|
|
323
338
|
xml.cbc :BuyerReference, buyer_reference
|
|
324
339
|
|
|
325
340
|
invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?
|
|
@@ -368,8 +383,10 @@ module Xrechnung
|
|
|
368
383
|
end
|
|
369
384
|
end
|
|
370
385
|
|
|
371
|
-
|
|
372
|
-
|
|
386
|
+
if payment_means
|
|
387
|
+
xml.cac :PaymentMeans do
|
|
388
|
+
payment_means&.to_xml(xml)
|
|
389
|
+
end
|
|
373
390
|
end
|
|
374
391
|
|
|
375
392
|
payee_party&.to_xml(xml) unless self.class.members[:payee_party].optional && payee_party.nil?
|
|
@@ -395,5 +412,48 @@ module Xrechnung
|
|
|
395
412
|
|
|
396
413
|
target
|
|
397
414
|
end
|
|
415
|
+
|
|
416
|
+
def update_amounts
|
|
417
|
+
self.tax_total = Xrechnung::TaxTotal.new
|
|
418
|
+
|
|
419
|
+
invoice_lines.each do |invoice_line|
|
|
420
|
+
tax_total.get_tax_subtotal(invoice_line.item.classified_tax_category).taxable_amount += invoice_line.line_extension_amount
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
allowance_charges.each do |ac|
|
|
424
|
+
element = tax_total.get_tax_subtotal(ac.tax_category)
|
|
425
|
+
if ac.charge_indicator
|
|
426
|
+
element.taxable_amount += ac.amount
|
|
427
|
+
else
|
|
428
|
+
element.taxable_amount -= ac.amount
|
|
429
|
+
end
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
tax_total.update_amounts
|
|
433
|
+
|
|
434
|
+
currency_id = tax_total.tax_amount.currency_id
|
|
435
|
+
zero = Xrechnung::Currency.new(currency_id: currency_id, value: BigDecimal(0))
|
|
436
|
+
|
|
437
|
+
legal_monetary_total.line_extension_amount = zero
|
|
438
|
+
legal_monetary_total.allowance_total_amount = zero
|
|
439
|
+
legal_monetary_total.charge_total_amount = zero
|
|
440
|
+
legal_monetary_total.prepaid_amount ||= zero
|
|
441
|
+
|
|
442
|
+
invoice_lines.each do |line|
|
|
443
|
+
legal_monetary_total.line_extension_amount += line.line_extension_amount
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
allowance_charges.each do |ac|
|
|
447
|
+
if ac.charge_indicator
|
|
448
|
+
legal_monetary_total.charge_total_amount += ac.amount
|
|
449
|
+
else
|
|
450
|
+
legal_monetary_total.allowance_total_amount += ac.amount
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
legal_monetary_total.tax_exclusive_amount = legal_monetary_total.line_extension_amount + legal_monetary_total.charge_total_amount - legal_monetary_total.allowance_total_amount
|
|
455
|
+
legal_monetary_total.tax_inclusive_amount = legal_monetary_total.tax_exclusive_amount + tax_total.tax_amount
|
|
456
|
+
legal_monetary_total.payable_amount = legal_monetary_total.tax_inclusive_amount - legal_monetary_total.prepaid_amount
|
|
457
|
+
end
|
|
398
458
|
end
|
|
399
459
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xrechnung
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Kornberger
|
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
137
|
version: '0'
|
|
138
138
|
requirements: []
|
|
139
|
-
rubygems_version: 4.0.
|
|
139
|
+
rubygems_version: 4.0.17
|
|
140
140
|
specification_version: 4
|
|
141
141
|
summary: Library to create invoices in the XRechnung format.
|
|
142
142
|
test_files: []
|