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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7be715d5bb4855f1931a991eb15d996170d645e94b6df75bcbfbb53326387dc6
4
- data.tar.gz: 6e01c51f98b6d2129cff0773e58d12bed8b2262e2392b10ccf155de7e871641a
3
+ metadata.gz: 27f87d4ed24cf44eb152e7cb6482f8dc78b378e2488a20d8b064ae196c202003
4
+ data.tar.gz: 273d6ca5ae2b8d5ae97e7adf1940321c088f10bd8ea48475f2ad7b3ecc408945
5
5
  SHA512:
6
- metadata.gz: 205460c6eff6e40a81d3d3b0e790726aa3ef34bf95738a159008dbe5277682022e1a16b8313a4708c12980ada01acfcd75fa9a8ba96742a723d3a52cf7bb0a55
7
- data.tar.gz: c85b7cfb3d0a19f03e2e5f296edce4891e1848780f35107e09c6955782d70d552df0c7c37e068f6c1917753c53a968c5b073393f8b8fc75ba8e1f97709fbc75d
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"><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
- &nbsp;&nbsp;&nbsp;&nbsp;
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
- &nbsp;&nbsp;&nbsp;&nbsp;
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>
5
+ <a href="https://www.company-mood.com"><img src=".github/sponsors/companymood.svg" alt="CompanyMood" height="60"></a>
6
+ &nbsp;
7
+ <a href="https://myron.app"><img src=".github/sponsors/myron.svg" alt="Myron" height="60"></a>
8
+ &nbsp;
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.
@@ -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])
@@ -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
- Subtotal.new(tax: tax, taxable: taxable, amount: (taxable * tax.rate / 100).round(2))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EN16931
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: en16931
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schwed