en16931 0.1.3 → 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/CHANGELOG.md +8 -0
- data/README.md +15 -4
- data/Rakefile +19 -0
- data/data/LICENSE-CLDR.txt +41 -0
- data/data/countries.yml +4632 -0
- data/lib/en16931/invoice.rb +1 -1
- data/lib/en16931/line.rb +2 -2
- data/lib/en16931/pdf/labels.rb +3 -0
- data/lib/en16931/pdf/renderer.rb +1 -4
- data/lib/en16931/pdf.rb +1 -0
- data/lib/en16931/tax.rb +1 -1
- data/lib/en16931/version.rb +1 -1
- data/lib/en16931.rb +8 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7be715d5bb4855f1931a991eb15d996170d645e94b6df75bcbfbb53326387dc6
|
|
4
|
+
data.tar.gz: 6e01c51f98b6d2129cff0773e58d12bed8b2262e2392b10ccf155de7e871641a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 205460c6eff6e40a81d3d3b0e790726aa3ef34bf95738a159008dbe5277682022e1a16b8313a4708c12980ada01acfcd75fa9a8ba96742a723d3a52cf7bb0a55
|
|
7
|
+
data.tar.gz: c85b7cfb3d0a19f03e2e5f296edce4891e1848780f35107e09c6955782d70d552df0c7c37e068f6c1917753c53a968c5b073393f8b8fc75ba8e1f97709fbc75d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.1] - 2026-10-22
|
|
4
|
+
|
|
5
|
+
- The buyer's country is named in the invoice language for every ISO country, from the Unicode CLDR (`data/countries.yml`, `rake countries`). Before, only nine countries had a name, in German.
|
|
6
|
+
|
|
7
|
+
## [0.2.0] - 2026-10-22
|
|
8
|
+
|
|
9
|
+
- **Breaking:** amounts, quantities and rates (`Line#unit_price`, `Line#quantity`, `AllowanceCharge#amount`, `Tax#rate`, `Invoice#prepaid`) refuse a `Float` with an `ArgumentError`. Pass a `BigDecimal`, an `Integer` or a decimal `String`.
|
|
10
|
+
|
|
3
11
|
## [0.1.3] - 2026-10-21
|
|
4
12
|
|
|
5
13
|
- The recipient block shows the buyer's contact person ("z. Hd.") and VAT identifier. Like the XML, it leaves the VAT identifier out for invoices outside the scope of VAT (category O).
|
data/README.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# en16931
|
|
2
2
|
|
|
3
|
+
<p align="center"><sub>SPONSORED BY</sub></p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://www.company-mood.com"><picture><source media="(prefers-color-scheme: dark)" srcset=".github/sponsors/companymood-dark.svg"><img src=".github/sponsors/companymood.svg" alt="CompanyMood" height="40"></picture></a>
|
|
6
|
+
|
|
7
|
+
<a href="https://myron.app"><picture><source media="(prefers-color-scheme: dark)" srcset=".github/sponsors/myron-dark.svg"><img src=".github/sponsors/myron.svg" alt="Myron" height="30"></picture></a>
|
|
8
|
+
|
|
9
|
+
<a href="https://www.affliq.com"><picture><source media="(prefers-color-scheme: dark)" srcset=".github/sponsors/affliq-dark.svg"><img src=".github/sponsors/affliq.svg" alt="Affliq" height="42"></picture></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
3
12
|
EN 16931 e-invoices for Ruby, in pure Ruby.
|
|
4
13
|
|
|
5
14
|
- A small invoice model: parties, lines, a VAT treatment, payment details.
|
|
@@ -39,7 +48,7 @@ invoice = EN16931::Invoice.new(
|
|
|
39
48
|
seller: seller, buyer: buyer, buyer_reference: "PO-4711",
|
|
40
49
|
references: { "Kostenstelle" => "4711" }, # printed in the header, an XML note
|
|
41
50
|
tax: EN16931::DE.standard,
|
|
42
|
-
lines: [EN16931::Line.new(description: "Produktvideo TikTok, 60 Sekunden", unit_price: "1500.00")],
|
|
51
|
+
lines: [EN16931::Line.new(description: "Produktvideo TikTok, 60 Sekunden", unit_price: BigDecimal("1500.00"))],
|
|
43
52
|
payment: EN16931::Payment.new(iban: "DE89 3704 0044 0532 0130 00", bic: "COBADEFFXXX", holder: "Lena Beispiel",
|
|
44
53
|
terms: "Zahlbar innerhalb von 14 Tagen ohne Abzug.")
|
|
45
54
|
)
|
|
@@ -49,6 +58,8 @@ pdf = EN16931::PDF.render(invoice) # ZUGFeRD hybrid PDF/A-3b, profi
|
|
|
49
58
|
File.binwrite("2026-0001.pdf", pdf)
|
|
50
59
|
```
|
|
51
60
|
|
|
61
|
+
Amounts, quantities and rates are kept as `BigDecimal`. They accept a `BigDecimal`, an `Integer` or a decimal `String` such as `"1500.00"`; a `Float` raises an `ArgumentError`, because it has already lost the exact value.
|
|
62
|
+
|
|
52
63
|
### Tax cases
|
|
53
64
|
|
|
54
65
|
| Preset | Category | Use |
|
|
@@ -81,7 +92,7 @@ branding = EN16931::Branding.new(
|
|
|
81
92
|
pdf = EN16931::PDF.render(invoice, branding:, locale: :de)
|
|
82
93
|
```
|
|
83
94
|
|
|
84
|
-
`locale:` sets the labels, number and date formats of the layout: `:de`, `:en`, `:cs`, `:da`, `:es`, `:et`, `:fi`, `:fr`, `:it`, `:lv`, `:nl`, `:pl`, `:pt`, `:ro`, `:ru`, `:sv`, `:tr` or `:zh` (a string works too; anything else falls back to German). DejaVu Sans covers every one of them but Chinese: for `:zh` pass a TrueType font with CJK glyphs as the branding font. Glyphs a branding font lacks, such as `€` in a subset, are taken from DejaVu Sans.
|
|
95
|
+
`locale:` sets the labels, number and date formats and the buyer's country name of the layout: `:de`, `:en`, `:cs`, `:da`, `:es`, `:et`, `:fi`, `:fr`, `:it`, `:lv`, `:nl`, `:pl`, `:pt`, `:ro`, `:ru`, `:sv`, `:tr` or `:zh` (a string works too; anything else falls back to German). DejaVu Sans covers every one of them but Chinese: for `:zh` pass a TrueType font with CJK glyphs as the branding font. Glyphs a branding font lacks, such as `€` in a subset, are taken from DejaVu Sans.
|
|
85
96
|
|
|
86
97
|
`Branding.new` rejects what would break PDF/A at construction time: CMYK JPEGs, interlaced PNGs, unknown image data. The GiroCode is drawn as vectors, so it adds no raster image; it carries the holder, IBAN, BIC, the amount due and the payment reference (or the invoice title) and is left out when the invoice is not in euro, has no IBAN or nothing is due.
|
|
87
98
|
|
|
@@ -107,7 +118,7 @@ EN16931::Invoice.new(type: :corrected, preceding: { number: "2026-0001", issue_d
|
|
|
107
118
|
EN16931::Invoice.new(type: :credit_note, ...)
|
|
108
119
|
EN16931::Invoice.new(type: :self_billed, ...) # Gutschrift im Sinne von § 14 Abs. 2 UStG
|
|
109
120
|
EN16931::Invoice.new(period: Date.new(2026, 10, 1)..Date.new(2026, 10, 31), ...) # BG-14, e.g. a retainer month
|
|
110
|
-
EN16931::Invoice.new(prepaid: "200.00", allowances: [EN16931::AllowanceCharge.new(amount: "100.00", reason: "Treuerabatt", reason_code: "95")], ...)
|
|
121
|
+
EN16931::Invoice.new(prepaid: BigDecimal("200.00"), allowances: [EN16931::AllowanceCharge.new(amount: BigDecimal("100.00"), reason: "Treuerabatt", reason_code: "95")], ...)
|
|
111
122
|
```
|
|
112
123
|
|
|
113
124
|
### Validation
|
|
@@ -144,4 +155,4 @@ git tag v0.2.0 && git push origin v0.2.0
|
|
|
144
155
|
|
|
145
156
|
## Licences
|
|
146
157
|
|
|
147
|
-
MIT. Bundled: DejaVu Sans (Bitstream Vera licence, `fonts/LICENSE-DejaVu.txt`) and the sRGB profile from [Compact ICC Profiles](https://github.com/saucecontrol/Compact-ICC-Profiles) (CC0).
|
|
158
|
+
MIT. Bundled: DejaVu Sans (Bitstream Vera licence, `fonts/LICENSE-DejaVu.txt`), the country names from the [Unicode CLDR](https://cldr.unicode.org) (Unicode licence, `data/LICENSE-CLDR.txt`) and the sRGB profile from [Compact ICC Profiles](https://github.com/saucecontrol/Compact-ICC-Profiles) (CC0).
|
data/Rakefile
CHANGED
|
@@ -40,3 +40,22 @@ task :validate do
|
|
|
40
40
|
end
|
|
41
41
|
abort "validation failed" if failed
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
CLDR_VERSION = "45.0.0"
|
|
45
|
+
|
|
46
|
+
desc "Fetch the country names in every invoice language from CLDR #{CLDR_VERSION} into data/countries.yml"
|
|
47
|
+
task :countries do
|
|
48
|
+
require "json"
|
|
49
|
+
require "net/http"
|
|
50
|
+
require "yaml"
|
|
51
|
+
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
|
|
52
|
+
require "en16931"
|
|
53
|
+
short = %w[HK MO PS] # the full names ("Sonderverwaltungsregion Hongkong") do not fit an address
|
|
54
|
+
names = EN16931::PDF::Renderer::LABELS.keys.to_h do |locale|
|
|
55
|
+
url = URI("https://cdn.jsdelivr.net/npm/cldr-localenames-full@#{CLDR_VERSION}/main/#{locale}/territories.json")
|
|
56
|
+
territories = JSON.parse(Net::HTTP.get(url)).dig("main", locale.to_s, "localeDisplayNames", "territories")
|
|
57
|
+
countries = territories.keys.grep(/\A[A-Z]{2}\z/) - %w[EU EZ UN QO XA XB ZZ]
|
|
58
|
+
[locale.to_s, countries.sort.to_h { |code| [code, territories[short.include?(code) ? "#{code}-alt-short" : code]] }]
|
|
59
|
+
end
|
|
60
|
+
File.write("data/countries.yml", "# Generated by `rake countries` from CLDR #{CLDR_VERSION}, do not edit.\n#{names.to_yaml}")
|
|
61
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
UNICODE LICENSE V3
|
|
2
|
+
|
|
3
|
+
COPYRIGHT AND PERMISSION NOTICE
|
|
4
|
+
|
|
5
|
+
Copyright © 2004-2024 Unicode, Inc.
|
|
6
|
+
|
|
7
|
+
NOTICE TO USER: Carefully read the following legal agreement. BY
|
|
8
|
+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
|
|
9
|
+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
|
10
|
+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
|
|
11
|
+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
14
|
+
copy of data files and any associated documentation (the "Data Files") or
|
|
15
|
+
software and any associated documentation (the "Software") to deal in the
|
|
16
|
+
Data Files or Software without restriction, including without limitation
|
|
17
|
+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
|
|
18
|
+
copies of the Data Files or Software, and to permit persons to whom the
|
|
19
|
+
Data Files or Software are furnished to do so, provided that either (a)
|
|
20
|
+
this copyright and permission notice appear with all copies of the Data
|
|
21
|
+
Files or Software, or (b) this copyright and permission notice appear in
|
|
22
|
+
associated Documentation.
|
|
23
|
+
|
|
24
|
+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
|
25
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
26
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
27
|
+
THIRD PARTY RIGHTS.
|
|
28
|
+
|
|
29
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
|
|
30
|
+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
|
|
31
|
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
32
|
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
33
|
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
|
|
34
|
+
FILES OR SOFTWARE.
|
|
35
|
+
|
|
36
|
+
Except as contained in this notice, the name of a copyright holder shall
|
|
37
|
+
not be used in advertising or otherwise to promote the sale, use or other
|
|
38
|
+
dealings in these Data Files or Software without prior written
|
|
39
|
+
authorization of the copyright holder.
|
|
40
|
+
|
|
41
|
+
SPDX-License-Identifier: Unicode-3.0
|