liberic 1.4.1 → 1.5.0
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/CHANGELOG.md +126 -0
- data/README.md +283 -146
- data/examples/est_2020.rb +40 -0
- data/lib/liberic/boot.rb +85 -10
- data/lib/liberic/certificate.rb +95 -16
- data/lib/liberic/config.rb +89 -20
- data/lib/liberic/core.rb +24 -0
- data/{rakelib/eric.rake → lib/liberic/eric_installer.rb} +38 -17
- data/lib/liberic/helpers/invocation.rb +46 -9
- data/lib/liberic/process.rb +233 -41
- data/lib/liberic/sdk/api.rb +28 -0
- data/lib/liberic/sdk/types.rb +49 -1
- data/lib/liberic/sdk.rb +12 -1
- data/lib/liberic/tasks.rb +27 -0
- data/lib/liberic/version.rb +1 -1
- data/lib/liberic.rb +5 -20
- metadata +29 -35
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/release.yml +0 -39
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.tool-versions +0 -1
- data/CODE_OF_CONDUCT.md +0 -13
- data/ERIC_SDK_UPGRADE_PROMPT.md +0 -16
- data/Gemfile +0 -6
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/examples/steuersatz.xml +0 -89
- data/examples/submit_ekst.rb +0 -13
- data/liberic.gemspec +0 -38
data/README.md
CHANGED
|
@@ -1,229 +1,366 @@
|
|
|
1
1
|
# Liberic
|
|
2
2
|
|
|
3
|
-
Liberic is a
|
|
4
|
-
|
|
3
|
+
Liberic is a Ruby wrapper for ERiC (ELSTER Rich Client), the native library
|
|
4
|
+
for validating, printing and submitting tax filings to Germany's tax
|
|
5
|
+
authorities through ELSTER.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
Most applications need only `Liberic::Process`, `Liberic::Certificate` and
|
|
8
|
+
`Liberic.config`; `Liberic::SDK::API` exposes the native functions directly.
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## Requirements
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
- Ruby 3.3 or newer.
|
|
13
|
+
- ERiC **43.5.4.0**. The SDK is not included in the gem; on Linux x86-64,
|
|
14
|
+
`bundle exec rake eric:install` downloads and installs it automatically.
|
|
15
|
+
- Your own ELSTER manufacturer ID (Hersteller-ID) for processing filings,
|
|
16
|
+
including the SDK's examples. The test manufacturer ID `74931` used in
|
|
17
|
+
older examples is blocked and no longer works.
|
|
18
|
+
|
|
19
|
+
The bundled SDK installer and SDK integration specs target **Linux x86-64**.
|
|
20
|
+
For macOS or other platforms, install the matching SDK manually and follow
|
|
21
|
+
the platform instructions in its `ERiC-Entwicklerhandbuch.pdf`. Ruby and the
|
|
22
|
+
native SDK must use matching architectures. macOS setup has not been
|
|
23
|
+
verified for this release.
|
|
24
|
+
|
|
25
|
+
See the [ELSTER developer information](https://www.elster.de/elsterweb/infoseite/entwickler)
|
|
26
|
+
for registration and manufacturer IDs.
|
|
12
27
|
|
|
13
28
|
## Installation
|
|
14
29
|
|
|
15
|
-
Add
|
|
30
|
+
Add Liberic to your application's `Gemfile`:
|
|
16
31
|
|
|
17
32
|
```ruby
|
|
18
|
-
gem 'liberic'
|
|
33
|
+
gem 'liberic', require: 'liberic/core'
|
|
19
34
|
```
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
Then run `bundle install`. Loading `liberic/core` lets the application start
|
|
37
|
+
without loading ERiC; initialize it explicitly in the process that needs it
|
|
38
|
+
(see [Initialization](#initialization)).
|
|
39
|
+
|
|
40
|
+
### Install the SDK on Linux x86-64
|
|
22
41
|
|
|
23
|
-
|
|
42
|
+
The `eric:install` task downloads the SDK and documentation directly from
|
|
43
|
+
ELSTER's public download server. No developer login is needed for this
|
|
44
|
+
download; a manufacturer ID is still required to process filings.
|
|
24
45
|
|
|
25
|
-
|
|
46
|
+
To use the installer from an application, add rubyzip to its `Gemfile` and
|
|
47
|
+
load the task in its `Rakefile`:
|
|
26
48
|
|
|
27
|
-
|
|
49
|
+
```ruby
|
|
50
|
+
# Gemfile — only needed for SDK installation, not at runtime
|
|
51
|
+
gem 'rubyzip', '>= 3.4', require: false
|
|
52
|
+
|
|
53
|
+
# Rakefile
|
|
54
|
+
require 'liberic/tasks'
|
|
55
|
+
```
|
|
28
56
|
|
|
29
|
-
|
|
30
|
-
download and install the SDK and its documentation with:
|
|
57
|
+
Run `bundle install`, then:
|
|
31
58
|
|
|
32
59
|
```sh
|
|
33
60
|
bundle exec rake eric:install
|
|
61
|
+
export ERIC_HOME="$PWD/.eric/ERiC-43.5.4.0/Linux-x86_64"
|
|
34
62
|
```
|
|
35
63
|
|
|
36
|
-
|
|
37
|
-
|
|
64
|
+
The task installs ERiC 43.5.4.0 and its documentation below `.eric/` in
|
|
65
|
+
the directory of the `Rakefile`. Allow at least 1.5 GB of free disk space
|
|
66
|
+
for the archives and extracted files. Completed downloads are cached in
|
|
67
|
+
`.eric/downloads/` for reuse.
|
|
68
|
+
|
|
69
|
+
The task prints the exact `export` command for the installed SDK. Run it in
|
|
70
|
+
the shell where Liberic will run, or configure `ERIC_HOME` in your deployment
|
|
71
|
+
environment; the task cannot change its parent shell's environment.
|
|
72
|
+
|
|
73
|
+
To choose another installation root, pass a task argument or set
|
|
74
|
+
`ERIC_INSTALL_ROOT`:
|
|
38
75
|
|
|
39
76
|
```sh
|
|
40
|
-
|
|
77
|
+
bundle exec rake "eric:install[/opt/myapp]"
|
|
78
|
+
ERIC_INSTALL_ROOT=/opt/myapp bundle exec rake eric:install
|
|
41
79
|
```
|
|
42
80
|
|
|
43
|
-
The
|
|
44
|
-
first component. It caches completed archives in `.eric/downloads/` and extracts
|
|
45
|
-
them below `.eric/`, producing this SDK home for the default version:
|
|
81
|
+
The installer can also be used without Rake:
|
|
46
82
|
|
|
47
|
-
```
|
|
48
|
-
|
|
83
|
+
```ruby
|
|
84
|
+
require 'liberic/eric_installer'
|
|
85
|
+
Liberic::EricInstaller.new(root: '/opt/myapp').install # => SDK home
|
|
49
86
|
```
|
|
50
87
|
|
|
51
|
-
|
|
52
|
-
their extracted contents. Downloads use temporary `.part` files, can be reused
|
|
53
|
-
on later runs, and are not included in the repository or packaged gem. The
|
|
54
|
-
installer supports only the official Linux x86-64 SDK.
|
|
88
|
+
### Use an existing or manually installed SDK
|
|
55
89
|
|
|
56
|
-
|
|
57
|
-
|
|
90
|
+
To install the SDK manually, download it through the
|
|
91
|
+
[ELSTER developer area](https://www.elster.de/elsterweb/entwickler/infoseite/eric)
|
|
92
|
+
(developer credentials required) and follow its installation instructions.
|
|
93
|
+
For a manual or existing installation, set `ERIC_HOME` to the platform
|
|
94
|
+
directory containing `bin/`, `include/` and `lib/`:
|
|
58
95
|
|
|
59
96
|
```sh
|
|
60
|
-
export ERIC_HOME
|
|
97
|
+
export ERIC_HOME=/opt/ERiC-43.5.4.0/Linux-x86_64
|
|
61
98
|
```
|
|
62
99
|
|
|
63
|
-
The
|
|
64
|
-
|
|
65
|
-
must run the command yourself or add it to your shell configuration.
|
|
100
|
+
The older `ERIC_HOME_40` variable remains a fallback when `ERIC_HOME` is
|
|
101
|
+
not set.
|
|
66
102
|
|
|
67
|
-
|
|
68
|
-
[ELSTER Entwicklerbereich](https://www.elster.de/elsterweb/entwickler/infoseite/eric),
|
|
69
|
-
which requires developer credentials. You can also browse the public
|
|
70
|
-
[ELSTER developer information](https://www.elster.de/elsterweb/infoseite/entwickler).
|
|
71
|
-
Follow the official installation instructions and extract the SDK to a location
|
|
72
|
-
of your choice. It should contain at least these folders:
|
|
103
|
+
## Initialization
|
|
73
104
|
|
|
74
|
-
|
|
75
|
-
bin/
|
|
76
|
-
include/
|
|
77
|
-
lib/
|
|
78
|
-
```
|
|
105
|
+
Load the Ruby code, then boot ERiC in the process that will use it:
|
|
79
106
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
fallback when `ERIC_HOME` is not set.
|
|
107
|
+
```ruby
|
|
108
|
+
require 'liberic/core'
|
|
83
109
|
|
|
84
|
-
|
|
110
|
+
Liberic.boot! # uses ERIC_HOME
|
|
111
|
+
```
|
|
85
112
|
|
|
86
|
-
|
|
87
|
-
|
|
113
|
+
You can alternatively pass the SDK location, log directory and plugin
|
|
114
|
+
directory explicitly:
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
Liberic.boot!(
|
|
118
|
+
eric_home: '/opt/ERiC-43.5.4.0/Linux-x86_64',
|
|
119
|
+
log_path: 'log/eric', # existing directory for eric.log; default: system temp directory
|
|
120
|
+
plugin_path: nil # default: ERiC's lib directory
|
|
121
|
+
)
|
|
88
122
|
```
|
|
89
123
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
when building the app in Docker). In this case, use `gem 'liberic', require: false` in your `Gemfile`.
|
|
94
|
-
And require the gem later in your Rails code (for example a model) by
|
|
95
|
-
calling `require 'liberic'`.
|
|
124
|
+
ERiC stops writing `eric.log` as soon as `Liberic.config` is used, including
|
|
125
|
+
reading or changing a setting, unless you set `Liberic.config.log_file = true`;
|
|
126
|
+
see [Configuration and logging](#configuration-and-logging).
|
|
96
127
|
|
|
97
|
-
|
|
128
|
+
ERiC can be initialized only once per process; a second `Liberic.boot!`
|
|
129
|
+
raises `Liberic::InitializationError`. `Liberic.booted?`
|
|
130
|
+
reports whether initialization succeeded. ERiC's single-threading API is
|
|
131
|
+
not thread safe; serialize calls within each process.
|
|
98
132
|
|
|
99
|
-
|
|
100
|
-
|
|
133
|
+
For compatibility, `require 'liberic'` still loads and initializes ERiC
|
|
134
|
+
immediately, unless already booted. It raises `Liberic::InitializationError`
|
|
135
|
+
if `ERIC_HOME` is not set. Use `liberic/core` to avoid
|
|
136
|
+
initialization in web processes or build tasks that do not need ERiC.
|
|
101
137
|
|
|
102
|
-
|
|
103
|
-
|
|
138
|
+
If `boot!` fails because the library cannot be loaded, you can retry with
|
|
139
|
+
another `eric_home`. If it fails later, during initialization, you can only
|
|
140
|
+
retry with the same `eric_home`; switching to a different SDK needs a new
|
|
141
|
+
process.
|
|
104
142
|
|
|
105
|
-
|
|
106
|
-
libs=`ls $ERIC_HOME/lib/*.dylib`
|
|
107
|
-
plugins=`ls $ERIC_HOME/lib/plugins2/*.dylib`
|
|
143
|
+
## Usage
|
|
108
144
|
|
|
109
|
-
|
|
110
|
-
do
|
|
111
|
-
for lib in $libs
|
|
112
|
-
do
|
|
113
|
-
install_name_tool -change "@rpath/"`basename $lib` "$ERIC_HOME/lib/"`basename $lib` $target
|
|
114
|
-
done
|
|
145
|
+
### Validate a filing
|
|
115
146
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
done
|
|
147
|
+
This example uses the **2020 test filing** shipped with the SDK to
|
|
148
|
+
demonstrate the API. Set `ERIC_HOME` and `ERIC_HERSTELLER_ID` before running
|
|
149
|
+
it. For real filings, supply the XML and matching data type for the relevant
|
|
150
|
+
tax year.
|
|
121
151
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
152
|
+
```ruby
|
|
153
|
+
require 'liberic/core'
|
|
154
|
+
Liberic.boot!
|
|
155
|
+
|
|
156
|
+
tax_filing = File.read(
|
|
157
|
+
File.join(Liberic.eric_home, 'Beispiel/ericdemo-java/ESt_2020.xml'),
|
|
158
|
+
encoding: 'UTF-8'
|
|
159
|
+
)
|
|
160
|
+
tax_filing = tax_filing.sub(
|
|
161
|
+
%r{<HerstellerID>\d+},
|
|
162
|
+
"<HerstellerID>#{ENV.fetch('ERIC_HERSTELLER_ID')}"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
submission = Liberic::Process.new(tax_filing, 'ESt_2020')
|
|
166
|
+
result = submission.execute # local validation; does not send the filing
|
|
167
|
+
|
|
168
|
+
if result.ok?
|
|
169
|
+
puts 'The tax filing is valid.'
|
|
170
|
+
else
|
|
171
|
+
puts "#{result.error} (#{result.code})"
|
|
172
|
+
puts result[:result]
|
|
173
|
+
end
|
|
129
174
|
```
|
|
130
175
|
|
|
131
|
-
|
|
176
|
+
`execute` returns a `Liberic::Process::Result`, a Hash with `:result`
|
|
177
|
+
(ERiC's result XML) and `:server_result` (the server response when sending),
|
|
178
|
+
plus `code`, `error` and `ok?`. **An empty `:result` does not mean success**:
|
|
179
|
+
always check `ok?`.
|
|
132
180
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
```
|
|
136
|
-
This should list you one file with an operating system dependend suffix.
|
|
181
|
+
Use `execute!` to raise `Liberic::Process::ProcessingError` on failure;
|
|
182
|
+
the exception exposes `code`, `error` and `result`.
|
|
137
183
|
|
|
138
|
-
|
|
184
|
+
For a separate XML schema check, call `submission.check`. It raises
|
|
185
|
+
`Liberic::Helpers::Invocation::Error` on failure, with ERiC's schema error
|
|
186
|
+
text in `buffer`. This check is optional; `execute` also checks the XML.
|
|
139
187
|
|
|
140
|
-
|
|
141
|
-
`Liberic::SDK::API` namespace.
|
|
188
|
+
### Actions and hints
|
|
142
189
|
|
|
143
|
-
|
|
144
|
-
'Eric' prefix, otherwise the original (German) names have been kept.
|
|
190
|
+
Pass `action:` to `execute` or `execute!`:
|
|
145
191
|
|
|
146
|
-
|
|
192
|
+
| Action | Behavior |
|
|
193
|
+
| --- | --- |
|
|
194
|
+
| `:validate` (default) | Validate locally. |
|
|
195
|
+
| `:validate_with_hints` | Validate locally and include hints. |
|
|
196
|
+
| `:print` | Create a preview PDF locally. |
|
|
197
|
+
| `:submit` | Send the filing to ELSTER. |
|
|
198
|
+
| `:print_and_submit` | Send the filing and create the PDF of the sent filing. |
|
|
147
199
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
200
|
+
Whether a submission is authenticated depends on `encryption:`, not on the
|
|
201
|
+
action. `:print_and_submit_auth` is a deprecated alias of `:print_and_submit`.
|
|
202
|
+
|
|
203
|
+
When validation finds hints but no errors, ERiC returns
|
|
204
|
+
`ERIC_GLOBAL_HINWEISE`, which counts as success. `hints?` identifies this
|
|
205
|
+
return code; the `<Hinweis>` elements are in `:result`:
|
|
152
206
|
|
|
153
207
|
```ruby
|
|
154
|
-
|
|
208
|
+
result = submission.execute(action: :validate_with_hints)
|
|
209
|
+
puts result[:result] if result.hints?
|
|
155
210
|
```
|
|
156
211
|
|
|
157
|
-
|
|
158
|
-
making (check out `Liberic::Process`).
|
|
159
|
-
|
|
160
|
-
## Examples
|
|
212
|
+
### Create PDFs
|
|
161
213
|
|
|
162
|
-
|
|
163
|
-
|
|
214
|
+
An action that prints needs a file name or `pdf: :memory`; ERiC has no
|
|
215
|
+
default output directory. Relative file names use the working directory.
|
|
164
216
|
|
|
165
217
|
```ruby
|
|
166
|
-
|
|
218
|
+
submission.execute!(action: :print, filename: '/tmp/est_2020.pdf')
|
|
167
219
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
version_info = Liberic::Helpers::Invocation.with_result_buffer do |handle|
|
|
220
|
+
result = submission.execute!(action: :print, pdf: :memory)
|
|
221
|
+
result.pdfs # => {"<Nutzdatenticket>" => "%PDF-1.4..."}
|
|
222
|
+
```
|
|
172
223
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
224
|
+
`Result#pdfs` maps ERiC's PDF names (the data block's Nutzdatenticket, or
|
|
225
|
+
`Uebertragungsprotokoll`) to binary strings. Pass either `filename:` or
|
|
226
|
+
`pdf: :memory`. Printing also accepts `footer:`, `duplex:` and `draft:`.
|
|
227
|
+
For `:print`, `draft` defaults to `true` (a preview marked `*** ENTWURF ***`);
|
|
228
|
+
ERiC 43 prints locally only as a preview. For `:print_and_submit` it
|
|
229
|
+
defaults to `false`: ERiC rejects `draft: true` there with
|
|
230
|
+
`ERIC_GLOBAL_UNGUELTIGER_PARAMETER`, before sending. A missing file name or
|
|
231
|
+
`pdf: :memory` is also rejected before sending.
|
|
232
|
+
|
|
233
|
+
A runnable example that validates and prints the SDK filing is included in
|
|
234
|
+
[examples/est_2020.rb](examples/est_2020.rb):
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
# With ERIC_HOME and ERIC_HERSTELLER_ID set:
|
|
238
|
+
bundle exec ruby examples/est_2020.rb /tmp/est_2020.pdf
|
|
239
|
+
```
|
|
176
240
|
|
|
177
|
-
|
|
178
|
-
puts version_info
|
|
241
|
+
### Certificates and authenticated submission
|
|
179
242
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
243
|
+
Open a certificate from a file, or use
|
|
244
|
+
`Liberic::Certificate.from_bytes(pkcs12_bytes, pin)` for a password-protected
|
|
245
|
+
PKCS#12 container in memory:
|
|
183
246
|
|
|
184
|
-
|
|
185
|
-
|
|
247
|
+
```ruby
|
|
248
|
+
certificate = Liberic::Certificate.new('cert.pfx', pin)
|
|
249
|
+
begin
|
|
250
|
+
certificate.encryption_params do |params|
|
|
251
|
+
submission.execute!(action: :submit, encryption: params)
|
|
252
|
+
end
|
|
253
|
+
ensure
|
|
254
|
+
certificate.release_handle!
|
|
255
|
+
end
|
|
256
|
+
```
|
|
186
257
|
|
|
187
|
-
|
|
188
|
-
|
|
258
|
+
When given a block, `encryption_params` wipes the native copy of the PIN
|
|
259
|
+
after the block returns; `from_bytes` wipes its temporary native copies of
|
|
260
|
+
the container and PIN.
|
|
261
|
+
The original Ruby strings cannot be wiped reliably.
|
|
189
262
|
|
|
190
|
-
|
|
191
|
-
result = submission.execute
|
|
263
|
+
### Datenabholung
|
|
192
264
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
265
|
+
A Datenabholung's request, retrieval and acknowledgement calls share an
|
|
266
|
+
`EricTransferHandle`. Create one `Liberic::Process::TransferHandle` per
|
|
267
|
+
Datenabholung and pass it to each call with `transfer_handle:`:
|
|
268
|
+
|
|
269
|
+
```ruby
|
|
270
|
+
handle = Liberic::Process::TransferHandle.new
|
|
271
|
+
Liberic::Process.new(request_xml, type)
|
|
272
|
+
.execute!(action: :submit, encryption: params, transfer_handle: handle)
|
|
273
|
+
Liberic::Process.new(retrieval_xml, type)
|
|
274
|
+
.execute!(action: :submit, encryption: params, transfer_handle: handle)
|
|
196
275
|
```
|
|
197
276
|
|
|
198
|
-
|
|
277
|
+
Leave `transfer_handle:` out for all other calls.
|
|
199
278
|
|
|
200
|
-
|
|
201
|
-
yet. It does support submitting various tax filings via
|
|
202
|
-
`Liberic::Process` which should be sufficient for the majority of use
|
|
203
|
-
cases. Dealing with certificates (necessary for retrieving the tax
|
|
204
|
-
assessment or cryptographically signing a tax filing) is possible, but
|
|
205
|
-
no Ruby style wrapper exists yet.
|
|
279
|
+
## Configuration and logging
|
|
206
280
|
|
|
207
|
-
|
|
281
|
+
`Liberic.config` reads and writes ERiC settings by German name or English
|
|
282
|
+
accessor, after initialization:
|
|
208
283
|
|
|
209
|
-
|
|
284
|
+
```ruby
|
|
285
|
+
require 'logger'
|
|
210
286
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
287
|
+
Liberic.config.validation_error_limit = 30
|
|
288
|
+
Liberic.config['validieren.fehler_max'] # => 30
|
|
289
|
+
Liberic.config.logger = Logger.new($stdout)
|
|
290
|
+
```
|
|
214
291
|
|
|
215
|
-
|
|
216
|
-
|
|
292
|
+
The first use of `Liberic.config`, including reading or changing a setting,
|
|
293
|
+
registers a Ruby log callback. From then on ERiC no longer writes `eric.log`
|
|
294
|
+
(to the `log_path` passed to `Liberic.boot!`) for the rest of the process.
|
|
295
|
+
Its log messages go only to `Liberic.config.logger`, and are discarded while
|
|
296
|
+
no logger is assigned. If your application uses `Liberic.config`, assign a
|
|
297
|
+
logger or keep the log file right after `Liberic.boot!`, so that no messages
|
|
298
|
+
are lost:
|
|
217
299
|
|
|
218
|
-
|
|
219
|
-
|
|
300
|
+
```ruby
|
|
301
|
+
Liberic.boot!(log_path: 'log/eric')
|
|
302
|
+
Liberic.config.log_file = true # keep writing eric.log, also with a logger
|
|
303
|
+
```
|
|
220
304
|
|
|
221
|
-
|
|
305
|
+
The accessors are `allow_test_id`, `detailed_logs`, `connect_timeout`,
|
|
306
|
+
`response_timeout`, `validation_error_limit`, `validation_hint_limit`,
|
|
307
|
+
`network` (`transfer.netz`), `test_date`, and `proxy_host`, `proxy_port`,
|
|
308
|
+
`proxy_username`, `proxy_password`, `proxy_auth`.
|
|
309
|
+
|
|
310
|
+
ERiC 43 removed the settings behind these older accessors; they raise
|
|
311
|
+
`Liberic::Config::UnsupportedSettingError`:
|
|
312
|
+
|
|
313
|
+
| Removed accessor | Replacement |
|
|
314
|
+
| --- | --- |
|
|
315
|
+
| `Liberic.config.eric_home` | `Liberic.eric_home` |
|
|
316
|
+
| `Liberic.config.log_path` | `Liberic.boot!(log_path: ...)`; read with `Liberic.log_path` |
|
|
317
|
+
| `Liberic.config.data_path` | `filename:` on `Process#execute` |
|
|
318
|
+
| `Liberic.config.online` | `Liberic.config.network` (`'ndb'` for the Netz des Bundes) |
|
|
319
|
+
|
|
320
|
+
## ERiC 43 behavior and limitations
|
|
321
|
+
|
|
322
|
+
Observed with ERiC 43.5.4.0:
|
|
323
|
+
|
|
324
|
+
- The native `ERIC_PRUEFE_HINWEISE` flag alone skips validation. Liberic's
|
|
325
|
+
`:validate_with_hints` combines it with `ERIC_VALIDIERE` to return both
|
|
326
|
+
errors and hints.
|
|
327
|
+
- `execute` reports invalid values and unknown elements as
|
|
328
|
+
`<FehlerRegelpruefung>` with a field and text (rule `formalePruefung`).
|
|
329
|
+
`check` (`EricCheckXML`) reports schema errors with line and column, one
|
|
330
|
+
`EC(<code>): ...` line per error, in `Invocation::Error#buffer`.
|
|
331
|
+
- Characters outside Unicode's Basic Multilingual Plane, such as emoji,
|
|
332
|
+
cause `ERIC_IO_UNGUELTIGE_UTF8_SEQUENZ` even when the XML is valid UTF-8.
|
|
333
|
+
Neither `execute` nor `check` identifies the field.
|
|
334
|
+
- PDF footers have a maximum of 30 characters
|
|
335
|
+
(`ERIC_PRINT_FUSSTEXT_ZU_LANG` otherwise). German umlauts, ß and € work;
|
|
336
|
+
characters such as Chinese characters or emoji cause
|
|
337
|
+
`ERIC_IO_UNGUELTIGE_ZEICHEN_IN_PARAMETER`. Liberic passes footers in UTF-8.
|
|
338
|
+
|
|
339
|
+
Liberic does not bind every native function, including ERiC's
|
|
340
|
+
multithreading API (`EricMt*`), and does not parse all response XML into Ruby
|
|
341
|
+
objects. For other use cases, check `Liberic::SDK::API` and the official
|
|
342
|
+
SDK documentation. Integration coverage is concentrated on the common
|
|
343
|
+
wrappers; not every native binding has been exercised.
|
|
344
|
+
|
|
345
|
+
Native function names use snake case without the `Eric` prefix; German
|
|
346
|
+
names are otherwise retained. For example, `EricSystemCheck()` is exposed
|
|
347
|
+
as `Liberic::SDK::API.system_check`. Functions returning buffers can use
|
|
348
|
+
the invocation helper, which releases the buffer and raises on ERiC errors:
|
|
222
349
|
|
|
223
|
-
|
|
350
|
+
```ruby
|
|
351
|
+
version_xml = Liberic::Helpers::Invocation.with_result_buffer do |handle|
|
|
352
|
+
Liberic::SDK::API.version(handle)
|
|
353
|
+
end
|
|
354
|
+
```
|
|
224
355
|
|
|
225
|
-
|
|
356
|
+
## Documentation and contributing
|
|
226
357
|
|
|
227
|
-
|
|
358
|
+
- [Changelog](CHANGELOG.md) for release notes and upgrade information.
|
|
359
|
+
- [Ruby API documentation](https://www.rubydoc.info/github/mpm/liberic-ruby).
|
|
360
|
+
- The SDK's `Dokumentation/ERiC-Entwicklerhandbuch.pdf` and
|
|
361
|
+
`Dokumentation/API-Referenz/HTML/` for ERiC setup, settings and native APIs.
|
|
362
|
+
- [GitHub issues](https://github.com/mpm/liberic-ruby/issues) for bug reports.
|
|
363
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) for running the specs, upgrading the SDK
|
|
364
|
+
and releasing.
|
|
228
365
|
|
|
229
|
-
|
|
366
|
+
Liberic is available under the [MIT license](LICENSE).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Validates the income tax example that comes with the ERiC SDK and creates
|
|
4
|
+
# its preview PDF. Run it with the SDK in ERIC_HOME and your ELSTER
|
|
5
|
+
# manufacturer ID (ERiC 43 blocks the SDK's test ID 74931):
|
|
6
|
+
#
|
|
7
|
+
# ERIC_HOME=... ERIC_HERSTELLER_ID=... bundle exec ruby examples/est_2020.rb [output.pdf]
|
|
8
|
+
|
|
9
|
+
require "bundler/setup"
|
|
10
|
+
require "liberic"
|
|
11
|
+
|
|
12
|
+
tax_filing = File.read(File.expand_path("Beispiel/ericdemo-java/ESt_2020.xml", Liberic.eric_home), encoding: "UTF-8")
|
|
13
|
+
tax_filing = tax_filing.sub(%r{<HerstellerID>\d+}, "<HerstellerID>#{ENV.fetch('ERIC_HERSTELLER_ID')}")
|
|
14
|
+
|
|
15
|
+
submission = Liberic::Process.new(tax_filing, "ESt_2020")
|
|
16
|
+
|
|
17
|
+
# Schema check: raises Liberic::Helpers::Invocation::Error, with ERiC's
|
|
18
|
+
# error text in #buffer.
|
|
19
|
+
submission.check
|
|
20
|
+
|
|
21
|
+
# Validation with errors and hints in one call.
|
|
22
|
+
result = submission.execute(action: :validate_with_hints)
|
|
23
|
+
puts "validate: #{result.ok? ? 'ok' : "#{result.error} (#{result.code})"}#{' with hints' if result.hints?}"
|
|
24
|
+
puts result[:result] unless result[:result].empty?
|
|
25
|
+
exit 1 unless result.ok?
|
|
26
|
+
|
|
27
|
+
# Preview PDF ("*** ENTWURF ***"), kept in memory and written here.
|
|
28
|
+
result = submission.execute!(action: :print, pdf: :memory, footer: "Liberic example")
|
|
29
|
+
filename = ARGV.fetch(0, "est_2020.pdf")
|
|
30
|
+
File.binwrite(filename, result.pdfs.values.first)
|
|
31
|
+
puts "PDF written to #{filename}"
|
|
32
|
+
|
|
33
|
+
# To send the filing to ELSTER, use action: :submit (or :print_and_submit with
|
|
34
|
+
# :filename or pdf: :memory) and, for authenticated submission, encryption
|
|
35
|
+
# params from a Liberic::Certificate:
|
|
36
|
+
#
|
|
37
|
+
# certificate = Liberic::Certificate.new("cert.pfx", pin)
|
|
38
|
+
# certificate.encryption_params do |params|
|
|
39
|
+
# submission.execute!(action: :submit, encryption: params)
|
|
40
|
+
# end
|