en16931 0.2.1 → 0.2.2
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 +5 -0
- data/README.md +5 -5
- data/lib/en16931/pdf/renderer.rb +2 -1
- data/lib/en16931/totals.rb +4 -1
- data/lib/en16931/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27f87d4ed24cf44eb152e7cb6482f8dc78b378e2488a20d8b064ae196c202003
|
|
4
|
+
data.tar.gz: 273d6ca5ae2b8d5ae97e7adf1940321c088f10bd8ea48475f2ad7b3ecc408945
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fc3bdbaedd2f241ccad65f0ad3cf4458cab35307a95dfc79bb29a97af8f665f06c8935172a9033648fbac93724b41b3b2a1ec35cbb0baa4b9ed74abed0e45b8
|
|
7
|
+
data.tar.gz: 0434aceab8455c904e2f6459ade6163bb4022c96bb03af7c537ff93d2a34d5d81795684ab1654497633c665b3dcae1de6ef162b2e20d9f93926b268b57d6a968
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.2] - 2026-10-26
|
|
4
|
+
|
|
5
|
+
- A cancellation with negative quantities at 0 % VAT (small business, reverse charge, outside the scope) no longer writes a VAT amount of "-0.00" into the breakdown, which failed BR-CO-14 against the total of "0.00".
|
|
6
|
+
- The reference layout prints negative quantities and amounts with their minus sign; it dropped the sign while grouping the thousands, so a cancellation read like an invoice.
|
|
7
|
+
|
|
3
8
|
## [0.2.1] - 2026-10-22
|
|
4
9
|
|
|
5
10
|
- 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.
|
data/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
<p align="center"><sub>SPONSORED BY</sub></p>
|
|
4
4
|
<p align="center">
|
|
5
|
-
<a href="https://www.company-mood.com"><
|
|
6
|
-
 
|
|
7
|
-
<a href="https://myron.app"><
|
|
8
|
-
 
|
|
9
|
-
<a href="https://www.affliq.com"><
|
|
5
|
+
<a href="https://www.company-mood.com"><img src=".github/sponsors/companymood.svg" alt="CompanyMood" height="60"></a>
|
|
6
|
+
|
|
7
|
+
<a href="https://myron.app"><img src=".github/sponsors/myron.svg" alt="Myron" height="60"></a>
|
|
8
|
+
|
|
9
|
+
<a href="https://www.affliq.com"><img src=".github/sponsors/affliq.svg" alt="Affliq" height="60"></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
EN 16931 e-invoices for Ruby, in pure Ruby.
|
data/lib/en16931/pdf/renderer.rb
CHANGED
|
@@ -244,12 +244,13 @@ module EN16931
|
|
|
244
244
|
|
|
245
245
|
def number(value, decimals)
|
|
246
246
|
text = format("%.#{decimals.max}f", value)
|
|
247
|
+
sign = text.delete_prefix!("-") ? "-" : ""
|
|
247
248
|
int, frac = text.split(".")
|
|
248
249
|
frac = frac&.sub(/0+\z/, "") if decimals.min < decimals.max
|
|
249
250
|
frac = nil if frac && frac.empty?
|
|
250
251
|
sep = FORMATS.fetch(locale)
|
|
251
252
|
int = int.reverse.scan(/\d{1,3}/).join(sep[0]).reverse
|
|
252
|
-
[int, frac].compact.join(sep[1])
|
|
253
|
+
sign + [int, frac].compact.join(sep[1])
|
|
253
254
|
end
|
|
254
255
|
|
|
255
256
|
def date(d) = d.strftime(FORMATS.fetch(locale)[2])
|
data/lib/en16931/totals.rb
CHANGED
|
@@ -25,13 +25,16 @@ module EN16931
|
|
|
25
25
|
private
|
|
26
26
|
|
|
27
27
|
# One subtotal per distinct tax treatment; amount = taxable × rate, rounded.
|
|
28
|
+
# A negative base at 0 % gives BigDecimal -0, which the XML would print as
|
|
29
|
+
# "-0.00" against a total of "0.00" (BR-CO-14); zero is zero.
|
|
28
30
|
def breakdown(invoice)
|
|
29
31
|
bases = Hash.new(BigDecimal("0"))
|
|
30
32
|
invoice.lines.each { |line| bases[invoice.tax_for(line)] += line.net }
|
|
31
33
|
invoice.allowances.each { |a| bases[a.tax || invoice.tax] -= a.amount }
|
|
32
34
|
invoice.charges.each { |c| bases[c.tax || invoice.tax] += c.amount }
|
|
33
35
|
bases.map do |tax, taxable|
|
|
34
|
-
|
|
36
|
+
amount = (taxable * tax.rate / 100).round(2)
|
|
37
|
+
Subtotal.new(tax: tax, taxable: taxable, amount: amount.zero? ? BigDecimal("0") : amount)
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
40
|
end
|
data/lib/en16931/version.rb
CHANGED