liberic 1.3.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 +144 -2
- data/README.md +293 -118
- data/examples/est_2020.rb +40 -0
- data/lib/liberic/boot.rb +85 -5
- data/lib/liberic/certificate.rb +95 -16
- data/lib/liberic/config.rb +89 -20
- data/lib/liberic/core.rb +24 -0
- data/lib/liberic/eric_installer.rb +210 -0
- data/lib/liberic/helpers/invocation.rb +46 -9
- data/lib/liberic/process.rb +233 -42
- data/lib/liberic/sdk/api.rb +28 -1
- data/lib/liberic/sdk/configuration.rb +1 -1
- data/lib/liberic/sdk/fehlercodes.rb +12 -0
- data/lib/liberic/sdk/types.rb +51 -2
- 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 +39 -28
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.tool-versions +0 -1
- data/.travis.yml +0 -4
- data/CODE_OF_CONDUCT.md +0 -13
- 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 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8417513770b914a40de51d3c4bba71f75a855b43e5500cc341305b98de8a89e4
|
|
4
|
+
data.tar.gz: 8a8b32e4d571bf47ae14b00dedfeb12d8660a8e9c048851363c84ed60ef969b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eab285814f43e9366e5bd256dd0722c0e50fa572cc4e392c01f2c2cbb25c5fff34d528176fded41782ab975fb499bc1552df2e2623801aba6139c3b1bcfb07a7
|
|
7
|
+
data.tar.gz: f650ae3c0e51f899765a7f60165e44be12eda3aa0609706e57939b724bd856edd6591782386b165b54814fb043a73d34333521459d74aa44e761aa3661ad1414
|
data/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,151 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [1.
|
|
8
|
+
## [1.5.0]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Fixes found while integrating Liberic with ERiC 43 in a Rails application
|
|
11
|
+
([#14](https://github.com/mpm/liberic-ruby/issues/14)). All changes are
|
|
12
|
+
backwards compatible.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `Process#execute` returns a `Liberic::Process::Result`: still a Hash with
|
|
17
|
+
`:result` and `:server_result`, plus `code`, `error` and `ok?` with ERiC's
|
|
18
|
+
return code.
|
|
19
|
+
- `Process#execute!` raises `Liberic::Process::ProcessingError` (with `code`,
|
|
20
|
+
`error` and `result`) unless ERiC returns `ERIC_OK`.
|
|
21
|
+
- `Liberic::Helpers::Invocation.call_with_result_buffer`, which returns the
|
|
22
|
+
return code together with the buffer content. `Invocation::Error` exposes
|
|
23
|
+
`code`, `error` and `buffer`, so `Process#check` failures carry ERiC's
|
|
24
|
+
schema error text.
|
|
25
|
+
- `require 'liberic/core'` and `Liberic.boot!(eric_home:, plugin_path:, log_path:)`
|
|
26
|
+
to load the gem without initializing ERiC and to initialize it explicitly,
|
|
27
|
+
including the `eric.log` directory. `require 'liberic'` still initializes
|
|
28
|
+
ERiC immediately.
|
|
29
|
+
- Config accessors `validation_hint_limit` (`validieren.hinweise_max`),
|
|
30
|
+
`network` (`transfer.netz`) and `test_date` (`test.datum`).
|
|
31
|
+
- `Liberic.config.log_file = true` keeps ERiC writing `eric.log` while
|
|
32
|
+
Liberic's log callback is registered. It defaults to `false`, which stops
|
|
33
|
+
`eric.log` once `Liberic.config` is used, as before.
|
|
34
|
+
- `require 'liberic/tasks'` provides `rake eric:install` to applications. The
|
|
35
|
+
install root defaults to the current directory and can be set with a task
|
|
36
|
+
argument or `ERIC_INSTALL_ROOT`.
|
|
37
|
+
- `Certificate#encryption_params` accepts a block and wipes the native PIN
|
|
38
|
+
copy afterwards; `release_handle!` wipes the copies of all params it issued.
|
|
39
|
+
- `Process#execute` action `:validate_with_hints` (`ERIC_VALIDIERE` with
|
|
40
|
+
`ERIC_PRUEFE_HINWEISE`) returns errors and hints in one call.
|
|
41
|
+
`Result#hints?` reports `ERIC_GLOBAL_HINWEISE`, which counts as `ok?`.
|
|
42
|
+
- `Process#execute(pdf: :memory)` receives PDFs through ERiC's `pdfCallback`
|
|
43
|
+
instead of a file; they are in `Result#pdfs`.
|
|
44
|
+
`SDK::API.generate_pdf_callback` and `DruckParameter#set_pdf_callback` bind
|
|
45
|
+
the callback.
|
|
46
|
+
- `Liberic::Certificate.from_bytes(pkcs12, pin)` opens a certificate from
|
|
47
|
+
memory (`EricZertifikatOeffnenAusBytes`) and wipes its native copies of the
|
|
48
|
+
container and the PIN afterwards.
|
|
49
|
+
- `Liberic::Process::TransferHandle` and the `:transfer_handle` option of
|
|
50
|
+
`Process#execute` for the calls of a Datenabholung.
|
|
51
|
+
- The README describes ERiC 43 behavior that applications run into: hints,
|
|
52
|
+
schema errors, characters outside the BMP, and the footer's limits.
|
|
53
|
+
- Specs for return codes, every Config accessor and the log callback against
|
|
54
|
+
the installed SDK. Specs that call `EricBearbeiteVorgang` use
|
|
55
|
+
`ERIC_HERSTELLER_ID` and are skipped without it.
|
|
56
|
+
|
|
57
|
+
### Changed
|
|
58
|
+
|
|
59
|
+
- `Liberic::EricInstaller` moved from `rakelib/eric.rake` to
|
|
60
|
+
`lib/liberic/eric_installer.rb` (not loaded by `require 'liberic'`) and
|
|
61
|
+
installs into the current directory by default.
|
|
62
|
+
- The installer requires rubyzip 3.4 or newer (older versions are vulnerable to
|
|
63
|
+
path traversal) and uses the rubyzip 3 extraction API. The development
|
|
64
|
+
dependency is now `rubyzip >= 3.4`.
|
|
65
|
+
- `require 'liberic/sdk'` no longer loads the ERiC library; `Liberic.boot!`
|
|
66
|
+
does.
|
|
67
|
+
- `EricInitialisiere` failures raise `Liberic::InitializationError` instead of
|
|
68
|
+
being ignored.
|
|
69
|
+
- `Process#execute` passes the print parameters only to actions that print
|
|
70
|
+
(ERiC documents NULL for the others) and passes `:footer` to ERiC in UTF-8.
|
|
71
|
+
- The `:draft` option of `Process#execute` defaults to `false` for
|
|
72
|
+
`:print_and_submit` and `:print_and_submit_auth`: ERiC prints sent filings
|
|
73
|
+
only as final documents and rejects a preview before sending.
|
|
74
|
+
- `examples/est_2020.rb` replaces `examples/submit_ekst.rb` and
|
|
75
|
+
`examples/steuersatz.xml` (ESt 2011 with the blocked test manufacturer ID
|
|
76
|
+
74931). It uses the SDK's example filing and `ERIC_HERSTELLER_ID`.
|
|
77
|
+
- Reorganized the README around requirements, installation and usage for
|
|
78
|
+
ERiC 43. Removed the unverified 2016 macOS library-rewriting workaround
|
|
79
|
+
and obsolete setup notes; clarified logging and the GitHub release workflow.
|
|
80
|
+
Development and release instructions moved to `CONTRIBUTING.md`.
|
|
81
|
+
- The gem packages only the library, the example, README, changelog and
|
|
82
|
+
license (no longer the repository's CI and container files). The gemspec
|
|
83
|
+
links to the changelog, API documentation and issue tracker.
|
|
84
|
+
- The release workflow also creates a GitHub release for each version tag,
|
|
85
|
+
with the version's changelog section as notes and the gem attached. It stops
|
|
86
|
+
before publishing if `CHANGELOG.md` has no section for the version.
|
|
87
|
+
- The Gemfile no longer pins Ruby 3.3.0. The gem still requires Ruby 3.3 or
|
|
88
|
+
newer and is tested on Ruby 3.3 and 4.0.
|
|
89
|
+
|
|
90
|
+
### Deprecated
|
|
91
|
+
|
|
92
|
+
- The `Process#execute` action `:print_and_submit_auth` is an alias of
|
|
93
|
+
`:print_and_submit` and warns (category `:deprecated`). ERiC uses the same
|
|
94
|
+
flags with and without authentication; `:encryption` decides.
|
|
95
|
+
- `Liberic.config.eric_home`, `log_path`, `data_path` and `online` refer to
|
|
96
|
+
settings that ERiC 43 removed. They raise
|
|
97
|
+
`Liberic::Config::UnsupportedSettingError` (a
|
|
98
|
+
`Liberic::Helpers::Invocation::Error`, as before) with the replacement
|
|
99
|
+
instead of ERiC's `ERIC_GLOBAL_EINSTELLUNG_NAME_UNGUELTIG`.
|
|
100
|
+
|
|
101
|
+
### Fixed
|
|
102
|
+
|
|
103
|
+
- Failed boot attempts no longer leave stale SDK home constants. Once the
|
|
104
|
+
native API has loaded, initialization retries must use the same SDK home.
|
|
105
|
+
- Certificates track encryption parameters weakly, so discarded structs and
|
|
106
|
+
their native PIN copies can be collected while the certificate stays open.
|
|
107
|
+
- `Process#execute` discarded ERiC's return code, so failures such as
|
|
108
|
+
`ERIC_IO_TESTHERSTELLERID_GESPERRT` looked like success.
|
|
109
|
+
- `Process#execute` passed a transfer handle when sending, although ERiC
|
|
110
|
+
requires NULL outside a Datenabholung.
|
|
111
|
+
- Strings passed to ERiC in structs (PDF file name, footer, PIN) could be freed
|
|
112
|
+
by the garbage collector before ERiC read them.
|
|
113
|
+
- The log callback registered by `Liberic.config` could be freed by the garbage
|
|
114
|
+
collector while ERiC still called it, which crashed the process.
|
|
115
|
+
- `PinFeatures#no_pin` was always `false`.
|
|
116
|
+
- Result buffers are released when the block raises.
|
|
117
|
+
- The documentation claimed PDFs are written to `data_path` without
|
|
118
|
+
`:filename`; ERiC 43 requires a file name whenever it prints.
|
|
119
|
+
- `Process#execute(action: :print_and_submit)` sent the filing without
|
|
120
|
+
creating a PDF: it passed `ERIC_SENDE` without `ERIC_DRUCKE`, and ERiC
|
|
121
|
+
43.5.4.0 ignores the print parameters then. It now passes
|
|
122
|
+
`ERIC_VALIDIERE | ERIC_SENDE | ERIC_DRUCKE`, as the ERiC developer handbook
|
|
123
|
+
requires for sending and printing.
|
|
124
|
+
- The README and the `Liberic.boot!` and `Config` documentation now state
|
|
125
|
+
that ERiC stops writing `eric.log` once `Liberic.config` is used, unless
|
|
126
|
+
`Liberic.config.log_file` is `true`.
|
|
127
|
+
- Liberic loads on Ruby 4.0 with Bundler. `logger` is no longer a default gem
|
|
128
|
+
since Ruby 4.0, so the gem now declares it as a dependency; `require 'liberic'`
|
|
129
|
+
previously failed with a `LoadError`.
|
|
130
|
+
- `bundle install` in a checkout of the repository works with Bundler 4,
|
|
131
|
+
which ships with Ruby 4.0. The gemspec no longer declares Bundler 2 as a
|
|
132
|
+
development dependency.
|
|
133
|
+
|
|
134
|
+
## [1.4.1]
|
|
135
|
+
|
|
136
|
+
### Changed
|
|
137
|
+
|
|
138
|
+
- Require Ruby 3.3 or newer and update gem dependencies.
|
|
139
|
+
|
|
140
|
+
## [1.4.0]
|
|
141
|
+
|
|
142
|
+
Support for ERIC 43.5.4.0.
|
|
143
|
+
|
|
144
|
+
### Added
|
|
145
|
+
|
|
146
|
+
- ERIC 43 error codes and installed-SDK compatibility coverage.
|
|
147
|
+
- A reusable prompt for future ERIC SDK upgrades.
|
|
148
|
+
|
|
149
|
+
### Changed
|
|
150
|
+
|
|
151
|
+
- Updated the version-4 print parameter layout for PDF callbacks.
|
|
152
|
+
- Updated the SDK installer for ELSTER's current download paths and artifacts.
|
|
11
153
|
|
|
12
154
|
## [1.3.0]
|
|
13
155
|
|
data/README.md
CHANGED
|
@@ -1,191 +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)).
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
### Install the SDK on Linux x86-64
|
|
24
41
|
|
|
25
|
-
|
|
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.
|
|
26
45
|
|
|
27
|
-
|
|
46
|
+
To use the installer from an application, add rubyzip to its `Gemfile` and
|
|
47
|
+
load the task in its `Rakefile`:
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
```ruby
|
|
50
|
+
# Gemfile — only needed for SDK installation, not at runtime
|
|
51
|
+
gem 'rubyzip', '>= 3.4', require: false
|
|
31
52
|
|
|
32
|
-
|
|
53
|
+
# Rakefile
|
|
54
|
+
require 'liberic/tasks'
|
|
55
|
+
```
|
|
33
56
|
|
|
34
|
-
|
|
35
|
-
containing at least three subfolders:
|
|
57
|
+
Run `bundle install`, then:
|
|
36
58
|
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
lib/
|
|
59
|
+
```sh
|
|
60
|
+
bundle exec rake eric:install
|
|
61
|
+
export ERIC_HOME="$PWD/.eric/ERiC-43.5.4.0/Linux-x86_64"
|
|
41
62
|
```
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
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.
|
|
45
68
|
|
|
46
|
-
|
|
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`:
|
|
47
75
|
|
|
48
76
|
```sh
|
|
49
|
-
|
|
77
|
+
bundle exec rake "eric:install[/opt/myapp]"
|
|
78
|
+
ERIC_INSTALL_ROOT=/opt/myapp bundle exec rake eric:install
|
|
50
79
|
```
|
|
51
80
|
|
|
52
|
-
The
|
|
53
|
-
In a Rails project this can interfere with running rake (for example
|
|
54
|
-
when building the app in Docker). In this case, use `gem 'liberic', require: false` in your `Gemfile`.
|
|
55
|
-
And require the gem later in your Rails code (for example a model) by
|
|
56
|
-
calling `require 'liberic'`.
|
|
81
|
+
The installer can also be used without Rake:
|
|
57
82
|
|
|
58
|
-
|
|
83
|
+
```ruby
|
|
84
|
+
require 'liberic/eric_installer'
|
|
85
|
+
Liberic::EricInstaller.new(root: '/opt/myapp').install # => SDK home
|
|
86
|
+
```
|
|
59
87
|
|
|
60
|
-
|
|
61
|
-
library (from 2016). Might be outdated or incorrect by now.
|
|
88
|
+
### Use an existing or manually installed SDK
|
|
62
89
|
|
|
63
|
-
|
|
64
|
-
|
|
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/`:
|
|
65
95
|
|
|
96
|
+
```sh
|
|
97
|
+
export ERIC_HOME=/opt/ERiC-43.5.4.0/Linux-x86_64
|
|
66
98
|
```
|
|
67
|
-
libs=`ls $ERIC_HOME_27/lib/*.dylib`
|
|
68
|
-
plugins=`ls $ERIC_HOME_27/lib/plugins2/*.dylib`
|
|
69
99
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
The older `ERIC_HOME_40` variable remains a fallback when `ERIC_HOME` is
|
|
101
|
+
not set.
|
|
102
|
+
|
|
103
|
+
## Initialization
|
|
104
|
+
|
|
105
|
+
Load the Ruby code, then boot ERiC in the process that will use it:
|
|
76
106
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
install_name_tool -change "@rpath/plugins2/"`basename $plugin` "$ERIC_HOME_27/lib/plugins2/"`basename $plugin` $target
|
|
80
|
-
done
|
|
81
|
-
done
|
|
107
|
+
```ruby
|
|
108
|
+
require 'liberic/core'
|
|
82
109
|
|
|
83
|
-
|
|
84
|
-
do
|
|
85
|
-
for lib in $libs
|
|
86
|
-
do
|
|
87
|
-
install_name_tool -change "@rpath/"`basename $lib` "$ERIC_HOME_27/lib/"`basename $lib` $target
|
|
88
|
-
done
|
|
89
|
-
done
|
|
110
|
+
Liberic.boot! # uses ERIC_HOME
|
|
90
111
|
```
|
|
91
112
|
|
|
92
|
-
|
|
113
|
+
You can alternatively pass the SDK location, log directory and plugin
|
|
114
|
+
directory explicitly:
|
|
93
115
|
|
|
94
|
-
```
|
|
95
|
-
|
|
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
|
+
)
|
|
96
122
|
```
|
|
97
|
-
This should list you one file with an operating system dependend suffix.
|
|
98
123
|
|
|
99
|
-
|
|
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).
|
|
100
127
|
|
|
101
|
-
|
|
102
|
-
`Liberic::
|
|
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.
|
|
103
132
|
|
|
104
|
-
|
|
105
|
-
|
|
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.
|
|
106
137
|
|
|
107
|
-
|
|
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.
|
|
108
142
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
143
|
+
## Usage
|
|
144
|
+
|
|
145
|
+
### Validate a filing
|
|
146
|
+
|
|
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.
|
|
113
151
|
|
|
114
152
|
```ruby
|
|
115
|
-
|
|
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
|
|
116
174
|
```
|
|
117
175
|
|
|
118
|
-
|
|
119
|
-
|
|
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?`.
|
|
180
|
+
|
|
181
|
+
Use `execute!` to raise `Liberic::Process::ProcessingError` on failure;
|
|
182
|
+
the exception exposes `code`, `error` and `result`.
|
|
183
|
+
|
|
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.
|
|
187
|
+
|
|
188
|
+
### Actions and hints
|
|
120
189
|
|
|
121
|
-
|
|
190
|
+
Pass `action:` to `execute` or `execute!`:
|
|
122
191
|
|
|
123
|
-
|
|
124
|
-
|
|
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. |
|
|
199
|
+
|
|
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`:
|
|
125
206
|
|
|
126
207
|
```ruby
|
|
127
|
-
|
|
208
|
+
result = submission.execute(action: :validate_with_hints)
|
|
209
|
+
puts result[:result] if result.hints?
|
|
210
|
+
```
|
|
128
211
|
|
|
129
|
-
|
|
130
|
-
# native function's results. This will also raise a Ruby exception if
|
|
131
|
-
# the native function returns anything else then 0 (= OK).
|
|
132
|
-
version_info = Liberic::Helpers::Invocation.with_result_buffer do |handle|
|
|
212
|
+
### Create PDFs
|
|
133
213
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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.
|
|
216
|
+
|
|
217
|
+
```ruby
|
|
218
|
+
submission.execute!(action: :print, filename: '/tmp/est_2020.pdf')
|
|
137
219
|
|
|
138
|
-
|
|
139
|
-
|
|
220
|
+
result = submission.execute!(action: :print, pdf: :memory)
|
|
221
|
+
result.pdfs # => {"<Nutzdatenticket>" => "%PDF-1.4..."}
|
|
222
|
+
```
|
|
223
|
+
|
|
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.
|
|
140
232
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tax_filing = File.read(File.expand_path('Beispiel/ericdemo-java/steuersatz.xml', Liberic.eric_home))
|
|
233
|
+
A runnable example that validates and prints the SDK filing is included in
|
|
234
|
+
[examples/est_2020.rb](examples/est_2020.rb):
|
|
144
235
|
|
|
145
|
-
|
|
146
|
-
|
|
236
|
+
```sh
|
|
237
|
+
# With ERIC_HOME and ERIC_HERSTELLER_ID set:
|
|
238
|
+
bundle exec ruby examples/est_2020.rb /tmp/est_2020.pdf
|
|
239
|
+
```
|
|
147
240
|
|
|
148
|
-
|
|
149
|
-
submission.check
|
|
241
|
+
### Certificates and authenticated submission
|
|
150
242
|
|
|
151
|
-
|
|
152
|
-
|
|
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:
|
|
153
246
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
157
256
|
```
|
|
158
257
|
|
|
159
|
-
|
|
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.
|
|
160
262
|
|
|
161
|
-
|
|
162
|
-
yet. It does support submitting various tax filings via
|
|
163
|
-
`Liberic::Process` which should be sufficient for the majority of use
|
|
164
|
-
cases. Dealing with certificates (necessary for retrieving the tax
|
|
165
|
-
assessment or cryptographically signing a tax filing) is possible, but
|
|
166
|
-
no Ruby style wrapper exists yet.
|
|
263
|
+
### Datenabholung
|
|
167
264
|
|
|
168
|
-
|
|
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:`:
|
|
169
268
|
|
|
170
|
-
|
|
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)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Leave `transfer_handle:` out for all other calls.
|
|
171
278
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
279
|
+
## Configuration and logging
|
|
280
|
+
|
|
281
|
+
`Liberic.config` reads and writes ERiC settings by German name or English
|
|
282
|
+
accessor, after initialization:
|
|
283
|
+
|
|
284
|
+
```ruby
|
|
285
|
+
require 'logger'
|
|
175
286
|
|
|
176
|
-
|
|
177
|
-
|
|
287
|
+
Liberic.config.validation_error_limit = 30
|
|
288
|
+
Liberic.config['validieren.fehler_max'] # => 30
|
|
289
|
+
Liberic.config.logger = Logger.new($stdout)
|
|
290
|
+
```
|
|
178
291
|
|
|
179
|
-
|
|
180
|
-
|
|
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:
|
|
181
299
|
|
|
182
|
-
|
|
300
|
+
```ruby
|
|
301
|
+
Liberic.boot!(log_path: 'log/eric')
|
|
302
|
+
Liberic.config.log_file = true # keep writing eric.log, also with a logger
|
|
303
|
+
```
|
|
183
304
|
|
|
184
|
-
|
|
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:
|
|
185
349
|
|
|
186
|
-
|
|
350
|
+
```ruby
|
|
351
|
+
version_xml = Liberic::Helpers::Invocation.with_result_buffer do |handle|
|
|
352
|
+
Liberic::SDK::API.version(handle)
|
|
353
|
+
end
|
|
354
|
+
```
|
|
187
355
|
|
|
188
|
-
##
|
|
356
|
+
## Documentation and contributing
|
|
189
357
|
|
|
190
|
-
|
|
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.
|
|
191
365
|
|
|
366
|
+
Liberic is available under the [MIT license](LICENSE).
|